@wordpress/plugins 6.7.0 → 6.8.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +8 -0
  3. package/build/api/index.js +4 -19
  4. package/build/api/index.js.map +1 -1
  5. package/build/components/index.js +6 -3
  6. package/build/components/index.js.map +1 -1
  7. package/build/components/plugin-area/index.js +2 -15
  8. package/build/components/plugin-area/index.js.map +1 -1
  9. package/build/components/plugin-context/index.js +18 -11
  10. package/build/components/plugin-context/index.js.map +1 -1
  11. package/build/components/plugin-error-boundary/index.js +2 -10
  12. package/build/components/plugin-error-boundary/index.js.map +1 -1
  13. package/build/index.js +0 -4
  14. package/build/index.js.map +1 -1
  15. package/build-module/api/index.js +4 -14
  16. package/build-module/api/index.js.map +1 -1
  17. package/build-module/components/index.js +1 -1
  18. package/build-module/components/index.js.map +1 -1
  19. package/build-module/components/plugin-area/index.js +3 -9
  20. package/build-module/components/plugin-area/index.js.map +1 -1
  21. package/build-module/components/plugin-context/index.js +16 -9
  22. package/build-module/components/plugin-context/index.js.map +1 -1
  23. package/build-module/components/plugin-error-boundary/index.js +1 -7
  24. package/build-module/components/plugin-error-boundary/index.js.map +1 -1
  25. package/build-module/index.js.map +1 -1
  26. package/build-types/components/index.d.ts +1 -1
  27. package/build-types/components/plugin-area/index.d.ts +1 -0
  28. package/build-types/components/plugin-area/index.d.ts.map +1 -1
  29. package/build-types/components/plugin-context/index.d.ts +8 -2
  30. package/build-types/components/plugin-context/index.d.ts.map +1 -1
  31. package/build-types/components/plugin-error-boundary/index.d.ts +1 -1
  32. package/build-types/components/plugin-error-boundary/index.d.ts.map +1 -1
  33. package/package.json +10 -9
  34. package/src/components/index.js +1 -1
  35. package/src/components/plugin-context/index.tsx +14 -5
  36. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 6.8.0 (2023-08-16)
6
+
5
7
  ## 6.7.0 (2023-08-10)
6
8
 
7
9
  ## 6.6.0 (2023-07-20)
package/README.md CHANGED
@@ -182,6 +182,14 @@ _Returns_
182
182
 
183
183
  - `WPPlugin | undefined`: The previous plugin settings object, if it has been successfully unregistered; otherwise `undefined`.
184
184
 
185
+ #### usePluginContext
186
+
187
+ A hook that returns the plugin context.
188
+
189
+ _Returns_
190
+
191
+ - `PluginContext`: Plugin context
192
+
185
193
  #### withPluginContext
186
194
 
187
195
  A Higher Order Component used to inject Plugin context to the wrapped component.
@@ -7,11 +7,8 @@ exports.getPlugin = getPlugin;
7
7
  exports.getPlugins = getPlugins;
8
8
  exports.registerPlugin = registerPlugin;
9
9
  exports.unregisterPlugin = unregisterPlugin;
10
-
11
10
  var _hooks = require("@wordpress/hooks");
12
-
13
11
  var _icons = require("@wordpress/icons");
14
-
15
12
  /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
16
13
 
17
14
  /**
@@ -22,6 +19,7 @@ var _icons = require("@wordpress/icons");
22
19
  * Plugin definitions keyed by plugin name.
23
20
  */
24
21
  const plugins = {};
22
+
25
23
  /**
26
24
  * Registers a plugin to the editor.
27
25
  *
@@ -99,50 +97,41 @@ const plugins = {};
99
97
  *
100
98
  * @return The final plugin settings object.
101
99
  */
102
-
103
100
  function registerPlugin(name, settings) {
104
101
  if (typeof settings !== 'object') {
105
102
  console.error('No settings object provided!');
106
103
  return null;
107
104
  }
108
-
109
105
  if (typeof name !== 'string') {
110
106
  console.error('Plugin name must be string.');
111
107
  return null;
112
108
  }
113
-
114
109
  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
115
110
  console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
116
111
  return null;
117
112
  }
