@wordpress/plugins 6.10.6 → 6.11.1

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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 6.11.0 (2023-10-05)
6
+
5
7
  ## 6.10.0 (2023-09-20)
6
8
 
7
9
  ## 6.9.0 (2023-08-31)
package/README.md CHANGED
@@ -48,7 +48,7 @@ _Usage_
48
48
 
49
49
  ```js
50
50
  // Using ES5 syntax
51
- var el = wp.element.createElement;
51
+ var el = React.createElement;
52
52
  var PluginArea = wp.plugins.PluginArea;
53
53
 
54
54
  function Layout() {
@@ -76,7 +76,7 @@ _Parameters_
76
76
 
77
77
  _Returns_
78
78
 
79
- - `WPComponent`: The component to be rendered.
79
+ - `Component`: The component to be rendered.
80
80
 
81
81
  #### registerPlugin
82
82
 
@@ -86,12 +86,12 @@ _Usage_
86
86
 
87
87
  ```js
88
88
  // Using ES5 syntax
89
- var el = wp.element.createElement;
89
+ var el = React.createElement;
90
90
  var Fragment = wp.element.Fragment;
91
91
  var PluginSidebar = wp.editPost.PluginSidebar;
92
92
  var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
93
93
  var registerPlugin = wp.plugins.registerPlugin;
94
- var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
94
+ var moreIcon = React.createElement( 'svg' ); //... svg element.
95
95
 
