@wordpress/plugins 7.32.0 → 7.32.1-next.b8c8708f3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,177 +1,82 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var api_exports = {};
20
+ __export(api_exports, {
21
+ getPlugin: () => getPlugin,
22
+ getPlugins: () => getPlugins,
23
+ registerPlugin: () => registerPlugin,
24
+ unregisterPlugin: () => unregisterPlugin
5
25
  });
6
- exports.getPlugin = getPlugin;
7
- exports.getPlugins = getPlugins;
8
- exports.registerPlugin = registerPlugin;
9
- exports.unregisterPlugin = unregisterPlugin;
10
- var _hooks = require("@wordpress/hooks");
11
- var _icons = require("@wordpress/icons");
12
- /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
13
- /**
14
- * External dependencies
15
- */
16
-
17
- /**
18
- * WordPress dependencies
19
- */
20
-
21
- /**
22
- * Defined behavior of a plugin type.
23
- */
24
-
25
- /**
26
- * Plugin definitions keyed by plugin name.
27
- */
26
+ module.exports = __toCommonJS(api_exports);
27
+ var import_hooks = require("@wordpress/hooks");
28
+ var import_icons = require("@wordpress/icons");
28
29
  const plugins = {};
29
-
30
- /**
31
- * Registers a plugin to the editor.
32
- *
33
- * @param name A string identifying the plugin. Must be
34
- * unique across all registered plugins.
35
- * @param settings The settings for this plugin.
36
- *
37
- * @example
38
- * ```js
39
- * // Using ES5 syntax
40
- * var el = React.createElement;
41
- * var Fragment = wp.element.Fragment;
42
- * var PluginSidebar = wp.editor.PluginSidebar;
43
- * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
44
- * var registerPlugin = wp.plugins.registerPlugin;
45
- * var moreIcon = React.createElement( 'svg' ); //... svg element.
46
- *
47
- * function Component() {
48
- * return el(
49
- * Fragment,
50
- * {},
51
- * el(
52
- * PluginSidebarMoreMenuItem,
53
- * {
54
- * target: 'sidebar-name',
55
- * },
56
- * 'My Sidebar'
57
- * ),
58
- * el(
59
- * PluginSidebar,
60
- * {
61
- * name: 'sidebar-name',
62
- * title: 'My Sidebar',
63
- * },
64
- * 'Content of the sidebar'
65
- * )
66
- * );
67
- * }
68
- * registerPlugin( 'plugin-name', {
69
- * icon: moreIcon,
70
- * render: Component,
71
- * scope: 'my-page',
72
- * } );
73
- * ```
74
- *
75
- * @example
76
- * ```js
77
- * // Using ESNext syntax
78
- * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
79
- * import { registerPlugin } from '@wordpress/plugins';
80
- * import { more } from '@wordpress/icons';
81
- *
82
- * const Component = () => (
83
- * <>
84
- * <PluginSidebarMoreMenuItem
85
- * target="sidebar-name"
86
- * >
87
- * My Sidebar
88
- * </PluginSidebarMoreMenuItem>
89
- * <PluginSidebar
90
- * name="sidebar-name"
91
- * title="My Sidebar"
92
- * >
93
- * Content of the sidebar
94
- * </PluginSidebar>
95
- * </>
96
- * );
97
- *
98
- * registerPlugin( 'plugin-name', {
99
- * icon: more,
100
- * render: Component,
101
- * scope: 'my-page',
102
- * } );
103
- * ```
104
- *
105
- * @return The final plugin settings object.
106
- */
107
30
  function registerPlugin(name, settings) {
108
- if (typeof settings !== 'object') {
109
- console.error('No settings object provided!');
31
+ if (typeof settings !== "object") {
32
+ console.error("No settings object provided!");
110
33
  return null;
111
34
  }
112
- if (typeof name !== 'string') {
113
- console.error('Plugin name must be string.');
35
+ if (typeof name !== "string") {
36
+ console.error("Plugin name must be string.");
114
37
  return null;
115
38
  }
116
39
  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
117
- console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
40
+ console.error(
41
+ 'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'
42
+ );
118
43
  return null;
119
44
  }
120
45
  if (plugins[name]) {
121
46
  console.error(`Plugin "${name}" is already registered.`);
122
47
  }
123
- settings = (0, _hooks.applyFilters)('plugins.registerPlugin', settings, name);
124
- const {
125
- render,
126
- scope
127
- } = settings;
128
- if (typeof render !== 'function') {
129
- console.error('The "render" property must be specified and must be a valid function.');
48
+ settings = (0, import_hooks.applyFilters)(
49
+ "plugins.registerPlugin",
50
+ settings,
51
+ name
52
+ );
53
+ const { render, scope } = settings;
54
+ if (typeof render !== "function") {
55
+ console.error(
56
+ 'The "render" property must be specified and must be a valid function.'
57
+ );
130
58
  return null;
131
59
  }
132
60
  if (scope) {
133
- if (typeof scope !== 'string') {
134
- console.error('Plugin scope must be string.');
61
+ if (typeof scope !== "string") {
62
+ console.error("Plugin scope must be string.");
135
63
  return null;
136
64
  }
137
65
  if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
138
- console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
66
+ console.error(
67
+ 'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'
68
+ );
139
69
  return null;
140
70
  }
141
71
  }
142
72
  plugins[name] = {
143
73
  name,
144
- icon: _icons.plugins,
74
+ icon: import_icons.plugins,
145
75
  ...settings
146
76
  };
147
- (0, _hooks.doAction)('plugins.pluginRegistered', settings, name);
77
+ (0, import_hooks.doAction)("plugins.pluginRegistered", settings, name);
148
78
  return settings;
149
79
  }
150
-
151
- /**
152
- * Unregisters a plugin by name.
153
- *
154
- * @param name Plugin name.
155
- *
156
- * @example
157
- * ```js
158
- * // Using ES5 syntax
159
- * var unregisterPlugin = wp.plugins.unregisterPlugin;
160
- *
161
- * unregisterPlugin( 'plugin-name' );
162
- * ```
163
- *
164
- * @example
165
- * ```js
166
- * // Using ESNext syntax
167
- * import { unregisterPlugin } from '@wordpress/plugins';
168
- *
169
- * unregisterPlugin( 'plugin-name' );
170
- * ```
171
- *
172
- * @return The previous plugin settings object, if it has been
173
- * successfully unregistered; otherwise `undefined`.
174
- */
175
80
  function unregisterPlugin(name) {
176
81
  if (!plugins[name]) {
177
82
  console.error('Plugin "' + name + '" is not registered.');
@@ -179,30 +84,22 @@ function unregisterPlugin(name) {
179
84
  }
180
85
  const oldPlugin = plugins[name];
181
86
  delete plugins[name];
182
- (0, _hooks.doAction)('plugins.pluginUnregistered', oldPlugin, name);
87
+ (0, import_hooks.doAction)("plugins.pluginUnregistered", oldPlugin, name);
183
88
  return oldPlugin;
184
89
  }
185
-
186
- /**
187
- * Returns a registered plugin settings.
188
- *
189
- * @param name Plugin name.
190
- *
191
- * @return Plugin setting.
192
- */
193
90
  function getPlugin(name) {
194
91
  return plugins[name];
195
92
  }
196
-
197
- /**
198
- * Returns all registered plugins without a scope or for a given scope.
199
- *
200
- * @param scope The scope to be used when rendering inside
201
- * a plugin area. No scope by default.
202
- *
203
- * @return The list of plugins without a scope or for a given scope.
204
- */
205
93
  function getPlugins(scope) {
206
- return Object.values(plugins).filter(plugin => plugin.scope === scope);
94
+ return Object.values(plugins).filter(
95
+ (plugin) => plugin.scope === scope
96
+ );
207
97
  }
208
- //# sourceMappingURL=index.js.map
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ getPlugin,
101
+ getPlugins,
102
+ registerPlugin,
103
+ unregisterPlugin
104
+ });
105
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
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.editor.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editor.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/editor';\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":"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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/api/index.ts"],
4
+ "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.editor.PluginSidebar;\n * var PluginSidebarMoreMenuItem = wp.editor.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/editor';\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAuC;AACvC,mBAAuC;AAoCvC,MAAM,UAAU,CAAC;AA+EV,SAAS,eACf,MACA,UACwB;AACxB,MAAK,OAAO,aAAa,UAAW;AACnC,YAAQ,MAAO,8BAA+B;AAC9C,WAAO;AAAA,EACR;AACA,MAAK,OAAO,SAAS,UAAW;AAC/B,YAAQ,MAAO,6BAA8B;AAC7C,WAAO;AAAA,EACR;AACA,MAAK,CAAE,oBAAoB,KAAM,IAAK,GAAI;AACzC,YAAQ;AAAA,MACP;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACA,MAAK,QAAS,IAAK,GAAI;AACtB,YAAQ,MAAO,WAAY,IAAK,0BAA2B;AAAA,EAC5D;AAEA,iBAAW;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,EAAE,QAAQ,MAAM,IAAI;AAE1B,MAAK,OAAO,WAAW,YAAa;AACnC,YAAQ;AAAA,MACP;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAEA,MAAK,OAAQ;AACZ,QAAK,OAAO,UAAU,UAAW;AAChC,cAAQ,MAAO,8BAA+B;AAC9C,aAAO;AAAA,IACR;AAEA,QAAK,CAAE,oBAAoB,KAAM,KAAM,GAAI;AAC1C,cAAQ;AAAA,QACP;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,UAAS,IAAK,IAAI;AAAA,IACjB;AAAA,IACA,MAAM,aAAAA;AAAA,IACN,GAAG;AAAA,EACJ;AAEA,6BAAU,4BAA4B,UAAU,IAAK;AAErD,SAAO;AACR;AA0BO,SAAS,iBAAkB,MAAqC;AACtE,MAAK,CAAE,QAAS,IAAK,GAAI;AACxB,YAAQ,MAAO,aAAa,OAAO,sBAAuB;AAC1D;AAAA,EACD;AACA,QAAM,YAAY,QAAS,IAAK;AAChC,SAAO,QAAS,IAAK;AAErB,6BAAU,8BAA8B,WAAW,IAAK;AAExD,SAAO;AACR;AASO,SAAS,UAAW,MAAqC;AAC/D,SAAO,QAAS,IAAK;AACtB;AAUO,SAAS,WAAY,OAA6B;AACxD,SAAO,OAAO,OAAQ,OAAQ,EAAE;AAAA,IAC/B,CAAE,WAAY,OAAO,UAAU;AAAA,EAChC;AACD;",
6
+ "names": ["pluginsIcon"]
7
+ }
@@ -1,27 +1,44 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "PluginArea", {
8
- enumerable: true,
9
- get: function () {
10
- return _pluginArea.default;
11
- }
12
- });
13
- Object.defineProperty(exports, "usePluginContext", {
14
- enumerable: true,
15
- get: function () {
16
- return _pluginContext.usePluginContext;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var components_exports = {};
30
+ __export(components_exports, {
31
+ PluginArea: () => import_plugin_area.default,
32
+ usePluginContext: () => import_plugin_context.usePluginContext,
33
+ withPluginContext: () => import_plugin_context.withPluginContext
18
34
  });
19
- Object.defineProperty(exports, "withPluginContext", {
20
- enumerable: true,
21
- get: function () {
22
- return _pluginContext.withPluginContext;
23
- }
35
+ module.exports = __toCommonJS(components_exports);
36
+ var import_plugin_area = __toESM(require("./plugin-area"));
37
+ var import_plugin_context = require("./plugin-context");
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ PluginArea,
41
+ usePluginContext,
42
+ withPluginContext
24
43
  });
25
- var _pluginArea = _interopRequireDefault(require("./plugin-area"));
26
- var _pluginContext = require("./plugin-context");
27
- //# sourceMappingURL=index.js.map
44
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_pluginArea","_interopRequireDefault","require","_pluginContext"],"sources":["@wordpress/plugins/src/components/index.ts"],"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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/components/index.ts"],
4
+ "sourcesContent": ["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAsC;AACtC,4BAAoD;",
6
+ "names": []
7
+ }
@@ -1,114 +1,101 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var plugin_area_exports = {};
30
+ __export(plugin_area_exports, {
31
+ default: () => plugin_area_default
6
32
  });
7
- exports.default = void 0;
8
- var _memize = _interopRequireDefault(require("memize"));
9
- var _element = require("@wordpress/element");
10
- var _hooks = require("@wordpress/hooks");
11
- var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
12
- var _pluginContext = require("../plugin-context");
13
- var _pluginErrorBoundary = require("../plugin-error-boundary");
14
- var _api = require("../../api");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- /**
17
- * External dependencies
18
- */
19
-
20
- /**
21
- * WordPress dependencies
22
- */
23
-
24
- /**
25
- * Internal dependencies
26
- */
27
-
28
- const getPluginContext = (0, _memize.default)((icon, name) => ({
29
- icon,
30
- name
31
- }));
32
-
33
- /**
34
- * A component that renders all plugin fills in a hidden div.
35
- *
36
- * @param props
37
- * @param props.scope
38
- * @param props.onError
39
- * @example
40
- * ```js
41
- * // Using ES5 syntax
42
- * var el = React.createElement;
43
- * var PluginArea = wp.plugins.PluginArea;
44
- *
45
- * function Layout() {
46
- * return el(
47
- * 'div',
48
- * { scope: 'my-page' },
49
- * 'Content of the page',
50
- * PluginArea
51
- * );
52
- * }
53
- * ```
54
- *
55
- * @example
56
- * ```js
57
- * // Using ESNext syntax
58
- * import { PluginArea } from '@wordpress/plugins';
59
- *
60
- * const Layout = () => (
61
- * <div>
62
- * Content of the page
63
- * <PluginArea scope="my-page" />
64
- * </div>
65
- * );
66
- * ```
67
- *
68
- * @return {Component} The component to be rendered.
69
- */
33
+ module.exports = __toCommonJS(plugin_area_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_memize = __toESM(require("memize"));
36
+ var import_element = require("@wordpress/element");
37
+ var import_hooks = require("@wordpress/hooks");
38
+ var import_is_shallow_equal = __toESM(require("@wordpress/is-shallow-equal"));
39
+ var import_plugin_context = require("../plugin-context");
40
+ var import_plugin_error_boundary = require("../plugin-error-boundary");
41
+ var import_api = require("../../api");
42
+ const getPluginContext = (0, import_memize.default)(
43
+ (icon, name) => ({
44
+ icon,
45
+ name
46
+ })
47
+ );
70
48
  function PluginArea({
71
49
  scope,
72
50
  onError
73
51
  }) {
74
- const store = (0, _element.useMemo)(() => {
52
+ const store = (0, import_element.useMemo)(() => {
75
53
  let lastValue = [];
76
54
  return {
77
55
  subscribe(listener) {
78
- (0, _hooks.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
79
- (0, _hooks.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
56
+ (0, import_hooks.addAction)(
57
+ "plugins.pluginRegistered",
58
+ "core/plugins/plugin-area/plugins-registered",
59
+ listener
60
+ );
61
+ (0, import_hooks.addAction)(
62
+ "plugins.pluginUnregistered",
63
+ "core/plugins/plugin-area/plugins-unregistered",
64
+ listener
65
+ );
80
66
  return () => {
81
- (0, _hooks.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
82
- (0, _hooks.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
67
+ (0, import_hooks.removeAction)(
68
+ "plugins.pluginRegistered",
69
+ "core/plugins/plugin-area/plugins-registered"
70
+ );
71
+ (0, import_hooks.removeAction)(
72
+ "plugins.pluginUnregistered",
73
+ "core/plugins/plugin-area/plugins-unregistered"
74
+ );
83
75
  };
84
76
  },
85
77
  getValue() {
86
- const nextValue = (0, _api.getPlugins)(scope);
87
- if (!(0, _isShallowEqual.default)(lastValue, nextValue)) {
78
+ const nextValue = (0, import_api.getPlugins)(scope);
79
+ if (!(0, import_is_shallow_equal.default)(lastValue, nextValue)) {
88
80
  lastValue = nextValue;
89
81
  }
90
82
  return lastValue;
91
83
  }
92
84
  };
93
85
  }, [scope]);
94
- const plugins = (0, _element.useSyncExternalStore)(store.subscribe, store.getValue, store.getValue);
95
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
96
- style: {
97
- display: 'none'
98
- },
99
- children: plugins.map(({
100
- icon,
101
- name,
102
- render: Plugin
103
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_pluginContext.PluginContextProvider, {
86
+ const plugins = (0, import_element.useSyncExternalStore)(
87
+ store.subscribe,
88
+ store.getValue,
89
+ store.getValue
90
+ );
91
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "none" }, children: plugins.map(({ icon, name, render: Plugin }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ import_plugin_context.PluginContextProvider,
93
+ {
104
94
  value: getPluginContext(icon, name),
105
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pluginErrorBoundary.PluginErrorBoundary, {
106
- name: name,
107
- onError: onError,
108
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Plugin, {})
109
- })
110
- }, name))
111
- });
95
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_error_boundary.PluginErrorBoundary, { name, onError, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plugin, {}) })
96
+ },
97
+ name
98
+ )) });
112
99
  }
113
- var _default = exports.default = PluginArea;
114
- //# sourceMappingURL=index.js.map
100
+ var plugin_area_default = PluginArea;
101
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_memize","_interopRequireDefault","require","_element","_hooks","_isShallowEqual","_pluginContext","_pluginErrorBoundary","_api","_jsxRuntime","getPluginContext","memoize","icon","name","PluginArea","scope","onError","store","useMemo","lastValue","subscribe","listener","addAction","removeAction","getValue","nextValue","getPlugins","isShallowEqual","plugins","useSyncExternalStore","jsx","style","display","children","map","render","Plugin","PluginContextProvider","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(\n\t\tstore.subscribe,\n\t\tstore.getValue,\n\t\tstore.getValue\n\t);\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;AAAuC,IAAAO,WAAA,GAAAP,OAAA;AAjBvC;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;AACA;AACA;AACA;AACA;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,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC5B,IAAIC,SAAqB,GAAG,EAAE;IAE9B,OAAO;MACNC,SAASA,CACRC,QAGS,EACR;QACD,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,6CAA6C,EAC7CD,QACD,CAAC;QACD,IAAAC,gBAAS,EACR,4BAA4B,EAC5B,+CAA+C,EAC/CD,QACD,CAAC;QACD,OAAO,MAAM;UACZ,IAAAE,mBAAY,EACX,0BAA0B,EAC1B,6CACD,CAAC;UACD,IAAAA,mBAAY,EACX,4BAA4B,EAC5B,+CACD,CAAC;QACF,CAAC;MACF,CAAC;MACDC,QAAQA,CAAA,EAAG;QACV,MAAMC,SAAS,GAAG,IAAAC,eAAU,EAAEX,KAAM,CAAC;QAErC,IAAK,CAAE,IAAAY,uBAAc,EAAER,SAAS,EAAEM,SAAU,CAAC,EAAG;UAC/CN,SAAS,GAAGM,SAAS;QACtB;QAEA,OAAON,SAAS;MACjB;IACD,CAAC;EACF,CAAC,EAAE,CAAEJ,KAAK,CAAG,CAAC;EAEd,MAAMa,OAAO,GAAG,IAAAC,6BAAoB,EACnCZ,KAAK,CAACG,SAAS,EACfH,KAAK,CAACO,QAAQ,EACdP,KAAK,CAACO,QACP,CAAC;EAED,oBACC,IAAAf,WAAA,CAAAqB,GAAA;IAAKC,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO,CAAG;IAAAC,QAAA,EAC/BL,OAAO,CAACM,GAAG,CAAE,CAAE;MAAEtB,IAAI;MAAEC,IAAI;MAAEsB,MAAM,EAAEC;IAAO,CAAC,kBAC9C,IAAA3B,WAAA,CAAAqB,GAAA,EAACxB,cAAA,CAAA+B,qBAAqB;MAErBC,KAAK,EAAG5B,gBAAgB,CAAEE,IAAI,EAAEC,IAAK,CAAG;MAAAoB,QAAA,eAExC,IAAAxB,WAAA,CAAAqB,GAAA,EAACvB,oBAAA,CAAAgC,mBAAmB;QAAC1B,IAAI,EAAGA,IAAM;QAACG,OAAO,EAAGA,OAAS;QAAAiB,QAAA,eACrD,IAAAxB,WAAA,CAAAqB,GAAA,EAACM,MAAM,IAAE;MAAC,CACU;IAAC,GALhBvB,IAMgB,CACtB;EAAC,CACC,CAAC;AAER;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc5B,UAAU","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/plugin-area/index.tsx"],
4
+ "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(\n\t\tstore.subscribe,\n\t\tstore.getValue,\n\t\tstore.getValue\n\t);\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiIM;AA9HN,oBAAoB;AAKpB,qBAA8C;AAC9C,mBAAwC;AACxC,8BAA2B;AAK3B,4BAAsC;AACtC,mCAAoC;AACpC,iBAA2B;AAI3B,MAAM,uBAAmB,cAAAA;AAAA,EACxB,CAAE,MAA+B,UAAqC;AAAA,IACrE;AAAA,IACA;AAAA,EACD;AACD;AAuCA,SAAS,WAAY;AAAA,EACpB;AAAA,EACA;AACD,GAGI;AACH,QAAM,YAAQ,wBAAS,MAAM;AAC5B,QAAI,YAAwB,CAAC;AAE7B,WAAO;AAAA,MACN,UACC,UAIC;AACD;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,eAAO,MAAM;AACZ;AAAA,YACC;AAAA,YACA;AAAA,UACD;AACA;AAAA,YACC;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,WAAW;AACV,cAAM,gBAAY,uBAAY,KAAM;AAEpC,YAAK,KAAE,wBAAAC,SAAgB,WAAW,SAAU,GAAI;AAC/C,sBAAY;AAAA,QACb;AAEA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD,GAAG,CAAE,KAAM,CAAE;AAEb,QAAM,cAAU;AAAA,IACf,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACP;AAEA,SACC,4CAAC,SAAI,OAAQ,EAAE,SAAS,OAAO,GAC5B,kBAAQ,IAAK,CAAE,EAAE,MAAM,MAAM,QAAQ,OAAO,MAC7C;AAAA,IAAC;AAAA;AAAA,MAEA,OAAQ,iBAAkB,MAAM,IAAK;AAAA,MAErC,sDAAC,oDAAoB,MAAc,SAClC,sDAAC,UAAO,GACT;AAAA;AAAA,IALM;AAAA,EAMP,CACC,GACH;AAEF;AAEA,IAAO,sBAAQ;",
6
+ "names": ["memoize", "isShallowEqual"]
7
+ }