118
-
119
113
  if (plugins[name]) {
120
114
  console.error(`Plugin "${name}" is already registered.`);
121
115
  }
122
-
123
116
  settings = (0, _hooks.applyFilters)('plugins.registerPlugin', settings, name);
124
117
  const {
125
118
  render,
126
119
  scope
127
120
  } = settings;
128
-
129
121
  if (typeof render !== 'function') {
130
122
  console.error('The "render" property must be specified and must be a valid function.');
131
123
  return null;
132
124
  }
133
-
134
125
  if (scope) {
135
126
  if (typeof scope !== 'string') {
136
127
  console.error('Plugin scope must be string.');
137
128
  return null;
138
129
  }
139
-
140
130
  if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
141
131
  console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
142
132
  return null;
143
133
  }
144
134
  }
145
-
146
135
  plugins[name] = {
147
136
  name,
148
137
  icon: _icons.plugins,
@@ -151,6 +140,7 @@ function registerPlugin(name, settings) {
151
140
  (0, _hooks.doAction)('plugins.pluginRegistered', settings, name);
152
141
  return settings;
153
142
  }
143
+
154
144
  /**
155
145
  * Unregisters a plugin by name.
156
146
  *
@@ -175,19 +165,17 @@ function registerPlugin(name, settings) {
175
165
  * @return The previous plugin settings object, if it has been
176
166
  * successfully unregistered; otherwise `undefined`.
177
167
  */
178
-
179
-
180
168
  function unregisterPlugin(name) {
181
169
  if (!plugins[name]) {
182
170
  console.error('Plugin "' + name + '" is not registered.');
183
171
  return;
184
172
  }
185
-
186
173
  const oldPlugin = plugins[name];
187
174
  delete plugins[name];
188
175
  (0, _hooks.doAction)('plugins.pluginUnregistered', oldPlugin, name);
189
176
  return oldPlugin;
190
177
  }
178
+
191
179
  /**
192
180
  * Returns a registered plugin settings.
193
181
  *
@@ -195,11 +183,10 @@ function unregisterPlugin(name) {
195
183
  *
196
184
  * @return Plugin setting.
197
185
  */
198
-
199
-
200
186
  function getPlugin(name) {
201
187
  return plugins[name];
202
188
  }
189
+
203
190
  /**
204
191
  * Returns all registered plugins without a scope or for a given scope.
205
192
  *
@@ -208,8 +195,6 @@ function getPlugin(name) {
208
195
  *
209
196
  * @return The list of plugins without a scope or for a given scope.
210
197
  */
211
-
212
-
213
198
  function getPlugins(scope) {
214
199
  return Object.values(plugins).filter(plugin => plugin.scope === scope);
215
200
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/api/index.ts"],"names":["plugins","registerPlugin","name","settings","console","error","test","render","scope","icon","pluginsIcon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"mappings":";;;;;;;;;;AAKA;;AACA;;AANA;;AAEA;AACA;AACA;;AAoCA;AACA;AACA;AACA,MAAMA,OAAO,GAAG,EAAhB;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;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,cAAT,CACNC,IADM,EAENC,QAFM,EAGkB;AACxB,MAAK,OAAOA,QAAP,KAAoB,QAAzB,EAAoC;AACnCC,IAAAA,OAAO,CAACC,KAAR,CAAe,8BAAf;AACA,WAAO,IAAP;AACA;;AACD,MAAK,OAAOH,IAAP,KAAgB,QAArB,EAAgC;AAC/BE,IAAAA,OAAO,CAACC,KAAR,CAAe,6BAAf;AACA,WAAO,IAAP;AACA;;AACD,MAAK,CAAE,oBAAoBC,IAApB,CAA0BJ,IAA1B,CAAP,EAA0C;AACzCE,IAAAA,OAAO,CAACC,KAAR,CACC,2HADD;AAGA,WAAO,IAAP;AACA;;AACD,MAAKL,OAAO,CAAEE,IAAF,CAAZ,EAAuB;AACtBE,IAAAA,OAAO,CAACC,KAAR,CAAgB,WAAWH,IAAM,0BAAjC;AACA;;AAEDC,EAAAA,QAAQ,GAAG,yBACV,wBADU,EAEV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SAAOF,OAAO,CAAEE,IAAF,CAAd;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASY,UAAT,CAAqBN,KAArB,EAAkD;AACxD,SAAOO,MAAM,CAACC,MAAP,CAAehB,OAAf,EAAyBiB,MAAzB,CACJC,MAAF,IAAcA,MAAM,CAACV,KAAP,KAAiBA,KADzB,CAAP;AAGA","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"]}
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,QAAwB,EACA;EACxB,IAAK,OAAOA,QAAQ,KAAK,QAAQ,EAAG;IACnCC,OAAO,CAACC,KAAK,CAAE,8BAA+B,CAAC;IAC/C,OAAO,IAAI;EACZ;EACA,IAAK,OAAOH,IAAI,KAAK,QAAQ,EAAG;IAC/BE,OAAO,CAACC,KAAK,CAAE,6BAA8B,CAA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E,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,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -11,14 +10,18 @@ Object.defineProperty(exports, "PluginArea", {
11
10
  return _pluginArea.default;
12
11
  }
13
12
  });
