Commit c32cfa8228f for woocommerce
commit c32cfa8228f2401de05397a80b5a07f7f934266d
Author: Luigi Teschio <gigitux@gmail.com>
Date: Mon Jun 8 11:24:46 2026 +0200
Remove block templates admin package (#65503)
* Remove create product editor block package
* refresh pnpm-lock
* Remove deprecated product block editor
* clean up changes
* Remove block templates admin package
* Add changelog entries for block templates removal
* restore file
* Add compatibility shims for the BlockTemplate feature (#65539)
* Add block templates compatibility shims
* Add changelog entry for block templates shims
diff --git a/packages/js/block-templates/.eslintrc.js b/packages/js/block-templates/.eslintrc.js
deleted file mode 100644
index 6e5f03af242..00000000000
--- a/packages/js/block-templates/.eslintrc.js
+++ /dev/null
@@ -1,24 +0,0 @@
-module.exports = {
- extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
- root: true,
- overrides: [
- {
- files: [ '**/*.js', '**/*.jsx', '**/*.tsx' ],
- rules: {
- 'react/react-in-jsx-scope': 'off',
- },
- },
- ],
- settings: {
- 'import/core-modules': [
- '@wordpress/core-data',
- '@wordpress/blocks',
- '@woocommerce/expression-evaluation',
- ],
- 'import/resolver': {
- node: {},
- webpack: {},
- typescript: {},
- },
- },
-};
diff --git a/packages/js/block-templates/.npmrc b/packages/js/block-templates/.npmrc
deleted file mode 100644
index 43c97e719a5..00000000000
--- a/packages/js/block-templates/.npmrc
+++ /dev/null
@@ -1 +0,0 @@
-package-lock=false
diff --git a/packages/js/block-templates/README.md b/packages/js/block-templates/README.md
deleted file mode 100644
index 58260d2572d..00000000000
--- a/packages/js/block-templates/README.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# @woocommerce/block-templates
-
-A collection of utility functions for use with WooCommerce admin block templates.
-
-## API
-
-### registerWooBlockType
-
-Registers a WooCommerce block type.
-
-#### Usage
-
-```js
-import { registerWooBlockType } from '@woocommerce/block-templates';
-
-import metadata from './block.json';
-import { Edit } from './edit';
-
-registerWooBlockType( {
- name: metadata.name,
- metadata: metadata,
- settings: {
- edit: Edit,
- },
-} );
-```
-
-#### Parameters
-
-- _blockMetadata_ `Object`: Block metadata.
-
-#### Returns
-
-- `WPBlockType | undefined`: The block type if it was registered successfully, otherwise `undefined`.
-
-### useLayoutTemplate
-
-This hook is used to retrieve a layout template from the server.
-
-#### Usage
-
-```js
-import { useLayoutTemplate } from '@woocommerce/block-templates';
-
-export function Example() {
- const { layoutTemplate, isResolving } =
- useLayoutTemplate( 'my-layout-template' );
-
- return (
- <div>
- { isResolving && <p>Loading layout template...</p> }
- { layoutTemplate && (
- <p>{ JSON.stringify( layoutTemplate, null, 4 ) }</p>
- ) }
- { ! layoutTemplate && ! isResolving && (
- <p>'Layout template does not exist!'</p>
- ) }
- </div>
- );
-}
-```
-
-#### Parameters
-
-- _layoutTemplateId_ `string`: The id of the layout template to retrieve.
-
-#### Returns
-
-- `Object`
- - _layoutTemplate_ `Object | undefined`: The layout template if it was found, otherwise `null`.
- - _isResolving_ `boolean`: Whether or not the layout template is resolving.
-
-### useWooBlockProps
-
-This hook is used to lightly mark an element as a WooCommerce block template block. The block's attributes must be passed to this hook and the return result passed to the outermost element of the block in order for the block to properly function in WooCommerce block template contexts.
-
-If you define a ref for the element, it is important to pass the ref to this hook, which the hook in turn will pass to the component through the props it returns. Optionally, you can also pass any other props through this hook, and they will be merged and returned.
-
-#### Usage
-
-```js
-import { useWooBlockProps } from '@woocommerce/block-templates';
-
-export function Edit( { attributes } ) {
- const { blockProps } = useWooBlockProps( attributes, {
- className: 'my-block',
- } );
-
- return <div { ...blockProps }>Block content</div>;
-}
-```
-
-#### Parameters
-
-- _attributes_ `Object`: Block attributes.
-- _props_ `Object`: Optional. Props to pass to the element.
-
-#### Returns
-
-- `Object`: Props to pass to the element to mark as a WooCommerce block.
diff --git a/packages/js/block-templates/babel.config.js b/packages/js/block-templates/babel.config.js
deleted file mode 100644
index f73e04467aa..00000000000
--- a/packages/js/block-templates/babel.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = {
- extends: '../internal-js-tests/babel.config.js',
-};
diff --git a/packages/js/block-templates/build.mjs b/packages/js/block-templates/build.mjs
deleted file mode 100644
index 2d76d01222e..00000000000
--- a/packages/js/block-templates/build.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-import { runPackageBuilder } from '@woocommerce/internal-build';
-
-await runPackageBuilder( { entryPoints: 'src/**/*.{ts,tsx,js,jsx}' } );
diff --git a/packages/js/block-templates/changelog.md b/packages/js/block-templates/changelog.md
deleted file mode 100644
index 03f112d5be7..00000000000
--- a/packages/js/block-templates/changelog.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Changelog
-
-This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [1.1.0](https://www.npmjs.com/package/@woocommerce/block-templates/v/1.1.0) - 2024-04-12
-
-- Patch - Corrected build configuration for packages that weren't outputting minified code. [#43716]
-- Minor - Added useLayoutTemplate React hook, to load layout templates via the REST API [#43347]
-- Patch - bump php version in packages/js/*/composer.json [#42020]
-
-## [1.0.0](https://www.npmjs.com/package/@woocommerce/block-templates/v/1.0.0) - 2023-11-27
-
-- Minor - New product editor: Disable focus on root blocks, fixing unnecessary tab between fields in new product editor [#41436]
-- Minor - Add conditional visibility support to registered blocks. [#40722]
-- Minor - Initial version of @woocommerce/block-templates package. Adds registerWooBlockType and useWooBlockProps. [#40263]
-- Minor - Use _templateBlockDisableConditions attribute to evaluate disabled attribute [#41307]
-
-[See legacy changelogs for previous versions](https://github.com/woocommerce/woocommerce/blob/68581955106947918d2b17607a01bdfdf22288a9/packages/js/block-templates/CHANGELOG.md).
diff --git a/packages/js/block-templates/changelog/.gitkeep b/packages/js/block-templates/changelog/.gitkeep
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/packages/js/block-templates/changelog/52815-dev-lock-dependencies b/packages/js/block-templates/changelog/52815-dev-lock-dependencies
deleted file mode 100644
index e7c745f6928..00000000000
--- a/packages/js/block-templates/changelog/52815-dev-lock-dependencies
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Stabilize JS dependency updates
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/53165-dev-ts-5-7-2 b/packages/js/block-templates/changelog/53165-dev-ts-5-7-2
deleted file mode 100644
index 81738c8709d..00000000000
--- a/packages/js/block-templates/changelog/53165-dev-ts-5-7-2
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: minor
-Type: dev
-
-Upgraded Typescript in the monorepo to 5.7.2
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/53531-dev-react-18-ghidorah b/packages/js/block-templates/changelog/53531-dev-react-18-ghidorah
deleted file mode 100644
index ce948100616..00000000000
--- a/packages/js/block-templates/changelog/53531-dev-react-18-ghidorah
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: major
-Type: dev
-
-Updated declared dependencies to React 18 and Wordpress 6.6
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/54996-chore-update-wireit b/packages/js/block-templates/changelog/54996-chore-update-wireit
deleted file mode 100644
index aef524f6c95..00000000000
--- a/packages/js/block-templates/changelog/54996-chore-update-wireit
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Update wireit to 0.14.10
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/55095-dev-rewrite-wireit-deps-update b/packages/js/block-templates/changelog/55095-dev-rewrite-wireit-deps-update
deleted file mode 100644
index 6815cebd675..00000000000
--- a/packages/js/block-templates/changelog/55095-dev-rewrite-wireit-deps-update
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: refresh wireit dependencyOutputs configuration synchronization when installing dependencies.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/56341-update-register-woo-block-type-util-react-18 b/packages/js/block-templates/changelog/56341-update-register-woo-block-type-util-react-18
deleted file mode 100644
index e949ab303aa..00000000000
--- a/packages/js/block-templates/changelog/56341-update-register-woo-block-type-util-react-18
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-Comment: Cleanup task: Fix TypeScript error in block templates package from React 18 upgrade.
-
diff --git a/packages/js/block-templates/changelog/56575-dev-bump-babel-deps b/packages/js/block-templates/changelog/56575-dev-bump-babel-deps
deleted file mode 100644
index 510ab9c2a2a..00000000000
--- a/packages/js/block-templates/changelog/56575-dev-bump-babel-deps
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: consolidate @babel/* dependencies versions across the monorepo.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/56746-dev-webpack-deps-review b/packages/js/block-templates/changelog/56746-dev-webpack-deps-review
deleted file mode 100644
index b5d0c2d9741..00000000000
--- a/packages/js/block-templates/changelog/56746-dev-webpack-deps-review
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: Webpack deps review and consolidation and a bit of deps grooming
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/57299-fix-wireit-in-ci b/packages/js/block-templates/changelog/57299-fix-wireit-in-ci
deleted file mode 100644
index 10f4279499b..00000000000
--- a/packages/js/block-templates/changelog/57299-fix-wireit-in-ci
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Bump wireit dependency version to latest.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/58941-dev-consolidate-packages-license-version b/packages/js/block-templates/changelog/58941-dev-consolidate-packages-license-version
deleted file mode 100644
index 879d15ddabc..00000000000
--- a/packages/js/block-templates/changelog/58941-dev-consolidate-packages-license-version
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: consolidate packages licenses to `GPL-2.0-or-later`.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/59166-dev-faster-watch-startup-batch-1 b/packages/js/block-templates/changelog/59166-dev-faster-watch-startup-batch-1
deleted file mode 100644
index 12fce504f86..00000000000
--- a/packages/js/block-templates/changelog/59166-dev-faster-watch-startup-batch-1
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: watch startup time optimization.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/63483-add-62921-shared-monorepo-ts-config b/packages/js/block-templates/changelog/63483-add-62921-shared-monorepo-ts-config
deleted file mode 100644
index 03e468e5a6e..00000000000
--- a/packages/js/block-templates/changelog/63483-add-62921-shared-monorepo-ts-config
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Replaced patched `@wordpress/data` types with opt-in internal package types.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/64111-dev-fix-admin-webpack-cache-misses b/packages/js/block-templates/changelog/64111-dev-fix-admin-webpack-cache-misses
deleted file mode 100644
index 13e547f58b4..00000000000
--- a/packages/js/block-templates/changelog/64111-dev-fix-admin-webpack-cache-misses
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: refresh DependencyExtractionWebpackPlugin for compatibility with filesystem cache, admin build cleanup.
\ No newline at end of file
diff --git a/packages/js/block-templates/changelog/64838-dev-esbuild-package-builds b/packages/js/block-templates/changelog/64838-dev-esbuild-package-builds
deleted file mode 100644
index 53b9c7cd29c..00000000000
--- a/packages/js/block-templates/changelog/64838-dev-esbuild-package-builds
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Replaced wireit + tsc package build pipeline with a per-package esbuild script.
diff --git a/packages/js/block-templates/changelog/add-backend-template-match b/packages/js/block-templates/changelog/add-backend-template-match
deleted file mode 100644
index 611477327a4..00000000000
--- a/packages/js/block-templates/changelog/add-backend-template-match
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: tweak
-
-Change useLayoutTemplate signature from 'undefined' to 'null'
diff --git a/packages/js/block-templates/changelog/build-webpack-filesystem-cache b/packages/js/block-templates/changelog/build-webpack-filesystem-cache
deleted file mode 100644
index 372ab63b961..00000000000
--- a/packages/js/block-templates/changelog/build-webpack-filesystem-cache
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: minor
-Type: dev
-
-Improve build time for block-templates by using webpack filesystem cache.
diff --git a/packages/js/block-templates/changelog/ci-add-workflow-call-event b/packages/js/block-templates/changelog/ci-add-workflow-call-event
deleted file mode 100644
index 4a94d942fe9..00000000000
--- a/packages/js/block-templates/changelog/ci-add-workflow-call-event
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Update events that should trigger the test job(s)
diff --git a/packages/js/block-templates/changelog/dev-55910-deps-consolidation b/packages/js/block-templates/changelog/dev-55910-deps-consolidation
deleted file mode 100644
index 2b9c4b53b13..00000000000
--- a/packages/js/block-templates/changelog/dev-55910-deps-consolidation
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: consolidate @wordpress/babel-preset-default, @wordpress/browserslist-config, glob packages versions.
diff --git a/packages/js/block-templates/changelog/dev-64837-type-check-only-on-lint b/packages/js/block-templates/changelog/dev-64837-type-check-only-on-lint
deleted file mode 100644
index efdb3bd771a..00000000000
--- a/packages/js/block-templates/changelog/dev-64837-type-check-only-on-lint
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Move TypeScript type-checking from the build to a new `lint:lang:types` script. Builds now emit types and JS without type-checking.
diff --git a/packages/js/block-templates/changelog/dev-build-profiling-tweaks-take-1 b/packages/js/block-templates/changelog/dev-build-profiling-tweaks-take-1
deleted file mode 100644
index bb77f6da5ff..00000000000
--- a/packages/js/block-templates/changelog/dev-build-profiling-tweaks-take-1
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: consolidate TypeScript config files and JS test directories naming.
diff --git a/packages/js/block-templates/changelog/dev-build-ram-1-admin-layout-block-themes b/packages/js/block-templates/changelog/dev-build-ram-1-admin-layout-block-themes
deleted file mode 100644
index e6d0ed6aaaf..00000000000
--- a/packages/js/block-templates/changelog/dev-build-ram-1-admin-layout-block-themes
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: build RAM usage optimization.
diff --git a/packages/js/block-templates/changelog/dev-ci-jobs-clean-up-cascading-keys-config-option b/packages/js/block-templates/changelog/dev-ci-jobs-clean-up-cascading-keys-config-option
deleted file mode 100644
index d36f953d7ba..00000000000
--- a/packages/js/block-templates/changelog/dev-ci-jobs-clean-up-cascading-keys-config-option
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-dev: clean-up ci-job config options - remove unused cascading keys
diff --git a/packages/js/block-templates/changelog/dev-ci-lint-monorepo-job-update b/packages/js/block-templates/changelog/dev-ci-lint-monorepo-job-update
deleted file mode 100644
index 4def83412ad..00000000000
--- a/packages/js/block-templates/changelog/dev-ci-lint-monorepo-job-update
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-CI: liverage composer packages cache in lint monorepo job
diff --git a/packages/js/block-templates/changelog/dev-cjs-prepack-only b/packages/js/block-templates/changelog/dev-cjs-prepack-only
deleted file mode 100644
index 0f64fecf28c..00000000000
--- a/packages/js/block-templates/changelog/dev-cjs-prepack-only
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Move the CommonJS build to prepack so day-to-day development only builds the ESM output.
diff --git a/packages/js/block-templates/changelog/dev-consolidate-syncpack-config b/packages/js/block-templates/changelog/dev-consolidate-syncpack-config
deleted file mode 100644
index 7ab3e6a6116..00000000000
--- a/packages/js/block-templates/changelog/dev-consolidate-syncpack-config
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: consolidate syncpack config around React 17/18 usage.
diff --git a/packages/js/block-templates/changelog/dev-monorepo-internal-packages-linking-fixes b/packages/js/block-templates/changelog/dev-monorepo-internal-packages-linking-fixes
deleted file mode 100644
index 52ec37bc356..00000000000
--- a/packages/js/block-templates/changelog/dev-monorepo-internal-packages-linking-fixes
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Monorepo: ensure monorepo packages are linked via workspace-version of the dependencies.
diff --git a/packages/js/block-templates/changelog/dev-updates-to-packages-for-dependencies b/packages/js/block-templates/changelog/dev-updates-to-packages-for-dependencies
deleted file mode 100644
index 213a23df05a..00000000000
--- a/packages/js/block-templates/changelog/dev-updates-to-packages-for-dependencies
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Update dependencies
diff --git a/packages/js/block-templates/changelog/fix-create-variations-crash-react-18 b/packages/js/block-templates/changelog/fix-create-variations-crash-react-18
deleted file mode 100644
index b3608188780..00000000000
--- a/packages/js/block-templates/changelog/fix-create-variations-crash-react-18
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: fix
-
-Only attempt to fetch layout template in useLayoutTemplate when layout template id is provided.
diff --git a/packages/js/block-templates/changelog/fix-experimental_role_warning b/packages/js/block-templates/changelog/fix-experimental_role_warning
deleted file mode 100644
index 6f2532f63ef..00000000000
--- a/packages/js/block-templates/changelog/fix-experimental_role_warning
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: minor
-Type: update
-
-Removing the use of __experimentalRole and using role instead.
diff --git a/packages/js/block-templates/changelog/fix-layout-template-request b/packages/js/block-templates/changelog/fix-layout-template-request
deleted file mode 100644
index 57f47afff7d..00000000000
--- a/packages/js/block-templates/changelog/fix-layout-template-request
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: minor
-Type: fix
-
-Fix layout template request not being executed
diff --git a/packages/js/block-templates/changelog/update-59804 b/packages/js/block-templates/changelog/update-59804
deleted file mode 100644
index 5a1702a76a3..00000000000
--- a/packages/js/block-templates/changelog/update-59804
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: minor
-Type: dev
-
-Bump jest package dependency to 29.5.x
diff --git a/packages/js/block-templates/changelog/update-pnpm-10-upgrade b/packages/js/block-templates/changelog/update-pnpm-10-upgrade
deleted file mode 100644
index 06fa4b8bf68..00000000000
--- a/packages/js/block-templates/changelog/update-pnpm-10-upgrade
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: dev
-
-Update @wordpress/* peerDependencies from dist-tags to semver ranges for pnpm 10 compatibility.
diff --git a/packages/js/block-templates/changelog/update-wp-68-packages b/packages/js/block-templates/changelog/update-wp-68-packages
deleted file mode 100644
index 866d7f6ed70..00000000000
--- a/packages/js/block-templates/changelog/update-wp-68-packages
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: major
-Type: update
-
-Update @wordpress/* dependencies to wp-6.8 minimum.
diff --git a/packages/js/block-templates/composer.json b/packages/js/block-templates/composer.json
deleted file mode 100644
index b6a4020bff1..00000000000
--- a/packages/js/block-templates/composer.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "name": "woocommerce/block-templates",
- "description": "WooCommerce Admin block templates component library",
- "type": "library",
- "license": "GPL-2.0-or-later",
- "minimum-stability": "dev",
- "require-dev": {
- "automattic/jetpack-changelogger": "3.3.0"
- },
- "config": {
- "platform": {
- "php": "7.4"
- }
- },
- "extra": {
- "changelogger": {
- "formatter": {
- "filename": "../../../tools/changelogger/class-package-formatter.php"
- },
- "types": {
- "fix": "Fixes an existing bug",
- "add": "Adds functionality",
- "update": "Update existing functionality",
- "dev": "Development related task",
- "tweak": "A minor adjustment to the codebase",
- "performance": "Address performance issues",
- "enhancement": "Improve existing functionality"
- },
- "changelog": "CHANGELOG.md"
- }
- }
-}
diff --git a/packages/js/block-templates/composer.lock b/packages/js/block-templates/composer.lock
deleted file mode 100644
index b22bf962af6..00000000000
--- a/packages/js/block-templates/composer.lock
+++ /dev/null
@@ -1,1084 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
- "This file is @generated automatically"
- ],
- "content-hash": "64cdabcee577502d768ecb072264a6fb",
- "packages": [],
- "packages-dev": [
- {
- "name": "automattic/jetpack-changelogger",
- "version": "v3.3.0",
- "source": {
- "type": "git",
- "url": "https://github.com/Automattic/jetpack-changelogger.git",
- "reference": "8f63c829b8d1b0d7b1d5de93510d78523ed18959"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/Automattic/jetpack-changelogger/zipball/8f63c829b8d1b0d7b1d5de93510d78523ed18959",
- "reference": "8f63c829b8d1b0d7b1d5de93510d78523ed18959",
- "shasum": ""
- },
- "require": {
- "php": ">=5.6",
- "symfony/console": "^3.4 || ^5.2 || ^6.0",
- "symfony/process": "^3.4 || ^5.2 || ^6.0",
- "wikimedia/at-ease": "^1.2 || ^2.0"
- },
- "require-dev": {
- "wikimedia/testing-access-wrapper": "^1.0 || ^2.0",
- "yoast/phpunit-polyfills": "1.0.4"
- },
- "bin": [
- "bin/changelogger"
- ],
- "type": "project",
- "extra": {
- "autotagger": true,
- "mirror-repo": "Automattic/jetpack-changelogger",
- "branch-alias": {
- "dev-trunk": "3.3.x-dev"
- },
- "changelogger": {
- "link-template": "https://github.com/Automattic/jetpack-changelogger/compare/${old}...${new}"
- },
- "version-constants": {
- "::VERSION": "src/Application.php"
- }
- },
- "autoload": {
- "psr-4": {
- "Automattic\\Jetpack\\Changelog\\": "lib",
- "Automattic\\Jetpack\\Changelogger\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "GPL-2.0-or-later"
- ],
- "description": "Jetpack Changelogger tool. Allows for managing changelogs by dropping change files into a changelog directory with each PR.",
- "support": {
- "source": "https://github.com/Automattic/jetpack-changelogger/tree/v3.3.0"
- },
- "time": "2022-12-26T13:49:01+00:00"
- },
- {
- "name": "psr/container",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/container.git",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
- "shasum": ""
- },
- "require": {
- "php": ">=7.4.0"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Psr\\Container\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "PHP-FIG",
- "homepage": "https://www.php-fig.org/"
- }
- ],
- "description": "Common Container Interface (PHP FIG PSR-11)",
- "homepage": "https://github.com/php-fig/container",
- "keywords": [
- "PSR-11",
- "container",
- "container-interface",
- "container-interop",
- "psr"
- ],
- "support": {
- "issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/1.1.2"
- },
- "time": "2021-11-05T16:50:12+00:00"
- },
- {
- "name": "symfony/console",
- "version": "5.4.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/console.git",
- "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
- "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.16",
- "symfony/service-contracts": "^1.1|^2|^3",
- "symfony/string": "^5.1|^6.0"
- },
- "conflict": {
- "psr/log": ">=3",
- "symfony/dependency-injection": "<4.4",
- "symfony/dotenv": "<5.1",
- "symfony/event-dispatcher": "<4.4",
- "symfony/lock": "<4.4",
- "symfony/process": "<4.4"
- },
- "provide": {
- "psr/log-implementation": "1.0|2.0"
- },
- "require-dev": {
- "psr/log": "^1|^2",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
- "symfony/lock": "^4.4|^5.0|^6.0",
- "symfony/process": "^4.4|^5.0|^6.0",
- "symfony/var-dumper": "^4.4|^5.0|^6.0"
- },
- "suggest": {
- "psr/log": "For using the console logger",
- "symfony/event-dispatcher": "",
- "symfony/lock": "",
- "symfony/process": ""
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Console\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Eases the creation of beautiful and testable command line interfaces",
- "homepage": "https://symfony.com",
- "keywords": [
- "cli",
- "command-line",
- "console",
- "terminal"
- ],
- "support": {
- "source": "https://github.com/symfony/console/tree/5.4"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-11-06T11:30:55+00:00"
- },
- {
- "name": "symfony/deprecation-contracts",
- "version": "2.5.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
- "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/contracts",
- "name": "symfony/contracts"
- },
- "branch-alias": {
- "dev-main": "2.5-dev"
- }
- },
- "autoload": {
- "files": [
- "function.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "A generic function and convention to trigger deprecation notices",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/2.5"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-09-25T14:11:13+00:00"
- },
- {
- "name": "symfony/polyfill-ctype",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
- "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "provide": {
- "ext-ctype": "*"
- },
- "suggest": {
- "ext-ctype": "For best performance"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Gert de Pagter",
- "email": "BackEndTea@gmail.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for ctype functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "ctype",
- "polyfill",
- "portable"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-09-09T11:45:10+00:00"
- },
- {
- "name": "symfony/polyfill-intl-grapheme",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70",
- "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "suggest": {
- "ext-intl": "For best performance"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for intl's grapheme_* functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "grapheme",
- "intl",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2025-06-27T09:58:17+00:00"
- },
- {
- "name": "symfony/polyfill-intl-normalizer",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "3833d7255cc303546435cb650316bff708a1c75c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c",
- "reference": "3833d7255cc303546435cb650316bff708a1c75c",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "suggest": {
- "ext-intl": "For best performance"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for intl's Normalizer class and related functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "intl",
- "normalizer",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-09-09T11:45:10+00:00"
- },
- {
- "name": "symfony/polyfill-mbstring",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
- "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
- "shasum": ""
- },
- "require": {
- "ext-iconv": "*",
- "php": ">=7.2"
- },
- "provide": {
- "ext-mbstring": "*"
- },
- "suggest": {
- "ext-mbstring": "For best performance"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Mbstring\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for the Mbstring extension",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "mbstring",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-12-23T08:48:59+00:00"
- },
- {
- "name": "symfony/polyfill-php73",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
- "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-09-09T11:45:10+00:00"
- },
- {
- "name": "symfony/polyfill-php80",
- "version": "1.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
- "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "default-branch": true,
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/polyfill",
- "name": "symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Ion Bazan",
- "email": "ion.bazan@gmail.com"
- },
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://github.com/nicolas-grekas",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2025-01-02T08:10:11+00:00"
- },
- {
- "name": "symfony/process",
- "version": "5.4.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/process.git",
- "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d",
- "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/polyfill-php80": "^1.16"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Process\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Executes commands in sub-processes",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/process/tree/5.4"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-11-06T11:36:42+00:00"
- },
- {
- "name": "symfony/service-contracts",
- "version": "2.5.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/service-contracts.git",
- "reference": "f37b419f7aea2e9abf10abd261832cace12e3300"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300",
- "reference": "f37b419f7aea2e9abf10abd261832cace12e3300",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "psr/container": "^1.1",
- "symfony/deprecation-contracts": "^2.1|^3"
- },
- "conflict": {
- "ext-psr": "<1.1|>=2"
- },
- "suggest": {
- "symfony/service-implementation": ""
- },
- "type": "library",
- "extra": {
- "thanks": {
- "url": "https://github.com/symfony/contracts",
- "name": "symfony/contracts"
- },
- "branch-alias": {
- "dev-main": "2.5-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Contracts\\Service\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Generic abstractions related to writing services",
- "homepage": "https://symfony.com",
- "keywords": [
- "abstractions",
- "contracts",
- "decoupling",
- "interfaces",
- "interoperability",
- "standards"
- ],
- "support": {
- "source": "https://github.com/symfony/service-contracts/tree/2.5"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-09-25T14:11:13+00:00"
- },
- {
- "name": "symfony/string",
- "version": "5.4.x-dev",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/string.git",
- "reference": "136ca7d72f72b599f2631aca474a4f8e26719799"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799",
- "reference": "136ca7d72f72b599f2631aca474a4f8e26719799",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/polyfill-ctype": "~1.8",
- "symfony/polyfill-intl-grapheme": "~1.0",
- "symfony/polyfill-intl-normalizer": "~1.0",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "~1.15"
- },
- "conflict": {
- "symfony/translation-contracts": ">=3.0"
- },
- "require-dev": {
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/http-client": "^4.4|^5.0|^6.0",
- "symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0|^6.0"
- },
- "type": "library",
- "autoload": {
- "files": [
- "Resources/functions.php"
- ],
- "psr-4": {
- "Symfony\\Component\\String\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
- "homepage": "https://symfony.com",
- "keywords": [
- "grapheme",
- "i18n",
- "string",
- "unicode",
- "utf-8",
- "utf8"
- ],
- "support": {
- "source": "https://github.com/symfony/string/tree/5.4"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2024-11-10T20:33:58+00:00"
- },
- {
- "name": "wikimedia/at-ease",
- "version": "v2.1.0",
- "source": {
- "type": "git",
- "url": "https://github.com/wikimedia/at-ease.git",
- "reference": "e8ebaa7bb7c8a8395481a05f6dc4deaceab11c33"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/wikimedia/at-ease/zipball/e8ebaa7bb7c8a8395481a05f6dc4deaceab11c33",
- "reference": "e8ebaa7bb7c8a8395481a05f6dc4deaceab11c33",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.9"
- },
- "require-dev": {
- "mediawiki/mediawiki-codesniffer": "35.0.0",
- "mediawiki/minus-x": "1.1.1",
- "ockcyp/covers-validator": "1.3.3",
- "php-parallel-lint/php-console-highlighter": "0.5.0",
- "php-parallel-lint/php-parallel-lint": "1.2.0",
- "phpunit/phpunit": "^8.5"
- },
- "type": "library",
- "autoload": {
- "files": [
- "src/Wikimedia/Functions.php"
- ],
- "psr-4": {
- "Wikimedia\\AtEase\\": "src/Wikimedia/AtEase/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "GPL-2.0-or-later"
- ],
- "authors": [
- {
- "name": "Tim Starling",
- "email": "tstarling@wikimedia.org"
- },
- {
- "name": "MediaWiki developers",
- "email": "wikitech-l@lists.wikimedia.org"
- }
- ],
- "description": "Safe replacement to @ for suppressing warnings.",
- "homepage": "https://www.mediawiki.org/wiki/at-ease",
- "support": {
- "source": "https://github.com/wikimedia/at-ease/tree/v2.1.0"
- },
- "time": "2021-02-27T15:53:37+00:00"
- }
- ],
- "aliases": [],
- "minimum-stability": "dev",
- "stability-flags": {},
- "prefer-stable": false,
- "prefer-lowest": false,
- "platform": {},
- "platform-dev": {},
- "platform-overrides": {
- "php": "7.4"
- },
- "plugin-api-version": "2.6.0"
-}
diff --git a/packages/js/block-templates/jest.config.json b/packages/js/block-templates/jest.config.json
deleted file mode 100644
index fa3347efcc7..00000000000
--- a/packages/js/block-templates/jest.config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "rootDir": "./",
- "roots": [
- "<rootDir>/src"
- ],
- "preset": "./node_modules/@woocommerce/internal-js-tests/jest-preset.js"
-}
diff --git a/packages/js/block-templates/package.json b/packages/js/block-templates/package.json
deleted file mode 100644
index 914a12a3a5b..00000000000
--- a/packages/js/block-templates/package.json
+++ /dev/null
@@ -1,143 +0,0 @@
-{
- "name": "@woocommerce/block-templates",
- "version": "1.1.0",
- "description": "Utilities for working with block templates in WooCommerce admin.",
- "author": "Automattic",
- "license": "GPL-2.0-or-later",
- "keywords": [
- "wordpress",
- "woocommerce"
- ],
- "homepage": "https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/block-templates/README.md",
- "repository": {
- "type": "git",
- "url": "https://github.com/woocommerce/woocommerce.git"
- },
- "bugs": {
- "url": "https://github.com/woocommerce/woocommerce/issues"
- },
- "exports": {
- ".": {
- "wc-source": "./src/index.ts",
- "types": "./build-types/index.d.ts",
- "import": "./build-module/index.js",
- "require": "./build/index.js"
- }
- },
- "main": "build/index.js",
- "module": "build-module/index.js",
- "types": "build-types/index.d.ts",
- "react-native": "src/index",
- "files": [
- "build",
- "build-module",
- "build-style",
- "build-types"
- ],
- "sideEffects": [
- "build-style/**",
- "src/**/*.scss"
- ],
- "scripts": {
- "build": "pnpm build:project",
- "build:project": "pnpm --stream '/^build:project:.*$/'",
- "build:project:bundle": "NODE_ENV=production webpack",
- "build:project:esm": "node build.mjs",
- "build:publish:project": "pnpm --stream '/^build:publish:project:.*$/'",
- "build:publish:project:cjs": "node build.mjs --commonjs",
- "build:publish:project:types": "tsc --build --emitDeclarationOnly",
- "build:publish:project:runtime": "pnpm build:project",
- "changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger",
- "lint": "pnpm --if-present '/^lint:lang:.*$/'",
- "lint:fix": "pnpm --if-present '/^lint:fix:lang:.*$/'",
- "lint:fix:lang:js": "eslint src --fix",
- "lint:lang:js": "eslint src",
- "lint:lang:types": "tsc --build --emitDeclarationOnly",
- "prepack": "pnpm build:publish:project",
- "test:js": "jest --config ./jest.config.json --passWithNoTests",
- "update:php": "XDEBUG_MODE=off composer update --quiet",
- "watch:build": "pnpm watch:build:project",
- "watch:build:project": "pnpm --stream '/^watch:build:project:.*$/'",
- "watch:build:project:bundle": "NODE_ENV=development webpack --watch",
- "watch:build:project:esm": "node build.mjs --watch"
- },
- "dependencies": {
- "@woocommerce/expression-evaluation": "workspace:*",
- "@woocommerce/settings": "1.0.0",
- "@wordpress/block-editor": "catalog:wp-min",
- "@wordpress/blocks": "catalog:wp-min",
- "@wordpress/core-data": "catalog:wp-min",
- "@wordpress/element": "catalog:wp-min"
- },
- "devDependencies": {
- "@babel/core": "7.25.7",
- "@babel/runtime": "7.25.7",
- "@testing-library/jest-dom": "^6.x.x",
- "@testing-library/react": "^16.x.x",
- "@types/jest": "29.5.x",
- "@types/react": "18.3.x",
- "@types/testing-library__jest-dom": "^5.14.9",
- "@types/wordpress__block-editor": "catalog:wp-min",
- "@types/wordpress__blocks": "catalog:wp-min",
- "@woocommerce/eslint-plugin": "workspace:*",
- "@woocommerce/internal-build": "workspace:*",
- "@woocommerce/internal-js-tests": "workspace:*",
- "@wordpress/browserslist-config": "next",
- "copy-webpack-plugin": "13.0.x",
- "css-loader": "6.11.x",
- "eslint": "^8.55.0",
- "jest": "29.5.x",
- "jest-cli": "29.5.x",
- "jest-environment-jsdom": "29.5.x",
- "postcss": "8.4.x",
- "postcss-loader": "4.3.x",
- "react": "18.3.x",
- "react-dom": "18.3.x",
- "rimraf": "5.0.5",
- "sass-loader": "10.5.x",
- "ts-jest": "29.1.x",
- "typescript": "5.7.x",
- "webpack": "5.97.x",
- "webpack-cli": "5.1.x"
- },
- "peerDependencies": {
- "@types/react": "18.3.x",
- "@wordpress/data": "^10.0.2",
- "react": "18.3.x",
- "react-dom": "18.3.x"
- },
- "publishConfig": {
- "access": "public",
- "exports": {
- ".": {
- "types": "./build-types/index.d.ts",
- "import": "./build-module/index.js",
- "require": "./build/index.js"
- }
- }
- },
- "config": {
- "ci": {
- "lint": {
- "command": "lint",
- "changes": "src/**/*.{js,jsx,ts,tsx}"
- },
- "tests": [
- {
- "name": "JavaScript",
- "command": "test:js",
- "changes": [
- "jest.config.js",
- "tsconfig.json",
- "src/**/*.{js,jsx,ts,tsx}",
- "typings/**/*.ts"
- ],
- "events": [
- "pull_request",
- "push"
- ]
- }
- ]
- }
- }
-}
diff --git a/packages/js/block-templates/src/hooks/index.ts b/packages/js/block-templates/src/hooks/index.ts
deleted file mode 100644
index 624b536d8e9..00000000000
--- a/packages/js/block-templates/src/hooks/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './use-layout-template';
-export * from './use-woo-block-props';
diff --git a/packages/js/block-templates/src/hooks/use-layout-template/index.ts b/packages/js/block-templates/src/hooks/use-layout-template/index.ts
deleted file mode 100644
index 9bd3663bb47..00000000000
--- a/packages/js/block-templates/src/hooks/use-layout-template/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './use-layout-template';
diff --git a/packages/js/block-templates/src/hooks/use-layout-template/use-layout-template.ts b/packages/js/block-templates/src/hooks/use-layout-template/use-layout-template.ts
deleted file mode 100644
index 681cc1ed033..00000000000
--- a/packages/js/block-templates/src/hooks/use-layout-template/use-layout-template.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * External dependencies
- */
-import { useEffect, useState } from '@wordpress/element';
-import { useEntityRecord, store as coreDataStore } from '@wordpress/core-data';
-import { dispatch, select } from '@wordpress/data';
-
-export const useLayoutTemplate = ( layoutTemplateId: string | null ) => {
- const [ isEntityRegistered, setIsEntityRegistered ] = useState( false );
-
- useEffect( () => {
- if ( ! layoutTemplateId ) return;
-
- const layoutTemplateEntity = select( coreDataStore ).getEntityConfig(
- 'root',
- 'wcLayoutTemplate'
- );
- if ( ! layoutTemplateEntity ) {
- dispatch( coreDataStore ).addEntities( [
- {
- kind: 'root',
- name: 'wcLayoutTemplate',
- baseURL: '/wc/v3/layout-templates',
- label: 'Layout Templates',
- },
- ] );
- }
-
- setIsEntityRegistered( true );
- }, [ layoutTemplateId ] );
-
- const { record: layoutTemplate, isResolving } = useEntityRecord(
- 'root',
- 'wcLayoutTemplate',
- // Because of the regression mentioned below, REST API requests will still be triggered
- // even when the query is disabled. This means that if we pass `undefined`/`null` as the ID,
- // the query will be triggered with no ID, which will return all layout templates.
- // To prevent this, we pass `__invalid-template-id` as the ID when there is no layout template ID.
- // A request will still be triggered, but it will return no results.
- layoutTemplateId || '__invalid-template-id',
- // Only perform the query if the layout template entity is registered and we have a layout template ID; otherwise, just return null.
- // Note: Until we are using @woocommerce/core-data 6.24.0 (Gutenberg 17.2),
- // the REST API requests will still be triggered even when the query is disabled due to a regression.
- // See: https://github.com/WordPress/gutenberg/pull/56108
- { enabled: isEntityRegistered && !! layoutTemplateId }
- );
-
- return { layoutTemplate, isResolving };
-};
diff --git a/packages/js/block-templates/src/hooks/use-woo-block-props/index.ts b/packages/js/block-templates/src/hooks/use-woo-block-props/index.ts
deleted file mode 100644
index 5a9815093b9..00000000000
--- a/packages/js/block-templates/src/hooks/use-woo-block-props/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './use-woo-block-props';
diff --git a/packages/js/block-templates/src/hooks/use-woo-block-props/test/use-woo-block-props.test.ts b/packages/js/block-templates/src/hooks/use-woo-block-props/test/use-woo-block-props.test.ts
deleted file mode 100644
index 8b58acc35cf..00000000000
--- a/packages/js/block-templates/src/hooks/use-woo-block-props/test/use-woo-block-props.test.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * External dependencies
- */
-import { renderHook } from '@testing-library/react';
-import { useBlockProps } from '@wordpress/block-editor';
-
-/**
- * Internal dependencies
- */
-import { useWooBlockProps } from '../use-woo-block-props';
-
-jest.mock( '@wordpress/block-editor', () => ( {
- useBlockProps: jest.fn(),
-} ) );
-
-describe( 'useWooBlockProps', () => {
- it( 'should return the block props with the block id, block order attributes, and tabindex', () => {
- renderHook( () =>
- useWooBlockProps(
- {
- foo: 'bar',
- _templateBlockId: 'test/block',
- _templateBlockOrder: 30,
- },
- {
- className: 'test',
- }
- )
- );
-
- expect( useBlockProps ).toHaveBeenCalledWith( {
- 'data-template-block-id': 'test/block',
- 'data-template-block-order': 30,
- tabIndex: -1,
- className: 'test',
- } );
- } );
-} );
diff --git a/packages/js/block-templates/src/hooks/use-woo-block-props/use-woo-block-props.ts b/packages/js/block-templates/src/hooks/use-woo-block-props/use-woo-block-props.ts
deleted file mode 100644
index c1728fd1121..00000000000
--- a/packages/js/block-templates/src/hooks/use-woo-block-props/use-woo-block-props.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * External dependencies
- */
-import { useBlockProps } from '@wordpress/block-editor';
-
-interface TemplateBlockAttributes {
- _templateBlockId?: string;
- _templateBlockOrder?: number;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- [ key: string ]: any;
-}
-
-export const useWooBlockProps = (
- attributes: TemplateBlockAttributes,
- props: Record< string, unknown > = {}
-) => {
- const additionalProps = {
- 'data-template-block-id': attributes._templateBlockId,
- 'data-template-block-order': attributes._templateBlockOrder,
- tabIndex: -1,
- ...props,
- };
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore the type definitions are slightly wrong. It should be possible to pass the tabIndex attribute.
- return useBlockProps( additionalProps );
-};
diff --git a/packages/js/block-templates/src/index.ts b/packages/js/block-templates/src/index.ts
deleted file mode 100644
index fd70c425092..00000000000
--- a/packages/js/block-templates/src/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './hooks';
-export * from './utils';
diff --git a/packages/js/block-templates/src/style.scss b/packages/js/block-templates/src/style.scss
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/packages/js/block-templates/src/typings/index.d.ts b/packages/js/block-templates/src/typings/index.d.ts
deleted file mode 100644
index 4d11d9a97aa..00000000000
--- a/packages/js/block-templates/src/typings/index.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-declare module '@woocommerce/settings' {
- export declare function getAdminLink( path: string ): string;
- export declare function getSetting< T >(
- name: string,
- fallback?: unknown,
- filter = ( val: unknown, fb: unknown ) =>
- typeof val !== 'undefined' ? val : fb
- ): T;
- export declare function isWpVersion(
- version: string,
- operator: '>' | '>=' | '=' | '<' | '<='
- ): boolean;
-}
diff --git a/packages/js/block-templates/src/utils/index.ts b/packages/js/block-templates/src/utils/index.ts
deleted file mode 100644
index b5e6f40e845..00000000000
--- a/packages/js/block-templates/src/utils/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './register-woo-block-type';
diff --git a/packages/js/block-templates/src/utils/register-woo-block-type.ts b/packages/js/block-templates/src/utils/register-woo-block-type.ts
deleted file mode 100644
index 77326aeedfc..00000000000
--- a/packages/js/block-templates/src/utils/register-woo-block-type.ts
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * External dependencies
- */
-import {
- Block,
- BlockConfiguration,
- BlockEditProps,
- registerBlockType,
-} from '@wordpress/blocks';
-import { createElement } from '@wordpress/element';
-import { evaluate } from '@woocommerce/expression-evaluation';
-import { isWpVersion, getSetting } from '@woocommerce/settings';
-import { ComponentType } from 'react';
-import { useSelect } from '@wordpress/data';
-
-// Define a more generic type for the select function to avoid TypeScript errors
-type SelectType = ( store: string ) => Record< string, unknown >;
-
-interface BlockRepresentation< T extends Record< string, object > > {
- name?: string;
- metadata: BlockConfiguration< T >;
- settings: Partial< BlockConfiguration< T > >;
-}
-
-type UseEvaluationContext = ( context: Record< string, unknown > ) => {
- getEvaluationContext: ( select: SelectType ) => Record< string, unknown >;
-};
-
-function defaultUseEvaluationContext( context: Record< string, unknown > ) {
- return {
- getEvaluationContext: () => context,
- };
-}
-
-function getEdit<
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- T extends Record< string, object > = Record< string, object >
->(
- edit: ComponentType< BlockEditProps< T > >,
- useEvaluationContext: UseEvaluationContext
-): ComponentType< BlockEditProps< T > > {
- return ( props ) => {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore context is added to the block props by the block editor.
- const { context } = props;
- const {
- _templateBlockHideConditions: hideConditions,
- _templateBlockDisableConditions: disableConditions,
- } = props.attributes;
-
- const { getEvaluationContext } = useEvaluationContext( context );
-
- const { shouldHide, shouldDisable } = useSelect(
- ( select: SelectType ) => {
- const evaluationContext = getEvaluationContext( select );
-
- return {
- shouldHide:
- hideConditions &&
- Array.isArray( hideConditions ) &&
- hideConditions.some( ( condition ) =>
- evaluate( condition.expression, evaluationContext )
- ),
- shouldDisable:
- disableConditions &&
- Array.isArray( disableConditions ) &&
- disableConditions.some( ( condition ) =>
- evaluate( condition.expression, evaluationContext )
- ),
- };
- },
- [ getEvaluationContext, hideConditions, disableConditions ]
- );
-
- if ( ! edit || shouldHide ) {
- return null;
- }
-
- return createElement( edit, {
- ...props,
- attributes: {
- ...props.attributes,
- disabled: props.attributes.disabled || shouldDisable,
- },
- } );
- };
-}
-
-let requiresExperimentalRole = isWpVersion( '6.7', '<' );
-const adminSettings: { gutenberg_version?: string } = getSetting( 'admin' );
-if ( requiresExperimentalRole && adminSettings.gutenberg_version ) {
- requiresExperimentalRole =
- parseFloat( adminSettings?.gutenberg_version ) < 19.4;
-}
-
-function augmentAttributes<
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- T extends Record< string, any > = Record< string, any >
->( attributes: T ) {
- const augmentedAttributes = {
- ...attributes,
- ...{
- _templateBlockId: {
- type: 'string',
- role: 'content',
- },
- _templateBlockOrder: {
- type: 'integer',
- role: 'content',
- },
- _templateBlockHideConditions: {
- type: 'array',
- role: 'content',
- },
- _templateBlockDisableConditions: {
- type: 'array',
- role: 'content',
- },
- disabled: attributes.disabled || {
- type: 'boolean',
- role: 'content',
- },
- },
- };
- if ( requiresExperimentalRole ) {
- return Object.keys( augmentedAttributes ).reduce(
- ( acc, key: keyof T ) => {
- if ( augmentedAttributes[ key ].role ) {
- acc[ key ] = {
- ...augmentedAttributes[ key ],
- __experimentalRole: augmentedAttributes[ key ].role,
- };
- } else {
- acc[ key ] = augmentedAttributes[ key ];
- }
- return acc;
- },
- {} as T
- );
- }
- return augmentedAttributes;
-}
-
-/**
- * Function to register an individual block.
- *
- * @param block The block to be registered.
- * @return The block, if it has been successfully registered; otherwise `undefined`.
- */
-export function registerWooBlockType<
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- T extends Record< string, any > = Record< string, any >
->(
- block: BlockRepresentation< T >,
- useEvaluationContext?: UseEvaluationContext
-): Block< T > | undefined {
- if ( ! block ) {
- return;
- }
- const { metadata, settings, name } = block;
- const { edit } = settings;
-
- if ( ! edit ) {
- return;
- }
-
- const augmentedMetadata = {
- ...metadata,
- attributes: augmentAttributes( metadata.attributes ),
- };
-
- return registerBlockType< T >(
- { name, ...augmentedMetadata },
- {
- ...settings,
- edit: getEdit< T >(
- edit,
- useEvaluationContext ?? defaultUseEvaluationContext
- ),
- }
- );
-}
diff --git a/packages/js/block-templates/src/utils/test/register-woo-block-type-older-wp-version.test.ts b/packages/js/block-templates/src/utils/test/register-woo-block-type-older-wp-version.test.ts
deleted file mode 100644
index 0ff376ac687..00000000000
--- a/packages/js/block-templates/src/utils/test/register-woo-block-type-older-wp-version.test.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * External dependencies
- */
-import { registerBlockType } from '@wordpress/blocks';
-/**
- * Internal dependencies
- */
-import { registerWooBlockType } from '../register-woo-block-type';
-
-jest.mock( '@wordpress/blocks', () => ( {
- registerBlockType: jest.fn(),
-} ) );
-
-jest.mock( '@woocommerce/settings', () => ( {
- isWpVersion: jest.fn().mockReturnValue( true ),
- getSetting: jest.fn().mockReturnValue( {} ),
-} ) );
-
-describe( 'registerWooBlockType with older wp version', () => {
- it( 'should add __experimentalRole to attributes when wp version is less than 6.7', () => {
- const block = {
- name: 'test/block',
- metadata: {
- attributes: {
- foo: {
- type: 'boolean',
- default: false,
- role: 'content',
- },
- },
- },
- settings: {
- foo: 'bar',
- edit: jest.fn(),
- },
- };
-
- ( registerBlockType as jest.Mock ).mockClear();
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore ts2345 Complaining about the type of the foo attribute; it's fine.
- registerWooBlockType( block );
-
- const args = ( registerBlockType as jest.Mock ).mock.calls[ 0 ][ 0 ];
- const attributes = args.attributes;
- for ( const attribute of Object.values( attributes ) ) {
- expect( attribute ).toHaveProperty( '__experimentalRole' );
- }
- } );
-} );
diff --git a/packages/js/block-templates/src/utils/test/register-woo-block-type.test.ts b/packages/js/block-templates/src/utils/test/register-woo-block-type.test.ts
deleted file mode 100644
index 3a98f76e4e6..00000000000
--- a/packages/js/block-templates/src/utils/test/register-woo-block-type.test.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * External dependencies
- */
-import { registerBlockType } from '@wordpress/blocks';
-/**
- * Internal dependencies
- */
-import { registerWooBlockType } from '../register-woo-block-type';
-
-jest.mock( '@wordpress/blocks', () => ( {
- registerBlockType: jest.fn(),
-} ) );
-
-jest.mock( '@woocommerce/settings', () => ( {
- isWpVersion: jest.fn().mockReturnValue( false ),
- getSetting: jest.fn().mockReturnValue( {} ),
-} ) );
-
-describe( 'registerWooBlockType', () => {
- it( 'should register a block type with the block id and block order attributes', () => {
- const block = {
- name: 'test/block',
- metadata: {
- attributes: {
- foo: {
- type: 'boolean',
- default: false,
- role: 'content',
- },
- },
- },
- settings: {
- foo: 'bar',
- edit: jest.fn(),
- },
- };
-
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore ts2345 Complaining about the type of the foo attribute; it's fine.
- registerWooBlockType( block );
-
- expect( registerBlockType ).toHaveBeenCalledWith(
- {
- name: 'test/block',
- attributes: {
- foo: {
- type: 'boolean',
- default: false,
- role: 'content',
- },
- _templateBlockId: {
- type: 'string',
- role: 'content',
- },
- _templateBlockOrder: {
- type: 'integer',
- role: 'content',
- },
- _templateBlockHideConditions: {
- type: 'array',
- role: 'content',
- },
- _templateBlockDisableConditions: {
- role: 'content',
- type: 'array',
- },
- disabled: {
- role: 'content',
- type: 'boolean',
- },
- },
- },
- {
- foo: 'bar',
- edit: expect.any( Function ),
- }
- );
- } );
-} );
diff --git a/packages/js/block-templates/tsconfig.json b/packages/js/block-templates/tsconfig.json
deleted file mode 100644
index ae9029b5e06..00000000000
--- a/packages/js/block-templates/tsconfig.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "extends": "@woocommerce/internal-build/configs/tsconfig.json",
- "compilerOptions": {
- "rootDir": "src",
- "outDir": "build-module",
- "declaration": true,
- "declarationMap": true,
- "declarationDir": "./build-types",
- "typeRoots": [
- "./typings",
- "./node_modules/@types"
- ],
- "composite": true
- },
- "include": [
- "typings/**/*",
- "src/**/*"
- ],
- "exclude": [
- "**/test/**"
- ],
- "references": [
- {
- "path": "../expression-evaluation"
- }
- ]
-}
diff --git a/packages/js/block-templates/typings/monorepo-enhancements.d.ts b/packages/js/block-templates/typings/monorepo-enhancements.d.ts
deleted file mode 100644
index 6871fc81e6b..00000000000
--- a/packages/js/block-templates/typings/monorepo-enhancements.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import '@woocommerce/internal-build/type-overrides/@wordpress/data';
-import '@woocommerce/internal-build/type-overrides/@wordpress/core-data';
-import '@woocommerce/internal-build/type-overrides/@wordpress/block-editor';
diff --git a/packages/js/block-templates/webpack.config.js b/packages/js/block-templates/webpack.config.js
deleted file mode 100644
index 0f8dbd47654..00000000000
--- a/packages/js/block-templates/webpack.config.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Internal dependencies
- */
-const { webpackConfig } = require( '@woocommerce/internal-build/style-build' );
-
-/**
- * External dependencies
- */
-const path = require( 'path' );
-
-const NODE_ENV = process.env.NODE_ENV || 'development';
-
-module.exports = {
- mode: NODE_ENV,
- cache: ( process.env.CI && { type: 'memory' } ) || {
- type: 'filesystem',
- cacheDirectory: path.resolve(
- __dirname,
- 'node_modules/.cache/webpack'
- ),
- buildDependencies: {
- config: [
- __filename,
- path.resolve( __dirname, '../../../pnpm-lock.yaml' ),
- require.resolve( '@woocommerce/internal-build/style-build' ),
- ],
- },
- },
- entry: {
- 'build-style': __dirname + '/src/style.scss',
- },
- output: {
- path: __dirname,
- },
- module: {
- parser: webpackConfig.parser,
- rules: webpackConfig.rules,
- },
- plugins: webpackConfig.plugins,
-};
diff --git a/packages/js/dependency-extraction-webpack-plugin/assets/packages.js b/packages/js/dependency-extraction-webpack-plugin/assets/packages.js
index 4e42cc2c1cb..c7f0aeaebbd 100644
--- a/packages/js/dependency-extraction-webpack-plugin/assets/packages.js
+++ b/packages/js/dependency-extraction-webpack-plugin/assets/packages.js
@@ -1,7 +1,6 @@
module.exports = [
// wc-admin packages
'@woocommerce/admin-layout',
- '@woocommerce/block-templates',
'@woocommerce/components',
'@woocommerce/csv-export',
'@woocommerce/currency',
diff --git a/packages/js/dependency-extraction-webpack-plugin/changelog/remove-block-templates-package b/packages/js/dependency-extraction-webpack-plugin/changelog/remove-block-templates-package
new file mode 100644
index 00000000000..fb1bf7aec82
--- /dev/null
+++ b/packages/js/dependency-extraction-webpack-plugin/changelog/remove-block-templates-package
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Remove the block templates package from dependency extraction.
diff --git a/plugins/woocommerce/changelog/fix-block-templates-compat b/plugins/woocommerce/changelog/fix-block-templates-compat
new file mode 100644
index 00000000000..2683d037848
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-block-templates-compat
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Add compatibility shims for the removed block templates PHP API to avoid third-party extension fatals.
diff --git a/plugins/woocommerce/changelog/remove-block-templates-package b/plugins/woocommerce/changelog/remove-block-templates-package
new file mode 100644
index 00000000000..494e69735ff
--- /dev/null
+++ b/plugins/woocommerce/changelog/remove-block-templates-package
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Remove the unused block templates admin package and PHP API.
diff --git a/plugins/woocommerce/client/admin/package.json b/plugins/woocommerce/client/admin/package.json
index 4aae4129113..9c95f06da61 100644
--- a/plugins/woocommerce/client/admin/package.json
+++ b/plugins/woocommerce/client/admin/package.json
@@ -155,7 +155,6 @@
"@types/wordpress__blocks": "catalog:wp-min",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
- "@woocommerce/block-templates": "workspace:*",
"@woocommerce/dependency-extraction-webpack-plugin": "workspace:*",
"@woocommerce/eslint-plugin": "workspace:*",
"@woocommerce/experimental-products-app": "workspace:*",
diff --git a/plugins/woocommerce/client/admin/webpack.config.js b/plugins/woocommerce/client/admin/webpack.config.js
index d3263dec38a..866d00a9c26 100644
--- a/plugins/woocommerce/client/admin/webpack.config.js
+++ b/plugins/woocommerce/client/admin/webpack.config.js
@@ -61,7 +61,6 @@ const wcAdminPackages = [
'data',
'tracks',
'onboarding',
- 'block-templates',
'sanitize',
'settings-ui-sdk',
'remote-logging',
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 75f51d67197..d24e26ec5cf 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -45717,54 +45717,6 @@ parameters:
count: 1
path: src/Admin/API/Themes.php
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:remove\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:remove_disable_condition\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:remove_hide_condition\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:set_attribute\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:set_attributes\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockInterface\:\:set_order\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/BlockInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\ContainerInterface\:\:remove_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/ContainerInterface.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Admin\\BlockTemplates\\ContainerInterface\:\:remove_blocks\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Admin/BlockTemplates/ContainerInterface.php
-
-
message: '#^Call to an undefined method object\:\:init\(\)\.$#'
identifier: method.notFound
@@ -56463,324 +56415,6 @@ parameters:
count: 1
path: src/Internal/Admin/Analytics.php
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:remove\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:remove_disable_condition\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:remove_hide_condition\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:set_attribute\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:set_attributes\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:set_order\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:validate\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^PHPDoc tag @param for parameter \$parent with type Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockContainerInterface\|null is not subtype of native type Automattic\\WooCommerce\\Admin\\BlockTemplates\\ContainerInterface\|null\.$#'
- identifier: parameter.phpDocType
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Parameter \$parent of method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:__construct\(\) has invalid type Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockContainerInterface\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Property Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlock\:\:\$root_template \(Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplate\) does not accept Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockTemplateInterface\.$#'
- identifier: assign.propertyType
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlock.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockTemplateInterface\:\:cache_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockTemplateInterface\:\:uncache_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\ContainerInterface\:\:remove_inner_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:get_attributes\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:get_disable_conditions\(\)\.$#'
- identifier: method.notFound
- count: 2
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:get_hide_conditions\(\)\.$#'
- identifier: method.notFound
- count: 2
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:get_name\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:get_order\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:cache_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_add_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_add_block_error_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_add_specific_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_remove_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_remove_block_error_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:do_after_remove_specific_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:remove_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:remove_blocks\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:remove_inner_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\AbstractBlockTemplate\:\:uncache_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
-
- -
- message: '#^ Parameter \#2 \$root_template of class Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block constructor is passed by reference, so it expects variables only$#'
- identifier: argument.byRef
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockTemplateInterface\:\:cache_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\BlockTemplateInterface\:\:uncache_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Call to an undefined method Automattic\\WooCommerce\\Admin\\BlockTemplates\\ContainerInterface\:\:remove_inner_block\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Call to function method_exists\(\) with \$this\(Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\) and ''is_detached'' will always evaluate to true\.$#'
- identifier: function.alreadyNarrowedType
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_add_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_add_block_error_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_add_specific_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_remove_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_remove_block_error_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:do_after_remove_specific_block_action\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:remove_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:remove_blocks\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block\:\:remove_inner_block\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/Block.php
-
- -
- message: '#^ Parameter \#2 \$root_template of class Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\Block constructor is passed by reference, so it expects variables only$#'
- identifier: argument.byRef
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplate.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:add_template_event\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:has_template_events_changed\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:log\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:log_template_events_to_file\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:set_template_events_log_hash\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:should_handle\(\) has no return type specified\.$#'
- identifier: missingType.return
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Parameter \#1 \$level of static method WC_Log_Levels\:\:get_level_severity\(\) expects string, int given\.$#'
- identifier: argument.type
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Parameter \#1 \$str of function md5 expects string, string\|false given\.$#'
- identifier: argument.type
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
- -
- message: '#^Property Automattic\\WooCommerce\\Internal\\Admin\\BlockTemplates\\BlockTemplateLogger\:\:\$logger \(WC_Logger\) does not accept WC_Logger_Interface\.$#'
- identifier: assign.propertyType
- count: 1
- path: src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
-
-
message: '#^Cannot access an offset on array\|WP_Error\.$#'
identifier: offsetAccess.nonOffsetAccessible
diff --git a/plugins/woocommerce/src/Admin/BlockTemplates/BlockContainerInterface.php b/plugins/woocommerce/src/Admin/BlockTemplates/BlockContainerInterface.php
index 7c221b6e4f6..6a9209856d3 100644
--- a/plugins/woocommerce/src/Admin/BlockTemplates/BlockContainerInterface.php
+++ b/plugins/woocommerce/src/Admin/BlockTemplates/BlockContainerInterface.php
@@ -1,8 +1,13 @@
<?php
+/**
+ * WooCommerce Block Templates block container interface compatibility shim.
+ */
namespace Automattic\WooCommerce\Admin\BlockTemplates;
/**
- * Interface for block containers.
+ * Removed block templates block container interface.
+ *
+ * @deprecated 10.9.0 Block template extension APIs were deprecated. The block templates API was removed in 11.0.0 with no replacement.
*/
interface BlockContainerInterface extends BlockInterface, ContainerInterface {}
diff --git a/plugins/woocommerce/src/Admin/BlockTemplates/BlockInterface.php b/plugins/woocommerce/src/Admin/BlockTemplates/BlockInterface.php
index 32af1f7b6ab..35a304364b0 100644
--- a/plugins/woocommerce/src/Admin/BlockTemplates/BlockInterface.php
+++ b/plugins/woocommerce/src/Admin/BlockTemplates/BlockInterface.php
@@ -1,9 +1,15 @@
<?php
+/**
+ * WooCommerce Block Templates block interface compatibility shim.
+ */
+
namespace Automattic\WooCommerce\Admin\BlockTemplates;
/**
- * Interface for block configuration used to specify blocks in BlockTemplate.
+ * Removed block templates block interface.
+ *
+ * @deprecated 10.9.0 Block template extension APIs were deprecated. The block templates API was removed in 11.0.0 with no replacement.
*/
interface BlockInterface {
/**
@@ -35,121 +41,4 @@ interface BlockInterface {
* Key for the block disable conditions in the block configuration.
*/
public const DISABLE_CONDITIONS_KEY = 'disableConditions';
-
- /**
- * Get the block name.
- */
- public function get_name(): string;
-
- /**
- * Get the block ID.
- */
- public function get_id(): string;
-
- /**
- * Get the block order.
- */
- public function get_order(): int;
-
- /**
- * Set the block order.
- *
- * @param int $order The block order.
- */
- public function set_order( int $order );
-
- /**
- * Get the block attributes.
- */
- public function get_attributes(): array;
-
- /**
- * Set the block attributes.
- *
- * @param array $attributes The block attributes.
- */
- public function set_attributes( array $attributes );
-
- /**
- * Set a block attribute value without replacing the entire attributes object.
- *
- * @param string $key The attribute key.
- * @param mixed $value The attribute value.
- */
- public function set_attribute( string $key, $value );
-
- /**
- * Get the parent container that the block belongs to.
- */
- public function &get_parent(): ContainerInterface;
-
- /**
- * Get the root template that the block belongs to.
- */
- public function &get_root_template(): BlockTemplateInterface;
-
- /**
- * Remove the block from its parent.
- */
- public function remove();
-
- /**
- * Check if the block is detached from its parent or root template.
- *
- * @return bool True if the block is detached from its parent or root template.
- */
- public function is_detached(): bool;
-
- /**
- * Add a hide condition to the block.
- *
- * The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden.
- * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details.
- *
- * @param string $expression An expression, which if true, will hide the block.
- * @return string The key of the hide condition, which can be used to remove the hide condition.
- */
- public function add_hide_condition( string $expression ): string;
-
- /**
- * Remove a hide condition from the block.
- *
- * @param string $key The key of the hide condition to remove.
- */
- public function remove_hide_condition( string $key );
-
- /**
- * Get the hide conditions of the block.
- */
- public function get_hide_conditions(): array;
-
- /**
- * Add a disable condition to the block.
- *
- * The disable condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be disabled.
- * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details.
- *
- * @param string $expression An expression, which if true, will disable the block.
- * @return string The key of the disable condition, which can be used to remove the disable condition.
- */
- public function add_disable_condition( string $expression ): string;
-
- /**
- * Remove a disable condition from the block.
- *
- * @param string $key The key of the disable condition to remove.
- */
- public function remove_disable_condition( string $key );
-
- /**
- * Get the disable conditions of the block.
- */
- public function get_disable_conditions(): array;
-
- /**
- * Get the block configuration as a formatted template.
- *
- * @return array The block configuration as a formatted template.
- */
- public function get_formatted_template(): array;
}
diff --git a/plugins/woocommerce/src/Admin/BlockTemplates/BlockTemplateInterface.php b/plugins/woocommerce/src/Admin/BlockTemplates/BlockTemplateInterface.php
index d736e61b8bc..2bb0251e5ff 100644
--- a/plugins/woocommerce/src/Admin/BlockTemplates/BlockTemplateInterface.php
+++ b/plugins/woocommerce/src/Admin/BlockTemplates/BlockTemplateInterface.php
@@ -1,43 +1,13 @@
<?php
+/**
+ * WooCommerce Block Templates template interface compatibility shim.
+ */
namespace Automattic\WooCommerce\Admin\BlockTemplates;
/**
- * Interface for block-based template.
+ * Removed block templates template interface.
+ *
+ * @deprecated 10.9.0 Block template extension APIs were deprecated. The block templates API was removed in 11.0.0 with no replacement.
*/
-interface BlockTemplateInterface extends ContainerInterface {
- /**
- * Get the template ID.
- */
- public function get_id(): string;
-
- /**
- * Get the template title.
- */
- public function get_title(): string;
-
- /**
- * Get the template description.
- */
- public function get_description(): string;
-
- /**
- * Get the template area.
- */
- public function get_area(): string;
-
- /**
- * Generate a block ID based on a base.
- *
- * @param string $id_base The base to use when generating an ID.
- * @return string
- */
- public function generate_block_id( string $id_base ): string;
-
- /**
- * Get the template as JSON like array.
- *
- * @return array The JSON.
- */
- public function to_json(): array;
-}
+interface BlockTemplateInterface extends ContainerInterface {}
diff --git a/plugins/woocommerce/src/Admin/BlockTemplates/ContainerInterface.php b/plugins/woocommerce/src/Admin/BlockTemplates/ContainerInterface.php
index 32305403183..9e1d7e1dd36 100644
--- a/plugins/woocommerce/src/Admin/BlockTemplates/ContainerInterface.php
+++ b/plugins/woocommerce/src/Admin/BlockTemplates/ContainerInterface.php
@@ -1,39 +1,13 @@
<?php
+/**
+ * WooCommerce Block Templates container interface compatibility shim.
+ */
namespace Automattic\WooCommerce\Admin\BlockTemplates;
/**
- * Interface for block containers.
+ * Removed block templates container interface.
+ *
+ * @deprecated 10.9.0 Block template extension APIs were deprecated. The block templates API was removed in 11.0.0 with no replacement.
*/
-interface ContainerInterface {
- /**
- * Get the root template that the block belongs to.
- */
- public function &get_root_template(): BlockTemplateInterface;
-
- /**
- * Get the block configuration as a formatted template.
- */
- public function get_formatted_template(): array;
-
- /**
- * Get a block by ID.
- *
- * @param string $block_id The block ID.
- */
- public function get_block( string $block_id ): ?BlockInterface;
-
- /**
- * Removes a block from the container.
- *
- * @param string $block_id The block ID.
- *
- * @throws \UnexpectedValueException If the block container is not an ancestor of the block.
- */
- public function remove_block( string $block_id );
-
- /**
- * Removes all blocks from the container.
- */
- public function remove_blocks();
-}
+interface ContainerInterface {}
diff --git a/plugins/woocommerce/src/Admin/BlockTemplates/README.md b/plugins/woocommerce/src/Admin/BlockTemplates/README.md
index 2e610ffd5cf..bd658977416 100644
--- a/plugins/woocommerce/src/Admin/BlockTemplates/README.md
+++ b/plugins/woocommerce/src/Admin/BlockTemplates/README.md
@@ -1,229 +1,7 @@
-# BlockTemplates
+# BlockTemplates compatibility shims
-The `Automattic\WooCommerce\Admin\BlockTemplates` namespace contains interfaces for working with block templates.
+This folder contains temporary compatibility shims for PHP interfaces that were part of the removed Block Templates API.
-## Usage
+The Block Templates extension APIs were deprecated in WooCommerce 10.9.0, and the Block Templates API was removed in WooCommerce 11.0.0 with no replacement. These interfaces remain only to avoid fatal errors in extensions or custom code that still reference the old PHP symbols during the transition period.
-Objects that implement the interfaces and fire the hooks in this namespace are instantiated using more specific APIs.
-
-Note: In order to use these interface type definitions, you will need to import them. For example to import the `BlockInterface`:
-
-```php
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-```
-
-## Hooks
-
-### `woocommerce_block_template_area_{template_area}_after_add_block_{block_id}`
-
-Fires after a specific block is added to any template in a specific area.
-
-The dynamic portion of the hook name, `$template_area`, refers to the area of the template the block was added to.
-
-The dynamic portion of the hook name, `$block_id`, refers to the ID of the block that was added.
-
-#### Parameters
-
-##### `BlockInterface $block`
-
-The block that was added.
-
-### `woocommerce_block_template_after_add_block`
-
-Fires after a block is added to a template.
-
-Unless you need to perform an action after any block is added to any template, you should use the more specific `woocommerce_block_template_area_{template_area}_after_add_block_{block_id}` hook instead for better performance.
-
-#### Parameters
-
-##### `BlockInterface $block`
-
-The block that was added.
-
-### `woocommerce_block_template_area_{template_area}_after_remove_block_{block_id}`
-
-Fires after a specific block is removed from any template in a specific area.
-
-The dynamic portion of the hook name, `$template_area`, refers to the area of the template the block was removed from.
-
-The dynamic portion of the hook name, `$block_id`, refers to the ID of the block that was removed.
-
-#### Parameters
-
-##### `BlockInterface $block`
-
-The block that was removed.
-
-### `woocommerce_block_template_after_remove_block`
-
-Fires after a block is removed from a template.
-
-Unless you need to perform an action after any block is removed from any template, you should use the more specific `woocommerce_block_template_area_{template_area}_after_remove_block_{block_id}` hook instead for better performance.
-
-#### Parameters
-
-##### `BlockInterface $block`
-
-The block that was removed.
-
-## Interfaces
-
-### BlockTemplateInterface
-
-All block templates implement this interface.
-
-#### Methods
-
-##### `get_id(): string`
-
-Get the template ID.
-
-##### `get_title(): string`
-
-Get the template title.
-
-##### `get_description(): string`
-
-Get the template description.
-
-##### `get_area(): string`
-
-Get the template area.
-
-##### `get_block( string $block_id ): ?BlockInterface`
-
-Get a block by ID.
-
-##### `remove_block( string $block_id )`
-
-Removes a block from the template.
-
-##### `remove_blocks()`
-
-Removes all blocks from the template.
-
-##### `get_formatted_template(): array`
-
-Get the formatted template.
-
-### BlockContainerInterface
-
-#### Methods
-
-##### `get_block( string $block_id ): ?BlockInterface`
-
-Get a block by ID.
-
-##### `remove_block( string $block_id )`
-
-Removes a block from the template.
-
-##### `remove_blocks()`
-
-Removes all blocks from the template.
-
-##### `&get_root_template(): BlockTemplateInterface`
-
-Get the root template that the block belongs to.
-
-##### `get_formatted_template(): array`
-
-Get the block configuration as a formatted template.
-
-### ContainerInterface
-
-#### Methods
-
-##### `get_block( string $block_id ): ?BlockInterface`
-
-Get a block by ID.
-
-##### `remove_block( string $block_id )`
-
-Removes a block from the container.
-
-##### `remove_blocks()`
-
-Removes all blocks from the container.
-
-##### `&get_root_template(): BlockTemplateInterface`
-
-Get the root template that the container belongs to.
-
-##### `get_formatted_template(): array`
-
-Get the container as a formatted template.
-
-### BlockInterface
-
-#### Methods
-
-##### `get_name(): string`
-
-Get the block name.
-
-#### `get_id(): string`
-
-Get the block ID.
-
-#### `get_order(): int`
-
-Get the block order.
-
-#### `set_order( int $order )`
-
-Set the block order.
-
-##### `get_attributes(): array`
-
-Get the block attributes as a key/value array.
-
-##### `set_attributes( array $attributes )`
-
-Set the block attributes as a key/value array.
-
-##### `&get_parent(): ContainerInterface`
-
-Get the parent container that the block belongs to.
-
-##### `&get_root_template(): BlockTemplateInterface`
-
-Get the root template that the block belongs to.
-
-##### `remove()`
-
-Removes the block from its parent. When a block is removed from its parent, it is detached from both the parent and the root template.
-
-##### `is_detached(): bool`
-
-Check if the block is detached from its parent or root template. A detached block is no longer a part of the template and will not be included in the formatted template.
-
-##### `add_hide_condition( string $expression ): string`
-
-Adds a hide condition to the block. The hide condition is a JavaScript-like expression that is evaluated at runtime on the client to determine if the block should be hidden.
-
-See [@woocommerce/expression-evaluation](../../../../../packages/js/expression-evaluation/README.md) for more information on the expression syntax.
-
-##### `remove_hide_condition( string $key )`
-
-Removes a hide condition from the block, referenced by the key returned from `add_hide_condition()`.
-
-##### `get_hide_conditions(): array`
-
-Get the hide conditions for the block.
-
-##### `add_disable_condition( string $expression ): string`
-
-Adds a disable condition to the block. Similar to `add_hide_condition()`, but the block is shown as disabled instead of hidden.
-
-##### `remove_disable_condition( string $key )`
-
-Removes a disable condition from the block, referenced by the key returned from `add_disable_condition()`.
-
-##### `get_disable_conditions(): array`
-
-Get the disable conditions for the block.
-
-##### `get_formatted_template(): array`
-
-Get the block configuration as a formatted template.
+Do not add new Block Templates behavior here. Any code in this folder should be limited to compatibility with the removed APIs, should avoid reintroducing the removed template system, and may be removed in a future WooCommerce version.
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlock.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlock.php
deleted file mode 100644
index 8e2dc8d1339..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlock.php
+++ /dev/null
@@ -1,352 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface;
-
-/**
- * Block configuration used to specify blocks in BlockTemplate.
- */
-class AbstractBlock implements BlockInterface {
- use BlockFormattedTemplateTrait;
-
- /**
- * The block name.
- *
- * @var string
- */
- private $name;
-
- /**
- * The block ID.
- *
- * @var string
- */
- private $id;
-
- /**
- * The block order.
- *
- * @var int
- */
- private $order = 10000;
-
- /**
- * The block attributes.
- *
- * @var array
- */
- private $attributes = array();
-
- /**
- * The block hide conditions.
- *
- * @var array
- */
- private $hide_conditions = array();
-
- /**
- * The block hide conditions counter.
- *
- * @var int
- */
- private $hide_conditions_counter = 0;
-
- /**
- * The block disable conditions.
- *
- * @var array
- */
- private $disable_conditions = array();
-
- /**
- * The block disable conditions counter.
- *
- * @var int
- */
- private $disable_conditions_counter = 0;
-
- /**
- * The block template that this block belongs to.
- *
- * @var BlockTemplate
- */
- private $root_template;
-
- /**
- * The parent container.
- *
- * @var ContainerInterface
- */
- private $parent;
-
- /**
- * Block constructor.
- *
- * @param array $config The block configuration.
- * @param BlockTemplateInterface $root_template The block template that this block belongs to.
- * @param BlockContainerInterface|null $parent The parent block container.
- *
- * @throws \ValueError If the block configuration is invalid.
- * @throws \ValueError If the parent block container does not belong to the same template as the block.
- */
- public function __construct( array $config, BlockTemplateInterface &$root_template, ?ContainerInterface &$parent = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
- $this->validate( $config, $root_template, $parent );
-
- $this->root_template = $root_template;
- $this->parent = is_null( $parent ) ? $root_template : $parent;
-
- $this->name = $config[ self::NAME_KEY ];
-
- if ( ! isset( $config[ self::ID_KEY ] ) ) {
- $this->id = $this->root_template->generate_block_id( $this->get_name() );
- } else {
- $this->id = $config[ self::ID_KEY ];
- }
-
- if ( isset( $config[ self::ORDER_KEY ] ) ) {
- $this->order = $config[ self::ORDER_KEY ];
- }
-
- if ( isset( $config[ self::ATTRIBUTES_KEY ] ) ) {
- $this->attributes = $config[ self::ATTRIBUTES_KEY ];
- }
-
- if ( isset( $config[ self::HIDE_CONDITIONS_KEY ] ) ) {
- foreach ( $config[ self::HIDE_CONDITIONS_KEY ] as $hide_condition ) {
- $this->add_hide_condition( $hide_condition['expression'] );
- }
- }
-
- if ( isset( $config[ self::DISABLE_CONDITIONS_KEY ] ) ) {
- foreach ( $config[ self::DISABLE_CONDITIONS_KEY ] as $disable_condition ) {
- $this->add_disable_condition( $disable_condition['expression'] );
- }
- }
- }
-
- /**
- * Validate block configuration.
- *
- * @param array $config The block configuration.
- * @param BlockTemplateInterface $root_template The block template that this block belongs to.
- * @param ContainerInterface|null $parent The parent block container.
- *
- * @throws \ValueError If the block configuration is invalid.
- * @throws \ValueError If the parent block container does not belong to the same template as the block.
- */
- protected function validate( array $config, BlockTemplateInterface &$root_template, ?ContainerInterface &$parent = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
- if ( isset( $parent ) && ( $parent->get_root_template() !== $root_template ) ) {
- throw new \ValueError( 'The parent block must belong to the same template as the block.' );
- }
-
- if ( ! isset( $config[ self::NAME_KEY ] ) || ! is_string( $config[ self::NAME_KEY ] ) ) {
- throw new \ValueError( 'The block name must be specified.' );
- }
-
- if ( isset( $config[ self::ORDER_KEY ] ) && ! is_int( $config[ self::ORDER_KEY ] ) ) {
- throw new \ValueError( 'The block order must be an integer.' );
- }
-
- if ( isset( $config[ self::ATTRIBUTES_KEY ] ) && ! is_array( $config[ self::ATTRIBUTES_KEY ] ) ) {
- throw new \ValueError( 'The block attributes must be an array.' );
- }
- }
-
- /**
- * Get the block name.
- */
- public function get_name(): string {
- return $this->name;
- }
-
- /**
- * Get the block ID.
- */
- public function get_id(): string {
- return $this->id;
- }
-
- /**
- * Get the block order.
- */
- public function get_order(): int {
- return $this->order;
- }
-
- /**
- * Set the block order.
- *
- * @param int $order The block order.
- */
- public function set_order( int $order ) {
- $this->order = $order;
- }
-
- /**
- * Get the block attributes.
- */
- public function get_attributes(): array {
- return $this->attributes;
- }
-
- /**
- * Set the block attributes.
- *
- * @param array $attributes The block attributes.
- */
- public function set_attributes( array $attributes ) {
- $this->attributes = $attributes;
- }
-
- /**
- * Set a block attribute value without replacing the entire attributes object.
- *
- * @param string $key The attribute key.
- * @param mixed $value The attribute value.
- */
- public function set_attribute( string $key, $value ) {
- $this->attributes[ $key ] = $value;
- }
-
- /**
- * Get the template that this block belongs to.
- */
- public function &get_root_template(): BlockTemplateInterface {
- return $this->root_template;
- }
-
- /**
- * Get the parent block container.
- */
- public function &get_parent(): ContainerInterface {
- return $this->parent;
- }
-
- /**
- * Remove the block from its parent.
- */
- public function remove() {
- $this->parent->remove_block( $this->id );
- }
-
- /**
- * Check if the block is detached from its parent block container or the template it belongs to.
- *
- * @return bool True if the block is detached from its parent block container or the template it belongs to.
- */
- public function is_detached(): bool {
- $is_in_parent = $this->parent->get_block( $this->id ) === $this;
- $is_in_root_template = $this->get_root_template()->get_block( $this->id ) === $this;
-
- return ! ( $is_in_parent && $is_in_root_template );
- }
-
- /**
- * Add a hide condition to the block.
- *
- * The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden.
- * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details.
- *
- * @param string $expression An expression, which if true, will hide the block.
- */
- public function add_hide_condition( string $expression ): string {
- $key = 'k' . $this->hide_conditions_counter;
- $this->hide_conditions_counter++;
-
- // Storing the expression in an array to allow for future expansion
- // (such as adding the plugin that added the condition).
- $this->hide_conditions[ $key ] = array(
- 'expression' => $expression,
- );
-
- /**
- * Action called after a hide condition is added to a block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.4.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_add_hide_condition',
- array( $this ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
-
- return $key;
- }
-
- /**
- * Remove a hide condition from the block.
- *
- * @param string $key The key of the hide condition to remove.
- */
- public function remove_hide_condition( string $key ) {
- unset( $this->hide_conditions[ $key ] );
-
- /**
- * Action called after a hide condition is removed from a block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.4.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_remove_hide_condition',
- array( $this ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- }
-
- /**
- * Get the hide conditions of the block.
- */
- public function get_hide_conditions(): array {
- return $this->hide_conditions;
- }
-
- /**
- * Add a disable condition to the block.
- *
- * The disable condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden.
- * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details.
- *
- * @param string $expression An expression, which if true, will disable the block.
- */
- public function add_disable_condition( string $expression ): string {
- $key = 'k' . $this->disable_conditions_counter;
- $this->disable_conditions_counter++;
-
- // Storing the expression in an array to allow for future expansion
- // (such as adding the plugin that added the condition).
- $this->disable_conditions[ $key ] = array(
- 'expression' => $expression,
- );
-
- return $key;
- }
-
- /**
- * Remove a disable condition from the block.
- *
- * @param string $key The key of the disable condition to remove.
- */
- public function remove_disable_condition( string $key ) {
- unset( $this->disable_conditions[ $key ] );
- }
-
- /**
- * Get the disable conditions of the block.
- */
- public function get_disable_conditions(): array {
- return $this->disable_conditions;
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
deleted file mode 100644
index af9fde3ee19..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/AbstractBlockTemplate.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-/**
- * Block template class.
- */
-abstract class AbstractBlockTemplate implements BlockTemplateInterface {
- use BlockContainerTrait;
-
- /**
- * Get the template ID.
- */
- abstract public function get_id(): string;
-
- /**
- * Get the template title.
- */
- public function get_title(): string {
- return '';
- }
-
- /**
- * Get the template description.
- */
- public function get_description(): string {
- return '';
- }
-
- /**
- * Get the template area.
- */
- public function get_area(): string {
- return 'uncategorized';
- }
-
- /**
- * The block cache.
- *
- * @var BlockInterface[]
- */
- private $block_cache = [];
-
- /**
- * Get a block by ID.
- *
- * @param string $block_id The block ID.
- */
- public function get_block( string $block_id ): ?BlockInterface {
- return $this->block_cache[ $block_id ] ?? null;
- }
-
- /**
- * Caches a block in the template. This is an internal method and should not be called directly
- * except for from the BlockContainerTrait's add_inner_block() method.
- *
- * @param BlockInterface $block The block to cache.
- *
- * @throws \ValueError If a block with the specified ID already exists in the template.
- * @throws \ValueError If the block template that the block belongs to is not this template.
- *
- * @ignore
- */
- public function cache_block( BlockInterface &$block ) {
- $id = $block->get_id();
-
- if ( isset( $this->block_cache[ $id ] ) ) {
- throw new \ValueError( 'A block with the specified ID already exists in the template.' );
- }
-
- if ( $block->get_root_template() !== $this ) {
- throw new \ValueError( 'The block template that the block belongs to must be the same as this template.' );
- }
-
- $this->block_cache[ $id ] = $block;
- }
-
- /**
- * Uncaches a block in the template. This is an internal method and should not be called directly
- * except for from the BlockContainerTrait's remove_block() method.
- *
- * @param string $block_id The block ID.
- *
- * @ignore
- */
- public function uncache_block( string $block_id ) {
- if ( isset( $this->block_cache[ $block_id ] ) ) {
- unset( $this->block_cache[ $block_id ] );
- }
- }
-
- /**
- * Generate a block ID based on a base.
- *
- * @param string $id_base The base to use when generating an ID.
- * @return string
- */
- public function generate_block_id( string $id_base ): string {
- $instance_count = 0;
-
- do {
- $instance_count++;
- $block_id = $id_base . '-' . $instance_count;
- } while ( isset( $this->block_cache[ $block_id ] ) );
-
- return $block_id;
- }
-
- /**
- * Get the root template.
- */
- public function &get_root_template(): BlockTemplateInterface {
- return $this;
- }
-
- /**
- * Get the inner blocks as a formatted template.
- */
- public function get_formatted_template(): array {
- $inner_blocks = $this->get_inner_blocks_sorted_by_order();
-
- $inner_blocks_formatted_template = array_map(
- function( BlockInterface $block ) {
- return $block->get_formatted_template();
- },
- $inner_blocks
- );
-
- return $inner_blocks_formatted_template;
- }
-
- /**
- * Get the template as JSON like array.
- *
- * @return array The JSON.
- */
- public function to_json(): array {
- return array(
- 'id' => $this->get_id(),
- 'title' => $this->get_title(),
- 'description' => $this->get_description(),
- 'area' => $this->get_area(),
- 'blockTemplates' => $this->get_formatted_template(),
- );
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/Block.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/Block.php
deleted file mode 100644
index 3d885afded7..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/Block.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-/**
- * Generic block with container properties to be used in BlockTemplate.
- */
-class Block extends AbstractBlock implements BlockContainerInterface {
- use BlockContainerTrait;
-
- /**
- * Add an inner block to this block.
- *
- * @param array $block_config The block data.
- */
- public function &add_block( array $block_config ): BlockInterface {
- $block = new Block( $block_config, $this->get_root_template(), $this );
- return $this->add_inner_block( $block );
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php
deleted file mode 100644
index 99e9eadcb80..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php
+++ /dev/null
@@ -1,384 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface;
-
-/**
- * Trait for block containers.
- */
-trait BlockContainerTrait {
- use BlockFormattedTemplateTrait {
- get_formatted_template as get_block_formatted_template;
- }
-
- /**
- * The inner blocks.
- *
- * @var BlockInterface[]
- */
- private $inner_blocks = array();
-
- // phpcs doesn't take into account exceptions thrown by called methods.
- // phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
-
- /**
- * Add a block to the block container.
- *
- * @param BlockInterface $block The block.
- *
- * @throws \ValueError If the block configuration is invalid.
- * @throws \ValueError If a block with the specified ID already exists in the template.
- * @throws \UnexpectedValueException If the block container is not the parent of the block.
- * @throws \UnexpectedValueException If the block container's root template is not the same as the block's root template.
- */
- protected function &add_inner_block( BlockInterface $block ): BlockInterface {
- if ( $block->get_parent() !== $this ) {
- throw new \UnexpectedValueException( 'The block container is not the parent of the block.' );
- }
-
- if ( $block->get_root_template() !== $this->get_root_template() ) {
- throw new \UnexpectedValueException( 'The block container\'s root template is not the same as the block\'s root template.' );
- }
-
- $is_detached = method_exists( $this, 'is_detached' ) && $this->is_detached();
- if ( ! $is_detached ) {
- $this->get_root_template()->cache_block( $block );
- }
-
- $this->inner_blocks[] = &$block;
-
- $this->do_after_add_block_action( $block );
- $this->do_after_add_specific_block_action( $block );
-
- return $block;
- }
-
- // phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
-
- /**
- * Checks if a block is a descendant of the block container.
- *
- * @param BlockInterface $block The block.
- */
- private function is_block_descendant( BlockInterface $block ): bool {
- $parent = $block->get_parent();
-
- if ( $parent === $this ) {
- return true;
- }
-
- if ( ! $parent instanceof BlockInterface ) {
- return false;
- }
-
- return $this->is_block_descendant( $parent );
- }
-
- /**
- * Get a block by ID.
- *
- * @param string $block_id The block ID.
- */
- public function get_block( string $block_id ): ?BlockInterface {
- foreach ( $this->inner_blocks as $block ) {
- if ( $block->get_id() === $block_id ) {
- return $block;
- }
- }
-
- foreach ( $this->inner_blocks as $block ) {
- if ( $block instanceof ContainerInterface ) {
- $block = $block->get_block( $block_id );
-
- if ( $block ) {
- return $block;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Remove a block from the block container.
- *
- * @param string $block_id The block ID.
- *
- * @throws \UnexpectedValueException If the block container is not an ancestor of the block.
- */
- public function remove_block( string $block_id ) {
- $root_template = $this->get_root_template();
-
- $block = $root_template->get_block( $block_id );
-
- if ( ! $block ) {
- return;
- }
-
- if ( ! $this->is_block_descendant( $block ) ) {
- throw new \UnexpectedValueException( 'The block container is not an ancestor of the block.' );
- }
-
- // If the block is a container, remove all of its blocks.
- if ( $block instanceof ContainerInterface ) {
- $block->remove_blocks();
- }
-
- $parent = $block->get_parent();
- $parent->remove_inner_block( $block );
- }
-
- /**
- * Remove all blocks from the block container.
- */
- public function remove_blocks() {
- array_map(
- function ( BlockInterface $block ) {
- $this->remove_block( $block->get_id() );
- },
- $this->inner_blocks
- );
- }
-
- /**
- * Remove a block from the block container's inner blocks. This is an internal method and should not be called directly
- * except for from the BlockContainerTrait's remove_block() method.
- *
- * @param BlockInterface $block The block.
- */
- public function remove_inner_block( BlockInterface $block ) {
- // Remove block from root template's cache.
- $root_template = $this->get_root_template();
- $root_template->uncache_block( $block->get_id() );
-
- $this->inner_blocks = array_filter(
- $this->inner_blocks,
- function ( BlockInterface $inner_block ) use ( $block ) {
- return $inner_block !== $block;
- }
- );
-
- $this->do_after_remove_block_action( $block );
- $this->do_after_remove_specific_block_action( $block );
- }
-
- /**
- * Get the inner blocks sorted by order.
- */
- private function get_inner_blocks_sorted_by_order(): array {
- $sorted_inner_blocks = $this->inner_blocks;
-
- usort(
- $sorted_inner_blocks,
- function( BlockInterface $a, BlockInterface $b ) {
- return $a->get_order() <=> $b->get_order();
- }
- );
-
- return $sorted_inner_blocks;
- }
-
- /**
- * Get the inner blocks as a formatted template.
- */
- public function get_formatted_template(): array {
- $arr = $this->get_block_formatted_template();
-
- $inner_blocks = $this->get_inner_blocks_sorted_by_order();
-
- if ( ! empty( $inner_blocks ) ) {
- $arr[] = array_map(
- function( BlockInterface $block ) {
- return $block->get_formatted_template();
- },
- $inner_blocks
- );
- }
-
- return $arr;
- }
-
- /**
- * Do the `woocommerce_block_template_after_add_block` action.
- * Handle exceptions thrown by the action.
- *
- * @param BlockInterface $block The block.
- */
- private function do_after_add_block_action( BlockInterface $block ) {
- try {
- /**
- * Action called after a block is added to a block container.
- *
- * This action can be used to perform actions after a block is added to the block container,
- * such as adding a dependent block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.2.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_add_block',
- array( $block ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- } catch ( \Exception $e ) {
- $this->do_after_add_block_error_action( $block, 'woocommerce_block_template_after_add_block', $e );
- }
- }
-
- /**
- * Do the `woocommerce_block_template_area_{template_area}_after_add_block_{block_id}` action.
- * Handle exceptions thrown by the action.
- *
- * @param BlockInterface $block The block.
- */
- private function do_after_add_specific_block_action( BlockInterface $block ) {
- $hook_name = "woocommerce_block_template_area_{$this->get_root_template()->get_area()}_after_add_block_{$block->get_id()}";
-
- try {
- /**
- * Action called after a specific block is added to a template with a specific area.
- *
- * This action can be used to perform actions after a specific block is added to a template with a specific area,
- * such as adding a dependent block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.2.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- $hook_name,
- array( $block ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- } catch ( \Exception $e ) {
- $this->do_after_add_block_error_action( $block, $hook_name, $e );
- }
- }
-
- /**
- * Do the `woocommerce_block_after_add_block_error` action.
- *
- * @param BlockInterface $block The block.
- * @param string $action The action that threw the exception.
- * @param \Exception $e The exception.
- */
- private function do_after_add_block_error_action( BlockInterface $block, string $action, \Exception $e ) {
- /**
- * Action called after an exception is thrown by a `woocommerce_block_template_after_add_block` action hook.
- *
- * @param BlockInterface $block The block.
- * @param string $action The action that threw the exception.
- * @param \Exception $exception The exception.
- *
- * @since 8.4.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_add_block_error',
- array( $block, $action, $e ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- }
-
- /**
- * Do the `woocommerce_block_template_after_remove_block` action.
- * Handle exceptions thrown by the action.
- *
- * @param BlockInterface $block The block.
- */
- private function do_after_remove_block_action( BlockInterface $block ) {
- try {
- /**
- * Action called after a block is removed from a block container.
- *
- * This action can be used to perform actions after a block is removed from the block container,
- * such as removing a dependent block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.2.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_remove_block',
- array( $block ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- } catch ( \Exception $e ) {
- $this->do_after_remove_block_error_action( $block, 'woocommerce_block_template_after_remove_block', $e );
- }
- }
-
- /**
- * Do the `woocommerce_block_template_area_{template_area}_after_remove_block_{block_id}` action.
- * Handle exceptions thrown by the action.
- *
- * @param BlockInterface $block The block.
- */
- private function do_after_remove_specific_block_action( BlockInterface $block ) {
- $hook_name = "woocommerce_block_template_area_{$this->get_root_template()->get_area()}_after_remove_block_{$block->get_id()}";
-
- try {
- /**
- * Action called after a specific block is removed from a template with a specific area.
- *
- * This action can be used to perform actions after a specific block is removed from a template with a specific area,
- * such as removing a dependent block.
- *
- * @param BlockInterface $block The block.
- *
- * @since 8.2.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- $hook_name,
- array( $block ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- } catch ( \Exception $e ) {
- $this->do_after_remove_block_error_action( $block, $hook_name, $e );
- }
- }
-
- /**
- * Do the `woocommerce_block_after_remove_block_error` action.
- *
- * @param BlockInterface $block The block.
- * @param string $action The action that threw the exception.
- * @param \Exception $e The exception.
- */
- private function do_after_remove_block_error_action( BlockInterface $block, string $action, \Exception $e ) {
- /**
- * Action called after an exception is thrown by a `woocommerce_block_template_after_remove_block` action hook.
- *
- * @param BlockInterface $block The block.
- * @param string $action The action that threw the exception.
- * @param \Exception $exception The exception.
- *
- * @since 8.4.0
- * @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
- */
- wc_do_deprecated_action(
- 'woocommerce_block_template_after_remove_block_error',
- array( $block, $action, $e ),
- '10.9.0',
- null,
- 'This block template hook will be removed in WooCommerce 11.0.'
- );
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockFormattedTemplateTrait.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockFormattedTemplateTrait.php
deleted file mode 100644
index 717ee4e6aba..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockFormattedTemplateTrait.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-/**
- * Trait for block formatted template.
- */
-trait BlockFormattedTemplateTrait {
- /**
- * Get the block configuration as a formatted template.
- *
- * @return array The block configuration as a formatted template.
- */
- public function get_formatted_template(): array {
- $arr = array(
- $this->get_name(),
- array_merge(
- $this->get_attributes(),
- array(
- '_templateBlockId' => $this->get_id(),
- '_templateBlockOrder' => $this->get_order(),
- ),
- ! empty( $this->get_hide_conditions() ) ? array(
- '_templateBlockHideConditions' => $this->get_formatted_hide_conditions(),
- ) : array(),
- ! empty( $this->get_disable_conditions() ) ? array(
- '_templateBlockDisableConditions' => $this->get_formatted_disable_conditions(),
- ) : array(),
- ),
- );
-
- return $arr;
- }
-
- /**
- * Get the block hide conditions formatted for inclusion in a formatted template.
- */
- private function get_formatted_hide_conditions(): array {
- return $this->format_conditions( $this->get_hide_conditions() );
- }
-
- /**
- * Get the block disable conditions formatted for inclusion in a formatted template.
- */
- private function get_formatted_disable_conditions(): array {
- return $this->format_conditions( $this->get_disable_conditions() );
- }
-
- /**
- * Formats conditions in the expected format to include in the template.
- *
- * @param array $conditions The conditions to format.
- */
- private function format_conditions( $conditions ): array {
- $formatted_expressions = array_map(
- function( $condition ) {
- return array(
- 'expression' => $condition['expression'],
- );
- },
- array_values( $conditions )
- );
-
- return $formatted_expressions;
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplate.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplate.php
deleted file mode 100644
index c2655cdea40..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplate.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-/**
- * Block template class.
- */
-class BlockTemplate extends AbstractBlockTemplate {
- /**
- * Get the template ID.
- */
- public function get_id(): string {
- return 'woocommerce-block-template';
- }
-
- /**
- * Add an inner block to this template.
- *
- * @param array $block_config The block data.
- */
- public function add_block( array $block_config ): BlockInterface {
- $block = new Block( $block_config, $this->get_root_template(), $this );
- return $this->add_inner_block( $block );
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
deleted file mode 100644
index 7266f6c60fa..00000000000
--- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockTemplateLogger.php
+++ /dev/null
@@ -1,507 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface;
-
-/**
- * Logger for block template modifications.
- */
-class BlockTemplateLogger {
- const BLOCK_ADDED = 'block_added';
- const BLOCK_REMOVED = 'block_removed';
- const BLOCK_MODIFIED = 'block_modified';
- const BLOCK_ADDED_TO_DETACHED_CONTAINER = 'block_added_to_detached_container';
- const HIDE_CONDITION_ADDED = 'hide_condition_added';
- const HIDE_CONDITION_REMOVED = 'hide_condition_removed';
- const HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK = 'hide_condition_added_to_detached_block';
- const ERROR_AFTER_BLOCK_ADDED = 'error_after_block_added';
- const ERROR_AFTER_BLOCK_REMOVED = 'error_after_block_removed';
-
- const LOG_HASH_TRANSIENT_BASE_NAME = 'wc_block_template_events_log_hash_';
-
- /**
- * Event types.
- *
- * @var array
- */
- public static $event_types = array(
- self::BLOCK_ADDED => array(
- 'level' => \WC_Log_Levels::DEBUG,
- 'message' => 'Block added to template.',
- ),
- self::BLOCK_REMOVED => array(
- 'level' => \WC_Log_Levels::NOTICE,
- 'message' => 'Block removed from template.',
- ),
- self::BLOCK_MODIFIED => array(
- 'level' => \WC_Log_Levels::NOTICE,
- 'message' => 'Block modified in template.',
- ),
- self::BLOCK_ADDED_TO_DETACHED_CONTAINER => array(
- 'level' => \WC_Log_Levels::WARNING,
- 'message' => 'Block added to detached container. Block will not be included in the template, since the container will not be included in the template.',
- ),
- self::HIDE_CONDITION_ADDED => array(
- 'level' => \WC_Log_Levels::NOTICE,
- 'message' => 'Hide condition added to block.',
- ),
- self::HIDE_CONDITION_REMOVED => array(
- 'level' => \WC_Log_Levels::NOTICE,
- 'message' => 'Hide condition removed from block.',
- ),
- self::HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK => array(
- 'level' => \WC_Log_Levels::WARNING,
- 'message' => 'Hide condition added to detached block. Block will not be included in the template, so the hide condition is not needed.',
- ),
- self::ERROR_AFTER_BLOCK_ADDED => array(
- 'level' => \WC_Log_Levels::WARNING,
- 'message' => 'Error after block added to template.',
- ),
- self::ERROR_AFTER_BLOCK_REMOVED => array(
- 'level' => \WC_Log_Levels::WARNING,
- 'message' => 'Error after block removed from template.',
- ),
- );
-
- /**
- * Singleton instance.
- *
- * @var BlockTemplateLogger
- */
- protected static $instance = null;
-
- /**
- * Logger instance.
- *
- * @var \WC_Logger
- */
- protected $logger = null;
-
- /**
- * All template events.
- *
- * @var array
- */
- private $all_template_events = array();
-
- /**
- * Templates.
- *
- * @var array
- */
- private $templates = array();
-
- /**
- * Threshold severity.
- *
- * @var int
- */
- private $threshold_severity = null;
-
- /**
- * Get the singleton instance.
- */
- public static function get_instance(): BlockTemplateLogger {
- if ( ! self::$instance ) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-
- /**
- * Constructor.
- */
- protected function __construct() {
- $this->logger = wc_get_logger();
-
- $threshold = get_option( 'woocommerce_block_template_logging_threshold', \WC_Log_Levels::WARNING );
- if ( ! \WC_Log_Levels::is_valid_level( $threshold ) ) {
- $threshold = \WC_Log_Levels::INFO;
- }
-
- $this->threshold_severity = \WC_Log_Levels::get_level_severity( $threshold );
-
- add_action(
- 'woocommerce_block_template_after_add_block',
- function ( BlockInterface $block ) {
- $is_detached = method_exists( $block->get_parent(), 'is_detached' ) && $block->get_parent()->is_detached();
-
- $this->log(
- $is_detached
- ? $this::BLOCK_ADDED_TO_DETACHED_CONTAINER
- : $this::BLOCK_ADDED,
- $block,
- );
- },
- 0,
- );
-
- add_action(
- 'woocommerce_block_template_after_remove_block',
- function ( BlockInterface $block ) {
- $this->log(
- $this::BLOCK_REMOVED,
- $block,
- );
- },
- 0,
- );
-
- add_action(
- 'woocommerce_block_template_after_add_hide_condition',
- function ( BlockInterface $block ) {
- $this->log(
- $block->is_detached()
- ? $this::HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK
- : $this::HIDE_CONDITION_ADDED,
- $block,
- );
- },
- 0
- );
-
- add_action(
- 'woocommerce_block_template_after_remove_hide_condition',
- function ( BlockInterface $block ) {
- $this->log(
- $this::HIDE_CONDITION_REMOVED,
- $block,
- );
- },
- 0
- );
-
- add_action(
- 'woocommerce_block_template_after_add_block_error',
- function ( BlockInterface $block, string $action, \Exception $exception ) {
- $this->log(
- $this::ERROR_AFTER_BLOCK_ADDED,
- $block,
- array(
- 'action' => $action,
- 'exception' => $exception,
- ),
- );
- },
- 0,
- 3
- );
-
- add_action(
- 'woocommerce_block_template_after_remove_block_error',
- function ( BlockInterface $block, string $action, \Exception $exception ) {
- $this->log(
- $this::ERROR_AFTER_BLOCK_REMOVED,
- $block,
- array(
- 'action' => $action,
- 'exception' => $exception,
- ),
- );
- },
- 0,
- 3
- );
- }
-
- /**
- * Get all template events for a given template as a JSON like array.
- *
- * @param string $template_id Template ID.
- */
- public function template_events_to_json( string $template_id ): array {
- if ( ! isset( $this->all_template_events[ $template_id ] ) ) {
- return array();
- }
-
- $template_events = $this->all_template_events[ $template_id ];
-
- return $this->to_json( $template_events );
- }
-
- /**
- * Get all template events as a JSON like array.
- *
- * @param array $template_events Template events.
- *
- * @return array The JSON.
- */
- private function to_json( array $template_events ): array {
- $json = array();
-
- foreach ( $template_events as $template_event ) {
- $container = $template_event['container'];
- $block = $template_event['block'];
-
- $json[] = array(
- 'level' => $template_event['level'],
- 'event_type' => $template_event['event_type'],
- 'message' => $template_event['message'],
- 'container' => $container instanceof BlockInterface
- ? array(
- 'id' => $container->get_id(),
- 'name' => $container->get_name(),
- )
- : null,
- 'block' => array(
- 'id' => $block->get_id(),
- 'name' => $block->get_name(),
- ),
- 'additional_info' => $this->format_info( $template_event['additional_info'] ),
- );
- }
-
- return $json;
- }
-
- /**
- * Log all template events for a given template to the log file.
- *
- * @param string $template_id Template ID.
- */
- public function log_template_events_to_file( string $template_id ) {
- if ( ! isset( $this->all_template_events[ $template_id ] ) ) {
- return;
- }
-
- $template_events = $this->all_template_events[ $template_id ];
-
- $hash = $this->generate_template_events_hash( $template_events );
-
- if ( ! $this->has_template_events_changed( $template_id, $hash ) ) {
- // Nothing has changed since the last time this was logged,
- // so don't log it again.
- return;
- }
-
- $this->set_template_events_log_hash( $template_id, $hash );
-
- $template = $this->templates[ $template_id ];
-
- foreach ( $template_events as $template_event ) {
- $info = array_merge(
- array(
- 'template' => $template,
- 'container' => $template_event['container'],
- 'block' => $template_event['block'],
- ),
- $template_event['additional_info']
- );
-
- $message = $this->format_message( $template_event['message'], $info );
-
- $this->logger->log(
- $template_event['level'],
- $message,
- array( 'source' => 'block_template' )
- );
- }
- }
-
- /**
- * Has the template events changed since the last time they were logged?
- *
- * @param string $template_id Template ID.
- * @param string $events_hash Events hash.
- */
- private function has_template_events_changed( string $template_id, string $events_hash ) {
- $previous_hash = get_transient( self::LOG_HASH_TRANSIENT_BASE_NAME . $template_id );
-
- return $previous_hash !== $events_hash;
- }
-
- /**
- * Generate a hash for a given set of template events.
- *
- * @param array $template_events Template events.
- */
- private function generate_template_events_hash( array $template_events ): string {
- return md5( wp_json_encode( $this->to_json( $template_events ) ) );
- }
-
- /**
- * Set the template events hash for a given template.
- *
- * @param string $template_id Template ID.
- * @param string $hash Hash of template events.
- */
- private function set_template_events_log_hash( string $template_id, string $hash ) {
- set_transient( self::LOG_HASH_TRANSIENT_BASE_NAME . $template_id, $hash );
- }
-
- /**
- * Log an event.
- *
- * @param string $event_type Event type.
- * @param BlockInterface $block Block.
- * @param array $additional_info Additional info.
- */
- private function log( string $event_type, BlockInterface $block, $additional_info = array() ) {
- if ( ! isset( self::$event_types[ $event_type ] ) ) {
- /* translators: 1: WC_Logger::log 2: level */
- wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid event type "%2$s".', 'woocommerce' ), '<code>BlockTemplateLogger::log</code>', $event_type ), '8.4' );
- }
-
- $event_type_info = isset( self::$event_types[ $event_type ] )
- ? array_merge(
- self::$event_types[ $event_type ],
- array(
- 'event_type' => $event_type,
- )
- )
- : array(
- 'level' => \WC_Log_Levels::ERROR,
- 'event_type' => $event_type,
- 'message' => 'Unknown error.',
- );
-
- if ( ! $this->should_handle( $event_type_info['level'] ) ) {
- return;
- }
-
- $template = $block->get_root_template();
- $container = $block->get_parent();
-
- $this->add_template_event( $event_type_info, $template, $container, $block, $additional_info );
- }
-
- /**
- * Should the logger handle a given level?
- *
- * @param int $level Level to check.
- */
- private function should_handle( $level ) {
- return $this->threshold_severity <= \WC_Log_Levels::get_level_severity( $level );
- }
-
- /**
- * Add a template event.
- *
- * @param array $event_type_info Event type info.
- * @param BlockTemplateInterface $template Template.
- * @param ContainerInterface $container Container.
- * @param BlockInterface $block Block.
- * @param array $additional_info Additional info.
- */
- private function add_template_event( array $event_type_info, BlockTemplateInterface $template, ContainerInterface $container, BlockInterface $block, array $additional_info = array() ) {
- $template_id = $template->get_id();
-
- if ( ! isset( $this->all_template_events[ $template_id ] ) ) {
- $this->all_template_events[ $template_id ] = array();
- $this->templates[ $template_id ] = $template;
- }
-
- $template_events = &$this->all_template_events[ $template_id ];
-
- $template_events[] = array(
- 'level' => $event_type_info['level'],
- 'event_type' => $event_type_info['event_type'],
- 'message' => $event_type_info['message'],
- 'container' => $container,
- 'block' => $block,
- 'additional_info' => $additional_info,
- );
- }
-
- /**
- * Format a message for logging.
- *
- * @param string $message Message to log.
- * @param array $info Additional info to log.
- */
- private function format_message( string $message, array $info = array() ): string {
- $formatted_message = sprintf(
- "%s\n%s",
- $message,
- // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
- print_r( $this->format_info( $info ), true ),
- );
-
- return $formatted_message;
- }
-
- /**
- * Format info for logging.
- *
- * @param array $info Info to log.
- */
- private function format_info( array $info ): array {
- $formatted_info = $info;
-
- if ( isset( $info['exception'] ) && $info['exception'] instanceof \Exception ) {
- $formatted_info['exception'] = $this->format_exception( $info['exception'] );
- }
-
- if ( isset( $info['container'] ) ) {
- if ( $info['container'] instanceof BlockContainerInterface ) {
- $formatted_info['container'] = $this->format_block( $info['container'] );
- } elseif ( $info['container'] instanceof BlockTemplateInterface ) {
- $formatted_info['container'] = $this->format_template( $info['container'] );
- } elseif ( $info['container'] instanceof BlockInterface ) {
- $formatted_info['container'] = $this->format_block( $info['container'] );
- }
- }
-
- if ( isset( $info['block'] ) && $info['block'] instanceof BlockInterface ) {
- $formatted_info['block'] = $this->format_block( $info['block'] );
- }
-
- if ( isset( $info['template'] ) && $info['template'] instanceof BlockTemplateInterface ) {
- $formatted_info['template'] = $this->format_template( $info['template'] );
- }
-
- return $formatted_info;
- }
-
- /**
- * Format an exception for logging.
- *
- * @param \Exception $exception Exception to format.
- */
- private function format_exception( \Exception $exception ): array {
- return array(
- 'message' => $exception->getMessage(),
- 'source' => "{$exception->getFile()}: {$exception->getLine()}",
- // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
- 'trace' => print_r( $this->format_exception_trace( $exception->getTrace() ), true ),
- );
- }
-
- /**
- * Format an exception trace for logging.
- *
- * @param array $trace Exception trace to format.
- */
- private function format_exception_trace( array $trace ): array {
- $formatted_trace = array();
-
- foreach ( $trace as $source ) {
- $formatted_trace[] = "{$source['file']}: {$source['line']}";
- }
-
- return $formatted_trace;
- }
-
- /**
- * Format a block template for logging.
- *
- * @param BlockTemplateInterface $template Template to format.
- */
- private function format_template( BlockTemplateInterface $template ): string {
- return "{$template->get_id()} (area: {$template->get_area()})";
- }
-
- /**
- * Format a block for logging.
- *
- * @param BlockInterface $block Block to format.
- */
- private function format_block( BlockInterface $block ): string {
- return "{$block->get_id()} (name: {$block->get_name()})";
- }
-}
diff --git a/plugins/woocommerce/src/Internal/Admin/WCAdminAssets.php b/plugins/woocommerce/src/Internal/Admin/WCAdminAssets.php
index 61f85ca2fad..fc386180067 100644
--- a/plugins/woocommerce/src/Internal/Admin/WCAdminAssets.php
+++ b/plugins/woocommerce/src/Internal/Admin/WCAdminAssets.php
@@ -313,7 +313,6 @@ class WCAdminAssets {
'wc-store-data',
'wc-currency',
'wc-navigation',
- 'wc-block-templates',
'wc-experimental-products-app',
'wc-settings-ui-sdk',
'wc-remote-logging',
@@ -384,9 +383,6 @@ class WCAdminAssets {
array(
'handle' => 'wc-components',
),
- array(
- 'handle' => 'wc-block-templates',
- ),
array(
'handle' => 'wc-experimental-products-app',
),
@@ -554,7 +550,6 @@ class WCAdminAssets {
'wc-date',
'wc-components',
'wc-tracks',
- 'wc-block-templates',
);
foreach ( $handles_for_injection as $handle ) {
$script = $wp_scripts->query( $handle, 'registered' );
diff --git a/plugins/woocommerce/src/LayoutTemplates/LayoutTemplateRegistry.php b/plugins/woocommerce/src/LayoutTemplates/LayoutTemplateRegistry.php
new file mode 100644
index 00000000000..511230987a6
--- /dev/null
+++ b/plugins/woocommerce/src/LayoutTemplates/LayoutTemplateRegistry.php
@@ -0,0 +1,119 @@
+<?php
+/**
+ * WooCommerce Layout Template Registry compatibility shim.
+ */
+
+namespace Automattic\WooCommerce\LayoutTemplates;
+
+/**
+ * Removed layout template registry.
+ *
+ * @deprecated 10.9.0 Block template extension APIs were deprecated. The block templates API was removed in 11.0.0 with no replacement.
+ */
+final class LayoutTemplateRegistry {
+ /**
+ * Singleton instance.
+ *
+ * @var LayoutTemplateRegistry|null
+ */
+ private static $instance = null;
+
+ /**
+ * Whether the removal warning has already been logged for the current request.
+ *
+ * @var bool
+ */
+ private static $removal_warning_logged = false;
+
+ /**
+ * Constructor.
+ */
+ public function __construct() {
+ self::maybe_log_removal_warning();
+ }
+
+ /**
+ * Get the singleton instance.
+ *
+ * @return LayoutTemplateRegistry
+ */
+ public static function get_instance(): LayoutTemplateRegistry {
+ $instance = self::$instance;
+
+ if ( null === $instance ) {
+ $instance = new self();
+ self::$instance = $instance;
+ }
+
+ self::maybe_log_removal_warning();
+
+ return $instance;
+ }
+
+ /**
+ * Unregister all layout templates.
+ *
+ * @return void
+ */
+ public function unregister_all() {
+ self::maybe_log_removal_warning();
+ }
+
+ /**
+ * Check if a layout template is registered.
+ *
+ * @param string $layout_template_id Layout template ID.
+ * @return bool
+ */
+ public function is_registered( $layout_template_id ): bool {
+ unset( $layout_template_id );
+
+ self::maybe_log_removal_warning();
+
+ return false;
+ }
+
+ /**
+ * Register a single layout template.
+ *
+ * @param string $layout_template_id Layout template ID.
+ * @param string $layout_template_area Layout template area.
+ * @param string $layout_template_class_name Layout template class to register.
+ * @return void
+ */
+ public function register( $layout_template_id, $layout_template_area, $layout_template_class_name ) {
+ unset( $layout_template_id, $layout_template_area, $layout_template_class_name );
+
+ self::maybe_log_removal_warning();
+ }
+
+ /**
+ * Instantiate the matching layout templates and return them.
+ *
+ * @param array $query_params Query params.
+ * @return array
+ */
+ public function instantiate_layout_templates( array $query_params = array() ): array {
+ unset( $query_params );
+
+ self::maybe_log_removal_warning();
+
+ return array();
+ }
+
+ /**
+ * Log a warning about the removed compatibility class.
+ */
+ private static function maybe_log_removal_warning(): void {
+ if ( self::$removal_warning_logged || ! function_exists( 'wc_get_logger' ) ) {
+ return;
+ }
+
+ self::$removal_warning_logged = true;
+
+ wc_get_logger()->warning(
+ 'Automattic\WooCommerce\LayoutTemplates\LayoutTemplateRegistry is a temporary compatibility shim and will be removed soon. Block template extension APIs were deprecated in WooCommerce 10.9.0, and the block templates API was removed in WooCommerce 11.0.0 with no replacement.',
+ array( 'source' => 'block-templates' )
+ );
+ }
+}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTemplateTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTemplateTest.php
deleted file mode 100644
index e34f73c3990..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTemplateTest.php
+++ /dev/null
@@ -1,655 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplate;
-
-use WC_Unit_Test_Case;
-
-/**
- * Tests for the BlockTemplate class.
- */
-class BlockTemplateTest extends WC_Unit_Test_Case {
- /**
- * Test generating a block ID.
- */
- public function test_generate_block_id() {
- $template = new BlockTemplate();
-
- $this->assertSame( 'test-block-id-1', $template->generate_block_id( 'test-block-id' ) );
- }
-
- /**
- * Test adding a block.
- */
- public function test_add_block() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $this->assertSame( $block, $template->get_block( 'test-block-id' ) );
- }
-
- /**
- * Test the after_add_block hooks fires.
- */
- public function test_after_add_block_hooks() {
- $template = new BlockTemplate();
-
- $hook_called = false;
-
- $after_add_block_hook = function( BlockInterface $block ) use ( &$hook_called ) {
- $hook_called = true;
-
- if ( 'test-block-id' === $block->get_id() ) {
- $hook_called = true;
- }
-
- $root_template = $block->get_root_template();
-
- if ( $root_template->get_block( 'test-block-id-2' ) ) {
- // The block was already added, so just return.
- // This short-circuiting done because this hook will be called two times:
- // 1. When the `test-block-id` block is added to the root template.
- // 2. When the `test-block-id-2` block is added to the template in this hook.
- // Without this short-circuiting, the second time `add_block` is called in this
- // hook would throw an exception, which is handled by the API (an error gets logged).
- return;
- }
-
- $root_template->add_block(
- [
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- ]
- );
- };
-
- try {
- add_action( 'woocommerce_block_template_after_add_block', $after_add_block_hook );
-
- $specific_hook_called = false;
-
- $specific_after_add_block_hook = function( BlockInterface $block ) use ( &$specific_hook_called ) {
- if ( 'test-block-id' === $block->get_id() ) {
- $specific_hook_called = true;
- }
- };
-
- add_action( 'woocommerce_block_template_area_uncategorized_after_add_block_test-block-id', $specific_after_add_block_hook );
-
- $this->setExpectedDeprecated( 'woocommerce_block_template_after_add_block' );
- $this->setExpectedDeprecated( 'woocommerce_block_template_area_uncategorized_after_add_block_test-block-id' );
-
- $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $this->assertTrue(
- $hook_called,
- 'Failed asserting that that the hook was called.'
- );
-
- $this->assertTrue(
- $specific_hook_called,
- 'Failed asserting that that the specific hook was called.'
- );
-
- $this->assertNotNull(
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the block was added to the template from the hook.'
- );
- } finally {
- remove_action( 'woocommerce_block_template_after_add_block', $after_add_block_hook );
- remove_action( 'woocommerce_block_template_area_uncategorized_after_add_block_test-block-id', $specific_after_add_block_hook );
- }
- }
-
- /**
- * Test the after_remove_block hooks fires.
- */
- public function test_after_remove_block_hooks() {
- $template = new BlockTemplate();
-
- $hook_called = false;
-
- $after_remove_block_hook = function( BlockInterface $block ) use ( &$hook_called ) {
- $hook_called = true;
-
- if ( 'test-block-id' === $block->get_id() ) {
- $hook_called = true;
- }
-
- $root_template = $block->get_root_template();
- };
-
- $specific_hook_called = false;
-
- $specific_after_remove_block_hook = function( BlockInterface $block ) use ( &$specific_hook_called ) {
- if ( 'test-block-id' === $block->get_id() ) {
- $specific_hook_called = true;
- }
- };
-
- try {
- add_action( 'woocommerce_block_template_after_remove_block', $after_remove_block_hook );
- add_action( 'woocommerce_block_template_area_uncategorized_after_remove_block_test-block-id', $specific_after_remove_block_hook );
-
- $this->setExpectedDeprecated( 'woocommerce_block_template_after_remove_block' );
- $this->setExpectedDeprecated( 'woocommerce_block_template_area_uncategorized_after_remove_block_test-block-id' );
-
- $block = $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $block->remove();
-
- $this->assertTrue(
- $hook_called,
- 'Failed asserting that that the hook was called.'
- );
-
- $this->assertTrue(
- $specific_hook_called,
- 'Failed asserting that that the specific hook was called.'
- );
-
- $this->assertTrue(
- $block->is_detached(),
- 'Failed asserting that the block was added to the template from the hook.'
- );
- } finally {
- remove_action( 'woocommerce_block_template_after_remove_block', $after_remove_block_hook );
- remove_action( 'woocommerce_block_template_area_uncategorized_after_remove_block_test-block-id', $specific_after_remove_block_hook );
- }
- }
-
- /**
- * Test adding a block throws an exception if a block with the same ID already exists.
- */
- public function test_add_block_throws_exception_if_block_with_same_id_already_exists() {
- $template = new BlockTemplate();
-
- $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $this->expectException( \ValueError::class );
-
- $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
- }
-
- /**
- * Test adding a block generates an ID if one is not provided.
- */
- public function test_add_block_generates_id_if_not_provided() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- [
- 'blockName' => 'test-block-name',
- ]
- );
-
- $this->assertSame( 'test-block-name-1', $block->get_id() );
- }
-
- /**
- * Test getting a block by ID returns null if the block does not exist.
- */
- public function test_get_block_returns_null_if_block_does_not_exist() {
- $template = new BlockTemplate();
-
- $this->assertNull( $template->get_block( 'test-block-id' ) );
- }
-
- /**
- * Test getting a block by ID returns a reference to the block.
- */
- public function test_get_block_returns_reference() {
- $template = new BlockTemplate();
-
- $template->add_block(
- [
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $block = $template->get_block( 'test-block-id' );
-
- $block->set_order( 23 );
-
- $this->assertSame( 23, $template->get_block( 'test-block-id' )->get_order() );
- }
-
- /**
- * Test that the formatted template representation of a block template is correct.
- */
- public function test_get_formatted_template() {
- $template = new BlockTemplate();
-
- $template->add_block(
- [
- 'blockName' => 'test-block-name-c',
- 'order' => 100,
- 'attributes' => [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- ],
- ]
- );
-
- $block_b = $template->add_block(
- [
- 'blockName' => 'test-block-name-b',
- 'order' => 50,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $template->add_block(
- [
- 'blockName' => 'test-block-name-a',
- 'order' => 10,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-2',
- 'order' => 20,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-1',
- 'order' => 10,
- 'attributes' => [
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-3',
- 'order' => 30,
- ]
- );
-
- $this->assertSame(
- [
- [
- 'test-block-name-a',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'test-block-name-a-1',
- '_templateBlockOrder' => 10,
- ],
- ],
- [
- 'test-block-name-b',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'test-block-name-b-1',
- '_templateBlockOrder' => 50,
- ],
- [
- [
- 'test-block-name-1',
- [
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- '_templateBlockId' => 'test-block-name-1-1',
- '_templateBlockOrder' => 10,
- ],
- ],
- [
- 'test-block-name-2',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'test-block-name-2-1',
- '_templateBlockOrder' => 20,
- ],
- ],
- [
- 'test-block-name-3',
- [
- '_templateBlockId' => 'test-block-name-3-1',
- '_templateBlockOrder' => 30,
- ],
- ],
- ],
- ],
- [
- 'test-block-name-c',
- [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- '_templateBlockId' => 'test-block-name-c-1',
- '_templateBlockOrder' => 100,
- ],
- ],
- ],
- $template->get_formatted_template(),
- 'Failed asserting that the block is converted to a simple array correctly.'
- );
- }
-
- /**
- * Test that inserting a block to a parent in the template works.
- */
- public function test_inserting_block_by_parent_id() {
- $template = new BlockTemplate();
-
- $template->add_block(
- [
- 'blockName' => 'test-block-name-c',
- 'order' => 100,
- 'attributes' => [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- ],
- ]
- );
-
- $block_b = $template->add_block(
- [
- 'id' => 'b',
- 'blockName' => 'test-block-name-b',
- 'order' => 50,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $template->add_block(
- [
- 'id' => 'a',
- 'blockName' => 'test-block-name-a',
- 'order' => 10,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-2',
- 'order' => 20,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-1',
- 'order' => 10,
- 'attributes' => [
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-3',
- 'order' => 30,
- ]
- );
-
- $block_to_insert_in = $template->get_block( 'a' );
-
- $block_to_insert_in->add_block(
- [
- 'blockName' => 'inserted-block',
- ]
- );
-
- $another_block_to_insert_in = $template->get_block( 'b' );
-
- $another_block_to_insert_in->add_block(
- [
- 'blockName' => 'another-inserted-block',
- 'order' => 15,
- ]
- );
-
- $this->assertSame(
- [
- [
- 'test-block-name-a',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'a',
- '_templateBlockOrder' => 10,
- ],
- [
- [
- 'inserted-block',
- [
- '_templateBlockId' => 'inserted-block-1',
- '_templateBlockOrder' => 10000,
- ],
- ],
- ],
- ],
- [
- 'test-block-name-b',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'b',
- '_templateBlockOrder' => 50,
- ],
- [
- [
- 'test-block-name-1',
- [
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- '_templateBlockId' => 'test-block-name-1-1',
- '_templateBlockOrder' => 10,
- ],
- ],
- [
- 'another-inserted-block',
- [
- '_templateBlockId' => 'another-inserted-block-1',
- '_templateBlockOrder' => 15,
- ],
- ],
- [
- 'test-block-name-2',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'test-block-name-2-1',
- '_templateBlockOrder' => 20,
- ],
- ],
- [
- 'test-block-name-3',
- [
- '_templateBlockId' => 'test-block-name-3-1',
- '_templateBlockOrder' => 30,
- ],
- ],
- ],
- ],
- [
- 'test-block-name-c',
- [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- '_templateBlockId' => 'test-block-name-c-1',
- '_templateBlockOrder' => 100,
- ],
- ],
- ],
- $template->get_formatted_template(),
- 'Failed asserting that the template is converted to a formatted template correctly.'
- );
- }
-
- /**
- * Test that removing a block in the template works.
- */
- public function test_removing_blocks() {
- $template = new BlockTemplate();
-
- $template->add_block(
- [
- 'blockName' => 'test-block-name-c',
- 'order' => 100,
- 'attributes' => [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- ],
- ]
- );
-
- $block_b = $template->add_block(
- [
- 'id' => 'b',
- 'blockName' => 'test-block-name-b',
- 'order' => 50,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $template->add_block(
- [
- 'id' => 'a',
- 'blockName' => 'test-block-name-a',
- 'order' => 10,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-2',
- 'order' => 20,
- 'attributes' => [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-1',
- 'order' => 10,
- 'attributes' => [
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- ],
- ]
- );
-
- $block_b->add_block(
- [
- 'blockName' => 'test-block-name-3',
- 'order' => 30,
- ]
- );
-
- $block_to_insert_in = $template->get_block( 'a' );
-
- $block_to_insert_in->add_block(
- [
- 'blockName' => 'inserted-block',
- ]
- );
-
- $template->remove_block( 'b' );
-
- $this->assertSame(
- [
- [
- 'test-block-name-a',
- [
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'a',
- '_templateBlockOrder' => 10,
- ],
- [
- [
- 'inserted-block',
- [
- '_templateBlockId' => 'inserted-block-1',
- '_templateBlockOrder' => 10000,
- ],
- ],
- ],
- ],
- [
- 'test-block-name-c',
- [
- 'attr-c1' => 'value-c1',
- 'attr-c2' => 'value-c2',
- '_templateBlockId' => 'test-block-name-c-1',
- '_templateBlockOrder' => 100,
- ],
- ],
- ],
- $template->get_formatted_template(),
- 'Failed asserting that the template is converted to a formatted template correctly.'
- );
- }
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php
deleted file mode 100644
index e39a25ca741..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php
+++ /dev/null
@@ -1,677 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\Block;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplate;
-
-use WC_Unit_Test_Case;
-
-/**
- * Tests for the Block class.
- */
-class BlockTest extends WC_Unit_Test_Case {
- /**
- * Test that the block name is required when creating a block.
- */
- public function test_name_is_required() {
- $template = new BlockTemplate();
-
- $this->expectException( \ValueError::class );
-
- new Block( array(), $template );
- }
-
- /**
- * Test that an ID is generated if not provided when creating a block.
- */
- public function test_id_is_generated_if_not_provided() {
- $template = new BlockTemplate();
-
- $block = new Block(
- array(
- 'blockName' => 'test-block-name',
- ),
- $template
- );
-
- $this->assertSame( 'test-block-name-1', $block->get_id() );
- }
-
- /**
- * Test that setting a parent from a different template is prevented.
- */
- public function test_parent_from_different_template_throws_exception() {
- $template = new BlockTemplate();
- $template_2 = new BlockTemplate();
-
- $parent = new Block(
- array(
- 'blockName' => 'test-block-parent-name',
- ),
- $template_2
- );
-
- $this->expectException( \ValueError::class );
-
- new Block(
- array(
- 'blockName' => 'test-block-name',
- ),
- $template,
- $parent
- );
- }
-
- /**
- * Test that adding a block to a block sets the parent and root template correctly
- * and that the block is added to the root template.
- */
- public function test_add_block() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $child_block = $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- )
- );
-
- $this->assertSame(
- $child_block->get_root_template(),
- $block->get_root_template(),
- 'Failed asserting that the child block has the same root template as the parent block.'
- );
-
- $this->assertSame(
- $block,
- $child_block->get_parent(),
- 'Failed asserting that the child block\'s parent is the block it was added to.'
- );
- $this->assertSame(
- $child_block,
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the child block is in the root template.'
- );
- }
-
- /**
- * Test that removing a block from a block detaches it
- * and that the block is removed from the root template.
- */
- public function test_remove_block() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $child_block = $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- )
- );
-
- $block->remove_block( 'test-block-id-2' );
-
- $this->assertNull(
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the child block was removed from the root template.'
- );
-
- $this->assertNull(
- $block->get_block( 'test-block-id-2' ),
- 'Failed asserting that the child block was removed from the parent.'
- );
-
- $this->assertTrue(
- $child_block->is_detached(),
- 'Failed asserting that the child block is detached from its parent and root template.'
- );
- }
-
- /**
- * Test that removing a block from a block detaches it
- * and that the block is removed from the root template, as well as any descendants.
- */
- public function test_remove_nested_block() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $child_block = $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- )
- );
-
- $template->remove_block( 'test-block-id-2' );
-
- $this->assertNull(
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the nested descendent block was removed from the root template.'
- );
-
- $this->assertNull(
- $block->get_block( 'test-block-id-2' ),
- 'Failed asserting that the nested descendent block was removed from the parent.'
- );
-
- $this->assertTrue(
- $child_block->is_detached(),
- 'Failed asserting that the nested descendent block is detached from its parent and root template.'
- );
- }
-
- /**
- * Test that removing a block from a block detaches it
- * and that the block is removed from the root template, as well as any descendants.
- */
- public function test_remove_block_and_descendants() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $child_block = $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- )
- );
-
- $template->remove_block( 'test-block-id' );
-
- $this->assertNull(
- $template->get_block( 'test-block-id' ),
- 'Failed asserting that the child block was removed from the root template.'
- );
-
- $this->assertNull(
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the nested descendent block was removed from the root template.'
- );
-
- $this->assertNull(
- $block->get_block( 'test-block-id-2' ),
- 'Failed asserting that the child block was removed from the parent.'
- );
-
- $this->assertTrue(
- $block->is_detached(),
- 'Failed asserting that the block is detached from its parent and root template.'
- );
-
- $this->assertTrue(
- $child_block->is_detached(),
- 'Failed asserting that the child block is detached from its parent and root template.'
- );
- }
-
- /**
- * Test that removing a block by calling remove on it detaches it.
- */
- public function test_remove_block_self() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $block->remove();
-
- $this->assertTrue(
- $block->is_detached(),
- 'Failed asserting that the block is detached from its parent and root template.'
- );
- }
-
- /**
- * Test that adding nested blocks sets the parent and root template correctly.
- */
- public function test_nested_add_block() {
- $block_template = new BlockTemplate();
-
- $block = $block_template->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $child_block_1 = $block->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $grandchild_block = $child_block_1->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $this->assertSame(
- $block_template,
- $grandchild_block->get_root_template(),
- 'Failed asserting that the grandchild block has the same root template.'
- );
-
- $grandchild_parent = $grandchild_block->get_parent();
-
- $this->assertSame(
- $child_block_1,
- $grandchild_parent,
- 'Failed asserting that the grandchild block\'s parent is the block it was added to.'
- );
-
- $this->assertInstanceOf(
- BlockContainerInterface::class,
- $grandchild_parent,
- 'Failed asserting that the grandchild block\'s parent is a BlockContainerInterface instance.'
- );
-
- $this->assertSame(
- $block,
- $grandchild_parent->get_parent(),
- 'Failed asserting that the grandchild block\'s grandparent is correct.'
- );
- }
-
- /**
- * Test that a block added to a detached block is detached.
- */
- public function test_block_added_to_detached_block_is_detached() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- )
- );
-
- $template->remove_block( 'test-block-id' );
-
- $child_block = $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- )
- );
-
- $this->assertNull(
- $template->get_block( 'test-block-id' ),
- 'Failed asserting that the block was removed from the root template.'
- );
-
- $this->assertNull(
- $template->get_block( 'test-block-id-2' ),
- 'Failed asserting that the nested block is not in the root template.'
- );
-
- $this->assertNotNull(
- $block->get_block( 'test-block-id-2' ),
- 'Failed asserting that the nested block is in the parent.'
- );
-
- $this->assertTrue(
- $child_block->is_detached(),
- 'Failed asserting that the nested descendent block is detached from its parent and root template.'
- );
- }
-
- /**
- * Test that hide conditions can be passed in when creating a block.
- */
- public function test_hide_conditions_in_constructor() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'blockName' => 'test-block-name',
- 'hideConditions' => array(
- array(
- 'expression' => 'foo === bar',
- ),
- ),
- )
- );
-
- $this->assertSame(
- array(
- 'k0' => array(
- 'expression' => 'foo === bar',
- ),
- ),
- $block->get_hide_conditions(),
- 'Failed asserting that the hide conditions are set correctly in the constructor.'
- );
- }
-
- /**
- * Test that disable conditions can be passed in when creating a block.
- */
- public function test_disable_conditions_in_constructor() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'blockName' => 'test-block-name',
- 'disableConditions' => array(
- array(
- 'expression' => 'foo === bar',
- ),
- ),
- )
- );
-
- $this->assertSame(
- array(
- 'k0' => array(
- 'expression' => 'foo === bar',
- ),
- ),
- $block->get_disable_conditions(),
- 'Failed asserting that the disable conditions are set correctly in the constructor.'
- );
- }
-
- /**
- * Test that hide conditions can be added to a block.
- */
- public function test_add_hide_condition() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $condition_1_key = $block->add_hide_condition( 'editedProduct.manage_stock === true' );
-
- $condition_2_key = $block->add_hide_condition( 'true' );
-
- $condition_3_key = $block->add_hide_condition( 'foo > 10' );
-
- $block->remove_hide_condition( $condition_2_key );
-
- $this->assertSame(
- array(
- $condition_1_key => array(
- 'expression' => 'editedProduct.manage_stock === true',
- ),
- $condition_3_key => array(
- 'expression' => 'foo > 10',
- ),
- ),
- $block->get_hide_conditions(),
- 'Failed asserting that the hide conditions are added correctly.'
- );
- }
-
- /**
- * Test that hide conditions can be added to a block.
- */
- public function test_add_disable_condition() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $condition_1_key = $block->add_disable_condition( 'editedProduct.manage_stock === true' );
-
- $condition_2_key = $block->add_disable_condition( 'true' );
-
- $condition_3_key = $block->add_disable_condition( 'foo > 10' );
-
- $block->remove_disable_condition( $condition_2_key );
-
- $this->assertSame(
- array(
- $condition_1_key => array(
- 'expression' => 'editedProduct.manage_stock === true',
- ),
- $condition_3_key => array(
- 'expression' => 'foo > 10',
- ),
- ),
- $block->get_disable_conditions(),
- 'Failed asserting that the hide conditions are added correctly.'
- );
- }
-
- /**
- * Test that getting the block as a formatted template is structured correctly.
- */
- public function test_get_formatted_template() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'id' => 'test-block-id',
- 'blockName' => 'test-block-name',
- 'attributes' => array(
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- ),
- )
- );
-
- $block->add_hide_condition( 'foo === bar' );
-
- $block->add_disable_condition( 'test > 100' );
-
- $block->add_block(
- array(
- 'id' => 'test-block-id-2',
- 'blockName' => 'test-block-name-2',
- 'attributes' => array(
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- ),
- )
- );
-
- $block->add_block(
- array(
- 'id' => 'test-block-id-3',
- 'blockName' => 'test-block-name-3',
- )
- );
-
- $formatted_template = $block->get_formatted_template();
-
- $this->assertSame(
- array(
- 'test-block-name',
- array(
- 'attr-1' => 'value-1',
- 'attr-2' => 'value-2',
- '_templateBlockId' => 'test-block-id',
- '_templateBlockOrder' => 10000,
- '_templateBlockHideConditions' => array(
- array(
- 'expression' => 'foo === bar',
- ),
- ),
- '_templateBlockDisableConditions' => array(
- array(
- 'expression' => 'test > 100',
- ),
- ),
- ),
- array(
- array(
- 'test-block-name-2',
- array(
- 'attr-3' => 'value-3',
- 'attr-4' => 'value-4',
- '_templateBlockId' => 'test-block-id-2',
- '_templateBlockOrder' => 10000,
- ),
- ),
- array(
- 'test-block-name-3',
- array(
- '_templateBlockId' => 'test-block-id-3',
- '_templateBlockOrder' => 10000,
- ),
- ),
- ),
- ),
- $formatted_template,
- 'Failed asserting that the block is converted to a formatted template correctly.'
- );
- }
-
- /**
- * Test that getting the inner blocks as a sorted formatted template is ordered correctly.
- */
- public function test_get_formatted_template_with_sorting() {
- $template = new BlockTemplate();
-
- $block = $template->add_block(
- array(
- 'blockName' => 'test-block-name',
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'five',
- 'order' => 5,
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'three',
- 'order' => 3,
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'one',
- 'order' => 1,
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'four',
- 'order' => 4,
- )
- );
-
- $block->add_block(
- array(
- 'blockName' => 'two',
- 'order' => 2,
- )
- );
-
- $this->assertSame(
- array(
- 'test-block-name',
- array(
- '_templateBlockId' => 'test-block-name-1',
- '_templateBlockOrder' => 10000,
- ),
- array(
- array(
- 'one',
- array(
- '_templateBlockId' => 'one-1',
- '_templateBlockOrder' => 1,
- ),
- ),
- array(
- 'two',
- array(
- '_templateBlockId' => 'two-1',
- '_templateBlockOrder' => 2,
- ),
- ),
- array(
- 'three',
- array(
- '_templateBlockId' => 'three-1',
- '_templateBlockOrder' => 3,
- ),
- ),
- array(
- 'four',
- array(
- '_templateBlockId' => 'four-1',
- '_templateBlockOrder' => 4,
- ),
- ),
- array(
- 'five',
- array(
- '_templateBlockId' => 'five-1',
- '_templateBlockOrder' => 5,
- ),
- ),
- ),
- ),
- $block->get_formatted_template(),
- 'Failed asserting that the inner blocks are sorted by order.'
- );
- }
- /**
- * Test for set_attribute method.
- */
- public function test_set_attribute() {
- $template = new BlockTemplate();
-
- $block = new Block(
- array(
- 'blockName' => 'test-block-name',
- ),
- $template
- );
-
- $block->set_attribute( 'test-attr', 'test-value' );
-
- $this->assertSame( 'test-value', $block->get_attributes()['test-attr'] );
- }
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlock.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlock.php
deleted file mode 100644
index f601d196db2..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlock.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlock;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\Block;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockContainerTrait;
-
-/**
- * Custom block class for testing.
- */
-class CustomBlock extends AbstractBlock implements CustomBlockInterface {
- use BlockContainerTrait;
-
- /**
- * Custom method.
- *
- * @param string $title The title.
- */
- public function add_custom_inner_block( string $title ): BlockInterface {
- $block = new Block(
- [
- 'blockName' => 'custom-inner-block',
- 'attributes' => [
- 'title' => $title,
- ],
- ],
- $this->get_root_template(),
- $this
- );
-
- $this->add_inner_block( $block );
-
- return $block;
- }
-}
-
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockInterface.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockInterface.php
deleted file mode 100644
index f920aadcc2d..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockInterface.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-
-interface CustomBlockInterface extends BlockContainerInterface {
- /**
- * Adds a method to insert a specific custom inner block.
- *
- * @param string $title The title.
- */
- public function add_custom_inner_block( string $title ): BlockInterface;
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplate.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplate.php
deleted file mode 100644
index 6d448fb8d81..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplate.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlockTemplate;
-
-/**
- * Custom block template class.
- */
-class CustomBlockTemplate extends AbstractBlockTemplate {
- /**
- * Get the template ID.
- */
- public function get_id(): string {
- return 'custom-block-template';
- }
-
- /**
- * Get the template title.
- */
- public function get_title(): string {
- return 'Custom Block Template';
- }
-
- /**
- * Get the template description.
- */
- public function get_description(): string {
- return 'A custom block template for testing.';
- }
-
- /**
- * Get the template area.
- */
- public function get_area(): string {
- return 'test-area';
- }
-
- /**
- * Add a custom block type to this template.
- *
- * @param array $block_config The block data.
- */
- public function add_custom_block( array $block_config ): CustomBlockInterface {
- $block = new CustomBlock( $block_config, $this->get_root_template(), $this );
- return $this->add_inner_block( $block );
- }
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplateTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplateTest.php
deleted file mode 100644
index 4eef05aab3a..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTemplateTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\Block;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplate;
-
-use WC_Unit_Test_Case;
-
-/**
- * Tests for the CustomBlockTemplate class.
- */
-class CustomBlockTemplateTest extends WC_Unit_Test_Case {
- /**
- * Test getting the template ID.
- */
- public function test_get_id() {
- $template = new CustomBlockTemplate();
- $this->assertEquals( $template->get_id(), 'custom-block-template' );
- }
-
- /**
- * Test getting the template ID.
- */
- public function test_get_title() {
- $template = new CustomBlockTemplate();
- $this->assertEquals( $template->get_title(), 'Custom Block Template' );
- }
-
- /**
- * Test getting the template ID.
- */
- public function test_get_description() {
- $template = new CustomBlockTemplate();
- $this->assertEquals( $template->get_description(), 'A custom block template for testing.' );
- }
-
- /**
- * Test that the add_block method does not exist by default on templates.
- */
- public function test_add_block_does_not_exist() {
- $template = new CustomBlockTemplate();
- $this->assertFalse( method_exists( $template, 'add_block' ) );
- }
-
- /**
- * Test that a custom block inserter method inserts as expected.
- */
- public function test_add_custom_block() {
- $template = new CustomBlockTemplate();
-
- $template->add_custom_block(
- [
- 'id' => 'test-block-name',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $block = $template->get_block( 'test-block-name' );
- $this->assertInstanceOf( CustomBlock::class, $block );
- }
-
- /**
- * Test that a custom block can be removed as expected.
- */
- public function test_remove_custom_block() {
- $template = new CustomBlockTemplate();
-
- $template->add_custom_block(
- [
- 'id' => 'test-block-name-1',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $template->add_custom_block(
- [
- 'id' => 'test-block-name-2',
- 'blockName' => 'test-block-name',
- ]
- );
-
- $template->remove_block( 'test-block-name-1' );
-
- $this->assertNull( $template->get_block( 'test-block-name-1' ) );
- }
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTest.php
deleted file mode 100644
index d5d5a8adc89..00000000000
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/CustomBlockTest.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-namespace Automattic\WooCommerce\Tests\Internal\Admin\BlockTemplates;
-
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface;
-use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface;
-
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\Block;
-use Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplate;
-use Customers;
-use WC_Unit_Test_Case;
-
-/**
- * Tests for the CustomBlock class.
- */
-class CustomBlockTest extends WC_Unit_Test_Case {
- /**
- * Test that the add_block method does not exist by default on blocks.
- */
- public function test_add_block_does_not_exist() {
- $template = new CustomBlockTemplate();
- $block = $template->add_custom_block( [ 'blockName' => 'test-block-name' ] );
-
- $this->assertFalse( method_exists( $block, 'add_block' ) );
- }
-
- /**
- * Test that a custom block inserter method inserts as expected.
- */
- public function test_add_custom_inner_block() {
- $template = new CustomBlockTemplate();
- $block = $template->add_custom_block( [ 'blockName' => 'test-block-name' ] );
-
- $block->add_custom_inner_block( 'a' );
- $block->add_custom_inner_block( 'b' );
-
- $this->assertSame(
- [
- 'test-block-name',
- [
- '_templateBlockId' => 'test-block-name-1',
- '_templateBlockOrder' => 10000,
- ],
- [
- [
- 'custom-inner-block',
- [
- 'title' => 'a',
- '_templateBlockId' => 'custom-inner-block-1',
- '_templateBlockOrder' => 10000,
- ],
- ],
- [
- 'custom-inner-block',
- [
- 'title' => 'b',
- '_templateBlockId' => 'custom-inner-block-2',
- '_templateBlockOrder' => 10000,
- ],
- ],
- ],
- ],
- $block->get_formatted_template(),
- 'Failed asserting that the inner block was added'
- );
- }
-
- /**
- * Test that a custom block is removed as expected.
- */
- public function test_remove_custom_inner_block() {
- $template = new CustomBlockTemplate();
- $block = $template->add_custom_block( [ 'blockName' => 'test-block-name' ] );
- $block->add_custom_inner_block( 'a' );
- $block->add_custom_inner_block( 'b' );
-
- $template->remove_block( 'custom-inner-block-1' );
-
- $this->assertSame(
- [
- 'test-block-name',
- [
- '_templateBlockId' => 'test-block-name-1',
- '_templateBlockOrder' => 10000,
- ],
- [
- [
- 'custom-inner-block',
- [
- 'title' => 'b',
- '_templateBlockId' => 'custom-inner-block-2',
- '_templateBlockOrder' => 10000,
- ],
- ],
- ],
- ],
- $block->get_formatted_template(),
- 'Failed asserting that the inner block was removed'
- );
- }
-}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b93adc1cc7d..cbeeb34119c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -250,7 +250,7 @@ importers:
version: 1.15.0
postcss-loader:
specifier: 4.3.x
- version: 4.3.0(postcss@8.5.9)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 4.3.0(postcss@8.5.9)(webpack@5.97.1)
prettier:
specifier: npm:wp-prettier@^2.8.5
version: wp-prettier@2.8.5
@@ -317,7 +317,7 @@ importers:
version: 29.5.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
postcss-loader:
specifier: 4.3.x
- version: 4.3.0(postcss@8.5.9)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 4.3.0(postcss@8.5.9)(webpack@5.97.1)
react:
specifier: 18.3.x
version: 18.3.1
@@ -329,119 +329,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
- ts-jest:
- specifier: 29.1.x
- version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
- typescript:
- specifier: 5.7.x
- version: 5.7.3
- webpack:
- specifier: 5.97.x
- version: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
- webpack-cli:
- specifier: 5.1.x
- version: 5.1.4(webpack@5.97.1)
-
- packages/js/block-templates:
- dependencies:
- '@woocommerce/expression-evaluation':
- specifier: workspace:*
- version: link:../expression-evaluation
- '@woocommerce/settings':
- specifier: 1.0.0
- version: 1.0.0
- '@wordpress/block-editor':
- specifier: catalog:wp-min
- version: 14.14.6(@babel/core@7.25.7)(@emotion/is-prop-valid@1.4.0)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(webpack-virtual-modules@0.6.2)(webpack@5.97.1)
- '@wordpress/blocks':
- specifier: catalog:wp-min
- version: 14.8.2(react@18.3.1)
- '@wordpress/core-data':
- specifier: catalog:wp-min
- version: 7.19.6(@emotion/is-prop-valid@1.4.0)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
- '@wordpress/data':
- specifier: ^10.0.2
- version: 10.19.2(react@18.3.1)
- '@wordpress/element':
- specifier: catalog:wp-min
- version: 6.19.1
- devDependencies:
- '@babel/core':
- specifier: 7.25.7
- version: 7.25.7
- '@babel/runtime':
- specifier: 7.25.7
- version: 7.25.7
- '@testing-library/jest-dom':
- specifier: ^6.x.x
- version: 6.4.5(@jest/globals@29.7.0)(@types/jest@29.5.14)(jest@29.5.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))
- '@testing-library/react':
- specifier: ^16.x.x
- version: 16.3.2(@testing-library/dom@10.4.1)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
- '@types/jest':
- specifier: 29.5.x
- version: 29.5.14
- '@types/react':
- specifier: 18.3.x
- version: 18.3.28
- '@types/testing-library__jest-dom':
- specifier: ^5.14.9
- version: 5.14.9
- '@types/wordpress__block-editor':
- specifier: catalog:wp-min
- version: 14.21.8(@emotion/is-prop-valid@1.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
- '@types/wordpress__blocks':
- specifier: catalog:wp-min
- version: 12.5.18(@emotion/is-prop-valid@1.4.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
- '@woocommerce/eslint-plugin':
- specifier: workspace:*
- version: link:../eslint-plugin
- '@woocommerce/internal-build':
- specifier: workspace:*
- version: link:../internal-build
- '@woocommerce/internal-js-tests':
- specifier: workspace:*
- version: link:../internal-js-tests
- '@wordpress/browserslist-config':
- specifier: next
- version: 6.43.1-next.v.202604091042.0
- copy-webpack-plugin:
- specifier: 13.0.x
- version: 13.0.1(webpack@5.97.1(@swc/core@1.15.24))
- css-loader:
- specifier: 6.11.x
- version: 6.11.0(webpack@5.97.1(@swc/core@1.15.24))
- eslint:
- specifier: ^8.55.0
- version: 8.57.1
- jest:
- specifier: 29.5.x
- version: 29.5.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
- jest-cli:
- specifier: 29.5.x
- version: 29.5.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
- jest-environment-jsdom:
- specifier: 29.5.x
- version: 29.5.0
- postcss:
- specifier: 8.4.x
- version: 8.4.49
- postcss-loader:
- specifier: 4.3.x
- version: 4.3.0(postcss@8.4.49)(webpack@5.97.1)
- react:
- specifier: 18.3.x
- version: 18.3.1
- react-dom:
- specifier: 18.3.x
- version: 18.3.1(react@18.3.1)
- rimraf:
- specifier: 5.0.5
- version: 5.0.5
- sass-loader:
- specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -516,7 +404,7 @@ importers:
version: 14.14.6(@babel/core@7.25.7)(@emotion/is-prop-valid@1.4.0)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(webpack-virtual-modules@0.6.2)(webpack@5.97.1)
'@wordpress/block-library':
specifier: catalog:wp-min
- version: 9.19.6(@emotion/is-prop-valid@1.4.0)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(stylelint@16.26.1(typescript@5.7.3))
+ version: 9.19.6(@emotion/is-prop-valid@1.4.0)(@types/react-dom@18.3.7(@types/react@18.3.28))(@types/react@18.3.28)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(stylelint@14.16.1)
'@wordpress/blocks':
specifier: catalog:wp-min
version: 14.8.2(react@18.3.1)
@@ -742,7 +630,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -972,7 +860,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -1633,7 +1521,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -1796,7 +1684,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -2346,7 +2234,7 @@ importers:
version: 5.0.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
ts-jest:
specifier: 29.1.x
version: 29.1.5(@babel/core@7.25.7)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.7))(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
@@ -3225,9 +3113,6 @@ importers:
'@typescript-eslint/parser':
specifier: ^5.62.0
version: 5.62.0(eslint@8.57.1)(typescript@5.7.3)
- '@woocommerce/block-templates':
- specifier: workspace:*
- version: link:../../../../packages/js/block-templates
'@woocommerce/dependency-extraction-webpack-plugin':
specifier: workspace:*
version: link:../../../../packages/js/dependency-extraction-webpack-plugin
@@ -3302,7 +3187,7 @@ importers:
version: 3.3.7
copy-webpack-plugin:
specifier: 13.0.x
- version: 13.0.1(webpack@5.97.1(@swc/core@1.15.24))
+ version: 13.0.1(webpack@5.97.1)
css-loader:
specifier: 6.11.x
version: 6.11.0(webpack@5.97.1(@swc/core@1.15.24))
@@ -3395,7 +3280,7 @@ importers:
version: 1.69.5
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
stylelint:
specifier: ^14.16.1
version: 14.16.1
@@ -3840,7 +3725,7 @@ importers:
version: 5.2.2(webpack@5.97.1)
copy-webpack-plugin:
specifier: 13.0.x
- version: 13.0.1(webpack@5.97.1(@swc/core@1.15.24))
+ version: 13.0.1(webpack@5.97.1)
core-js:
specifier: 3.25.0
version: 3.25.0
@@ -3969,7 +3854,7 @@ importers:
version: 4.3.0
sass-loader:
specifier: 10.5.x
- version: 10.5.2(sass@1.69.5)(webpack@5.97.1(@swc/core@1.15.24))
+ version: 10.5.2(sass@1.69.5)(webpack@5.97.1)
storybook:
specifier: ^7.6.4
version: 7.6.19(encoding@0.1.13)
@@ -4304,7 +4189,7 @@ importers:
version: link:../../packages/js/eslint-plugin
copy-webpack-plugin:
specifier: 13.0.x
- version: 13.0.1(webpack@5.97.1(@swc/core@1.15.24))
+ version: 13.0.1(webpack@5.97.1)
eslint:
specifier: ^8.55.0
version: 8.57.1
@@ -26305,7 +26190,7 @@ snapshots:
'@types/istanbul-lib-coverage': 2.0.6
collect-v8-coverage: 1.0.3
- '@jest/test-sequencer@26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))':
+ '@jest/test-sequencer@26.6.3':
dependencies:
'@jest/test-result': 26.6.2
graceful-fs: 4.2.11
@@ -26313,11 +26198,7 @@ snapshots:
jest-runner: 26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
jest-runtime: 26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
transitivePeerDependencies:
- - bufferutil
- - canvas
- supports-color
- - ts-node
- - utf-8-validate
'@jest/test-sequencer@29.7.0':
dependencies:
@@ -32136,10 +32017,10 @@ snapshots:
'@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@4.15.2)(webpack@5.97.1)':
dependencies:
- webpack: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
+ webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.18.20)(webpack-cli@5.1.4)
webpack-cli: 5.1.4(webpack-bundle-analyzer@4.9.1)(webpack-dev-server@4.15.2)(webpack@5.97.1)
optionalDependencies:
- webpack-dev-server: 4.15.2(debug@4.4.3)(webpack-cli@5.1.4)(webpack@5.97.1)
+ webpack-dev-server: 4.15.2(webpack-cli@5.1.4)(webpack@5.97.1)
'@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack@5.97.1)':
dependencies:
@@ -35367,7 +35248,7 @@ snapshots:
cosmiconfig: 7.1.0
eslint: 8.57.1
eslint-config-prettier: 8.10.2(eslint@8.57.1)
- eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@4.4.4)(eslint-import-resolver-webpack@0.13.2)(eslint@8.57.1)
+ eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@3.6.1)(eslint-import-resolver-webpack@0.13.11)(eslint@8.57.1)
eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
eslint-plugin-jsdoc: 39.9.1(eslint@8.57.1)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
@@ -35396,7 +35277,7 @@ snapshots:
cosmiconfig: 7.1.0
eslint: 8.57.1
eslint-config-prettier: 8.10.2(eslint@8.57.1)
- eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@4.4.4)(eslint-import-resolver-webpack@0.13.2)(eslint@8.57.1)
+ eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@3.6.1)(eslint-import-resolver-webpack@0.13.11)(eslint@8.57.1)
eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(jest@29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
eslint-plugin-jsdoc: 39.9.1(eslint@8.57.1)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
@@ -35425,7 +35306,7 @@ snapshots:
cosmiconfig: 7.1.0
eslint: 8.57.1
eslint-config-prettier: 8.10.2(eslint@8.57.1)
- eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@4.4.4)(eslint-import-resolver-webpack@0.13.2)(eslint@8.57.1)
+ eslint-plugin-import: 2.32.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint-import-resolver-typescript@3.6.1)(eslint-import-resolver-webpack@0.13.11)(eslint@8.57.1)
eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(jest@29.5.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))(typescript@5.7.3)
eslint-plugin-jsdoc: 39.9.1(eslint@8.57.1)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
@@ -36191,7 +36072,7 @@ snapshots:
jest-matcher-utils: 29.7.0
jest-mock: 29.7.0
- '@wordpress/jest-console@8.44.0(jest@29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))':
+ '@wordpress/jest-console@8.44.0(jest@29.7.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))':
dependencies:
jest: 29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
jest-matcher-utils: 29.7.0
@@ -36209,7 +36090,7 @@ snapshots:
'@wordpress/jest-preset-default@12.22.0(@babel/core@7.25.7)(jest@29.7.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))':
dependencies:
'@babel/core': 7.25.7
- '@wordpress/jest-console': 8.44.0(jest@29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))
+ '@wordpress/jest-console': 8.44.0(jest@29.7.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))
babel-jest: 29.7.0(@babel/core@7.25.7)
jest: 29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
transitivePeerDependencies:
@@ -36227,7 +36108,7 @@ snapshots:
'@wordpress/jest-preset-default@12.44.0(@babel/core@7.25.7)(jest@29.7.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))':
dependencies:
'@babel/core': 7.25.7
- '@wordpress/jest-console': 8.44.0(jest@29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))
+ '@wordpress/jest-console': 8.44.0(jest@29.7.0(@types/node@24.12.2)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)))
babel-jest: 29.7.0(@babel/core@7.25.7)
jest: 29.7.0(@types/node@24.12.2)(babel-plugin-macros@3.1.0)(node-notifier@8.0.2)(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
transitivePeerDependencies:
@@ -37210,7 +37091,7 @@ snapshots:
expect-puppeteer: 4.4.0
filenamify: 4.3.0
jest: 26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
- jest-circus: 26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
+ jest-circus: 26.6.3
jest-dev-server: 5.0.3
jest-environment-node: 26.6.2
markdownlint: 0.23.1
@@ -38057,7 +37938,7 @@ snapshots:
'@wordpress/keycodes': 4.45.0
'@wordpress/primitives': 4.45.0(react@18.3.1)
'@wordpress/private-apis': 1.44.0
- '@wordpress/theme': 0.12.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(stylelint@16.26.1(typescript@5.7.3))
+ '@wordpress/theme': 0.12.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(stylelint@14.16.1)
clsx: 2.1.1
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
@@ -40603,6 +40484,15 @@ snapshots:
tinyglobby: 0.2.16
webpack: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
+ copy-webpack-plugin@13.0.1(webpack@5.97.1):
+ dependencies:
+ glob-parent: 6.0.2
+ normalize-path: 3.0.0
+ schema-utils: 4.3.3
+ serialize-javascript: 6.0.2
+ tinyglobby: 0.2.16
+ webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.18.20)(webpack-cli@5.1.4)
+
core-js-compat@3.49.0:
dependencies:
browserslist: 4.28.2
@@ -45271,7 +45161,7 @@ snapshots:
jest-util: 29.7.0
p-limit: 3.1.0
- jest-circus@26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)):
+ jest-circus@26.6.3:
dependencies:
'@babel/traverse': 7.29.0
'@jest/environment': 26.6.2
@@ -45295,11 +45185,7 @@ snapshots:
stack-utils: 2.0.6
throat: 5.0.0
transitivePeerDependencies:
- - bufferutil
- - canvas
- supports-color
- - ts-node
- - utf-8-validate
jest-circus@29.5.0:
dependencies:
@@ -45420,7 +45306,7 @@ snapshots:
jest-config@26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3)):
dependencies:
'@babel/core': 7.25.7
- '@jest/test-sequencer': 26.6.3(ts-node@10.9.2(@swc/core@1.15.24)(@types/node@24.12.2)(typescript@5.7.3))
+ '@jest/test-sequencer': 26.6.3
'@jest/types': 26.6.2
babel-jest: 26.6.3(@babel/core@7.25.7)
chalk: 4.1.2
@@ -48964,7 +48850,7 @@ snapshots:
postcss: 8.4.49
schema-utils: 3.3.0
semver: 7.7.4
- webpack: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
+ webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.18.20)(webpack-cli@5.1.4)
postcss-loader@4.3.0(postcss@8.5.9)(webpack@5.97.1(@swc/core@1.15.24)(esbuild@0.24.2)):
dependencies:
@@ -48976,7 +48862,7 @@ snapshots:
semver: 7.7.4
webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.24.2)
- postcss-loader@4.3.0(postcss@8.5.9)(webpack@5.97.1(@swc/core@1.15.24)):
+ postcss-loader@4.3.0(postcss@8.5.9)(webpack@5.97.1):
dependencies:
cosmiconfig: 7.1.0
klona: 2.0.6
@@ -50928,6 +50814,17 @@ snapshots:
optionalDependencies:
sass: 1.69.5
+ sass-loader@10.5.2(sass@1.69.5)(webpack@5.97.1):
+ dependencies:
+ klona: 2.0.6
+ loader-utils: 2.0.4
+ neo-async: 2.6.2
+ schema-utils: 3.3.0
+ semver: 7.7.4
+ webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.18.20)(webpack-cli@5.1.4)
+ optionalDependencies:
+ sass: 1.69.5
+
sass-loader@12.6.0(sass@1.69.5)(webpack@5.97.1):
dependencies:
klona: 2.0.6
@@ -53505,11 +53402,11 @@ snapshots:
import-local: 3.2.0
interpret: 3.1.1
rechoir: 0.8.0
- webpack: 5.97.1(@swc/core@1.15.24)(webpack-cli@5.1.4)
+ webpack: 5.97.1(@swc/core@1.15.24)(esbuild@0.18.20)(webpack-cli@5.1.4)
webpack-merge: 5.10.0
optionalDependencies:
webpack-bundle-analyzer: 4.9.1
- webpack-dev-server: 4.15.2(debug@4.4.3)(webpack-cli@5.1.4)(webpack@5.97.1)
+ webpack-dev-server: 4.15.2(webpack-cli@5.1.4)(webpack@5.97.1)
webpack-cli@5.1.4(webpack-dev-server@4.15.2)(webpack@5.97.1):
dependencies: