@wordpress/plugins 7.32.0 → 7.32.1-next.47f435fc9.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,64 +1,17 @@
1
- /**
2
- * External dependencies
3
- */
4
- import memoize from 'memize';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useMemo, useSyncExternalStore } from '@wordpress/element';
10
- import { addAction, removeAction } from '@wordpress/hooks';
11
- import isShallowEqual from '@wordpress/is-shallow-equal';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { PluginContextProvider } from '../plugin-context';
17
- import { PluginErrorBoundary } from '../plugin-error-boundary';
18
- import { getPlugins } from '../../api';
19
- import { jsx as _jsx } from "react/jsx-runtime";
20
- const getPluginContext = memoize((icon, name) => ({
21
- icon,
22
- name
23
- }));
24
-
25
- /**
26
- * A component that renders all plugin fills in a hidden div.
27
- *
28
- * @param props
29
- * @param props.scope
30
- * @param props.onError
31
- * @example
32
- * ```js
33
- * // Using ES5 syntax
34
- * var el = React.createElement;
35
- * var PluginArea = wp.plugins.PluginArea;
36
- *
37
- * function Layout() {
38
- * return el(
39
- * 'div',
40
- * { scope: 'my-page' },
41
- * 'Content of the page',
42
- * PluginArea
43
- * );
44
- * }
45
- * ```
46
- *
47
- * @example
48
- * ```js
49
- * // Using ESNext syntax
50
- * import { PluginArea } from '@wordpress/plugins';
51
- *
52
- * const Layout = () => (
53
- * <div>
54
- * Content of the page
55
- * <PluginArea scope="my-page" />
56
- * </div>
57
- * );
58
- * ```
59
- *
60
- * @return {Component} The component to be rendered.
61
- */
1
+ import { jsx } from "react/jsx-runtime";
2
+ import memoize from "memize";
3
+ import { useMemo, useSyncExternalStore } from "@wordpress/element";
4
+ import { addAction, removeAction } from "@wordpress/hooks";
5
+ import isShallowEqual from "@wordpress/is-shallow-equal";
6
+ import { PluginContextProvider } from "../plugin-context";
7
+ import { PluginErrorBoundary } from "../plugin-error-boundary";
8
+ import { getPlugins } from "../../api";
9
+ const getPluginContext = memoize(
10
+ (icon, name) => ({
11
+ icon,
12
+ name
13
+ })
14
+ );
62
15
  function PluginArea({
63
16
  scope,
64
17
  onError
@@ -67,11 +20,25 @@ function PluginArea({
67
20
  let lastValue = [];
68
21
  return {
69
22
  subscribe(listener) {
70
- addAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
71
- addAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
23
+ addAction(
24
+ "plugins.pluginRegistered",
25
+ "core/plugins/plugin-area/plugins-registered",
26
+ listener
27
+ );
28
+ addAction(
29
+ "plugins.pluginUnregistered",
30
+ "core/plugins/plugin-area/plugins-unregistered",
31
+ listener
32
+ );
72
33
  return () => {
73
- removeAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
74
- removeAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
34
+ removeAction(
35
+ "plugins.pluginRegistered",
36
+ "core/plugins/plugin-area/plugins-registered"
37
+ );
38
+ removeAction(
39
+ "plugins.pluginUnregistered",
40
+ "core/plugins/plugin-area/plugins-unregistered"
41
+ );
75
42
  };
76
43
  },
77
44
  getValue() {
@@ -83,24 +50,22 @@ function PluginArea({
83
50
  }
84
51
  };
85
52
  }, [scope]);
86
- const plugins = useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
87
- return /*#__PURE__*/_jsx("div", {
88
- style: {
89
- display: 'none'
90
- },
91
- children: plugins.map(({
92
- icon,
93
- name,
94
- render: Plugin
95
- }) => /*#__PURE__*/_jsx(PluginContextProvider, {
53
+ const plugins = useSyncExternalStore(
54
+ store.subscribe,
55
+ store.getValue,
56
+ store.getValue
57
+ );
58
+ return /* @__PURE__ */ jsx("div", { style: { display: "none" }, children: plugins.map(({ icon, name, render: Plugin }) => /* @__PURE__ */ jsx(
59
+ PluginContextProvider,
60
+ {
96
61
  value: getPluginContext(icon, name),
97
- children: /*#__PURE__*/_jsx(PluginErrorBoundary, {
98
- name: name,
99
- onError: onError,
100
- children: /*#__PURE__*/_jsx(Plugin, {})
101
- })
102
- }, name))
103
- });
62
+ children: /* @__PURE__ */ jsx(PluginErrorBoundary, { name, onError, children: /* @__PURE__ */ jsx(Plugin, {}) })
63
+ },
64
+ name
65
+ )) });
104
66
  }
105
- export default PluginArea;
106
- //# sourceMappingURL=index.js.map
67
+ var plugin_area_default = PluginArea;
68
+ export {
69
+ plugin_area_default as default
70
+ };
71
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["memoize","useMemo","useSyncExternalStore","addAction","removeAction","isShallowEqual","PluginContextProvider","PluginErrorBoundary","getPlugins","jsx","_jsx","getPluginContext","icon","name","PluginArea","scope","onError","store","lastValue","subscribe","listener","getValue","nextValue","plugins","style","display","children","map","render","Plugin","value"],"sources":["@wordpress/plugins/src/components/plugin-area/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { PluginContextProvider } from '../plugin-context';\nimport { PluginErrorBoundary } from '../plugin-error-boundary';\nimport { getPlugins } from '../../api';\nimport type { PluginContext } from '../plugin-context';\nimport type { WPPlugin } from '../../api';\n\nconst getPluginContext = memoize(\n\t( icon: PluginContext[ 'icon' ], name: PluginContext[ 'name' ] ) => ( {\n\t\ticon,\n\t\tname,\n\t} )\n);\n\n/**\n * A component that renders all plugin fills in a hidden div.\n *\n * @param props\n * @param props.scope\n * @param props.onError\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var PluginArea = wp.plugins.PluginArea;\n *\n * function Layout() {\n * \treturn el(\n * \t\t'div',\n * \t\t{ scope: 'my-page' },\n * \t\t'Content of the page',\n * \t\tPluginArea\n * \t);\n * }\n * ```\n *\n * @example\n * ```js\n * // Using ESNext syntax\n * import { PluginArea } from '@wordpress/plugins';\n *\n * const Layout = () => (\n * \t<div>\n * \t\tContent of the page\n * \t\t<PluginArea scope=\"my-page\" />\n * \t</div>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nfunction PluginArea( {\n\tscope,\n\tonError,\n}: {\n\tscope?: string;\n\tonError?: ( name: WPPlugin[ 'name' ], error: Error ) => void;\n} ) {\n\tconst store = useMemo( () => {\n\t\tlet lastValue: WPPlugin[] = [];\n\n\t\treturn {\n\t\t\tsubscribe(\n\t\t\t\tlistener: (\n\t\t\t\t\tplugin: Omit< WPPlugin, 'name' >,\n\t\t\t\t\tname: WPPlugin[ 'name' ]\n\t\t\t\t) => void\n\t\t\t) {\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-registered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\taddAction(\n\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered',\n\t\t\t\t\tlistener\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginRegistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-registered'\n\t\t\t\t\t);\n\t\t\t\t\tremoveAction(\n\t\t\t\t\t\t'plugins.pluginUnregistered',\n\t\t\t\t\t\t'core/plugins/plugin-area/plugins-unregistered'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\tconst nextValue = getPlugins( scope );\n\n\t\t\t\tif ( ! isShallowEqual( lastValue, nextValue ) ) {\n\t\t\t\t\tlastValue = nextValue;\n\t\t\t\t}\n\n\t\t\t\treturn lastValue;\n\t\t\t},\n\t\t};\n\t}, [ scope ] );\n\n\tconst plugins = useSyncExternalStore(\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":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA,SAASC,OAAO,EAAEC,oBAAoB,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,SAASC,qBAAqB,QAAQ,mBAAmB;AACzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,UAAU,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIvC,MAAMC,gBAAgB,GAAGX,OAAO,CAC/B,CAAEY,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,GAAGhB,OAAO,CAAE,MAAM;IAC5B,IAAIiB,SAAqB,GAAG,EAAE;IAE9B,OAAO;MACNC,SAASA,CACRC,QAGS,EACR;QACDjB,SAAS,CACR,0BAA0B,EAC1B,6CAA6C,EAC7CiB,QACD,CAAC;QACDjB,SAAS,CACR,4BAA4B,EAC5B,+CAA+C,EAC/CiB,QACD,CAAC;QACD,OAAO,MAAM;UACZhB,YAAY,CACX,0BAA0B,EAC1B,6CACD,CAAC;UACDA,YAAY,CACX,4BAA4B,EAC5B,+CACD,CAAC;QACF,CAAC;MACF,CAAC;MACDiB,QAAQA,CAAA,EAAG;QACV,MAAMC,SAAS,GAAGd,UAAU,CAAEO,KAAM,CAAC;QAErC,IAAK,CAAEV,cAAc,CAAEa,SAAS,EAAEI,SAAU,CAAC,EAAG;UAC/CJ,SAAS,GAAGI,SAAS;QACtB;QAEA,OAAOJ,SAAS;MACjB;IACD,CAAC;EACF,CAAC,EAAE,CAAEH,KAAK,CAAG,CAAC;EAEd,MAAMQ,OAAO,GAAGrB,oBAAoB,CACnCe,KAAK,CAACE,SAAS,EACfF,KAAK,CAACI,QAAQ,EACdJ,KAAK,CAACI,QACP,CAAC;EAED,oBACCX,IAAA;IAAKc,KAAK,EAAG;MAAEC,OAAO,EAAE;IAAO,CAAG;IAAAC,QAAA,EAC/BH,OAAO,CAACI,GAAG,CAAE,CAAE;MAAEf,IAAI;MAAEC,IAAI;MAAEe,MAAM,EAAEC;IAAO,CAAC,kBAC9CnB,IAAA,CAACJ,qBAAqB;MAErBwB,KAAK,EAAGnB,gBAAgB,CAAEC,IAAI,EAAEC,IAAK,CAAG;MAAAa,QAAA,eAExChB,IAAA,CAACH,mBAAmB;QAACM,IAAI,EAAGA,IAAM;QAACG,OAAO,EAAGA,OAAS;QAAAU,QAAA,eACrDhB,IAAA,CAACmB,MAAM,IAAE;MAAC,CACU;IAAC,GALhBhB,IAMgB,CACtB;EAAC,CACC,CAAC;AAER;AAEA,eAAeC,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": "AAiIM;AA9HN,OAAO,aAAa;AAKpB,SAAS,SAAS,4BAA4B;AAC9C,SAAS,WAAW,oBAAoB;AACxC,OAAO,oBAAoB;AAK3B,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAI3B,MAAM,mBAAmB;AAAA,EACxB,CAAE,MAA+B,UAAqC;AAAA,IACrE;AAAA,IACA;AAAA,EACD;AACD;AAuCA,SAAS,WAAY;AAAA,EACpB;AAAA,EACA;AACD,GAGI;AACH,QAAM,QAAQ,QAAS,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,YAAY,WAAY,KAAM;AAEpC,YAAK,CAAE,eAAgB,WAAW,SAAU,GAAI;AAC/C,sBAAY;AAAA,QACb;AAEA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD,GAAG,CAAE,KAAM,CAAE;AAEb,QAAM,UAAU;AAAA,IACf,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACP;AAEA,SACC,oBAAC,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,8BAAC,uBAAoB,MAAc,SAClC,8BAAC,UAAO,GACT;AAAA;AAAA,IALM;AAAA,EAMP,CACC,GACH;AAEF;AAEA,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -1,52 +1,32 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext, useContext } from '@wordpress/element';
5
- import { createHigherOrderComponent } from '@wordpress/compose';
6
- import deprecated from '@wordpress/deprecated';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "@wordpress/element";
3
+ import { createHigherOrderComponent } from "@wordpress/compose";
4
+ import deprecated from "@wordpress/deprecated";
12
5
  const Context = createContext({
13
6
  name: null,
14
7
  icon: null
15
8
  });
16
- Context.displayName = 'PluginContext';
17
- export const PluginContextProvider = Context.Provider;
18
-
19
- /**
20
- * A hook that returns the plugin context.
21
- *
22
- * @return {PluginContext} Plugin context
23
- */
24
- export function usePluginContext() {
9
+ Context.displayName = "PluginContext";
10
+ const PluginContextProvider = Context.Provider;
11
+ function usePluginContext() {
25
12
  return useContext(Context);
26
13
  }
27
-
28
- /**
29
- * A Higher Order Component used to inject Plugin context to the
30
- * wrapped component.
31
- *
32
- * @deprecated 6.8.0 Use `usePluginContext` hook instead.
33
- *
34
- * @param mapContextToProps Function called on every context change,
35
- * expected to return object of props to
36
- * merge with the component's own props.
37
- *
38
- * @return {Component} Enhanced component with injected context as props.
39
- */
40
- export const withPluginContext = mapContextToProps => createHigherOrderComponent(OriginalComponent => {
41
- deprecated('wp.plugins.withPluginContext', {
42
- since: '6.8.0',
43
- alternative: 'wp.plugins.usePluginContext'
14
+ const withPluginContext = (mapContextToProps) => createHigherOrderComponent((OriginalComponent) => {
15
+ deprecated("wp.plugins.withPluginContext", {
16
+ since: "6.8.0",
17
+ alternative: "wp.plugins.usePluginContext"
44
18
  });
45
- return props => /*#__PURE__*/_jsx(Context.Consumer, {
46
- children: context => /*#__PURE__*/_jsx(OriginalComponent, {
19
+ return (props) => /* @__PURE__ */ jsx(Context.Consumer, { children: (context) => /* @__PURE__ */ jsx(
20
+ OriginalComponent,
21
+ {
47
22
  ...props,
48
23
  ...mapContextToProps(context, props)
49
- })
50
- });
51
- }, 'withPluginContext');
52
- //# sourceMappingURL=index.js.map
24
+ }
25
+ ) });
26
+ }, "withPluginContext");
27
+ export {
28
+ PluginContextProvider,
29
+ usePluginContext,
30
+ withPluginContext
31
+ };
32
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createContext","useContext","createHigherOrderComponent","deprecated","jsx","_jsx","Context","name","icon","displayName","PluginContextProvider","Provider","usePluginContext","withPluginContext","mapContextToProps","OriginalComponent","since","alternative","props","Consumer","children","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';\nimport deprecated from '@wordpress/deprecated';\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} );\nContext.displayName = 'PluginContext';\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 * @deprecated 6.8.0 Use `usePluginContext` hook instead.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\tdeprecated( 'wp.plugins.withPluginContext', {\n\t\t\tsince: '6.8.0',\n\t\t\talternative: 'wp.plugins.usePluginContext',\n\t\t} );\n\t\treturn ( props ) => (\n\t\t\t<Context.Consumer>\n\t\t\t\t{ ( context ) => (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t{ ...mapContextToProps( context, props ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Context.Consumer>\n\t\t);\n\t}, 'withPluginContext' );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAC9D,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAUA,MAAMC,OAAO,GAAGN,aAAa,CAAmB;EAC/CO,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AACHF,OAAO,CAACG,WAAW,GAAG,eAAe;AAErC,OAAO,MAAMC,qBAAqB,GAAGJ,OAAO,CAACK,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAOX,UAAU,CAAEK,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,iBAAiB,GAC7BC,iBAGsB,IAEtBZ,0BAA0B,CAAIa,iBAAiB,IAAM;EACpDZ,UAAU,CAAE,8BAA8B,EAAE;IAC3Ca,KAAK,EAAE,OAAO;IACdC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAASC,KAAK,iBACbb,IAAA,CAACC,OAAO,CAACa,QAAQ;IAAAC,QAAA,EACZC,OAAO,iBACVhB,IAAA,CAACU,iBAAiB;MAAA,GACZG,KAAK;MAAA,GACLJ,iBAAiB,CAAEO,OAAO,EAAEH,KAAM;IAAC,CACxC;EACD,CACgB,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/plugin-context/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\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} );\nContext.displayName = 'PluginContext';\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 * @deprecated 6.8.0 Use `usePluginContext` hook instead.\n *\n * @param mapContextToProps Function called on every context change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @return {Component} Enhanced component with injected context as props.\n */\nexport const withPluginContext = (\n\tmapContextToProps: < T >(\n\t\tcontext: PluginContext,\n\t\tprops: T\n\t) => T & PluginContext\n) =>\n\tcreateHigherOrderComponent( ( OriginalComponent ) => {\n\t\tdeprecated( 'wp.plugins.withPluginContext', {\n\t\t\tsince: '6.8.0',\n\t\t\talternative: 'wp.plugins.usePluginContext',\n\t\t} );\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"],
5
+ "mappings": "AA4DK;AAzDL,SAAS,eAAe,kBAAkB;AAC1C,SAAS,kCAAkC;AAC3C,OAAO,gBAAgB;AAYvB,MAAM,UAAU,cAAgC;AAAA,EAC/C,MAAM;AAAA,EACN,MAAM;AACP,CAAE;AACF,QAAQ,cAAc;AAEf,MAAM,wBAAwB,QAAQ;AAOtC,SAAS,mBAAmB;AAClC,SAAO,WAAY,OAAQ;AAC5B;AAcO,MAAM,oBAAoB,CAChC,sBAKA,2BAA4B,CAAE,sBAAuB;AACpD,aAAY,gCAAgC;AAAA,IAC3C,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AACF,SAAO,CAAE,UACR,oBAAC,QAAQ,UAAR,EACE,WAAE,YACH;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAG,kBAAmB,SAAS,KAAM;AAAA;AAAA,EACxC,GAEF;AAEF,GAAG,mBAAoB;",
6
+ "names": []
7
+ }
@@ -1,13 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Component } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
-
10
- export class PluginErrorBoundary extends Component {
1
+ import { Component } from "@wordpress/element";
2
+ class PluginErrorBoundary extends Component {
11
3
  constructor(props) {
12
4
  super(props);
13
5
  this.state = {
@@ -15,15 +7,10 @@ export class PluginErrorBoundary extends Component {
15
7
  };
16
8
  }
17
9
  static getDerivedStateFromError() {
18
- return {
19
- hasError: true
20
- };
10
+ return { hasError: true };
21
11
  }
22
12
  componentDidCatch(error) {
23
- const {
24
- name,
25
- onError
26
- } = this.props;
13
+ const { name, onError } = this.props;
27
14
  if (onError) {
28
15
  onError(name, error);
29
16
  }
@@ -35,4 +22,7 @@ export class PluginErrorBoundary extends Component {
35
22
  return null;
36
23
  }
37
24
  }
38
- //# sourceMappingURL=index.js.map
25
+ export {
26
+ PluginErrorBoundary
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Component","PluginErrorBoundary","constructor","props","state","hasError","getDerivedStateFromError","componentDidCatch","error","name","onError","render","children"],"sources":["@wordpress/plugins/src/components/plugin-error-boundary/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPluginErrorBoundaryProps as Props,\n\tPluginErrorBoundaryState as State,\n} from '../../types';\n\nexport class PluginErrorBoundary extends Component< Props, State > {\n\tconstructor( props: Props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError(): State {\n\t\treturn { hasError: true };\n\t}\n\n\tcomponentDidCatch( error: Error ): void {\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(): React.ReactNode {\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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;;AAMA,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAiB;EAClEE,WAAWA,CAAEC,KAAY,EAAG;IAC3B,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MACZC,QAAQ,EAAE;IACX,CAAC;EACF;EAEA,OAAOC,wBAAwBA,CAAA,EAAU;IACxC,OAAO;MAAED,QAAQ,EAAE;IAAK,CAAC;EAC1B;EAEAE,iBAAiBA,CAAEC,KAAY,EAAS;IACvC,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,EAAoB;IACzB,IAAK,CAAE,IAAI,CAACP,KAAK,CAACC,QAAQ,EAAG;MAC5B,OAAO,IAAI,CAACF,KAAK,CAACS,QAAQ;IAC3B;IAEA,OAAO,IAAI;EACZ;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/plugin-error-boundary/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPluginErrorBoundaryProps as Props,\n\tPluginErrorBoundaryState as State,\n} from '../../types';\n\nexport class PluginErrorBoundary extends Component< Props, State > {\n\tconstructor( props: Props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError(): State {\n\t\treturn { hasError: true };\n\t}\n\n\tcomponentDidCatch( error: Error ): void {\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(): React.ReactNode {\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"],
5
+ "mappings": "AAGA,SAAS,iBAAiB;AAUnB,MAAM,4BAA4B,UAA0B;AAAA,EAClE,YAAa,OAAe;AAC3B,UAAO,KAAM;AACb,SAAK,QAAQ;AAAA,MACZ,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EAEA,OAAO,2BAAkC;AACxC,WAAO,EAAE,UAAU,KAAK;AAAA,EACzB;AAAA,EAEA,kBAAmB,OAAqB;AACvC,UAAM,EAAE,MAAM,QAAQ,IAAI,KAAK;AAC/B,QAAK,SAAU;AACd,cAAS,MAAM,KAAM;AAAA,IACtB;AAAA,EACD;AAAA,EAEA,SAA0B;AACzB,QAAK,CAAE,KAAK,MAAM,UAAW;AAC5B,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -1,3 +1,3 @@
1
- export * from './components';
2
- export * from './api';
3
- //# sourceMappingURL=index.js.map
1
+ export * from "./components";
2
+ export * from "./api";
3
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/plugins/src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './api';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export * from './components';\nexport * from './api';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ //# sourceMappingURL=types.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/plugins/src/types.ts"],"sourcesContent":["/**\n * Props for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryProps {\n\t/**\n\t * The name of the plugin that may encounter an error.\n\t */\n\tname: string;\n\t/**\n\t * The child components to render.\n\t */\n\tchildren: React.ReactNode;\n\t/**\n\t * Callback function called when an error occurs.\n\t */\n\tonError?: ( name: string, error: Error ) => void;\n}\n\n/**\n * State for the PluginErrorBoundary component.\n */\nexport interface PluginErrorBoundaryState {\n\thasError: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/plugins",
3
- "version": "7.32.0",
3
+ "version": "7.32.1-next.47f435fc9.0",
4
4
  "description": "Plugins module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -24,18 +24,25 @@
24
24
  },
25
25
  "main": "build/index.js",
26
26
  "module": "build-module/index.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./build-types/index.d.ts",
30
+ "import": "./build-module/index.js",
31
+ "require": "./build/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
27
35
  "react-native": "src/index",
28
36
  "wpScript": true,
29
37
  "types": "build-types",
30
38
  "dependencies": {
31
- "@babel/runtime": "7.25.7",
32
- "@wordpress/components": "^30.5.0",
33
- "@wordpress/compose": "^7.32.0",
34
- "@wordpress/deprecated": "^4.32.0",
35
- "@wordpress/element": "^6.32.0",
36
- "@wordpress/hooks": "^4.32.0",
37
- "@wordpress/icons": "^10.32.0",
38
- "@wordpress/is-shallow-equal": "^5.32.0",
39
+ "@wordpress/components": "^30.6.1-next.47f435fc9.0",
40
+ "@wordpress/compose": "^7.32.1-next.47f435fc9.0",
41
+ "@wordpress/deprecated": "^4.32.1-next.47f435fc9.0",
42
+ "@wordpress/element": "^6.32.1-next.47f435fc9.0",
43
+ "@wordpress/hooks": "^4.32.1-next.47f435fc9.0",
44
+ "@wordpress/icons": "^11.0.1-next.47f435fc9.0",
45
+ "@wordpress/is-shallow-equal": "^5.32.1-next.47f435fc9.0",
39
46
  "memize": "^2.0.1"
40
47
  },
41
48
  "peerDependencies": {
@@ -45,5 +52,5 @@
45
52
  "publishConfig": {
46
53
  "access": "public"
47
54
  },
48
- "gitHead": "a030b4c0e0695239b942c7dc18511782b64f10ed"
55
+ "gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
49
56
  }