13
+ Object.defineProperty(exports, "usePluginContext", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _pluginContext.usePluginContext;
17
+ }
18
+ });
14
19
  Object.defineProperty(exports, "withPluginContext", {
15
20
  enumerable: true,
16
21
  get: function () {
17
22
  return _pluginContext.withPluginContext;
18
23
  }
19
24
  });
20
-
21
25
  var _pluginArea = _interopRequireDefault(require("./plugin-area"));
22
-
23
26
  var _pluginContext = require("./plugin-context");
24
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { withPluginContext } from './plugin-context';\n"]}
1
+ {"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.js"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA"}
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _element = require("@wordpress/element");
11
-
12
9
  var _memize = _interopRequireDefault(require("memize"));
13
-
14
10
  var _hooks = require("@wordpress/hooks");
15
-
16
11
  var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
17
-
18
12
  var _pluginContext = require("../plugin-context");
19
-
20
13
  var _pluginErrorBoundary = require("../plugin-error-boundary");
21
-
22
14
  var _api = require("../../api");
23
-
24
15
  /**
25
16
  * External dependencies
26
17
  */
@@ -32,10 +23,12 @@ var _api = require("../../api");
32
23
  /**
33
24
  * Internal dependencies
34
25
  */
26
+
35
27
  const getPluginContext = (0, _memize.default)((icon, name) => ({
36
28
  icon,
37
29
  name
38
30
  }));
31
+
39
32
  /**
40
33
  * A component that renders all plugin fills in a hidden div.
41
34
  *
@@ -73,7 +66,6 @@ const getPluginContext = (0, _memize.default)((icon, name) => ({
73
66
  *
74
67
  * @return {WPComponent} The component to be rendered.
75
68
  */
76
-
77
69
  function PluginArea({
78
70
  scope,
79
71
  onError
@@ -89,17 +81,13 @@ function PluginArea({
89
81
  (0, _hooks.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
90
82
  };
91
83
  },
92
-
93
84
  getValue() {
94
85
  const nextValue = (0, _api.getPlugins)(scope);
95
-
96
86
  if (!(0, _isShallowEqual.default)(lastValue, nextValue)) {
97
87
  lastValue = nextValue;
98
88
  }
99
-
100
89
  return lastValue;
101
90
  }
102
-
103
91
  };
104
92
  }, [scope]);
105
93
  const plugins = (0, _element.useSyncExternalStore)(store.subscribe, store.getValue);
@@ -119,7 +107,6 @@ function PluginArea({
119
107
  onError: onError
120
108
  }, (0, _element.createElement)(Plugin, null)))));