96
96
  function Component() {
97
97
  return el(
@@ -200,7 +200,7 @@ _Parameters_
200
200
 
201
201
  _Returns_
202
202
 
203
- - `WPComponent`: Enhanced component with injected context as props.
203
+ - `Component`: Enhanced component with injected context as props.
204
204
 
205
205
  <!-- END TOKEN(Autogenerated API docs) -->
206
206
 
@@ -10,6 +10,9 @@ exports.unregisterPlugin = unregisterPlugin;
10
10
  var _hooks = require("@wordpress/hooks");
11
11
  var _icons = require("@wordpress/icons");
12
12
  /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
13
+ /**
14
+ * External dependencies
15
+ */
13
16
 
14
17
  /**
15
18
  * WordPress dependencies
@@ -30,12 +33,12 @@ const plugins = {};
30
33
  * @example
31
34
  * ```js
32
35
  * // Using ES5 syntax
33
- * var el = wp.element.createElement;
36
+ * var el = React.createElement;
34
37
  * var Fragment = wp.element.Fragment;
35
38
  * var PluginSidebar = wp.editPost.PluginSidebar;
36
39
  * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
37
40
  * var registerPlugin = wp.plugins.registerPlugin;
38
- * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
41
+ * var moreIcon = React.createElement( 'svg' ); //... svg element.
39
42
  *
40
43
  * function Component() {
41
44
  * return el(
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_icons","plugins","registerPlugin","name","settings","console","error","test","applyFilters","render","scope","icon","pluginsIcon","doAction","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\nimport type { WPComponent } from '@wordpress/element';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: WPComponent;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = wp.element.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editPost.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":";;;;;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AANA;;AAEA;AACA;AACA;;AAoCA;AACA;AACA;AACA,MAAME,OAAO,GAAG,CAAC,CAA+B;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC7BC,IAAY,EACZC,QAAw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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,gBAAgBA,CAAEX,IAAY,EAAyB;EACtE,IAAK,CAAEF,OAAO,CAAEE,IAAI,CAAE,EAAG;IACxBE,OAAO,CAACC,KAAK,CAAE,UAAU,GAAGH,IAAI,GAAG,sBAAuB,CAAC;IAC3D;EACD;EACA,MAAMY,SAAS,GAAGd,OAAO,CAAEE,IAAI,CAAE;EACjC,OAAOF,OAAO,CAAEE,IAAI,CAAE;EAEtB,IAAAU,eAAQ,EAAE,4BAA4B,EAAEE,SAAS,EAAEZ,IAAK,CAAC;EAEzD,OAAOY,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAEb,IAAY,EAAyB;EAC/D,OAAOF,OAAO,CAAEE,IAAI,CAAE;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,UAAUA,CAAEP,KAAc,EAAe;EACxD,OAAOQ,MAAM,CAACC,MAAM,CAAElB,OAAQ,CAAC,CAACmB,MAAM,CACnCC,MAAM,IAAMA,MAAM,CAACX,KAAK,KAAKA,KAChC,CAAC;AACF"}
1
+ {"version":3,"names":["_hooks","require","_icons","plugins","registerPlugin","name","settings","console","error","test","applyFilters","render","scope","icon","pluginsIcon","doAction","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editPost.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = React.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":";;;;;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAVA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAmCA;AACA;AACA;AACA,MAAME,OAAO,GAAG,CAAC,CAA+B;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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IAAI,CAAEG,KAAM,CAAC,EAAG;MAC1CL,OAAO,CAACC,KAAK,CACZ,0HACD,CAAC;MACD,OAAO,IAAI;IACZ;EACD;EAEAL,OAAO,CAAEE,IAAI,CAAE,GAAG;IACjBA,IAAI;IACJQ,IAAI,EAAEC,cAAW;IACjB,GAAGR;EACJ,CAAC;EAED,IAAAS,eAAQ,EAAE,0BAA0B,EAAET,QAAQ,EAAED,IAAK,CAAC;EAEtD,OAAOC,QAAQ;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,gBAAgBA,CAAEX,IAAY,EAAyB;EACtE,IAAK,CAAEF,OAAO,CAAEE,IAAI,CAAE,EAAG;IACxBE,OAAO,CAACC,KAAK,CAAE,UAAU,GAAGH,IAAI,GAAG,sBAAuB,CAAC;IAC3D;EACD;EACA,MAAMY,SAAS,GAAGd,OAAO,CAAEE,IAAI,CAAE;EACjC,OAAOF,OAAO,CAAEE,IAAI,CAAE;EAEtB,IAAAU,eAAQ,EAAE,4BAA4B,EAAEE,SAAS,EAAEZ,IAAK,CAAC;EAEzD,OAAOY,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAEb,IAAY,EAAyB;EAC/D,OAAOF,OAAO,CAAEE,IAAI,CAAE;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,UAAUA,CAAEP,KAAc,EAAe;EACxD,OAAOQ,MAAM,CAACC,MAAM,CAAElB,OAAQ,CAAC,CAACmB,MAAM,CACnCC,MAAM,IAAMA,MAAM,CAACX,KAAK,KAAKA,KAChC,CAAC;AACF"}
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _element = require("@wordpress/element");
8
+ var _react = require("react");
9
9
  var _memize = _interopRequireDefault(require("memize"));
10
+ var _element = require("@wordpress/element");
10
11
  var _hooks = require("@wordpress/hooks");
11
12
  var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
12
13
  var _pluginContext = require("../plugin-context");
@@ -38,7 +39,7 @@ const getPluginContext = (0, _memize.default)((icon, name) => ({
38
39
  * @example
39
40
  * ```js
40
41
  * // Using ES5 syntax
41
- * var el = wp.element.createElement;
42
+ * var el = React.createElement;
42
43
  * var PluginArea = wp.plugins.PluginArea;
43
44
  *
44
45
  * function Layout() {
@@ -64,7 +65,7 @@ const getPluginContext = (0, _memize.default)((icon, name) => ({
64
65
  * );
65
66
  * ```
66
67
  *
67
- * @return {WPComponent} The component to be rendered.
68
+ * @return {Component} The component to be rendered.
68
69
  */
69
70
  function PluginArea({
70
71
  scope,
@@ -91,7 +92,7 @@ function PluginArea({
91
92
  };
92
93
  }, [scope]);
93
94
  const plugins = (0, _element.useSyncExternalStore)(store.subscribe, store.getValue);
94
- return (0, _element.createElement)("div", {
95
+ return (0, _react.createElement)("div", {
95
96
  style: {
96
97
  display: 'none'
97
98
  }
@@ -99,13 +100,13 @@ function PluginArea({
99
100
  icon,
100
101
  name,
101
102
  render: Plugin
102
- }) => (0, _element.createElement)(_pluginContext.PluginContextProvider, {
103
+ }) => (0, _react.createElement)(_pluginContext.PluginContextProvider, {
103
104
  key: name,
104
105
  value: getPluginContext(icon, name)
105
- }, (0, _element.createElement)(_pluginErrorBoundary.PluginErrorBoundary, {
106
+ }, (0, _react.createElement)(_pluginErrorBoundary.PluginErrorBoundary, {
106
107
  name: name,
107
108
  onError: onError
108
- }, (0, _element.createElement)(Plugin, null)))));
109
+ }, (0, _react.createElement)(Plugin, null)))));
109
110
  }
110
111
  var _default = PluginArea;
