diff --git a/.eslintrc.js b/.eslintrc.js index cf90aac8ca850e..646fcbbeab91c0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,9 +25,6 @@ module.exports = { env: { 'jest/globals': true, }, - globals: { - wpApiSettings: true, - }, plugins: [ 'jest', ], diff --git a/components/code-editor/index.js b/components/code-editor/index.js index 083229dc600759..889f24d24783b3 100644 --- a/components/code-editor/index.js +++ b/components/code-editor/index.js @@ -11,6 +11,20 @@ import CodeEditor from './editor'; import Placeholder from '../../packages/components/src/placeholder'; import Spinner from '../../packages/components/src/spinner'; +/** + * @var {string?} siteURL WordPRess Site URL + */ +let siteURL; + +/** + * Configure the site's URL to lazy load scripts and styles. + * + * @param {string} url Site url. + */ +export function unstable__setSiteURL( url ) { // eslint-disable-line camelcase + siteURL = url; +} + function loadScript() { return new Promise( ( resolve, reject ) => { const handles = [ 'wp-codemirror', 'code-editor', 'htmlhint', 'csslint', 'jshint' ]; @@ -21,7 +35,7 @@ function loadScript() { } const script = document.createElement( 'script' ); - script.src = `${ wpApiSettings.schema.url }/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`; + script.src = `${ siteURL }/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`; script.onload = resolve; script.onerror = reject; @@ -35,7 +49,7 @@ function loadStyle() { const style = document.createElement( 'link' ); style.rel = 'stylesheet'; - style.href = `${ wpApiSettings.schema.url }/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`; + style.href = `${ siteURL }/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`; style.onload = resolve; style.onerror = reject; diff --git a/components/index.js b/components/index.js index 23381ba91b09d5..8e723cfc5bfd5f 100644 --- a/components/index.js +++ b/components/index.js @@ -1,5 +1,5 @@ // Components -export { default as CodeEditor } from './code-editor'; +export { default as CodeEditor, unstable__setSiteURL } from './code-editor'; // eslint-disable-line camelcase export * from '../packages/components/src'; import '../packages/components/src/style.scss'; diff --git a/docs/data/data-core.md b/docs/data/data-core.md index 39f89c0c2c6caa..be3d99f4a1a6f9 100644 --- a/docs/data/data-core.md +++ b/docs/data/data-core.md @@ -2,54 +2,6 @@ ## Selectors -### getTerms - -Returns all the available terms for the given taxonomy. - -*Parameters* - - * state: Data state. - * taxonomy: Taxonomy name. - -### getCategories - -Returns all the available categories. - -*Parameters* - - * state: Data state. - -*Returns* - -Categories list. - -### isRequestingTerms - -Returns true if a request is in progress for terms data of a given taxonomy, -or false otherwise. - -*Parameters* - - * state: Data state. - * taxonomy: Taxonomy name. - -*Returns* - -Whether a request is in progress for taxonomy's terms. - -### isRequestingCategories - -Returns true if a request is in progress for categories data, or false -otherwise. - -*Parameters* - - * state: Data state. - -*Returns* - -Whether a request is in progress for categories. - ### isRequestingEmbedPreview Returns true if a request is in progress for embed preview data, or false @@ -60,10 +12,6 @@ otherwise. * state: Data state. * url: URL the preview would be for. -*Returns* - -Whether a request is in progress for an embed preview. - ### getAuthors Returns all available authors. @@ -177,16 +125,6 @@ Is the preview for the URL an oEmbed link fallback. ## Actions -### receiveTerms - -Returns an action object used in signalling that terms have been received -for a given taxonomy. - -*Parameters* - - * taxonomy: Taxonomy name. - * terms: Terms received. - ### receiveUserQuery Returns an action object used in signalling that authors have been received. diff --git a/docs/reference/deprecated.md b/docs/reference/deprecated.md index 4c154b55212028..79777dfd454818 100644 --- a/docs/reference/deprecated.md +++ b/docs/reference/deprecated.md @@ -18,10 +18,12 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo - `wp.components.withAPIData` has been removed. Please use the Core Data module or `wp.apiFetch` directly instead. - `wp.data.dispatch("core").receiveTerms` has been deprecated. Please use `wp.data.dispatch("core").receiveEntityRecords` instead. - - `getCategories` resolvers has been deprecated. Please use `getEntityRecords` resolver instead. + - `getCategories` resolver has been deprecated. Please use `getEntityRecords` resolver instead. - `wp.data.select("core").getTerms` has been deprecated. Please use `wp.data.select("core").getEntityRecords` instead. - `wp.data.select("core").getCategories` has been deprecated. Please use `wp.data.select("core").getEntityRecords` instead. - - `wp.data.select("core").isRequestingTerms` has been deprecated. Please use `wp.data.select("core").getEntitiesByKind` instead. + - `wp.data.select("core").isRequestingCategories` has been deprecated. Please use `wp.data.select("core/data").isResolving` instead. + - `wp.data.select("core").isRequestingTerms` has been deprecated. Please use `wp.data.select("core").isResolving` instead. + - `wp.data.restrictPersistence`, `wp.data.setPersistenceStorage` and `wp.data.setupPersistence` has been removed. Please use the data persistence plugin instead. ## 3.6.0 diff --git a/eslint/config.js b/eslint/config.js index 24b8c5ff0bbd23..5ba1ba4f43e843 100644 --- a/eslint/config.js +++ b/eslint/config.js @@ -18,7 +18,6 @@ module.exports = { }, }, globals: { - wp: true, window: true, document: true, }, diff --git a/lib/client-assets.php b/lib/client-assets.php index dbb8db25bc423f..8df08a980bd250 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -237,7 +237,6 @@ function gutenberg_register_scripts_and_styles() { 'wp-data', gutenberg_url( 'build/data/index.js' ), array( - 'wp-deprecated', 'wp-element', 'wp-compose', 'wp-is-shallow-equal', @@ -252,15 +251,9 @@ function gutenberg_register_scripts_and_styles() { implode( "\n", array( - // TODO: Transferring old storage should be removed at v3.7. '( function() {', ' var userId = window.userSettings.uid;', - ' var oldStorageKey = "WP_EDIT_POST_DATA_" + userId;', ' var storageKey = "WP_DATA_USER_" + userId;', - ' if ( localStorage[ oldStorageKey ] ) {', - ' localStorage[ storageKey ] = localStorage[ oldStorageKey ];', - ' delete localStorage[ oldStorageKey ];', - ' }', ' wp.data', ' .use( wp.data.plugins.persistence, { storageKey: storageKey } )', ' .use( wp.data.plugins.controls );', @@ -368,7 +361,6 @@ function gutenberg_register_scripts_and_styles() { 'lodash', 'moment', 'wp-a11y', - 'wp-api', 'wp-api-fetch', 'wp-compose', 'wp-deprecated', @@ -384,6 +376,10 @@ function gutenberg_register_scripts_and_styles() { filemtime( gutenberg_dir_path() . 'build/components/index.js' ), true ); + wp_add_inline_script( + 'wp-components', + sprintf( 'wp.components.unstable__setSiteURL(%s);', json_encode( site_url() ) ) + ); wp_register_script( 'wp-blocks', gutenberg_url( 'build/blocks/index.js' ), @@ -612,7 +608,6 @@ function gutenberg_register_scripts_and_styles() { 'media-models', 'media-views', 'wp-a11y', - 'wp-api', 'wp-api-fetch', 'wp-components', 'wp-compose', @@ -965,47 +960,6 @@ function gutenberg_register_vendor_script( $handle, $src, $deps = array() ) { ); } -/** - * Provide the components script with the required config to make withAPIData work. - */ -function gutenberg_prepare_wp_components_script() { - $schema_response = rest_do_request( new WP_REST_Request( 'GET', '/' ) ); - if ( ! $schema_response->is_error() ) { - wp_add_inline_script( - 'wp-components', - sprintf( - 'wpApiSettings.cacheSchema = true; wpApiSettings.schema = %s;', - wp_json_encode( $schema_response->get_data() ) - ), - 'before' - ); - } - - // Post Types Mapping. - $post_type_rest_base_mapping = array(); - foreach ( get_post_types( array(), 'objects' ) as $post_type_object ) { - $rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; - $post_type_rest_base_mapping[ $post_type_object->name ] = $rest_base; - } - - // Taxonomies Mapping. - $taxonomy_rest_base_mapping = array(); - foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy_object ) { - $rest_base = ! empty( $taxonomy_object->rest_base ) ? $taxonomy_object->rest_base : $taxonomy_object->name; - $taxonomy_rest_base_mapping[ $taxonomy_object->name ] = $rest_base; - } - - wp_add_inline_script( - 'wp-components', - sprintf( - 'wp.components.unstable__setApiSettings( wpApiSettings.schema, %s, %s )', - wp_json_encode( $post_type_rest_base_mapping ), - wp_json_encode( $taxonomy_rest_base_mapping ) - ), - 'after' - ); -} - /** * Prepares server-registered blocks for JavaScript, returning an associative * array of registered block data keyed by block name. Data includes properties @@ -1218,8 +1172,6 @@ function get_block_categories( $post ) { function gutenberg_editor_scripts_and_styles( $hook ) { $is_demo = isset( $_GET['gutenberg-demo'] ); - gutenberg_prepare_wp_components_script(); - global $wp_scripts; // Add "wp-hooks" as dependency of "heartbeat". @@ -1446,10 +1398,8 @@ function gutenberg_editor_scripts_and_styles( $hook ) { ( function() { var editorSettings = %s; window._wpLoadGutenbergEditor = new Promise( function( resolve ) { - wp.api.init().then( function() { - wp.domReady( function() { - resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) ); - } ); + wp.domReady( function() { + resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) ); } ); } ); } )(); diff --git a/package-lock.json b/package-lock.json index 58b391907c13f7..7f6a6256b739e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -704,14 +704,6 @@ "semver": "^5.3.0" } }, - "@babel/runtime": { - "version": "7.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0-rc.1.tgz", - "integrity": "sha512-Nifv2kwP/nwR39cAOasNxzjYfpeuf/ZbZNtQz5eYxWTC9yHARU9wItFnAwz1GTZ62MU+AtSjzZPMbLK5Q9hmbg==", - "requires": { - "regenerator-runtime": "^0.12.0" - } - }, "@babel/runtime-corejs2": { "version": "7.0.0-beta.56", "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.0.0-beta.56.tgz", @@ -2010,7 +2002,7 @@ "@wordpress/block-library": { "version": "file:packages/block-library", "requires": { - "@babel/runtime": "^7.0.0-beta.52", + "@babel/runtime-corejs2": "7.0.0-beta.56", "@wordpress/autop": "file:packages/autop", "@wordpress/blob": "file:packages/blob", "@wordpress/blocks": "file:packages/blocks", @@ -2403,7 +2395,6 @@ "requires": { "@babel/runtime-corejs2": "7.0.0-beta.56", "@wordpress/compose": "file:packages/compose", - "@wordpress/deprecated": "file:packages/deprecated", "@wordpress/element": "file:packages/element", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/redux-routine": "file:packages/redux-routine", @@ -14416,7 +14407,7 @@ "npm-package-json-lint": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/npm-package-json-lint/-/npm-package-json-lint-3.3.1.tgz", - "integrity": "sha512-Npd7o3qMkNWcBr/2sjNWJPY7N8911+EIdlqwLpfMOMUNGNo230eJTWA0zVc/PzIlviyO4d5o545cc4hLpIn7jg==", + "integrity": "sha512-Wz5byxFKbitRcQS66wCTqrje/uCLJPH+jsEvIV4H2G//E4iB/X0utVPLZzbs4hukoeKuLFadHbMcILa6Cr027w==", "dev": true, "requires": { "ajv": "^6.5.2", @@ -14434,15 +14425,15 @@ }, "dependencies": { "ajv": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.2.tgz", - "integrity": "sha512-hOs7GfvI6tUI1LfZddH82ky6mOMyTuY0mk7kE2pWpmhhUSkumzaTO5vbVwij39MdwPQWCV4Zv57Eo06NtL/GVA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.3.tgz", + "integrity": "sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.1" + "uri-js": "^4.2.2" } }, "fast-deep-equal": { diff --git a/packages/a11y/CHANGELOG.md b/packages/a11y/CHANGELOG.md index 100e805e5f1497..dfe5f27ed0c06d 100644 --- a/packages/a11y/CHANGELOG.md +++ b/packages/a11y/CHANGELOG.md @@ -1,4 +1,9 @@ ## 1.1.0 (2018-07-12) +### New feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Polish + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) diff --git a/packages/autop/CHANGELOG.md b/packages/autop/CHANGELOG.md index 3cf21249467436..2b0da1ca2c4312 100644 --- a/packages/autop/CHANGELOG.md +++ b/packages/autop/CHANGELOG.md @@ -1,8 +1,15 @@ ## 1.1.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.6 (2018-05-08) +### Polish + - Documentation: Fix API method typo for `removep`. ([#120](https://github.com/WordPress/packages/pull/120)) diff --git a/packages/babel-plugin-makepot/CHANGELOG.md b/packages/babel-plugin-makepot/CHANGELOG.md index bad78d826daaaf..3b5e4499a6a385 100644 --- a/packages/babel-plugin-makepot/CHANGELOG.md +++ b/packages/babel-plugin-makepot/CHANGELOG.md @@ -1,8 +1,15 @@ ## 2.0.0 (2018-07-12) -- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) +### Breaking Change + +- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.1 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/babel-preset-default/CHANGELOG.md b/packages/babel-preset-default/CHANGELOG.md index c3b8a6ebdebe40..f4d2090997bf85 100644 --- a/packages/babel-preset-default/CHANGELOG.md +++ b/packages/babel-preset-default/CHANGELOG.md @@ -1,12 +1,21 @@ ## 2.0.0 (2018-07-12) -- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) +### Breaking Change + +- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.3.0 (2018-05-22) +### New Feature + - Added support for async generator functions ([#126](https://github.com/WordPress/packages/pull/126)) ## 1.2.1 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/block-library/src/categories/edit.js b/packages/block-library/src/categories/edit.js index d0c0f1b00e1048..49097d18b888d8 100644 --- a/packages/block-library/src/categories/edit.js +++ b/packages/block-library/src/categories/edit.js @@ -203,10 +203,12 @@ class CategoriesEdit extends Component { } export default withSelect( ( select ) => { - const { getCategories, isRequestingCategories } = select( 'core' ); + const { getEntityRecords } = select( 'core' ); + const { isResolving } = select( 'core/data' ); + const query = { per_page: -1 }; return { - categories: getCategories(), - isRequesting: isRequestingCategories(), + categories: getEntityRecords( 'taxonomy', 'category', query ), + isRequesting: isResolving( 'core', 'getEntityRecords', [ 'taxonomy', 'category', query ] ), }; } )( CategoriesEdit ); diff --git a/packages/blocks/CHANGELOG.md b/packages/blocks/CHANGELOG.md index 040e4309e04d3c..5184c8e339e7f3 100644 --- a/packages/blocks/CHANGELOG.md +++ b/packages/blocks/CHANGELOG.md @@ -1,3 +1,5 @@ ## v3.0.0 (Unreleased) -- Breaking: The `isSharedBlock` function is removed. Use `isReusableBlock` instead. +### Breaking Change + +- The `isSharedBlock` function is removed. Use `isReusableBlock` instead. diff --git a/packages/browserslist-config/CHANGELOG.md b/packages/browserslist-config/CHANGELOG.md index f8f8ed2277ce62..f0805564bdcd22 100644 --- a/packages/browserslist-config/CHANGELOG.md +++ b/packages/browserslist-config/CHANGELOG.md @@ -1,41 +1,61 @@ ## 2.2.0 (2018-07-12) +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 2.1.4 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) ## 2.1.3 (2018-05-18) +### Polish + - Docs update of the Browserslist example repo URL ([#98](https://github.com/WordPress/packages/pull/98)) ## 2.1.2 (2018-02-28) +### Polish + - Removed `package-lock.json` file, lockfiles for apps, not packages ([#88](https://github.com/WordPress/packages/pull/88)) ## 2.1.1 (2018-02-21) +### Polish + - Added "Code is Poetry" footer to README.md ([#82](https://github.com/WordPress/packages/pull/82)) ## 2.1.0 (2018-02-15) +### New Feature + - Updated Browserslist to v3.1.0 ([#81](https://github.com/WordPress/packages/pull/81)) ## 2.0.0 +### Breaking Change + - Transfer to @wordpress npm organization. - Published as @wordpress/browserslist-config. ## 1.1.0 +### New Feature + - Add browserslist tests. - Refactor per coding standards. ## 1.0.1 +### Polish + - Update installation documentation. ## 1.0.0 +### New Feature + - Initial release. diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md new file mode 100644 index 00000000000000..d5b6a36fd74a09 --- /dev/null +++ b/packages/components/CHANGELOG.md @@ -0,0 +1,5 @@ +## v3.0.0 (Unreleased) + +### Breaking Change + +- `withAPIData` has been removed. Please use the Core Data module or `@wordpress/api-fetch` directly instead. \ No newline at end of file diff --git a/packages/components/src/higher-order/with-api-data/README.md b/packages/components/src/higher-order/with-api-data/README.md deleted file mode 100644 index 98c5761fc2cf56..00000000000000 --- a/packages/components/src/higher-order/with-api-data/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# withAPIData - -`withAPIData` is a React [higher-order component](https://facebook.github.io/react/docs/higher-order-components.html) for orchestrating REST API data fetching. Simply compose your component using `withAPIData` and a description of your component's data needs, and the requisite network requests will be performed automatically on your behalf. - -Out of the box, it includes: - -- Auto-fetching when your component mounts -- Reusing cached data if request has already been made -- Provides status updates so you can render accordingly -- Trigger creation, updates, or deletes on data - -## Example: - -Consider a post component which displays a placeholder message while it loads, and the post's title once it becomes available: - -```jsx -import { withAPIData } from '@wordpress/components'; -import PropTypes from 'prop-types'; - -class Context extends React.Component { - getChildContext() { - return { - getAPISchema: () => ( { - routes: { - 'http://demo.wp-api.org/wp-json/wp/v2/posts/(?P[\\d]+)': { - methods: [ 'GET' ], - }, - }, - } ) , - getAPIPostTypeRestBaseMapping: () => {}, - getAPITaxonomyRestBaseMapping: () => {}, - }; - } - - render() { - return this.props.children; - } -} - -Context.childContextTypes = { - getAPISchema: PropTypes.func, - getAPIPostTypeRestBaseMapping: PropTypes.func, - getAPITaxonomyRestBaseMapping: PropTypes.func, -}; - -const MyPost = withAPIData( ( props, { type } ) => ( { - post: `http://demo.wp-api.org/wp-json/wp/v2/posts/${ props.postId }` -} ) )( - ( { post } ) => { - if ( post.isLoading || 'undefined' === typeof post.data ) { - return
Loading...
; - } - - return
{ post.data.title.rendered }
; - } -); - -const MyComponentWithAPIData = () => ( - - - -); -``` - -## Usage - -`withAPIData` expects a function argument describing a mapping between prop keys and the REST API endpoint path. In the data mapping function, you have access to the component's incoming props, plus a few REST API helper utilities. It returns a function which can then be used in composing your component. - -The REST API helpers currently include tools to retrieve the `rest_base` of a post type or taxonomy: - -- `type( postType: String ): String` -- `taxonomy( taxonomy: String ): String` - -Data-bound props take the shape of an object with a number of properties, depending on the methods supported for the particular endpoint: - -- `GET` - - `isLoading`: Whether the resource is currently being fetched - - `data`: The resource, available once fetch succeeds - - `get`: Function to invoke a new fetch request - - `error`: The error object, if the fetch failed -- `POST` - - `isCreating`: Whether the resource is currently being created - - `createdData`: The created resource, available once create succeeds - - `create`: Function to invoke a new create request - - `createError`: The error object, if the create failed -- `PUT` - - `isSaving`: Whether the resource is currently being saved - - `savedData`: The saved resource, available once save succeeds - - `save`: Function to invoke a new save request - - `saveError`: The error object, if the save failed -- `PATCH` - - `isPatching`: Whether the resource is currently being patched - - `patchedData`: The patched resource, available once patch succeeds - - `patch`: Function to invoke a new patch request - - `patchError`: The error object, if the patch failed -- `DELETE` - - `isDeleting`: Whether the resource is currently being deleted - - `deletedData`: The deleted resource, available once delete succeeds - - `delete`: Function to invoke a new delete request - - `deleteError`: The error object, if the delete failed diff --git a/packages/components/src/higher-order/with-api-data/index.js b/packages/components/src/higher-order/with-api-data/index.js deleted file mode 100644 index c57ffc6786417a..00000000000000 --- a/packages/components/src/higher-order/with-api-data/index.js +++ /dev/null @@ -1,232 +0,0 @@ -/** - * External dependencies - */ -import { mapValues, reduce, forEach, noop } from 'lodash'; - -/** - * WordPress dependencies - */ -import { Component } from '@wordpress/element'; -import { createHigherOrderComponent } from '@wordpress/compose'; -import isShallowEqual from '@wordpress/is-shallow-equal'; -import deprecated from '@wordpress/deprecated'; - -/** - * Internal dependencies - */ -import request, { getCachedResponse } from './request'; -import { getRoute } from './routes'; - -export default ( mapPropsToData ) => createHigherOrderComponent( ( WrappedComponent ) => { - deprecated( 'wp.components.withAPIData', { - version: 3.7, - plugin: 'Gutenberg', - alternative: 'the Core Data Module or wp.apiFetch directly', - } ); - - class APIDataComponent extends Component { - constructor( props, context ) { - super( ...arguments ); - this.schema = context.getAPISchema(); - this.routeHelpers = mapValues( { - type: context.getAPIPostTypeRestBaseMapping(), - taxonomy: context.getAPITaxonomyRestBaseMapping(), - }, ( mapping ) => ( key ) => mapping[ key ] ); - this.state = { - dataProps: this.applyMapping( props ), - }; - this.isStillMounted = true; - } - - componentDidMount() { - this.initializeFetchable( {} ); - } - - componentDidUpdate( prevProps, prevState ) { - if ( ! isShallowEqual( prevProps, this.props ) ) { - const dataProps = this.applyMapping( this.props, this.state.dataProps ); - this.setState( { dataProps } ); - } - this.initializeFetchable( prevState.dataProps ); - } - - componentWillUnmount() { - this.isStillMounted = false; - } - - initializeFetchable( prevDataProps ) { - const { dataProps } = this.state; - - // Trigger first fetch on initial entries into state. Assumes GET - // request by presence of isLoading flag. - forEach( dataProps, ( dataProp, propName ) => { - if ( - prevDataProps.hasOwnProperty( propName ) && - prevDataProps[ propName ].path === dataProp.path - ) { - return; - } - - // Skip request is already assigned via cache - if ( dataProp[ this.getResponseDataKey( 'GET' ) ] ) { - return; - } - - if ( this.getPendingKey( 'GET' ) in dataProp ) { - dataProp[ this.getRequestKey( 'GET' ) ](); - } - } ); - } - - setIntoDataProp( propName, values ) { - if ( ! this.isStillMounted ) { - return; - } - - this.setState( ( prevState ) => { - const { dataProps } = prevState; - return { - dataProps: { - ...dataProps, - [ propName ]: { - ...dataProps[ propName ], - ...values, - }, - }, - }; - } ); - } - - getRequestKey( method ) { - switch ( method ) { - case 'GET': return 'get'; - case 'POST': return 'create'; - case 'PUT': return 'save'; - case 'PATCH': return 'patch'; - case 'DELETE': return 'delete'; - } - } - - getPendingKey( method ) { - switch ( method ) { - case 'GET': return 'isLoading'; - case 'POST': return 'isCreating'; - case 'PUT': return 'isSaving'; - case 'PATCH': return 'isPatching'; - case 'DELETE': return 'isDeleting'; - } - } - - getResponseDataKey( method ) { - switch ( method ) { - case 'GET': return 'data'; - case 'POST': return 'createdData'; - case 'PUT': return 'savedData'; - case 'PATCH': return 'patchedData'; - case 'DELETE': return 'deletedData'; - } - } - - getErrorResponseKey( method ) { - switch ( method ) { - case 'GET': return 'error'; - case 'POST': return 'createError'; - case 'PUT': return 'saveError'; - case 'PATCH': return 'patchError'; - case 'DELETE': return 'deleteError'; - } - } - - request( propName, method, path ) { - this.setIntoDataProp( propName, { - [ this.getPendingKey( method ) ]: true, - } ); - - request( { path, method } ) - // [Success] Set the data prop: - .then( ( response ) => ( { - [ this.getResponseDataKey( method ) ]: response.body, - } ) ) - - // [Failure] Set the error prop: - .catch( ( error ) => ( { - [ this.getErrorResponseKey( method ) ]: error, - } ) ) - - // Always reset loading prop: - .then( ( nextDataProp ) => { - this.setIntoDataProp( propName, { - [ this.getPendingKey( method ) ]: false, - ...nextDataProp, - } ); - } ); - } - - applyMapping( props, previousDataProps = {} ) { - const mapping = mapPropsToData( props, this.routeHelpers ); - const nextDataProps = reduce( mapping, ( result, path, propName ) => { - // Skip if mapping already assigned into state data props - // Example: Component updates with one new prop and other - // previously existing; previously existing should not be - // clobbered or re-trigger fetch - const dataProp = previousDataProps[ propName ]; - if ( dataProp && dataProp.path === path ) { - result[ propName ] = dataProp; - return result; - } - - result[ propName ] = {}; - - const route = getRoute( this.schema, path ); - if ( ! route ) { - return result; - } - - route.methods.forEach( ( method ) => { - // Add request initiator into data props - const requestKey = this.getRequestKey( method ); - result[ propName ][ requestKey ] = this.request.bind( - this, - propName, - method, - path - ); - - // Initialize pending flags as explicitly false - const pendingKey = this.getPendingKey( method ); - result[ propName ][ pendingKey ] = false; - - // If cached data already exists, populate in result - const cachedResponse = getCachedResponse( { path, method } ); - if ( cachedResponse ) { - const dataKey = this.getResponseDataKey( method ); - result[ propName ][ dataKey ] = cachedResponse.body; - } - - // Track path for future map skipping - result[ propName ].path = path; - } ); - - return result; - }, {} ); - - return nextDataProps; - } - - render() { - return ( - - ); - } - } - - APIDataComponent.contextTypes = { - getAPISchema: noop, - getAPIPostTypeRestBaseMapping: noop, - getAPITaxonomyRestBaseMapping: noop, - }; - - return APIDataComponent; -}, 'withAPIData' ); diff --git a/packages/components/src/higher-order/with-api-data/provider.js b/packages/components/src/higher-order/with-api-data/provider.js deleted file mode 100644 index 1f348358abf686..00000000000000 --- a/packages/components/src/higher-order/with-api-data/provider.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * External dependencies - */ -import { mapValues, noop } from 'lodash'; - -/** - * WordPress dependencies - */ -import { Component } from '@wordpress/element'; - -/** - * Module constants - */ -let apiSettings = {}; - -/** - * Do not use this API, it's only here while we deprecated withAPIData. - * - * @param {Object} schema - * @param {Object} postTypeRestBaseMapping - * @param {Object} taxonomyRestBaseMapping - */ -// eslint-disable-next-line camelcase -export const unstable__setApiSettings = ( schema, postTypeRestBaseMapping, taxonomyRestBaseMapping ) => { - apiSettings = { - schema, - postTypeRestBaseMapping, - taxonomyRestBaseMapping, - }; -}; - -export default class APIProvider extends Component { - getChildContext() { - return mapValues( { - getAPISchema: 'schema', - getAPIPostTypeRestBaseMapping: 'postTypeRestBaseMapping', - getAPITaxonomyRestBaseMapping: 'taxonomyRestBaseMapping', - }, ( key ) => () => apiSettings[ key ] ); - } - - render() { - return this.props.children; - } -} - -APIProvider.childContextTypes = { - getAPISchema: noop, - getAPIPostTypeRestBaseMapping: noop, - getAPITaxonomyRestBaseMapping: noop, -}; diff --git a/packages/components/src/higher-order/with-api-data/request.js b/packages/components/src/higher-order/with-api-data/request.js deleted file mode 100644 index e4aad4320eba2a..00000000000000 --- a/packages/components/src/higher-order/with-api-data/request.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * External dependencies - */ -import memoize from 'memize'; -import { mapKeys } from 'lodash'; - -/** - * WordPress dependencies - */ -import apiFetch from '@wordpress/api-fetch'; - -export const getStablePath = memoize( ( path ) => { - const [ base, query ] = path.split( '?' ); - if ( ! query ) { - return base; - } - - // 'b=1&c=2&a=5' - return base + '?' + query - - // [ 'b=1', 'c=2', 'a=5' ] - .split( '&' ) - - // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ] - .map( ( entry ) => entry.split( '=' ) ) - - // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ] - .sort( ( a, b ) => a[ 0 ].localeCompare( b[ 0 ] ) ) - - // [ 'a=5', 'b=1', 'c=2' ] - .map( ( pair ) => pair.join( '=' ) ) - - // 'a=5&b=1&c=2' - .join( '&' ); -} ); - -/** - * Response cache of path to response (object of data, headers arrays). - * Optionally populated from window global for preloading. - * - * @type {Object} - */ -export const cache = mapKeys( - window._wpAPIDataPreload, - ( value, key ) => getStablePath( key ) -); - -/** - * Returns a response payload if GET request and a cached result exists, or - * undefined otherwise. - * - * @param {Object} request Request object (path, method). - * - * @return {?Object} Response object (body, headers). - */ -export function getCachedResponse( request ) { - if ( isRequestMethod( request, 'GET' ) ) { - return cache[ getStablePath( request.path ) ]; - } -} - -export function getResponseFromNetwork( request ) { - const promise = apiFetch( { ...request, parse: false } ) - .then( ( response ) => { - return response.json().then( ( body ) => ( { - body: body, - headers: response.headers, - } ) ); - } ); - - if ( isRequestMethod( request, 'GET' ) ) { - promise.then( ( response ) => { - cache[ getStablePath( request.path ) ] = response; - } ); - } - - // Upgrade jQuery.Deferred to native promise - return Promise.resolve( promise ); -} - -export function isRequestMethod( request, method ) { - return request.method === method; -} - -export default function( request ) { - const cachedResponse = getCachedResponse( request ); - if ( cachedResponse ) { - return Promise.resolve( cachedResponse ); - } - - return getResponseFromNetwork( request ); -} diff --git a/packages/components/src/higher-order/with-api-data/routes.js b/packages/components/src/higher-order/with-api-data/routes.js deleted file mode 100644 index 72c13d5f5ab92e..00000000000000 --- a/packages/components/src/higher-order/with-api-data/routes.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * External dependencies - */ -import { find } from 'lodash'; -import createSelector from 'rememo'; - -/** - * Match PCRE named subpatterns in a string. This implementation is not strict - * on balanced delimiters, but assumes this would be a broken pattern anyways. - * - * See: http://www.pcre.org/original/doc/html/pcrepattern.html#SEC16 - * See: http://php.net/manual/en/function.preg-match.php - * - * @type {RegExp} - */ -const RE_NAMED_SUBPATTERN = /\(\?P?[<']\w+[>'](.*?)\)/g; - -/** - * Coerces a REST route pattern to an equivalent JavaScript regular expression, - * replacing named subpatterns (unsupported in JavaScript), allowing trailing - * slash, allowing query parameters, but otherwise enforcing strict equality. - * - * @param {string} pattern PCRE regular expression string. - * - * @return {RegExp} Equivalent JavaScript RegExp. - */ -export function getNormalizedRegExp( pattern ) { - pattern = pattern.replace( RE_NAMED_SUBPATTERN, '($1)' ); - pattern = '^' + pattern + '/?(\\?.*)?$'; - return new RegExp( pattern ); -} - -/** - * Returns true if the route path pattern string matches the given path. - * - * @param {string} pattern PCRE route path pattern. - * @param {string} path URL path. - * - * @return {boolean} Whether path is a match. - */ -export function isRouteMatch( pattern, path ) { - return getNormalizedRegExp( pattern ).test( path ); -} - -/** - * Returns a REST route object for a given path, if one exists. - * - * @param {Object} schema REST schema. - * @param {string} path URL path. - * - * @returns {?Object} REST route. - */ -export const getRoute = createSelector( ( schema, path ) => { - return find( schema.routes, ( route, pattern ) => { - return isRouteMatch( pattern, path ); - } ); -} ); diff --git a/packages/components/src/higher-order/with-api-data/test/index.js b/packages/components/src/higher-order/with-api-data/test/index.js deleted file mode 100644 index fdfbb85f7da336..00000000000000 --- a/packages/components/src/higher-order/with-api-data/test/index.js +++ /dev/null @@ -1,253 +0,0 @@ -/** - * External dependencies - */ -import renderer from 'react-test-renderer'; -import { identity, fromPairs } from 'lodash'; -import PropTypes from 'prop-types'; - -/** - * Internal dependencies - */ -import withAPIData from '../'; - -/** - * WordPress dependencies - */ -import { Component } from '@wordpress/element'; - -class PassContext extends Component { - getChildContext() { - return this.props.value; - } - - render() { - return this.props.children; - } -} - -PassContext.childContextTypes = { - getAPISchema: PropTypes.any, - getAPIPostTypeRestBaseMapping: PropTypes.any, - getAPITaxonomyRestBaseMapping: PropTypes.any, -}; - -jest.mock( '../request', () => { - const request = jest.fn( ( { path } ) => { - if ( /\/users$/.test( path ) ) { - return Promise.reject( { - code: 'rest_forbidden_context', - message: 'Sorry, you are not allowed to list users.', - data: { status: 403 }, - } ); - } - - return Promise.resolve( { body: {} } ); - } ); - - request.getCachedResponse = ( { method, path } ) => { - return method === 'GET' && '/wp/v2/pages/10' === path ? - { body: { title: 'OK!' }, headers: [] } : - undefined; - }; - - return request; -} ); - -describe( 'withAPIData()', () => { - const schema = { - routes: { - '/wp/v2/pages/(?P[\\d]+)/revisions': { - methods: [ 'GET' ], - }, - '/wp/v2/users': { - methods: [ 'GET' ], - }, - '/wp/v2/pages/(?P[\\d]+)': { - methods: [ - 'GET', - 'POST', - 'PUT', - 'PATCH', - 'DELETE', - ], - }, - }, - }; - - let TestComponent, context; - - function getWrapper( mapPropsToData, props ) { - if ( ! mapPropsToData ) { - mapPropsToData = () => ( { - revisions: '/wp/v2/pages/5/revisions', - } ); - } - - TestComponent = withAPIData( mapPropsToData )( () => '' ); - context = { - getAPISchema: () => schema, - getAPIPostTypeRestBaseMapping: identity, - getAPITaxonomyRestBaseMapping: identity, - }; - return renderer.create( getTestComponent( context, props ) ); - } - - function getTestComponent( contextValues, props ) { - return ( - - - - ); - } - - const getDataProps = ( wrapper ) => { - return wrapper.toTree().rendered.instance.state.dataProps; - }; - - it( 'should initialize fetchables on mount', ( done ) => { - const wrapper = getWrapper(); - - expect( Object.keys( getDataProps( wrapper ) ) ).toEqual( [ 'revisions' ] ); - expect( Object.keys( getDataProps( wrapper ).revisions ) ).toEqual( [ - 'get', - 'isLoading', - 'path', - ] ); - expect( getDataProps( wrapper ).revisions.isLoading ).toBe( true ); - expect( console ).toHaveWarned(); - - process.nextTick( () => { - expect( getDataProps( wrapper ).revisions.isLoading ).toBe( false ); - expect( getDataProps( wrapper ).revisions.data ).toEqual( {} ); - done(); - } ); - } ); - - it( 'should handle error response', ( done ) => { - const wrapper = getWrapper( () => ( { - users: '/wp/v2/users', - } ) ); - - process.nextTick( () => { - expect( getDataProps( wrapper ).users.isLoading ).toBe( false ); - expect( getDataProps( wrapper ).users ).not.toHaveProperty( 'data' ); - expect( getDataProps( wrapper ).users.error.code ).toBe( 'rest_forbidden_context' ); - - done(); - } ); - } ); - - it( 'should preassign cached data', ( done ) => { - const wrapper = getWrapper( () => ( { - page: '/wp/v2/pages/10', - } ) ); - - expect( Object.keys( getDataProps( wrapper ) ) ).toEqual( [ 'page' ] ); - expect( Object.keys( getDataProps( wrapper ).page ) ).toEqual( expect.arrayContaining( [ - 'get', - 'isLoading', - 'path', - 'data', - ] ) ); - expect( getDataProps( wrapper ).page.isLoading ).toBe( false ); - expect( getDataProps( wrapper ).page.data ).toEqual( { title: 'OK!' } ); - - process.nextTick( () => { - expect( getDataProps( wrapper ).page.isLoading ).toBe( false ); - - done(); - } ); - } ); - - it( 'should assign an empty prop object for unmatched resources', () => { - const wrapper = getWrapper( () => ( { - unknown: '/wp/v2/unknown/route', - } ) ); - - expect( Object.keys( getDataProps( wrapper ) ) ).toEqual( [ 'unknown' ] ); - expect( Object.keys( getDataProps( wrapper ).unknown ) ).toEqual( [] ); - expect( wrapper.toTree().rendered.rendered.props.unknown ).toEqual( {} ); - } ); - - it( 'should include full gamut of method available properties', () => { - const wrapper = getWrapper( () => ( { - page: '/wp/v2/pages/5', - } ) ); - - expect( Object.keys( getDataProps( wrapper ) ) ).toEqual( [ 'page' ] ); - expect( Object.keys( getDataProps( wrapper ).page ) ).toEqual( [ - 'get', - 'isLoading', - 'path', - 'create', - 'isCreating', - 'save', - 'isSaving', - 'patch', - 'isPatching', - 'delete', - 'isDeleting', - ] ); - expect( getDataProps( wrapper ).page.isLoading ).toBe( true ); - expect( getDataProps( wrapper ).page.isCreating ).toBe( false ); - expect( getDataProps( wrapper ).page.isSaving ).toBe( false ); - expect( getDataProps( wrapper ).page.isPatching ).toBe( false ); - expect( getDataProps( wrapper ).page.isDeleting ).toBe( false ); - } ); - - it( 'should not clobber existing data when receiving new props', ( done ) => { - const wrapper = getWrapper( - ( { pages } ) => fromPairs( pages.map( ( page ) => [ - 'page' + page, - '/wp/v2/pages/' + page, - ] ) ), - { pages: [ 1 ] } - ); - - process.nextTick( () => { - wrapper.update( getTestComponent( context, { pages: [ 1, 2 ] } ) ); - - expect( getDataProps( wrapper ).page1.isLoading ).toBe( false ); - expect( getDataProps( wrapper ).page1.data ).toEqual( {} ); - expect( getDataProps( wrapper ).page2.isLoading ).toBe( true ); - - done(); - } ); - } ); - - it( 'should remove dropped mappings', ( done ) => { - const wrapper = getWrapper( - ( { pages } ) => fromPairs( pages.map( ( page ) => [ - 'page' + page, - '/wp/v2/pages/' + page, - ] ) ), - { pages: [ 1 ] } - ); - - process.nextTick( () => { - wrapper.update( getTestComponent( context, { pages: [ 2 ] } ) ); - - expect( getDataProps( wrapper ) ).not.toHaveProperty( 'page1' ); - expect( getDataProps( wrapper ) ).toHaveProperty( 'page2' ); - - done(); - } ); - } ); - - it( 'should refetch on changed path', ( done ) => { - const wrapper = getWrapper( - ( { pageId } ) => ( { - page: `/wp/v2/pages/${ pageId }`, - } ), - { pageId: 5 } - ); - - process.nextTick( () => { - expect( getDataProps( wrapper ).page.isLoading ).toBe( false ); - wrapper.update( getTestComponent( context, { pageId: 7 } ) ); - expect( getDataProps( wrapper ).page.isLoading ).toBe( true ); - - done(); - } ); - } ); -} ); diff --git a/packages/components/src/higher-order/with-api-data/test/request.js b/packages/components/src/higher-order/with-api-data/test/request.js deleted file mode 100644 index 1a8d7e27f39072..00000000000000 --- a/packages/components/src/higher-order/with-api-data/test/request.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * WordPress dependencies - */ -import apiFetch from '@wordpress/api-fetch'; - -/** - * Internal dependencies - */ -import request, { - cache, - getStablePath, - getCachedResponse, - getResponseFromNetwork, - isRequestMethod, -} from '../request'; - -jest.mock( '@wordpress/api-fetch', () => jest.fn() ); - -describe( 'request', () => { - const actualResponse = { - json: () => Promise.resolve( {} ), - headers: { - connection: 'Keep-Alive', - 'content-type': 'text/plain; charset=utf-8', - }, - }; - - beforeEach( () => { - getStablePath.clear(); - for ( const key in cache ) { - delete cache[ key ]; - } - - apiFetch.mockImplementation( () => Promise.resolve( actualResponse ) ); - } ); - - describe( 'getCachedResponse()', () => { - it( 'returns undefined for missing cache', () => { - const cachedResponse = getCachedResponse( { - path: '/wp?b=5&c=5&a=5', - method: 'GET', - } ); - - expect( cachedResponse ).toBe( undefined ); - } ); - - it( 'returns undefined for non-GET request', () => { - cache[ getStablePath( '/wp?c=5&a=5&b=5' ) ] = actualResponse; - const cachedResponse = getCachedResponse( { - path: '/wp?b=5&c=5&a=5', - method: 'POST', - } ); - - expect( cachedResponse ).toBe( undefined ); - } ); - - it( 'returns response from cache', () => { - cache[ getStablePath( '/wp?c=5&a=5&b=5' ) ] = actualResponse; - const cachedResponse = getCachedResponse( { - path: '/wp?b=5&c=5&a=5', - method: 'GET', - } ); - - expect( cachedResponse ).toEqual( actualResponse ); - } ); - } ); - - describe( 'getResponseFromNetwork()', () => { - it( 'triggers a network request', () => { - const awaitResponse = getResponseFromNetwork( { - path: '/wp?b=5&c=5&a=5', - } ); - - return awaitResponse.then( ( data ) => { - expect( apiFetch ).toHaveBeenCalled(); - expect( data ).toEqual( { - headers: actualResponse.headers, - body: {}, - } ); - } ); - } ); - } ); - - describe( 'getStablePath()', () => { - it( 'should return a path without query arguments', () => { - const path = '/wp'; - - expect( getStablePath( path ) ).toBe( path ); - } ); - - it( 'should return a path with sorted query arguments', () => { - const a = getStablePath( '/wp?c=5&a=5&b=5' ); - const b = getStablePath( '/wp?b=5&c=5&a=5' ); - - expect( a ).toBe( b ); - } ); - } ); - - describe( 'isRequestMethod()', () => { - it( 'returns false if not method', () => { - expect( isRequestMethod( { method: 'POST' }, 'GET' ) ).toBe( false ); - } ); - - it( 'returns true if method', () => { - expect( isRequestMethod( { method: 'GET' }, 'GET' ) ).toBe( true ); - } ); - } ); - - describe( 'request()', () => { - beforeEach( () => { - apiFetch.mockClear(); - } ); - - it( 'should try from cache for GET', () => { - cache[ getStablePath( '/wp?c=5&a=5&b=5' ) ] = actualResponse; - const awaitResponse = request( { - path: '/wp?b=5&c=5&a=5', - method: 'GET', - } ); - - return awaitResponse.then( ( data ) => { - expect( apiFetch ).not.toHaveBeenCalled(); - expect( data ).toEqual( actualResponse ); - } ); - } ); - - it( 'should not try from cache for non-GET', () => { - cache[ getStablePath( '/wp?c=5&a=5&b=5' ) ] = actualResponse; - const awaitResponse = request( { - path: '/wp?b=5&c=5&a=5', - method: 'POST', - } ); - - return awaitResponse.then( ( data ) => { - expect( apiFetch ).toHaveBeenCalled(); - expect( data ).toEqual( { - headers: actualResponse.headers, - body: {}, - } ); - } ); - } ); - - it( 'should fall back to network', () => { - const awaitResponse = request( { - path: '/wp?b=5&c=5&a=5', - method: 'GET', - } ); - - return awaitResponse.then( ( data ) => { - expect( apiFetch ).toHaveBeenCalled(); - expect( data ).toEqual( { - headers: actualResponse.headers, - body: {}, - } ); - } ); - } ); - } ); -} ); diff --git a/packages/components/src/higher-order/with-api-data/test/routes.js b/packages/components/src/higher-order/with-api-data/test/routes.js deleted file mode 100644 index 994575e2035dc4..00000000000000 --- a/packages/components/src/higher-order/with-api-data/test/routes.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Internal dependencies - */ -import { - isRouteMatch, - getRoute, - getNormalizedRegExp, -} from '../routes'; - -describe( 'routes', () => { - describe( 'getNormalizedRegExp()', () => { - it( 'should strip named subpatterns', () => { - const regexp = getNormalizedRegExp( '(?P[\\d]+)' ); - - expect( '5' ).toMatch( regexp ); - } ); - - it( 'should match with trailing slashes', () => { - const regexp = getNormalizedRegExp( '/wp' ); - - expect( '/wp/' ).toMatch( regexp ); - } ); - - it( 'should match with query parameters slashes', () => { - const regexp = getNormalizedRegExp( '/wp' ); - - expect( '/wp?ok=true' ).toMatch( regexp ); - } ); - - it( 'should otherwise be strictly equal', () => { - const regexp = getNormalizedRegExp( '/wp' ); - - expect( '/wp/notok' ).not.toMatch( regexp ); - } ); - } ); - - describe( 'isRouteMatch()', () => { - it( 'should return false for non-match', () => { - const isMatch = isRouteMatch( - '/wp/v2/pages/(?P[\\d]+)/revisions', - '/wp/v2/pages/1/revisions/2' - ); - - expect( isMatch ).toBe( false ); - } ); - - it( 'should return true for match', () => { - const isMatch = isRouteMatch( - '/wp/v2/pages/(?P[\\d]+)/revisions/(?P[\\d]+)', - '/wp/v2/pages/1/revisions/2' - ); - - expect( isMatch ).toBe( true ); - } ); - } ); - - describe( 'getRoute()', () => { - const expected = { base: {}, nested: {} }; - const schema = { - routes: { - '/wp/v2/pages/(?P[\\d]+)/revisions': expected.base, - '/wp/v2/pages/(?P[\\d]+)/revisions/(?P[\\d]+)': expected.nested, - }, - }; - - beforeEach( () => { - getRoute.clear(); - } ); - - it( 'should match base route with balanced match pattern', () => { - const path = '/wp/v2/pages/1/revisions'; - const route = getRoute( schema, path ); - - expect( route ).toBe( expected.base ); - } ); - - it( 'should match nested route with balanced match pattern', () => { - const path = '/wp/v2/pages/1/revisions/2'; - const route = getRoute( schema, path ); - - expect( route ).toBe( expected.nested ); - } ); - } ); -} ); diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 9e3186358ab13b..a74aa8a20cb288 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -1,7 +1,6 @@ // Components export * from './primitives'; // eslint-disable-next-line camelcase -export { default as APIProvider, unstable__setApiSettings } from './higher-order/with-api-data/provider'; export { default as Autocomplete } from './autocomplete'; export { default as BaseControl } from './base-control'; export { default as Button } from './button'; @@ -60,7 +59,6 @@ export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot // Higher-Order Components export { default as navigateRegions } from './higher-order/navigate-regions'; -export { default as withAPIData } from './higher-order/with-api-data'; export { default as withContext } from './higher-order/with-context'; export { default as withConstrainedTabbing } from './higher-order/with-constrained-tabbing'; export { default as withFallbackStyles } from './higher-order/with-fallback-styles'; diff --git a/packages/core-data/CHANGELOG.md b/packages/core-data/CHANGELOG.md new file mode 100644 index 00000000000000..9f48f7fe3ebaae --- /dev/null +++ b/packages/core-data/CHANGELOG.md @@ -0,0 +1,10 @@ +## v2.0.0 (Unreleased) + +### Breaking Change + +- `dispatch("core").receiveTerms` has been deprecated. Please use `dispatch("core").receiveEntityRecords` instead. +- `getCategories` resolvers has been deprecated. Please use `getEntityRecords` resolver instead. +- `select("core").getTerms` has been deprecated. Please use `select("core").getEntityRecords` instead. +- `select("core").getCategories` has been deprecated. Please use `select("core").getEntityRecords` instead. +- `wp.data.select("core").isRequestingCategories` has been deprecated. Please use `wp.data.select("core/data").isResolving` instead. +- `select("core").isRequestingTerms` has been deprecated. Please use `select("core").isResolving` instead. \ No newline at end of file diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index 8ce1befbb86ba9..b3b08fb138bf63 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -2,7 +2,6 @@ * External dependencies */ import { castArray } from 'lodash'; -import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -12,28 +11,6 @@ import { receiveQueriedItems, } from './queried-data'; -/** - * Returns an action object used in signalling that terms have been received - * for a given taxonomy. - * - * @param {string} taxonomy Taxonomy name. - * @param {Object[]} terms Terms received. - * - * @return {Object} Action object. - */ -export function receiveTerms( taxonomy, terms ) { - deprecated( 'wp.data.dispatch("core").receiveTerms', { - version: '3.7.0', - alternative: 'wp.data.dispatch("core").receiveEntityRecords', - plugin: 'Gutenberg', - } ); - return { - type: 'RECEIVE_TERMS', - taxonomy, - terms, - }; -} - /** * Returns an action object used in signalling that authors have been received. * diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index e9ec41f577650f..2b7e9386a05ee8 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -8,13 +8,11 @@ import { find } from 'lodash'; */ import apiFetch from '@wordpress/api-fetch'; import { addQueryArgs } from '@wordpress/url'; -import deprecated from '@wordpress/deprecated'; /** * Internal dependencies */ import { - receiveTerms, receiveUserQuery, receiveEntityRecords, receiveThemeSupportsFromIndex, @@ -22,20 +20,6 @@ import { } from './actions'; import { getKindEntities } from './entities'; -/** - * Requests categories from the REST API, yielding action objects on request - * progress. - */ -export async function* getCategories() { - deprecated( 'getCategories resolver', { - version: '3.7.0', - alternative: 'getEntityRecords resolver', - plugin: 'Gutenberg', - } ); - const categories = await apiFetch( { path: '/wp/v2/categories?per_page=-1' } ); - yield receiveTerms( 'categories', categories ); -} - /** * Requests authors from the REST API. */ diff --git a/packages/core-data/src/selectors.js b/packages/core-data/src/selectors.js index 00af63aa6e147d..57e8a758ca3929 100644 --- a/packages/core-data/src/selectors.js +++ b/packages/core-data/src/selectors.js @@ -8,7 +8,6 @@ import { map, find, get, filter } from 'lodash'; * WordPress dependencies */ import { select } from '@wordpress/data'; -import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -29,74 +28,6 @@ function isResolving( selectorName, ...args ) { return select( 'core/data' ).isResolving( REDUCER_KEY, selectorName, args ); } -/** - * Returns all the available terms for the given taxonomy. - * - * @param {Object} state Data state. - * @param {string} taxonomy Taxonomy name. - * - * @return {Array} Categories list. - */ -export function getTerms( state, taxonomy ) { - deprecated( 'wp.data.select("core").getTerms', { - version: '3.7.0', - alternative: 'wp.data.select("core").getEntityRecords', - plugin: 'Gutenberg', - } ); - return state.terms[ taxonomy ]; -} - -/** - * Returns all the available categories. - * - * @param {Object} state Data state. - * - * @return {Array} Categories list. - */ -export function getCategories( state ) { - deprecated( 'wp.data.select("core").getCategories', { - version: '3.7.0', - alternative: 'wp.data.select("core").getEntityRecords', - plugin: 'Gutenberg', - } ); - return getTerms( state, 'categories' ); -} - -/** - * Returns true if a request is in progress for terms data of a given taxonomy, - * or false otherwise. - * - * @param {Object} state Data state. - * @param {string} taxonomy Taxonomy name. - * - * @return {boolean} Whether a request is in progress for taxonomy's terms. - */ -export function isRequestingTerms( state, taxonomy ) { - deprecated( 'wp.data.select("core").isRequestingTerms', { - version: '3.7.0', - alternative: 'wp.data.select("core").getEntitiesByKind', - plugin: 'Gutenberg', - } ); - return isResolving( 'getTerms', taxonomy ); -} - -/** - * Returns true if a request is in progress for categories data, or false - * otherwise. - * - * @param {Object} state Data state. - * - * @return {boolean} Whether a request is in progress for categories. - */ -export function isRequestingCategories() { - deprecated( 'wp.data.select("core").isRequestingCategories', { - version: '3.7.0', - alternative: 'wp.data.select("core").getEntitiesByKind', - plugin: 'Gutenberg', - } ); - return isResolving( 'getCategories' ); -} - /** * Returns true if a request is in progress for embed preview data, or false * otherwise. diff --git a/packages/core-data/src/test/resolvers.js b/packages/core-data/src/test/resolvers.js index 55eef7026b4bbc..a9733b6cad8498 100644 --- a/packages/core-data/src/test/resolvers.js +++ b/packages/core-data/src/test/resolvers.js @@ -11,30 +11,11 @@ import { addQueryArgs } from '@wordpress/url'; /** * Internal dependencies */ -import { getCategories, getEntityRecord, getEntityRecords, getEmbedPreview } from '../resolvers'; -import { receiveTerms, receiveEntityRecords, addEntities, receiveEmbedPreview } from '../actions'; +import { getEntityRecord, getEntityRecords, getEmbedPreview } from '../resolvers'; +import { receiveEntityRecords, addEntities, receiveEmbedPreview } from '../actions'; jest.mock( '@wordpress/api-fetch', () => jest.fn() ); -describe( 'getCategories', () => { - const CATEGORIES = [ { id: 1 } ]; - - beforeAll( () => { - apiFetch.mockImplementation( ( options ) => { - if ( options.path === '/wp/v2/categories?per_page=-1' ) { - return Promise.resolve( CATEGORIES ); - } - } ); - } ); - - it( 'yields with requested terms', async () => { - const fulfillment = getCategories(); - const received = ( await fulfillment.next() ).value; - expect( received ).toEqual( receiveTerms( 'categories', CATEGORIES ) ); - expect( console ).toHaveWarnedWith( 'getCategories resolver is deprecated and will be removed from Gutenberg in 3.7.0. Please use getEntityRecords resolver instead.' ); - } ); -} ); - describe( 'getEntityRecord', () => { const POST_TYPE = { slug: 'post' }; const POST_TYPES = { diff --git a/packages/core-data/src/test/selectors.js b/packages/core-data/src/test/selectors.js index 35bd9f7bdee31e..b982ada4f3a9d2 100644 --- a/packages/core-data/src/test/selectors.js +++ b/packages/core-data/src/test/selectors.js @@ -7,73 +7,11 @@ import deepFreeze from 'deep-freeze'; * Internal dependencies */ import { - getTerms, - isRequestingCategories, getEntityRecord, getEntityRecords, getEmbedPreview, isPreviewEmbedFallback, } from '../selectors'; -import { select } from '@wordpress/data'; - -jest.mock( '@wordpress/data', () => { - return { - select: jest.fn().mockReturnValue( { - isResolving: jest.fn().mockReturnValue( false ), - } ), - }; -} ); - -describe( 'getTerms()', () => { - it( 'returns value of terms by taxonomy', () => { - let state = deepFreeze( { - terms: {}, - } ); - expect( getTerms( state, 'categories' ) ).toBe( undefined ); - - state = deepFreeze( { - terms: { - categories: [ { id: 1 } ], - }, - } ); - expect( getTerms( state, 'categories' ) ).toEqual( [ { id: 1 } ] ); - expect( console ).toHaveWarnedWith( 'wp.data.select("core").getTerms is deprecated and will be removed from Gutenberg in 3.7.0. Please use wp.data.select("core").getEntityRecords instead.' ); - } ); -} ); - -describe( 'isRequestingCategories()', () => { - afterAll( () => { - select( 'core/data' ).isResolving.mockRestore(); - } ); - - function setIsResolving( isResolving ) { - select( 'core/data' ).isResolving.mockImplementation( - ( reducerKey, selectorName ) => ( - isResolving && - reducerKey === 'core' && - selectorName === 'getCategories' - ) - ); - } - - it( 'returns false if never requested', () => { - const result = isRequestingCategories(); - expect( result ).toBe( false ); - expect( console ).toHaveWarnedWith( 'wp.data.select("core").isRequestingCategories is deprecated and will be removed from Gutenberg in 3.7.0. Please use wp.data.select("core").getEntitiesByKind instead.' ); - } ); - - it( 'returns false if categories resolution finished', () => { - setIsResolving( false ); - const result = isRequestingCategories(); - expect( result ).toBe( false ); - } ); - - it( 'returns true if categories resolution started', () => { - setIsResolving( true ); - const result = isRequestingCategories(); - expect( result ).toBe( true ); - } ); -} ); describe( 'getEntityRecord', () => { it( 'should return undefined for unknown record’s key', () => { diff --git a/packages/custom-templated-path-webpack-plugin/CHANGELOG.md b/packages/custom-templated-path-webpack-plugin/CHANGELOG.md index 7d81dfb39f7ebb..9ee57a0904c4b9 100644 --- a/packages/custom-templated-path-webpack-plugin/CHANGELOG.md +++ b/packages/custom-templated-path-webpack-plugin/CHANGELOG.md @@ -1,7 +1,11 @@ ## 1.1.0 (2018-07-12) +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.2 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/data/CHANGELOG.md b/packages/data/CHANGELOG.md index 01ff341e295d5d..a3bac5e41a87a6 100644 --- a/packages/data/CHANGELOG.md +++ b/packages/data/CHANGELOG.md @@ -1,4 +1,7 @@ ## v2.0.0 (Unreleased) -- Breaking: The `withRehdyration` function is removed. Use the persistence plugin instead. -- Breaking: The `loadAndPersist` function is removed. Use the persistence plugin instead. +### Breaking Change + +- The `withRehdyration` function is removed. Use the persistence plugin instead. +- The `loadAndPersist` function is removed. Use the persistence plugin instead. +- `restrictPersistence`, `setPersistenceStorage` and `setupPersistence` functions have been removed. Please use the data persistence plugin instead. diff --git a/packages/data/package.json b/packages/data/package.json index d73676170b991e..5404f472ba6600 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -23,7 +23,6 @@ "dependencies": { "@babel/runtime-corejs2": "7.0.0-beta.56", "@wordpress/compose": "file:../compose", - "@wordpress/deprecated": "file:../deprecated", "@wordpress/element": "file:../element", "@wordpress/is-shallow-equal": "file:../is-shallow-equal", "@wordpress/redux-routine": "file:../redux-routine", diff --git a/packages/data/src/deprecated.js b/packages/data/src/deprecated.js deleted file mode 100644 index 81458978f88919..00000000000000 --- a/packages/data/src/deprecated.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * WordPress dependencies - */ -import deprecated from '@wordpress/deprecated'; - -/** - * Internal dependencies - */ -import * as persistence from './plugins/persistence'; - -/** - * Higher-order reducer used to persist just one key from the reducer state. - * - * @param {function} reducer Reducer function. - * @param {string} keyToPersist The reducer key to persist. - * - * @return {function} Updated reducer. - */ -export function restrictPersistence( reducer, keyToPersist ) { - deprecated( 'wp.data.restrictPersistence', { - alternative: 'registerStore persist option with persistence plugin', - version: '3.7', - plugin: 'Gutenberg', - hint: 'See https://github.com/WordPress/gutenberg/pull/8341 for more details', - } ); - - reducer.__deprecatedKeyToPersist = keyToPersist; - - return reducer; -} - -/** - * Sets a different persistence storage. - * - * @param {Object} storage Persistence storage. - */ -export function setPersistenceStorage( storage ) { - deprecated( 'wp.data.setPersistenceStorage', { - alternative: 'persistence plugin with storage option', - version: '3.7', - plugin: 'Gutenberg', - hint: 'See https://github.com/WordPress/gutenberg/pull/8341 for more details', - } ); - - const originalCreatePersistenceInterface = persistence.createPersistenceInterface; - persistence.createPersistenceInterface = ( options ) => { - originalCreatePersistenceInterface( { - storage, - ...options, - } ); - }; -} diff --git a/packages/data/src/index.js b/packages/data/src/index.js index d2405dd0fa4efe..2e71774abcdbbf 100644 --- a/packages/data/src/index.js +++ b/packages/data/src/index.js @@ -13,10 +13,6 @@ export { default as withSelect } from './components/with-select'; export { default as withDispatch } from './components/with-dispatch'; export { default as RegistryProvider, RegistryConsumer } from './components/registry-provider'; export { createRegistry } from './registry'; -export { - restrictPersistence, - setPersistenceStorage, -} from './deprecated'; export { plugins }; /** @@ -39,5 +35,4 @@ export const registerReducer = defaultRegistry.registerReducer; export const registerActions = defaultRegistry.registerActions; export const registerSelectors = defaultRegistry.registerSelectors; export const registerResolvers = defaultRegistry.registerResolvers; -export const setupPersistence = defaultRegistry.setupPersistence; export const use = defaultRegistry.use; diff --git a/packages/data/src/plugins/persistence/index.js b/packages/data/src/plugins/persistence/index.js index f31484c5b5098b..3be7142a576d92 100644 --- a/packages/data/src/plugins/persistence/index.js +++ b/packages/data/src/plugins/persistence/index.js @@ -144,15 +144,6 @@ export default function( registry, pluginOptions ) { return { registerStore( reducerKey, options ) { - // REMOVEME: Deprecation: v3.7 - if ( options.reducer.__deprecatedKeyToPersist ) { - options = { - ...options, - persist: [ options.reducer.__deprecatedKeyToPersist ], - }; - delete options.reducer.__deprecatedKeyToPersist; - } - if ( ! options.persist ) { return registry.registerStore( reducerKey, options ); } diff --git a/packages/data/src/registry.js b/packages/data/src/registry.js index 2a35bd7a03ff09..96cbe8379bd200 100644 --- a/packages/data/src/registry.js +++ b/packages/data/src/registry.js @@ -10,16 +10,10 @@ import { get, } from 'lodash'; -/** - * WordPress dependencies - */ -import deprecated from '@wordpress/deprecated'; - /** * Internal dependencies */ import dataStore from './store'; -import { persistence } from './plugins'; /** * An isolated orchestrator of store registrations. @@ -337,22 +331,6 @@ export function createRegistry( storeConfigs = {} ) { return get( namespaces, [ reducerKey, 'actions' ] ); } - /** - * Setup persistence for the current registry. - * - * @param {string} storageKey The storage key. - */ - function setupPersistence( storageKey ) { - deprecated( 'data registry setupPersistence', { - alternative: 'persistence plugin', - version: '3.7', - plugin: 'Gutenberg', - hint: 'See https://github.com/WordPress/gutenberg/pull/8341 for more details', - } ); - - registry.use( persistence, { storageKey } ); - } - /** * Maps an object of function values to proxy invocation through to the * current internal representation of the registry, which may be enhanced @@ -377,7 +355,6 @@ export function createRegistry( storeConfigs = {} ) { subscribe, select, dispatch, - setupPersistence, use, }; diff --git a/packages/dom-ready/CHANGELOG.md b/packages/dom-ready/CHANGELOG.md index 100e805e5f1497..62b919fff218fc 100644 --- a/packages/dom-ready/CHANGELOG.md +++ b/packages/dom-ready/CHANGELOG.md @@ -1,4 +1,9 @@ ## 1.1.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Polish + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) diff --git a/packages/editor/CHANGELOG.md b/packages/editor/CHANGELOG.md index 6ec52a246f7f6a..3014beb547f14b 100644 --- a/packages/editor/CHANGELOG.md +++ b/packages/editor/CHANGELOG.md @@ -1,14 +1,16 @@ ## 3.0.0 (Unreleased) -- Breaking: The `wideAlign` block supports hook has been removed. Use `alignWide` instead. -- Breaking: `fetchSharedBlocks` action has been removed. Use `fetchReusableBlocks` instead. -- Breaking: `receiveSharedBlocks` action has been removed. Use `receiveReusableBlocks` instead. -- Breaking: `saveSharedBlock` action has been removed. Use `saveReusableBlock` instead. -- Breaking: `deleteSharedBlock` action has been removed. Use `deleteReusableBlock` instead. -- Breaking: `updateSharedBlockTitle` action has been removed. Use `updateReusableBlockTitle` instead. -- Breaking: `convertBlockToSaved` action has been removed. Use `convertBlockToReusable` instead. -- Breaking: `getSharedBlock` selector has been removed. Use `getReusableBlock` instead. -- Breaking: `isSavingSharedBlock` selector has been removed. Use `isSavingReusableBlock` instead. -- Breaking: `isFetchingSharedBlock` selector has been removed. Use `isFetchingReusableBlock` instead. -- Breaking: `getSharedBlocks` selector has been removed. Use `getReusableBlocks` instead. -- Breaking: `editorMediaUpload` has been removed. Use `mediaUpload` instead. +### Breaking Change + +- The `wideAlign` block supports hook has been removed. Use `alignWide` instead. +- `fetchSharedBlocks` action has been removed. Use `fetchReusableBlocks` instead. +- `receiveSharedBlocks` action has been removed. Use `receiveReusableBlocks` instead. +- `saveSharedBlock` action has been removed. Use `saveReusableBlock` instead. +- `deleteSharedBlock` action has been removed. Use `deleteReusableBlock` instead. +- `updateSharedBlockTitle` action has been removed. Use `updateReusableBlockTitle` instead. +- `convertBlockToSaved` action has been removed. Use `convertBlockToReusable` instead. +- `getSharedBlock` selector has been removed. Use `getReusableBlock` instead. +- `isSavingSharedBlock` selector has been removed. Use `isSavingReusableBlock` instead. +- `isFetchingSharedBlock` selector has been removed. Use `isFetchingReusableBlock` instead. +- `getSharedBlocks` selector has been removed. Use `getReusableBlocks` instead. +- `editorMediaUpload` has been removed. Use `mediaUpload` instead. diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index cc655af81c7173..a6216bad3a4647 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -7,11 +7,7 @@ import { flow } from 'lodash'; * WordPress Dependencies */ import { createElement, Component } from '@wordpress/element'; -import { - APIProvider, - DropZoneProvider, - SlotFillProvider, -} from '@wordpress/components'; +import { DropZoneProvider, SlotFillProvider } from '@wordpress/components'; import { withDispatch } from '@wordpress/data'; /** @@ -68,15 +64,6 @@ class EditorProvider extends Component { SlotFillProvider, ], - // APIProvider - // - // - context.getAPISchema - // - context.getAPIPostTypeRestBaseMapping - // - context.getAPITaxonomyRestBaseMapping - [ - APIProvider, - ], - // DropZone provider: [ DropZoneProvider, diff --git a/packages/hooks/CHANGELOG.md b/packages/hooks/CHANGELOG.md index b9896565b210d8..87f385f8f70edb 100644 --- a/packages/hooks/CHANGELOG.md +++ b/packages/hooks/CHANGELOG.md @@ -1,12 +1,21 @@ ## 1.2.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Polish + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.1.8 (2018-05-08) +### Polish + - Documentation: Improve usage examples ([#121](https://github.com/WordPress/packages/pull/121)) ## 1.1.6 (2018-03-21) +### Bug Fix + - Fix: Resolves issue where action argument would be undefined on all but the first action callback. diff --git a/packages/i18n/CHANGELOG.md b/packages/i18n/CHANGELOG.md index 040570db2d06eb..f2245df88b1a57 100644 --- a/packages/i18n/CHANGELOG.md +++ b/packages/i18n/CHANGELOG.md @@ -1,8 +1,15 @@ ## 1.2.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.1.1 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/is-shallow-equal/CHANGELOG.md b/packages/is-shallow-equal/CHANGELOG.md index 6cdaffc5f4b208..0cecb31b299468 100644 --- a/packages/is-shallow-equal/CHANGELOG.md +++ b/packages/is-shallow-equal/CHANGELOG.md @@ -1,16 +1,27 @@ ## 1.1.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.2 (2018-05-08) +### Bug Fix + - Fix: Use implicit `index.js` for main entry ([#124](https://github.com/WordPress/packages/pull/124)) ## 1.0.1 (2018-05-01) +### Bug Fix + - Fix: Passing a null-ish value as one of the arguments now correctly falls back to a strict equality comparison. ([#116](https://github.com/WordPress/packages/pull/116)) ## 1.0.0 (2018-04-25) +### New Feature + - Initial release diff --git a/packages/jest-console/CHANGELOG.md b/packages/jest-console/CHANGELOG.md index 54eddcdee23f73..e412ba1466eb07 100644 --- a/packages/jest-console/CHANGELOG.md +++ b/packages/jest-console/CHANGELOG.md @@ -1,13 +1,22 @@ ## 2.0.0 (2018-07-12) -- Breaking: Add new API methods `toHaveInformed`, `toHaveInformedWith`, `toHaveLogged` and `toHaveLoggedWith` ([#137](https://github.com/WordPress/packages/pull/137)). If the code under test calls `console.log` or `console.info` it will fail, unless one of the newly introduced methods is explicitly used to verify it. -- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) +### Breaking Change + +- Add new API methods `toHaveInformed`, `toHaveInformedWith`, `toHaveLogged` and `toHaveLoggedWith` ([#137](https://github.com/WordPress/packages/pull/137)). If the code under test calls `console.log` or `console.info` it will fail, unless one of the newly introduced methods is explicitly used to verify it. +- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.7 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) ## 1.0.6 (2018-02-28) +### Polish + - Removed `package-lock.json` file, lockfiles for apps, not packages ([#88](https://github.com/WordPress/packages/pull/88)) diff --git a/packages/jest-preset-default/CHANGELOG.md b/packages/jest-preset-default/CHANGELOG.md index 42232a0ab5062e..fcac1256024078 100644 --- a/packages/jest-preset-default/CHANGELOG.md +++ b/packages/jest-preset-default/CHANGELOG.md @@ -1,13 +1,22 @@ ## 2.0.0 (2018-07-12) -- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) +### Breaking Change + +- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.6 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) ## 1.0.5 (2018-03-22) +### Polish + - Docs: Wrap filename in backticks ([#89](https://github.com/WordPress/packages/pull/89)) - Add `jest-preset` keyword to `jest-preset-default` package ([#92](https://github.com/WordPress/packages/pull/92)) diff --git a/packages/npm-package-json-lint-config/CHANGELOG.md b/packages/npm-package-json-lint-config/CHANGELOG.md index 24f7259311b428..13524084f2ef77 100644 --- a/packages/npm-package-json-lint-config/CHANGELOG.md +++ b/packages/npm-package-json-lint-config/CHANGELOG.md @@ -6,9 +6,16 @@ ## 1.1.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.0 (2018-05-18) +### New Feature + - Initial release `@wordpress/npm-package-json-lint-config` ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 561b84b344f5f8..cd4b2aa331c2d2 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -4,20 +4,29 @@ - Resolves an issue where npm package lint script did not work in Windows environments ([#9321](https://github.com/WordPress/gutenberg/pull/9321) -### Updated Dependencies +### Polish - Updated dependencies: `jest`, `npm-package-json-lint` and `read-pkg-up` ## 2.0.0 (2018-07-12) -- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) +### Breaking Change + +- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Internal + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.2.0 (2018-05-29) +### New Feature + - Added support for `lint-pkg-json` script ([#128](https://github.com/WordPress/packages/pull/128)) ## 1.1.5 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/wordcount/CHANGELOG.md b/packages/wordcount/CHANGELOG.md index 229a5a6cc2f061..488fb52eec4784 100644 --- a/packages/wordcount/CHANGELOG.md +++ b/packages/wordcount/CHANGELOG.md @@ -1,20 +1,33 @@ ## 1.1.0 (2018-07-12) +### New Feature + - Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832)) + +### Polish + - Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) ## 1.0.3 (2018-05-18) +### Polish + - Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) ## 1.0.2 (2018-05-08) +### Bug Fix + - Fix: Resolve error when input strings contains only whitespace ([#123](https://github.com/WordPress/packages/pull/123)) ## 1.0.1 (2018-05-01) +### Polish + - Internal: Include `publishConfig` configuration in `package.json`. ([#114](https://github.com/WordPress/packages/pull/114)) ## 1.0.0 (2018-04-24) +### New Feature + - Initial release