121
109
  }
122
-
123
110
  var _default = PluginArea;
124
111
  exports.default = _default;
125
112
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"names":["getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","display","map","render","Plugin"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAOA,MAAMA,gBAAgB,GAAG,qBACxB,CAAEC,IAAF,EAAiCC,IAAjC,MAAsE;AACrED,EAAAA,IADqE;AAErEC,EAAAA;AAFqE,CAAtE,CADwB,CAAzB;AAOA;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,UAAT,CAAqB;AACpBC,EAAAA,KADoB;AAEpBC,EAAAA;AAFoB,CAArB,EAMI;AACH,QAAMC,KAAK,GAAG,sBAAS,MAAM;AAC5B,QAAIC,SAAqB,GAAG,EAA5B;AAEA,WAAO;AACNC,MAAAA,SAAS,CACRC,QADQ,EAKP;AACD,8BACC,0BADD,EAEC,6CAFD,EAGCA,QAHD;AAKA,8BACC,4BADD,EAEC,+CAFD,EAGCA,QAHD;AAKA,eAAO,MAAM;AACZ,mCACC,0BADD,EAEC,6CAFD;AAIA,mCACC,4BADD,EAEC,+CAFD;AAIA,SATD;AAUA,OA3BK;;AA4BNC,MAAAA,QAAQ,GAAG;AACV,cAAMC,SAAS,GAAG,qBAAYP,KAAZ,CAAlB;;AAEA,YAAK,CAAE,6BAAgBG,SAAhB,EAA2BI,SAA3B,CAAP,EAAgD;AAC/CJ,UAAAA,SAAS,GAAGI,SAAZ;AACA;;AAED,eAAOJ,SAAP;AACA;;AApCK,KAAP;AAsCA,GAzCa,EAyCX,CAAEH,KAAF,CAzCW,CAAd;AA2CA,QAAMQ,OAAO,GAAG,mCAAsBN,KAAK,CAACE,SAA5B,EAAuCF,KAAK,CAACI,QAA7C,CAAhB;AAEA,SACC;AAAK,IAAA,KAAK,EAAG;AAAEG,MAAAA,OAAO,EAAE;AAAX;AAAb,KACGD,OAAO,CAACE,GAAR,CAAa,CAAE;AAAEb,IAAAA,IAAF;AAAQC,IAAAA,IAAR;AAAca,IAAAA,MAAM,EAAEC;AAAtB,GAAF,KACd,4BAAC,oCAAD;AACC,IAAA,GAAG,EAAGd,IADP;AAEC,IAAA,KAAK,EAAGF,gBAAgB,CAAEC,IAAF,EAAQC,IAAR;AAFzB,KAIC,4BAAC,wCAAD;AAAqB,IAAA,IAAI,EAAGA,IAA5B;AAAmC,IAAA,OAAO,EAAGG;AAA7C,KACC,4BAAC,MAAD,OADD,CAJD,CADC,CADH,CADD;AAcA;;eAEcF,U","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"]}
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,GAAAC,OAAA;AALA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAF,sBAAA,CAAAF,OAAA;AAKA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,MAAMQ,gBAAgB,GAAG,IAAAC,eAAO,EAC/B,CAAEC,IAA6B,EAAEC,IAA6B,MAAQ;EACrED,IAAI;EACJC;AACD,CAAC,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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B,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"}
@@ -3,23 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withPluginContext = exports.PluginContextProvider = void 0;
7
-
6
+ exports.PluginContextProvider = void 0;
7
+ exports.usePluginContext = usePluginContext;
8
+ exports.withPluginContext = void 0;
8
9
  var _element = require("@wordpress/element");
9
-
10
10
  var _compose = require("@wordpress/compose");
11
-
12
11
  /**
13
12
  * WordPress dependencies
14
13
  */
15
- const {
16
- Consumer,
17
- Provider
18
- } = (0, _element.createContext)({
14
+
15
+ const Context = (0, _element.createContext)({
19
16
  name: null,
20
17
  icon: null
21
18
  });
22
- exports.PluginContextProvider = Provider;
19
+ const PluginContextProvider = Context.Provider;
20
+
21
+ /**
22
+ * A hook that returns the plugin context.
23
+ *
24
+ * @return {PluginContext} Plugin context
25
+ */
26
+ exports.PluginContextProvider = PluginContextProvider;
27
+ function usePluginContext() {
28
+ return (0, _element.useContext)(Context);
29
+ }
23
30
 
24
31
  /**
25
32
  * A Higher Order Component used to inject Plugin context to the
@@ -32,10 +39,10 @@ exports.PluginContextProvider = Provider;
32
39
  * @return {WPComponent} Enhanced component with injected context as props.
33
40
  */
34
41
  const withPluginContext = mapContextToProps => (0, _compose.createHigherOrderComponent)(OriginalComponent => {
35
- return props => (0, _element.createElement)(Consumer, null, context => (0, _element.createElement)(OriginalComponent, { ...props,
42
+ return props => (0, _element.createElement)(Context.Consumer, null, context => (0, _element.createElement)(OriginalComponent, {
43
+ ...props,
36
44
  ...mapContextToProps(context, props)
37
45
  }));
38
46
  }, 'withPluginContext');
39
-
40
47
  exports.withPluginContext = withPluginContext;
41
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/components/plugin-context/index.tsx"],"names":["Consumer","Provider","name","icon","withPluginContext","mapContextToProps","OriginalComponent","props","context"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAcA,MAAM;AAAEA,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,IAAyB,4BAAgC;AAC9DC,EAAAA,IAAI,EAAE,IADwD;AAE9DC,EAAAA,IAAI,EAAE;AAFwD,CAAhC,CAA/B;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAC7BC,iBADgC,IAMhC,yCAA8BC,iBAAF,IAAyB;AACpD,SAASC,KAAF,IACN,4BAAC,QAAD,QACKC,OAAF,IACD,4BAAC,iBAAD,OACMD,KADN;AAAA,OAEMF,iBAAiB,CAAEG,OAAF,EAAWD,KAAX;AAFvB,IAFF,CADD;AAUA,CAXD,EAWG,mBAXH,CANM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } 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 { Consumer, Provider } = createContext< PluginContext >( {\n\tname: null,\n\ticon: null,\n} );\n\nexport { Provider as PluginContextProvider };\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<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</Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"]}
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"}
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PluginErrorBoundary = void 0;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  /**
11
9
  * WordPress dependencies
12
10
  */
11
+
13
12
  class PluginErrorBoundary extends _element.Component {
14
13
  /**
15
14
  * @param {Object} props
@@ -20,37 +19,30 @@ class PluginErrorBoundary extends _element.Component {
20
19
  hasError: false
21
20
  };
22
21
  }
23
-
24
22
  static getDerivedStateFromError() {
25
23
  return {
26
24
  hasError: true
27
25
  };
28
26
  }
27
+
29
28
  /**
30
29
  * @param {Error} error Error object passed by React.
31
30
  */
32
-
33
-
34
31
  componentDidCatch(error) {
35
32
  const {
36
33
  name,
37
34
  onError
38
35
  } = this.props;
39
-
40
36
  if (onError) {
41
37
  onError(name, error);
42
38
  }
43
39
  }
44
-
45
40
  render() {
46
41
  if (!this.state.hasError) {
47
42
  return this.props.children;
48
43
  }
49
-
50
44
  return null;
51
45
  }
52
-
53
46
  }
54
-
55
47
  exports.PluginErrorBoundary = PluginErrorBoundary;
56
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"names":["PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,mBAAN,SAAkCC,kBAAlC,CAA4C;AAClD;AACD;AACA;AACCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AACA,SAAKC,KAAL,GAAa;AACZC,MAAAA,QAAQ,EAAE;AADE,KAAb;AAGA;;AAE8B,SAAxBC,wBAAwB,GAAG;AACjC,WAAO;AAAED,MAAAA,QAAQ,EAAE;AAAZ,KAAP;AACA;AAED;AACD;AACA;;;AACCE,EAAAA,iBAAiB,CAAEC,KAAF,EAAU;AAC1B,UAAM;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,QAAoB,KAAKP,KAA/B;;AACA,QAAKO,OAAL,EAAe;AACdA,MAAAA,OAAO,CAAED,IAAF,EAAQD,KAAR,CAAP;AACA;AACD;;AAEDG,EAAAA,MAAM,GAAG;AACR,QAAK,CAAE,KAAKP,KAAL,CAAWC,QAAlB,EAA6B;AAC5B,aAAO,KAAKF,KAAL,CAAWS,QAAlB;AACA;;AAED,WAAO,IAAP;AACA;;AA/BiD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"]}
1
+ {"version":3,"names":["_element","require","PluginErrorBoundary","Component","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children","exports"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\nexport class PluginErrorBoundary extends Component {\n\t/**\n\t * @param {Object} props\n\t */\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError() {\n\t\treturn { hasError: true };\n\t}\n\n\t/**\n\t * @param {Error} error Error object passed by React.\n\t */\n\tcomponentDidCatch( error ) {\n\t\tconst { name, onError } = this.props;\n\t\tif ( onError ) {\n\t\t\tonError( name, error );\n\t\t}\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,mBAAmB,SAASC,kBAAS,CAAC;EAClD;AACD;AACA;EACCC,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAG;IACjC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;;EAEA;AACD;AACA;EACCE,iBAAiBA,CAAEC,KAAK,EAAG;IAC1B,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAG,IAAI,CAACP,KAAK;IACpC,IAAKO,OAAO,EAAG;MACdA,OAAO,CAAED,IAAI,EAAED,KAAM,CAAC;IACvB;EACD;EAEAG,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA"}
package/build/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _components = require("./components");
8
-
9
7
  Object.keys(_components).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _components[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_components).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _api = require("./api");
21
-
22
18
  Object.keys(_api).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _api[key]) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/index.js"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './components';\nexport * from './api';\n"]}
1
+ {"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.js"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,IAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,IAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,IAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,IAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -5,11 +5,11 @@
5
5
  */
6
6
  import { applyFilters, doAction } from '@wordpress/hooks';
7
7
  import { plugins as pluginsIcon } from '@wordpress/icons';
8
-
9
8
  /**
10
9
  * Plugin definitions keyed by plugin name.
11
10
  */
12
11
  const plugins = {};
12
+
13
13
  /**
14
14
  * Registers a plugin to the editor.
15
15
  *
@@ -87,50 +87,41 @@ const plugins = {};
87
87
  *
88
88
  * @return The final plugin settings object.
89
89
  */
90
-
91
90
  export function registerPlugin(name, settings) {
92
91
  if (typeof settings !== 'object') {
93
92
  console.error('No settings object provided!');
94
93
  return null;
95
94
  }
96
-
97
95
  if (typeof name !== 'string') {
98
96
  console.error('Plugin name must be string.');
99
97
  return null;
100
98
  }
101
-
102
99
  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
103
100
  console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
104
101
  return null;
105
102
  }
106
-
107
103
  if (plugins[name]) {
108
104
  console.error(`Plugin "${name}" is already registered.`);
109
105
  }
110
-
111
106
  settings = applyFilters('plugins.registerPlugin', settings, name);
112
107
  const {
113
108
  render,
114
109
  scope
115
110
  } = settings;
116
-
117
111
  if (typeof render !== 'function') {
118
112
  console.error('The "render" property must be specified and must be a valid function.');
119
113
  return null;
120
114
  }
121
-
122
115
  if (scope) {
123
116
  if (typeof scope !== 'string') {
124
117
  console.error('Plugin scope must be string.');
125
118
  return null;
126
119
  }
127
-
128
120
  if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
129
121
  console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
130
122
  return null;
131
123
  }
132
124
  }
133
-
134
125
  plugins[name] = {
135
126
  name,
136
127
  icon: pluginsIcon,
@@ -139,6 +130,7 @@ export function registerPlugin(name, settings) {
139
130
  doAction('plugins.pluginRegistered', settings, name);
140
131
  return settings;
141
132
  }
133
+
142
134
  /**
143
135
  * Unregisters a plugin by name.
144
136
  *
@@ -163,18 +155,17 @@ export function registerPlugin(name, settings) {
163
155
  * @return The previous plugin settings object, if it has been
164
156
  * successfully unregistered; otherwise `undefined`.
165
157
  */
166
-
167
158
  export function unregisterPlugin(name) {
168
159
  if (!plugins[name]) {
169
160
  console.error('Plugin "' + name + '" is not registered.');
170
161
  return;
171
162
  }
172
-
173
163
  const oldPlugin = plugins[name];
174
164
  delete plugins[name];
175
165
  doAction('plugins.pluginUnregistered', oldPlugin, name);
176
166
  return oldPlugin;
177
167
  }
168
+
178
169
  /**
179
170
  * Returns a registered plugin settings.
180
171
  *
@@ -182,10 +173,10 @@ export function unregisterPlugin(name) {
182
173
  *
183
174
  * @return Plugin setting.
184
175
  */
185
-
186
176
  export function getPlugin(name) {
187
177
  return plugins[name];
188
178
  }
179
+
189
180
  /**
190
181
  * Returns all registered plugins without a scope or for a given scope.
191
182
  *
@@ -194,7 +185,6 @@ export function getPlugin(name) {
194
185
  *
195
186
  * @return The list of plugins without a scope or for a given scope.
196
187
  */
197
-
198
188
  export function getPlugins(scope) {
199
189
  return Object.values(plugins).filter(plugin => plugin.scope === scope);
200
190
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/plugins/src/api/index.ts"],"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,QAAvB,QAAuC,kBAAvC;AACA,SAASC,OAAO,IAAIC,WAApB,QAAuC,kBAAvC;;AAkCA;AACA;AACA;AACA,MAAMD,OAAO,GAAG,EAAhB;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;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,cAAT,CACNC,IADM,EAENC,QAFM,EAGkB;AACxB,MAAK,OAAOA,QAAP,KAAoB,QAAzB,EAAoC;AACnCC,IAAAA,OAAO,CAACC,KAAR,CAAe,8BAAf;AACA,WAAO,IAAP;AACA;;AACD,MAAK,OAAOH,IAAP,KAAgB,QAArB,EAAgC;AAC/BE,IAAAA,OAAO,CAACC,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,CAAEH,OAAO,CAAEG,IAAF,CAAd,EAAyB;AACxBE,IAAAA,OAAO,CAACC,KAAR,CAAe,aAAaH,IAAb,GAAoB,sBAAnC;AACA;AACA;;AACD,QAAMS,SAAS,GAAGZ,OAAO,CAAEG,IAAF,CAAzB;AACA,SAAOH,OAAO,CAAEG,IAAF,CAAd;AAEAJ,EAAAA,QAAQ,CAAE,4BAAF,EAAgCa,SAAhC,EAA2CT,IAA3C,CAAR;AAEA,SAAOS,SAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,SAAT,CAAoBV,IAApB,EAAyD;AAC/D,SAAOH,OAAO,CAAEG,IAAF,CAAd;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,UAAT,CAAqBL,KAArB,EAAkD;AACxD,SAAOM,MAAM,CAACC,MAAP,CAAehB,OAAf,EAAyBiB,MAAzB,CACJC,MAAF,IAAcA,MAAM,CAACT,KAAP,KAAiBA,KADzB,CAAP;AAGA","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"]}
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;A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AAE,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,3 +1,3 @@
1
1
  export { default as PluginArea } from './plugin-area';
2
- export { withPluginContext } from './plugin-context';
2
+ export { usePluginContext, withPluginContext } from './plugin-context';
3
3
  //# sourceMappingURL=index.js.map