111
112
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_memize","_interopRequireDefault","_hooks","_isShallowEqual","_pluginContext","_pluginErrorBoundary","_api","getPluginContext","memoize","icon","name","PluginArea","scope","onError","store","useMemo","lastValue","subscribe","listener","addAction","removeAction","getValue","nextValue","getPlugins","isShallowEqual","plugins","useSyncExternalStore","createElement","style","display","map","render","Plugin","PluginContextProvider","key","value","PluginErrorBoundary","_default","exports","default"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = wp.element.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";;;;;;;AAQA,IAAAA,QAAA,G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QACtB;QAEA,OAAON,SAAS;MACjB;IACD,CAAC;EACF,CAAC,EAAE,CAAEJ,KAAK,CAAG,CAAC;EAEd,MAAMa,OAAO,GAAG,IAAAC,6BAAoB,EAAEZ,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACO,QAAS,CAAC;EAEvE,OACC,IAAAvB,QAAA,CAAA6B,aAAA;IAAKC,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO;EAAG,GAC/BJ,OAAO,CAACK,GAAG,CAAE,CAAE;IAAErB,IAAI;IAAEC,IAAI;IAAEqB,MAAM,EAAEC;EAAO,CAAC,KAC9C,IAAAlC,QAAA,CAAA6B,aAAA,EAACvB,cAAA,CAAA6B,qBAAqB;IACrBC,GAAG,EAAGxB,IAAM;IACZyB,KAAK,EAAG5B,gBAAgB,CAAEE,IAAI,EAAEC,IAAK;EAAG,GAExC,IAAAZ,QAAA,CAAA6B,aAAA,EAACtB,oBAAA,CAAA+B,mBAAmB;IAAC1B,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrD,IAAAf,QAAA,CAAA6B,aAAA,EAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAAC,IAAAK,QAAA,GAEc1B,UAAU;AAAA2B,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_memize","_interopRequireDefault","require","_element","_hooks","_isShallowEqual","_pluginContext","_pluginErrorBoundary","_api","getPluginContext","memoize","icon","name","PluginArea","scope","onError","store","useMemo","lastValue","subscribe","listener","addAction","removeAction","getValue","nextValue","getPlugins","isShallowEqual","plugins","useSyncExternalStore","_react","createElement","style","display","map","render","Plugin","PluginContextProvider","key","value","PluginErrorBoundary","_default","exports","default"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAKA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,MAAMO,gBAAgB,GAAG,IAAAC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IAAI;IAAEC,IAAI;IAAEsB,MAAM,EAAEC;EAAO,CAAC,KAC9C,IAAAN,MAAA,CAAAC,aAAA,EAACxB,cAAA,CAAA8B,qBAAqB;IACrBC,GAAG,EAAGzB,IAAM;IACZ0B,KAAK,EAAG7B,gBAAgB,CAAEE,IAAI,EAAEC,IAAK;EAAG,GAExC,IAAAiB,MAAA,CAAAC,aAAA,EAACvB,oBAAA,CAAAgC,mBAAmB;IAAC3B,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrD,IAAAc,MAAA,CAAAC,aAAA,EAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAAC,IAAAK,QAAA,GAEc3B,UAAU;AAAA4B,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PluginContextProvider = void 0;
7
7
  exports.usePluginContext = usePluginContext;
8
8
  exports.withPluginContext = void 0;
9
+ var _react = require("react");
9
10
  var _element = require("@wordpress/element");
10
11
  var _compose = require("@wordpress/compose");
11
12
  /**
@@ -36,10 +37,10 @@ function usePluginContext() {
36
37
  * expected to return object of props to
37
38
  * merge with the component's own props.
38
39
  *
39
- * @return {WPComponent} Enhanced component with injected context as props.
40
+ * @return {Component} Enhanced component with injected context as props.
40
41
  */
