@wordpress/list-reusable-blocks 3.8.0 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.11.0 (2022-07-13)
6
+
7
+ ## 3.10.0 (2022-06-29)
8
+
9
+ ## 3.9.0 (2022-06-15)
10
+
5
11
  ## 3.8.0 (2022-06-01)
6
12
 
7
13
  ## 3.7.0 (2022-05-18)
@@ -7,16 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
13
11
 
14
12
  var _file = require("./file");
15
13
 
16
- /**
17
- * External dependencies
18
- */
19
-
20
14
  /**
21
15
  * WordPress dependencies
22
16
  */
@@ -41,7 +35,7 @@ async function importReusableBlock(file) {
41
35
  throw new Error('Invalid JSON file');
42
36
  }
43
37
 
44
- if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !(0, _lodash.isString)(parsedContent.title) || !(0, _lodash.isString)(parsedContent.content)) {
38
+ if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string') {
45
39
  throw new Error('Invalid Reusable block JSON file');
46
40
  }
47
41
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/import.js"],"names":["importReusableBlock","file","fileContent","parsedContent","JSON","parse","e","Error","__file","title","content","postType","path","reusableBlock","rest_base","data","status","method"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAf,CAAoCC,IAApC,EAA2C;AAC1C,QAAMC,WAAW,GAAG,MAAM,wBAAcD,IAAd,CAA1B;AACA,MAAIE,aAAJ;;AACA,MAAI;AACHA,IAAAA,aAAa,GAAGC,IAAI,CAACC,KAAL,CAAYH,WAAZ,CAAhB;AACA,GAFD,CAEE,OAAQI,CAAR,EAAY;AACb,UAAM,IAAIC,KAAJ,CAAW,mBAAX,CAAN;AACA;;AACD,MACCJ,aAAa,CAACK,MAAd,KAAyB,UAAzB,IACA,CAAEL,aAAa,CAACM,KADhB,IAEA,CAAEN,aAAa,CAACO,OAFhB,IAGA,CAAE,sBAAUP,aAAa,CAACM,KAAxB,CAHF,IAIA,CAAE,sBAAUN,aAAa,CAACO,OAAxB,CALH,EAME;AACD,UAAM,IAAIH,KAAJ,CAAW,kCAAX,CAAN;AACA;;AACD,QAAMI,QAAQ,GAAG,MAAM,uBAAU;AAAEC,IAAAA,IAAI,EAAG;AAAT,GAAV,CAAvB;AACA,QAAMC,aAAa,GAAG,MAAM,uBAAU;AACrCD,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,EADA;AAErCC,IAAAA,IAAI,EAAE;AACLN,MAAAA,KAAK,EAAEN,aAAa,CAACM,KADhB;AAELC,MAAAA,OAAO,EAAEP,aAAa,CAACO,OAFlB;AAGLM,MAAAA,MAAM,EAAE;AAHH,KAF+B;AAOrCC,IAAAA,MAAM,EAAE;AAP6B,GAAV,CAA5B;AAUA,SAAOJ,aAAP;AACA;;eAEcb,mB","sourcesContent":["/**\n * External dependencies\n */\nimport { isString } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\t! isString( parsedContent.title ) ||\n\t\t! isString( parsedContent.content )\n\t) {\n\t\tthrow new Error( 'Invalid Reusable block JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"]}
1
+ {"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/import.js"],"names":["importReusableBlock","file","fileContent","parsedContent","JSON","parse","e","Error","__file","title","content","postType","path","reusableBlock","rest_base","data","status","method"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAf,CAAoCC,IAApC,EAA2C;AAC1C,QAAMC,WAAW,GAAG,MAAM,wBAAcD,IAAd,CAA1B;AACA,MAAIE,aAAJ;;AACA,MAAI;AACHA,IAAAA,aAAa,GAAGC,IAAI,CAACC,KAAL,CAAYH,WAAZ,CAAhB;AACA,GAFD,CAEE,OAAQI,CAAR,EAAY;AACb,UAAM,IAAIC,KAAJ,CAAW,mBAAX,CAAN;AACA;;AACD,MACCJ,aAAa,CAACK,MAAd,KAAyB,UAAzB,IACA,CAAEL,aAAa,CAACM,KADhB,IAEA,CAAEN,aAAa,CAACO,OAFhB,IAGA,OAAOP,aAAa,CAACM,KAArB,KAA+B,QAH/B,IAIA,OAAON,aAAa,CAACO,OAArB,KAAiC,QALlC,EAME;AACD,UAAM,IAAIH,KAAJ,CAAW,kCAAX,CAAN;AACA;;AACD,QAAMI,QAAQ,GAAG,MAAM,uBAAU;AAAEC,IAAAA,IAAI,EAAG;AAAT,GAAV,CAAvB;AACA,QAAMC,aAAa,GAAG,MAAM,uBAAU;AACrCD,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,EADA;AAErCC,IAAAA,IAAI,EAAE;AACLN,MAAAA,KAAK,EAAEN,aAAa,CAACM,KADhB;AAELC,MAAAA,OAAO,EAAEP,aAAa,CAACO,OAFlB;AAGLM,MAAAA,MAAM,EAAE;AAHH,KAF+B;AAOrCC,IAAAA,MAAM,EAAE;AAP6B,GAAV,CAA5B;AAUA,SAAOJ,aAAP;AACA;;eAEcb,mB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\ttypeof parsedContent.title !== 'string' ||\n\t\ttypeof parsedContent.content !== 'string'\n\t) {\n\t\tthrow new Error( 'Invalid Reusable block JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"]}
@@ -1,11 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isString } from 'lodash';
5
1
  /**
6
2
  * WordPress dependencies
7
3
  */
8
-
9
4
  import apiFetch from '@wordpress/api-fetch';
10
5
  /**
11
6
  * Internal dependencies
@@ -29,7 +24,7 @@ async function importReusableBlock(file) {
29
24
  throw new Error('Invalid JSON file');
30
25
  }
31
26
 
32
- if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !isString(parsedContent.title) || !isString(parsedContent.content)) {
27
+ if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string') {
33
28
  throw new Error('Invalid Reusable block JSON file');
34
29
  }
35
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/import.js"],"names":["isString","apiFetch","readTextFile","importReusableBlock","file","fileContent","parsedContent","JSON","parse","e","Error","__file","title","content","postType","path","reusableBlock","rest_base","data","status","method"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,QAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeC,mBAAf,CAAoCC,IAApC,EAA2C;AAC1C,QAAMC,WAAW,GAAG,MAAMH,YAAY,CAAEE,IAAF,CAAtC;AACA,MAAIE,aAAJ;;AACA,MAAI;AACHA,IAAAA,aAAa,GAAGC,IAAI,CAACC,KAAL,CAAYH,WAAZ,CAAhB;AACA,GAFD,CAEE,OAAQI,CAAR,EAAY;AACb,UAAM,IAAIC,KAAJ,CAAW,mBAAX,CAAN;AACA;;AACD,MACCJ,aAAa,CAACK,MAAd,KAAyB,UAAzB,IACA,CAAEL,aAAa,CAACM,KADhB,IAEA,CAAEN,aAAa,CAACO,OAFhB,IAGA,CAAEb,QAAQ,CAAEM,aAAa,CAACM,KAAhB,CAHV,IAIA,CAAEZ,QAAQ,CAAEM,aAAa,CAACO,OAAhB,CALX,EAME;AACD,UAAM,IAAIH,KAAJ,CAAW,kCAAX,CAAN;AACA;;AACD,QAAMI,QAAQ,GAAG,MAAMb,QAAQ,CAAE;AAAEc,IAAAA,IAAI,EAAG;AAAT,GAAF,CAA/B;AACA,QAAMC,aAAa,GAAG,MAAMf,QAAQ,CAAE;AACrCc,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,EADA;AAErCC,IAAAA,IAAI,EAAE;AACLN,MAAAA,KAAK,EAAEN,aAAa,CAACM,KADhB;AAELC,MAAAA,OAAO,EAAEP,aAAa,CAACO,OAFlB;AAGLM,MAAAA,MAAM,EAAE;AAHH,KAF+B;AAOrCC,IAAAA,MAAM,EAAE;AAP6B,GAAF,CAApC;AAUA,SAAOJ,aAAP;AACA;;AAED,eAAeb,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isString } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\t! isString( parsedContent.title ) ||\n\t\t! isString( parsedContent.content )\n\t) {\n\t\tthrow new Error( 'Invalid Reusable block JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"]}
1
+ {"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/import.js"],"names":["apiFetch","readTextFile","importReusableBlock","file","fileContent","parsedContent","JSON","parse","e","Error","__file","title","content","postType","path","reusableBlock","rest_base","data","status","method"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,QAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeC,mBAAf,CAAoCC,IAApC,EAA2C;AAC1C,QAAMC,WAAW,GAAG,MAAMH,YAAY,CAAEE,IAAF,CAAtC;AACA,MAAIE,aAAJ;;AACA,MAAI;AACHA,IAAAA,aAAa,GAAGC,IAAI,CAACC,KAAL,CAAYH,WAAZ,CAAhB;AACA,GAFD,CAEE,OAAQI,CAAR,EAAY;AACb,UAAM,IAAIC,KAAJ,CAAW,mBAAX,CAAN;AACA;;AACD,MACCJ,aAAa,CAACK,MAAd,KAAyB,UAAzB,IACA,CAAEL,aAAa,CAACM,KADhB,IAEA,CAAEN,aAAa,CAACO,OAFhB,IAGA,OAAOP,aAAa,CAACM,KAArB,KAA+B,QAH/B,IAIA,OAAON,aAAa,CAACO,OAArB,KAAiC,QALlC,EAME;AACD,UAAM,IAAIH,KAAJ,CAAW,kCAAX,CAAN;AACA;;AACD,QAAMI,QAAQ,GAAG,MAAMb,QAAQ,CAAE;AAAEc,IAAAA,IAAI,EAAG;AAAT,GAAF,CAA/B;AACA,QAAMC,aAAa,GAAG,MAAMf,QAAQ,CAAE;AACrCc,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,EADA;AAErCC,IAAAA,IAAI,EAAE;AACLN,MAAAA,KAAK,EAAEN,aAAa,CAACM,KADhB;AAELC,MAAAA,OAAO,EAAEP,aAAa,CAACO,OAFlB;AAGLM,MAAAA,MAAM,EAAE;AAHH,KAF+B;AAOrCC,IAAAA,MAAM,EAAE;AAP6B,GAAF,CAApC;AAUA,SAAOJ,aAAP;AACA;;AAED,eAAeb,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\ttypeof parsedContent.title !== 'string' ||\n\t\ttypeof parsedContent.content !== 'string'\n\t) {\n\t\tthrow new Error( 'Invalid Reusable block JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/list-reusable-blocks",
3
- "version": "3.8.0",
3
+ "version": "3.11.0",
4
4
  "description": "Adding Export/Import support to the reusable blocks listing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,11 +26,11 @@
26
26
  "module": "build-module/index.js",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/api-fetch": "^6.7.0",
30
- "@wordpress/components": "^19.12.0",
31
- "@wordpress/compose": "^5.8.0",
32
- "@wordpress/element": "^4.8.0",
33
- "@wordpress/i18n": "^4.10.0",
29
+ "@wordpress/api-fetch": "^6.10.0",
30
+ "@wordpress/components": "^19.15.0",
31
+ "@wordpress/compose": "^5.11.0",
32
+ "@wordpress/element": "^4.11.0",
33
+ "@wordpress/i18n": "^4.13.0",
34
34
  "lodash": "^4.17.21"
35
35
  },
36
36
  "peerDependencies": {
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
43
+ "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
44
44
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isString } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -31,8 +26,8 @@ async function importReusableBlock( file ) {
31
26
  parsedContent.__file !== 'wp_block' ||
32
27
  ! parsedContent.title ||
33
28
  ! parsedContent.content ||
34
- ! isString( parsedContent.title ) ||
35
- ! isString( parsedContent.content )
29
+ typeof parsedContent.title !== 'string' ||
30
+ typeof parsedContent.content !== 'string'
36
31
  ) {
37
32
  throw new Error( 'Invalid Reusable block JSON file' );
38
33
  }