41
42
  const withPluginContext = mapContextToProps => (0, _compose.createHigherOrderComponent)(OriginalComponent => {
42
- return props => (0, _element.createElement)(Context.Consumer, null, context => (0, _element.createElement)(OriginalComponent, {
43
+ return props => (0, _react.createElement)(Context.Consumer, null, context => (0, _react.createElement)(OriginalComponent, {
43
44
  ...props,
44
45
  ...mapContextToProps(context, props)
45
46
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","Context","createContext","name","icon","PluginContextProvider","Provider","exports","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","props","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {WPComponent} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAcA,MAAME,OAAO,GAAG,IAAAC,sBAAa,EAAmB;EAC/CC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEI,MAAMC,qBAAqB,GAAGJ,OAAO,CAACK,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAF,qBAAA,GAAAA,qBAAA;AAKO,SAASG,gBAAgBA,CAAA,EAAG;EAClC,OAAO,IAAAC,mBAAU,EAAER,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,iBAAiB,GAC7BC,iBAGsB,IAEtB,IAAAC,mCAA0B,EAAIC,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACb,IAAAhB,QAAA,CAAAiB,aAAA,EAACd,OAAO,CAACe,QAAQ,QACZC,OAAO,IACV,IAAAnB,QAAA,CAAAiB,aAAA,EAACF,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLH,iBAAiB,CAAEM,OAAO,EAAEH,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC;AAACP,OAAA,CAAAG,iBAAA,GAAAA,iBAAA"}
1
+ {"version":3,"names":["_element","require","_compose","Context","createContext","name","icon","PluginContextProvider","Provider","exports","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","props","_react","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAcA,MAAME,OAAO,GAAG,IAAAC,sBAAa,EAAmB;EAC/CC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEI,MAAMC,qBAAqB,GAAGJ,OAAO,CAACK,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAF,qBAAA,GAAAA,qBAAA;AAKO,SAASG,gBAAgBA,CAAA,EAAG;EAClC,OAAO,IAAAC,mBAAU,EAAER,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,iBAAiB,GAC7BC,iBAGsB,IAEtB,IAAAC,mCAA0B,EAAIC,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACb,IAAAC,MAAA,CAAAC,aAAA,EAACf,OAAO,CAACgB,QAAQ,QACZC,OAAO,IACV,IAAAH,MAAA,CAAAC,aAAA,EAACH,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLH,iBAAiB,CAAEO,OAAO,EAAEJ,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC;AAACP,OAAA,CAAAG,iBAAA,GAAAA,iBAAA"}
@@ -1,4 +1,7 @@
1
1
  /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
2
+ /**
3
+ * External dependencies
4
+ */
2
5
 
3
6
  /**
4
7
  * WordPress dependencies
@@ -20,12 +23,12 @@ const plugins = {};
20
23
  * @example
21
24
  * ```js
22
25
  * // Using ES5 syntax
23
- * var el = wp.element.createElement;
26
+ * var el = React.createElement;
24
27
  * var Fragment = wp.element.Fragment;
25
28
  * var PluginSidebar = wp.editPost.PluginSidebar;
26
29
  * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
27
30
  * var registerPlugin = wp.plugins.registerPlugin;
28
- * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
31
+ * var moreIcon = React.createElement( 'svg' ); //... svg element.
29
32
  *
30
33
  * function Component() {
31
34
  * return el(
@@ -1 +1 @@
1
- {"version":3,"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\nimport type { WPComponent } from '@wordpress/element';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: WPComponent;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = wp.element.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editPost.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,kBAAkB;AACzD,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AAkCzD;AACA;AACA;AACA,MAAMD,OAAO,GAAG,CAAC,CAA+B;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,cAAcA,CAC7BC,IAAY,EACZC,QAAwB,EACA;EACxB,IAAK,OAAOA,Q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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,gBAAgBA,CAAER,IAAY,EAAyB;EACtE,IAAK,CAAEH,OAAO,CAAEG,IAAI,CAAE,EAAG;IACxBE,OAAO,CAACC,KAAK,CAAE,UAAU,GAAGH,IAAI,GAAG,sBAAuB,CAAC;IAC3D;EACD;EACA,MAAMS,SAAS,GAAGZ,OAAO,CAAEG,IAAI,CAAE;EACjC,OAAOH,OAAO,CAAEG,IAAI,CAAE;EAEtBJ,QAAQ,CAAE,4BAA4B,EAAEa,SAAS,EAAET,IAAK,CAAC;EAEzD,OAAOS,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAEV,IAAY,EAAyB;EAC/D,OAAOH,OAAO,CAAEG,IAAI,CAAE;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,UAAUA,CAAEL,KAAc,EAAe;EACxD,OAAOM,MAAM,CAACC,MAAM,CAAEhB,OAAQ,CAAC,CAACiB,MAAM,CACnCC,MAAM,IAAMA,MAAM,CAACT,KAAK,KAAKA,KAChC,CAAC;AACF"}
1
+ {"version":3,"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.editPost.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var moreIcon = React.createElement( 'svg' ); //... svg element.\n *\n * function Component() {\n * \treturn el(\n * \t\tFragment,\n * \t\t{},\n * \t\tel(\n * \t\t\tPluginSidebarMoreMenuItem,\n * \t\t\t{\n * \t\t\t\ttarget: 'sidebar-name',\n * \t\t\t},\n * \t\t\t'My Sidebar'\n * \t\t),\n * \t\tel(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'sidebar-name',\n * \t\t\t\ttitle: 'My Sidebar',\n * \t\t\t},\n * \t\t\t'Content of the sidebar'\n * \t\t)\n * \t);\n * }\n * registerPlugin( 'plugin-name', {\n * \ticon: moreIcon,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';\n * import { registerPlugin } from '@wordpress/plugins';\n * import { more } from '@wordpress/icons';\n *\n * const Component = () => (\n * \t<>\n * \t\t<PluginSidebarMoreMenuItem\n * \t\t\ttarget=\"sidebar-name\"\n * \t\t>\n * \t\t\tMy Sidebar\n * \t\t</PluginSidebarMoreMenuItem>\n * \t\t<PluginSidebar\n * \t\t\tname=\"sidebar-name\"\n * \t\t\ttitle=\"My Sidebar\"\n * \t\t>\n * \t\t\tContent of the sidebar\n * \t\t</PluginSidebar>\n * \t</>\n * );\n *\n * registerPlugin( 'plugin-name', {\n * \ticon: more,\n * \trender: Component,\n * \tscope: 'my-page',\n * } );\n * ```\n *\n * @return The final plugin settings object.\n */\nexport function registerPlugin(\n\tname: string,\n\tsettings: PluginSettings\n): PluginSettings | null {\n\tif ( typeof settings !== 'object' ) {\n\t\tconsole.error( 'No settings object provided!' );\n\t\treturn null;\n\t}\n\tif ( typeof name !== 'string' ) {\n\t\tconsole.error( 'Plugin name must be string.' );\n\t\treturn null;\n\t}\n\tif ( ! /^[a-z][a-z0-9-]*$/.test( name ) ) {\n\t\tconsole.error(\n\t\t\t'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-plugin\".'\n\t\t);\n\t\treturn null;\n\t}\n\tif ( plugins[ name ] ) {\n\t\tconsole.error( `Plugin \"${ name }\" is already registered.` );\n\t}\n\n\tsettings = applyFilters(\n\t\t'plugins.registerPlugin',\n\t\tsettings,\n\t\tname\n\t) as PluginSettings;\n\n\tconst { render, scope } = settings;\n\n\tif ( typeof render !== 'function' ) {\n\t\tconsole.error(\n\t\t\t'The \"render\" property must be specified and must be a valid function.'\n\t\t);\n\t\treturn null;\n\t}\n\n\tif ( scope ) {\n\t\tif ( typeof scope !== 'string' ) {\n\t\t\tconsole.error( 'Plugin scope must be string.' );\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( ! /^[a-z][a-z0-9-]*$/.test( scope ) ) {\n\t\t\tconsole.error(\n\t\t\t\t'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: \"my-page\".'\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tplugins[ name ] = {\n\t\tname,\n\t\ticon: pluginsIcon,\n\t\t...settings,\n\t};\n\n\tdoAction( 'plugins.pluginRegistered', settings, name );\n\n\treturn settings;\n}\n\n/**\n * Unregisters a plugin by name.\n *\n * @param name Plugin name.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var unregisterPlugin = wp.plugins.unregisterPlugin;\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { unregisterPlugin } from '@wordpress/plugins';\n *\n * unregisterPlugin( 'plugin-name' );\n * ```\n *\n * @return The previous plugin settings object, if it has been\n * successfully unregistered; otherwise `undefined`.\n */\nexport function unregisterPlugin( name: string ): WPPlugin | undefined {\n\tif ( ! plugins[ name ] ) {\n\t\tconsole.error( 'Plugin \"' + name + '\" is not registered.' );\n\t\treturn;\n\t}\n\tconst oldPlugin = plugins[ name ];\n\tdelete plugins[ name ];\n\n\tdoAction( 'plugins.pluginUnregistered', oldPlugin, name );\n\n\treturn oldPlugin;\n}\n\n/**\n * Returns a registered plugin settings.\n *\n * @param name Plugin name.\n *\n * @return Plugin setting.\n */\nexport function getPlugin( name: string ): WPPlugin | undefined {\n\treturn plugins[ name ];\n}\n\n/**\n * Returns all registered plugins without a scope or for a given scope.\n *\n * @param scope The scope to be used when rendering inside\n * a plugin area. No scope by default.\n *\n * @return The list of plugins without a scope or for a given scope.\n */\nexport function getPlugins( scope?: string ): WPPlugin[] {\n\treturn Object.values( plugins ).filter(\n\t\t( plugin ) => plugin.scope === scope\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,kBAAkB;AACzD,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AAiCzD;AACA;AACA;AACA,MAAMD,OAAO,GAAG,CAAC,CAA+B;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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C,EAAG;MAC1CJ,OAAO,CAACC,KAAK,CACZ,0HACD,CAAC;MACD,OAAO,IAAI;IACZ;EACD;EAEAN,OAAO,CAAEG,IAAI,CAAE,GAAG;IACjBA,IAAI;IACJO,IAAI,EAAET,WAAW;IACjB,GAAGG;EACJ,CAAC;EAEDL,QAAQ,CAAE,0BAA0B,EAAEK,QAAQ,EAAED,IAAK,CAAC;EAEtD,OAAOC,QAAQ;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,gBAAgBA,CAAER,IAAY,EAAyB;EACtE,IAAK,CAAEH,OAAO,CAAEG,IAAI,CAAE,EAAG;IACxBE,OAAO,CAACC,KAAK,CAAE,UAAU,GAAGH,IAAI,GAAG,sBAAuB,CAAC;IAC3D;EACD;EACA,MAAMS,SAAS,GAAGZ,OAAO,CAAEG,IAAI,CAAE;EACjC,OAAOH,OAAO,CAAEG,IAAI,CAAE;EAEtBJ,QAAQ,CAAE,4BAA4B,EAAEa,SAAS,EAAET,IAAK,CAAC;EAEzD,OAAOS,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAEV,IAAY,EAAyB;EAC/D,OAAOH,OAAO,CAAEG,IAAI,CAAE;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,UAAUA,CAAEL,KAAc,EAAe;EACxD,OAAOM,MAAM,CAACC,MAAM,CAAEhB,OAAQ,CAAC,CAACiB,MAAM,CACnCC,MAAM,IAAMA,MAAM,CAACT,KAAK,KAAKA,KAChC,CAAC;AACF"}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
@@ -31,7 +31,7 @@ const getPluginContext = memoize((icon, name) => ({
31
31
  * @example
32
32
  * ```js
33
33
  * // Using ES5 syntax
34
- * var el = wp.element.createElement;
34
+ * var el = React.createElement;
35
35
  * var PluginArea = wp.plugins.PluginArea;
36
36
  *
37
37
  * function Layout() {
@@ -57,7 +57,7 @@ const getPluginContext = memoize((icon, name) => ({
57
57
  * );
58
58
  * ```
59
59
  *
60
- * @return {WPComponent} The component to be rendered.
60
+ * @return {Component} The component to be rendered.
61
61
  */
62
62
  function PluginArea({
63
63
  scope,
@@ -1 +1 @@
1
- {"version":3,"names":["memoize","useMemo","useSyncExternalStore","addAction","removeAction","isShallowEqual","PluginContextProvider","PluginErrorBoundary","getPlugins","getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","createElement","style","display","map","render","Plugin","key","value"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = wp.element.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,OAAO,EAAEC,oBAAoB,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,SAASC,qBAAqB,QAAQ,mBAAmB;AACzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,UAAU,QAAQ,WAAW;AAItC,MAAMC,gBAAgB,GAAGT,OAAO,CAC/B,CAAEU,IAA6B,EAAEC,IAA6B,MAAQ;EACrED,IAAI;EACJC;AACD,CAAC,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAE;EACpBC,KAAK;EACLC;AAID,CAAC,EAAG;EACH,MAAMC,KAAK,GAAGd,OAAO,CAAE,MAAM;IAC5B,IAAIe,SAAqB,GAAG,EAAE;IAE9B,OAAO;MACNC,SAASA,CACRC,QAGS,EACR;QACDf,SAAS,CACR,0BAA0B,EAC1B,6CAA6C,EAC7Ce,QACD,CAAC;QACDf,SAAS,CACR,4BAA4B,EAC5B,+CAA+C,EAC/Ce,QACD,CAAC;QACD,OAAO,MAAM;UACZd,YAAY,CACX,0BAA0B,EAC1B,6CACD,CAAC;UACDA,YAAY,CACX,4BAA4B,EAC5B,+CACD,CAAC;QACF,CAAC;MACF,CAAC;MACDe,QAAQA,CAAA,EAAG;QACV,MAAMC,SAAS,GAAGZ,UAAU,CAAEK,KAAM,CAAC;QAErC,IAAK,CAAER,cAAc,CAAEW,SAAS,EAAEI,SAAU,CAAC,EAAG;UAC/CJ,SAAS,GAAGI,SAAS;QACtB;QAEA,OAAOJ,SAAS;MACjB;IACD,CAAC;EACF,CAAC,EAAE,CAAEH,KAAK,CAAG,CAAC;EAEd,MAAMQ,OAAO,GAAGnB,oBAAoB,CAAEa,KAAK,CAACE,SAAS,EAAEF,KAAK,CAACI,QAAS,CAAC;EAEvE,OACCG,aAAA;IAAKC,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO;EAAG,GAC/BH,OAAO,CAACI,GAAG,CAAE,CAAE;IAAEf,IAAI;IAAEC,IAAI;IAAEe,MAAM,EAAEC;EAAO,CAAC,KAC9CL,aAAA,CAAChB,qBAAqB;IACrBsB,GAAG,EAAGjB,IAAM;IACZkB,KAAK,EAAGpB,gBAAgB,CAAEC,IAAI,EAAEC,IAAK;EAAG,GAExCW,aAAA,CAACf,mBAAmB;IAACI,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrDQ,aAAA,CAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAEA,eAAef,UAAU"}
1
+ {"version":3,"names":["memoize","useMemo","useSyncExternalStore","addAction","removeAction","isShallowEqual","PluginContextProvider","PluginErrorBoundary","getPlugins","getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","createElement","style","display","map","render","Plugin","key","value"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore( store.subscribe, store.getValue );\n\n\treturn (\n\t\t<div style={ { display: 'none' } }>\n\t\t\t{ plugins.map( ( { icon, name, render: Plugin } ) => (\n\t\t\t\t<PluginContextProvider\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ getPluginContext( icon, name ) }\n\t\t\t\t>\n\t\t\t\t\t<PluginErrorBoundary name={ name } onError={ onError }>\n\t\t\t\t\t\t<Plugin />\n\t\t\t\t\t</PluginErrorBoundary>\n\t\t\t\t</PluginContextProvider>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nexport default PluginArea;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,OAAO,EAAEC,oBAAoB,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,SAASC,qBAAqB,QAAQ,mBAAmB;AACzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,UAAU,QAAQ,WAAW;AAItC,M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C,KAC9CL,aAAA,CAAChB,qBAAqB;IACrBsB,GAAG,EAAGjB,IAAM;IACZkB,KAAK,EAAGpB,gBAAgB,CAAEC,IAAI,EAAEC,IAAK;EAAG,GAExCW,aAAA,CAACf,mBAAmB;IAACI,IAAI,EAAGA,IAAM;IAACG,OAAO,EAAGA;EAAS,GACrDQ,aAAA,CAACK,MAAM,MAAE,CACW,CACC,CACtB,CACE,CAAC;AAER;AAEA,eAAef,UAAU"}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
@@ -32,7 +32,7 @@ export function usePluginContext() {
32
32
  * expected to return object of props to
33
33
  * merge with the component's own props.
34
34
  *
35
- * @return {WPComponent} Enhanced component with injected context as props.
35
+ * @return {Component} Enhanced component with injected context as props.
36
36
  */
37
37
  export const withPluginContext = mapContextToProps => createHigherOrderComponent(OriginalComponent => {
38
38
  return props => createElement(Context.Consumer, null, context => createElement(OriginalComponent, {
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","createHigherOrderComponent","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","props","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {WPComponent} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;;AAQA,MAAMC,OAAO,GAAGH,aAAa,CAAmB;EAC/CI,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEH,OAAO,MAAMC,qBAAqB,GAAGH,OAAO,CAACI,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOP,UAAU,CAAEE,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC7BC,iBAGsB,IAEtBR,0BAA0B,CAAIS,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACbC,aAAA,CAACV,OAAO,CAACW,QAAQ,QACZC,OAAO,IACVF,aAAA,CAACF,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLF,iBAAiB,CAAEK,OAAO,EAAEH,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC"}
1
+ {"version":3,"names":["createContext","useContext","createHigherOrderComponent","Context","name","icon","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","props","createElement","Consumer","context"],"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { WPPlugin } from '../../api';\n\nexport interface PluginContext {\n\tname: null | WPPlugin[ 'name' ];\n\ticon: null | WPPlugin[ 'icon' ];\n}\n\nconst Context = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport const PluginContextProvider = Context.Provider;\n\n/**\n * A hook that returns the plugin context.\n *\n * @return {PluginContext} Plugin context\n */\nexport function usePluginContext() {\n\treturn useContext( Context );\n}\n\n/**\n * A Higher Order Component used to inject Plugin context to the\n * wrapped component.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;;AAQA,MAAMC,OAAO,GAAGH,aAAa,CAAmB;EAC/CI,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AAEH,OAAO,MAAMC,qBAAqB,GAAGH,OAAO,CAACI,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOP,UAAU,CAAEE,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC7BC,iBAGsB,IAEtBR,0BAA0B,CAAIS,iBAAiB,IAAM;EACpD,OAASC,KAAK,IACbC,aAAA,CAACV,OAAO,CAACW,QAAQ,QACZC,OAAO,IACVF,aAAA,CAACF,iBAAiB;IAAA,GACZC,KAAK;IAAA,GACLF,iBAAiB,CAAEK,OAAO,EAAEH,KAAM;EAAC,CACxC,CAEe,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC"}
@@ -1,5 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentType } from 'react';
1
5
  import type { IconType } from '@wordpress/components';
2
- import type { WPComponent } from '@wordpress/element';
3
6
  /**
4
7
  * Defined behavior of a plugin type.
5
8
  */
@@ -17,7 +20,7 @@ export interface WPPlugin {
17
20
  /**
18
21
  * A component containing the UI elements to be rendered.
19
22
  */
20
- render: WPComponent;
23
+ render: ComponentType;
21
24
  /**
22
25
  * The optional scope to be used when rendering inside a plugin area.
23
26
  * No scope by default.
@@ -35,12 +38,12 @@ type PluginSettings = Omit<WPPlugin, 'name'>;
35
38
  * @example
36
39
  * ```js
37
40
  * // Using ES5 syntax
38
- * var el = wp.element.createElement;
41
+ * var el = React.createElement;
39
42
  * var Fragment = wp.element.Fragment;
40
43
  * var PluginSidebar = wp.editPost.PluginSidebar;
41
44
  * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
42
45
  * var registerPlugin = wp.plugins.registerPlugin;
43
- * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
46
+ * var moreIcon = React.createElement( 'svg' ); //... svg element.
44
47
  *
45
48
  * function Component() {
46
49
  * return el(
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,KAAK,cAAc,GAAG,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAC;AAO/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,GACtB,cAAc,GAAG,IAAI,CAyDvB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,GAAG,SAAS,CAWrE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,GAAG,SAAS,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,QAAQ,EAAE,CAIvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,KAAK,cAAc,GAAG,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAC;AAO/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,GACtB,cAAc,GAAG,IAAI,CAyDvB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,GAAG,SAAS,CAWrE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,GAAG,SAAS,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAE,KAAK,CAAC,EAAE,MAAM,GAAI,QAAQ,EAAE,CAIvD"}
@@ -9,7 +9,7 @@ import type { WPPlugin } from '../../api';
9
9
  * @example
10
10
  * ```js
11
11
  * // Using ES5 syntax
12
- * var el = wp.element.createElement;
12
+ * var el = React.createElement;
13
13
  * var PluginArea = wp.plugins.PluginArea;
14
14
  *
15
15
  * function Layout() {
@@ -35,7 +35,7 @@ import type { WPPlugin } from '../../api';
35
35
  * );
36
36
  * ```
37
37
  *
38
- * @return {WPComponent} The component to be rendered.
38
+ * @return {Component} The component to be rendered.
39
39
  */
40
40
  declare function PluginArea({ scope, onError, }: {
41
41
  scope?: string;
@@ -22,7 +22,7 @@ export declare function usePluginContext(): PluginContext;
22
22
  * expected to return object of props to
23
23
  * merge with the component's own props.
24
24
  *
25
- * @return {WPComponent} Enhanced component with injected context as props.
25
+ * @return {Component} Enhanced component with injected context as props.
26
26
  */
27
27
  export declare const withPluginContext: (mapContextToProps: <T>(context: PluginContext, props: T) => T & PluginContext) => (Inner: import("react").ComponentType<any>) => (props: any) => JSX.Element;
28
28
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/plugins",
3
- "version": "6.10.6",
3
+ "version": "6.11.1",
4
4
  "description": "Plugins module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,12 +27,12 @@
27
27
  "types": "build-types",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/components": "^25.8.6",
31
- "@wordpress/compose": "^6.19.6",
32
- "@wordpress/element": "^5.19.6",
33
- "@wordpress/hooks": "^3.42.6",
34
- "@wordpress/icons": "^9.33.6",
35
- "@wordpress/is-shallow-equal": "^4.42.6",
30
+ "@wordpress/components": "^25.9.1",
31
+ "@wordpress/compose": "^6.20.0",
32
+ "@wordpress/element": "^5.20.0",
33
+ "@wordpress/hooks": "^3.43.0",
34
+ "@wordpress/icons": "^9.34.0",
35
+ "@wordpress/is-shallow-equal": "^4.43.0",
36
36
  "memize": "^2.0.1"
37
37
  },
38
38
  "peerDependencies": {
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "640c80ab0fb4e0e2bce87e33895939f257e674df"
45
+ "gitHead": "e17f760ed0dc11cce78157d7c2f2086b1b3c09d8"
46
46
  }
package/src/api/index.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import type { ComponentType } from 'react';
2
6
 
3
7
  /**
4
8
  * WordPress dependencies
@@ -6,7 +10,6 @@
6
10
  import { applyFilters, doAction } from '@wordpress/hooks';
7
11
  import { plugins as pluginsIcon } from '@wordpress/icons';
8
12
  import type { IconType } from '@wordpress/components';
9
- import type { WPComponent } from '@wordpress/element';
10
13
 
11
14
  /**
12
15
  * Defined behavior of a plugin type.
@@ -27,7 +30,7 @@ export interface WPPlugin {
27
30
  /**
28
31
  * A component containing the UI elements to be rendered.
29
32
  */
30
- render: WPComponent;
33
+ render: ComponentType;
31
34
 
32
35
  /**
33
36
  * The optional scope to be used when rendering inside a plugin area.
@@ -53,12 +56,12 @@ const plugins = {} as Record< string, WPPlugin >;
53
56
  * @example
54
57
  * ```js
55
58
  * // Using ES5 syntax
56
- * var el = wp.element.createElement;
59
+ * var el = React.createElement;
57
60
  * var Fragment = wp.element.Fragment;
58
61
  * var PluginSidebar = wp.editPost.PluginSidebar;
59
62
  * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
60
63
  * var registerPlugin = wp.plugins.registerPlugin;
61
- * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
64
+ * var moreIcon = React.createElement( 'svg' ); //... svg element.
62
65
  *
63
66
  * function Component() {
64
67
  * return el(
@@ -35,7 +35,7 @@ const getPluginContext = memoize(
35
35
  * @example
36
36
  * ```js
37
37
  * // Using ES5 syntax
38
- * var el = wp.element.createElement;
38
+ * var el = React.createElement;
39
39
  * var PluginArea = wp.plugins.PluginArea;
40
40
  *
41
41
  * function Layout() {
@@ -61,7 +61,7 @@ const getPluginContext = memoize(
61
61
  * );
62
62
  * ```
63
63
  *
64
- * @return {WPComponent} The component to be rendered.
64
+ * @return {Component} The component to be rendered.
65
65
  */
66
66
  function PluginArea( {
67
67
  scope,
@@ -38,7 +38,7 @@ export function usePluginContext() {
38
38
  * expected to return object of props to
39
39
  * merge with the component's own props.
40
40
  *
41
- * @return {WPComponent} Enhanced component with injected context as props.
41
+ * @return {Component} Enhanced component with injected context as props.
42
42
  */
43
43
  export const withPluginContext = (
44
44
  mapContextToProps: < T >(
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ // eslint-disable-next-line testing-library/no-manual-cleanup
4
5
  import { act, render, cleanup } from '@testing-library/react';
5
6
 
6
7
  /**