@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,63 +1,68 @@
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_context_exports = {};
30
+ __export(plugin_context_exports, {
31
+ PluginContextProvider: () => PluginContextProvider,
32
+ usePluginContext: () => usePluginContext,
33
+ withPluginContext: () => withPluginContext
6
34
  });
7
- exports.PluginContextProvider = void 0;
8
- exports.usePluginContext = usePluginContext;
9
- exports.withPluginContext = void 0;
10
- var _element = require("@wordpress/element");
11
- var _compose = require("@wordpress/compose");
12
- var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
13
- var _jsxRuntime = require("react/jsx-runtime");
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
-
22
- const Context = (0, _element.createContext)({
35
+ module.exports = __toCommonJS(plugin_context_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_element = require("@wordpress/element");
38
+ var import_compose = require("@wordpress/compose");
39
+ var import_deprecated = __toESM(require("@wordpress/deprecated"));
40
+ const Context = (0, import_element.createContext)({
23
41
  name: null,
24
42
  icon: null
25
43
  });
26
- Context.displayName = 'PluginContext';
27
- const PluginContextProvider = exports.PluginContextProvider = Context.Provider;
28
-
29
- /**
30
- * A hook that returns the plugin context.
31
- *
32
- * @return {PluginContext} Plugin context
33
- */
44
+ Context.displayName = "PluginContext";
45
+ const PluginContextProvider = Context.Provider;
34
46
  function usePluginContext() {
35
- return (0, _element.useContext)(Context);
47
+ return (0, import_element.useContext)(Context);
36
48
  }
37
-
38
- /**
39
- * A Higher Order Component used to inject Plugin context to the
40
- * wrapped component.
41
- *
42
- * @deprecated 6.8.0 Use `usePluginContext` hook instead.
43
- *
44
- * @param mapContextToProps Function called on every context change,
45
- * expected to return object of props to
46
- * merge with the component's own props.
47
- *
48
- * @return {Component} Enhanced component with injected context as props.
49
- */
50
- const withPluginContext = mapContextToProps => (0, _compose.createHigherOrderComponent)(OriginalComponent => {
51
- (0, _deprecated.default)('wp.plugins.withPluginContext', {
52
- since: '6.8.0',
53
- alternative: 'wp.plugins.usePluginContext'
49
+ const withPluginContext = (mapContextToProps) => (0, import_compose.createHigherOrderComponent)((OriginalComponent) => {
50
+ (0, import_deprecated.default)("wp.plugins.withPluginContext", {
51
+ since: "6.8.0",
52
+ alternative: "wp.plugins.usePluginContext"
54
53
  });
55
- return props => /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Consumer, {
56
- children: context => /*#__PURE__*/(0, _jsxRuntime.jsx)(OriginalComponent, {
54
+ return (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Consumer, { children: (context) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ OriginalComponent,
56
+ {
57
57
  ...props,
58
58
  ...mapContextToProps(context, props)
59
- })
60
- });
61
- }, 'withPluginContext');
62
- exports.withPluginContext = withPluginContext;
63
- //# sourceMappingURL=index.js.map
59
+ }
60
+ ) });
61
+ }, "withPluginContext");
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ PluginContextProvider,
65
+ usePluginContext,
66
+ withPluginContext
67
+ });
68
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_element","require","_compose","_deprecated","_interopRequireDefault","_jsxRuntime","Context","createContext","name","icon","displayName","PluginContextProvider","exports","Provider","usePluginContext","useContext","withPluginContext","mapContextToProps","createHigherOrderComponent","OriginalComponent","deprecated","since","alternative","props","jsx","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":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA+C,IAAAI,WAAA,GAAAJ,OAAA;AAL/C;AACA;AACA;;AAKA;AACA;AACA;;AAQA,MAAMK,OAAO,GAAG,IAAAC,sBAAa,EAAmB;EAC/CC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE;AACP,CAAE,CAAC;AACHH,OAAO,CAACI,WAAW,GAAG,eAAe;AAE9B,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAGL,OAAO,CAACO,QAAQ;;AAErD;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAAG;EAClC,OAAO,IAAAC,mBAAU,EAAET,OAAQ,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,iBAAiB,GAC7BC,iBAGsB,IAEtB,IAAAC,mCAA0B,EAAIC,iBAAiB,IAAM;EACpD,IAAAC,mBAAU,EAAE,8BAA8B,EAAE;IAC3CC,KAAK,EAAE,OAAO;IACdC,WAAW,EAAE;EACd,CAAE,CAAC;EACH,OAASC,KAAK,iBACb,IAAAlB,WAAA,CAAAmB,GAAA,EAAClB,OAAO,CAACmB,QAAQ;IAAAC,QAAA,EACZC,OAAO,iBACV,IAAAtB,WAAA,CAAAmB,GAAA,EAACL,iBAAiB;MAAA,GACZI,KAAK;MAAA,GACLN,iBAAiB,CAAEU,OAAO,EAAEJ,KAAM;IAAC,CACxC;EACD,CACgB,CAClB;AACF,CAAC,EAAE,mBAAoB,CAAC;AAACX,OAAA,CAAAI,iBAAA,GAAAA,iBAAA","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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DK;AAzDL,qBAA0C;AAC1C,qBAA2C;AAC3C,wBAAuB;AAYvB,MAAM,cAAU,8BAAgC;AAAA,EAC/C,MAAM;AAAA,EACN,MAAM;AACP,CAAE;AACF,QAAQ,cAAc;AAEf,MAAM,wBAAwB,QAAQ;AAOtC,SAAS,mBAAmB;AAClC,aAAO,2BAAY,OAAQ;AAC5B;AAcO,MAAM,oBAAoB,CAChC,0BAKA,2CAA4B,CAAE,sBAAuB;AACpD,wBAAAA,SAAY,gCAAgC;AAAA,IAC3C,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AACF,SAAO,CAAE,UACR,4CAAC,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": ["deprecated"]
7
+ }
@@ -1,19 +1,28 @@
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 plugin_error_boundary_exports = {};
20
+ __export(plugin_error_boundary_exports, {
21
+ PluginErrorBoundary: () => PluginErrorBoundary
5
22
  });
6
- exports.PluginErrorBoundary = void 0;
7
- var _element = require("@wordpress/element");
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- class PluginErrorBoundary extends _element.Component {
23
+ module.exports = __toCommonJS(plugin_error_boundary_exports);
24
+ var import_element = require("@wordpress/element");
25
+ class PluginErrorBoundary extends import_element.Component {
17
26
  constructor(props) {
18
27
  super(props);
19
28
  this.state = {
@@ -21,15 +30,10 @@ class PluginErrorBoundary extends _element.Component {
21
30
  };
22
31
  }
23
32
  static getDerivedStateFromError() {
24
- return {
25
- hasError: true
26
- };
33
+ return { hasError: true };
27
34
  }
28
35
  componentDidCatch(error) {
29
- const {
30
- name,
31
- onError
32
- } = this.props;
36
+ const { name, onError } = this.props;
33
37
  if (onError) {
34
38
  onError(name, error);
35
39
  }
@@ -41,5 +45,8 @@ class PluginErrorBoundary extends _element.Component {
41
45
  return null;
42
46
  }
43
47
  }
44
- exports.PluginErrorBoundary = PluginErrorBoundary;
45
- //# sourceMappingURL=index.js.map
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ PluginErrorBoundary
51
+ });
52
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
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.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":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAMO,MAAMC,mBAAmB,SAASC,kBAAS,CAAiB;EAClEC,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;AAACC,OAAA,CAAAb,mBAAA,GAAAA,mBAAA","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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAUnB,MAAM,4BAA4B,yBAA0B;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
+ }
package/build/index.js CHANGED
@@ -1,28 +1,25 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./components"), module.exports);
19
+ __reExport(index_exports, require("./api"), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require("./components"),
23
+ ...require("./api")
5
24
  });
6
- var _components = require("./components");
7
- Object.keys(_components).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _components[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _components[key];
14
- }
15
- });
16
- });
17
- var _api = require("./api");
18
- Object.keys(_api).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _api[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _api[key];
25
- }
26
- });
27
- });
28
- //# sourceMappingURL=index.js.map
25
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_components","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_api"],"sources":["@wordpress/plugins/src/index.ts"],"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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export * from './components';\nexport * from './api';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;AACA,0BAAc,kBADd;",
6
+ "names": []
7
+ }
package/build/types.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# 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": ["../src/types.ts"],
4
+ "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"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,132 +1,45 @@
1
- /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
2
- /**
3
- * External dependencies
4
- */
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { applyFilters, doAction } from '@wordpress/hooks';
10
- import { plugins as pluginsIcon } from '@wordpress/icons';
11
-
12
- /**
13
- * Defined behavior of a plugin type.
14
- */
15
-
16
- /**
17
- * Plugin definitions keyed by plugin name.
18
- */
1
+ import { applyFilters, doAction } from "@wordpress/hooks";
2
+ import { plugins as pluginsIcon } from "@wordpress/icons";
19
3
  const plugins = {};
20
-
21
- /**
22
- * Registers a plugin to the editor.
23
- *
24
- * @param name A string identifying the plugin. Must be
25
- * unique across all registered plugins.
26
- * @param settings The settings for this plugin.
27
- *
28
- * @example
29
- * ```js
30
- * // Using ES5 syntax
31
- * var el = React.createElement;
32
- * var Fragment = wp.element.Fragment;
33
- * var PluginSidebar = wp.editor.PluginSidebar;
34
- * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
35
- * var registerPlugin = wp.plugins.registerPlugin;
36
- * var moreIcon = React.createElement( 'svg' ); //... svg element.
37
- *
38
- * function Component() {
39
- * return el(
40
- * Fragment,
41
- * {},
42
- * el(
43
- * PluginSidebarMoreMenuItem,
44
- * {
45
- * target: 'sidebar-name',
46
- * },
47
- * 'My Sidebar'
48
- * ),
49
- * el(
50
- * PluginSidebar,
51
- * {
52
- * name: 'sidebar-name',
53
- * title: 'My Sidebar',
54
- * },
55
- * 'Content of the sidebar'
56
- * )
57
- * );
58
- * }
59
- * registerPlugin( 'plugin-name', {
60
- * icon: moreIcon,
61
- * render: Component,
62
- * scope: 'my-page',
63
- * } );
64
- * ```
65
- *
66
- * @example
67
- * ```js
68
- * // Using ESNext syntax
69
- * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
70
- * import { registerPlugin } from '@wordpress/plugins';
71
- * import { more } from '@wordpress/icons';
72
- *
73
- * const Component = () => (
74
- * <>
75
- * <PluginSidebarMoreMenuItem
76
- * target="sidebar-name"
77
- * >
78
- * My Sidebar
79
- * </PluginSidebarMoreMenuItem>
80
- * <PluginSidebar
81
- * name="sidebar-name"
82
- * title="My Sidebar"
83
- * >
84
- * Content of the sidebar
85
- * </PluginSidebar>
86
- * </>
87
- * );
88
- *
89
- * registerPlugin( 'plugin-name', {
90
- * icon: more,
91
- * render: Component,
92
- * scope: 'my-page',
93
- * } );
94
- * ```
95
- *
96
- * @return The final plugin settings object.
97
- */
98
- export function registerPlugin(name, settings) {
99
- if (typeof settings !== 'object') {
100
- console.error('No settings object provided!');
4
+ function registerPlugin(name, settings) {
5
+ if (typeof settings !== "object") {
6
+ console.error("No settings object provided!");
101
7
  return null;
102
8
  }
103
- if (typeof name !== 'string') {
104
- console.error('Plugin name must be string.');
9
+ if (typeof name !== "string") {
10
+ console.error("Plugin name must be string.");
105
11
  return null;
106
12
  }
107
13
  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
108
- console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
14
+ console.error(
15
+ 'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'
16
+ );
109
17
  return null;
110
18
  }
111
19
  if (plugins[name]) {
112
20
  console.error(`Plugin "${name}" is already registered.`);
113
21
  }
114
- settings = applyFilters('plugins.registerPlugin', settings, name);
115
- const {
116
- render,
117
- scope
118
- } = settings;
119
- if (typeof render !== 'function') {
120
- console.error('The "render" property must be specified and must be a valid function.');
22
+ settings = applyFilters(
23
+ "plugins.registerPlugin",
24
+ settings,
25
+ name
26
+ );
27
+ const { render, scope } = settings;
28
+ if (typeof render !== "function") {
29
+ console.error(
30
+ 'The "render" property must be specified and must be a valid function.'
31
+ );
121
32
  return null;
122
33
  }
123
34
  if (scope) {
124
- if (typeof scope !== 'string') {
125
- console.error('Plugin scope must be string.');
35
+ if (typeof scope !== "string") {
36
+ console.error("Plugin scope must be string.");
126
37
  return null;
127
38
  }
128
39
  if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
129
- console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
40
+ console.error(
41
+ 'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'
42
+ );
130
43
  return null;
131
44
  }
132
45
  }
@@ -135,65 +48,31 @@ export function registerPlugin(name, settings) {
135
48
  icon: pluginsIcon,
136
49
  ...settings
137
50
  };
138
- doAction('plugins.pluginRegistered', settings, name);
51
+ doAction("plugins.pluginRegistered", settings, name);
139
52
  return settings;
140
53
  }
141
-
142
- /**
143
- * Unregisters a plugin by name.
144
- *
145
- * @param name Plugin name.
146
- *
147
- * @example
148
- * ```js
149
- * // Using ES5 syntax
150
- * var unregisterPlugin = wp.plugins.unregisterPlugin;
151
- *
152
- * unregisterPlugin( 'plugin-name' );
153
- * ```
154
- *
155
- * @example
156
- * ```js
157
- * // Using ESNext syntax
158
- * import { unregisterPlugin } from '@wordpress/plugins';
159
- *
160
- * unregisterPlugin( 'plugin-name' );
161
- * ```
162
- *
163
- * @return The previous plugin settings object, if it has been
164
- * successfully unregistered; otherwise `undefined`.
165
- */
166
- export function unregisterPlugin(name) {
54
+ function unregisterPlugin(name) {
167
55
  if (!plugins[name]) {
168
56
  console.error('Plugin "' + name + '" is not registered.');
169
57
  return;
170
58
  }
171
59
  const oldPlugin = plugins[name];
172
60
  delete plugins[name];
173
- doAction('plugins.pluginUnregistered', oldPlugin, name);
61
+ doAction("plugins.pluginUnregistered", oldPlugin, name);
174
62
  return oldPlugin;
175
63
  }
176
-
177
- /**
178
- * Returns a registered plugin settings.
179
- *
180
- * @param name Plugin name.
181
- *
182
- * @return Plugin setting.
183
- */
184
- export function getPlugin(name) {
64
+ function getPlugin(name) {
185
65
  return plugins[name];
186
66
  }
187
-
188
- /**
189
- * Returns all registered plugins without a scope or for a given scope.
190
- *
191
- * @param scope The scope to be used when rendering inside
192
- * a plugin area. No scope by default.
193
- *
194
- * @return The list of plugins without a scope or for a given scope.
195
- */
196
- export function getPlugins(scope) {
197
- return Object.values(plugins).filter(plugin => plugin.scope === scope);
67
+ function getPlugins(scope) {
68
+ return Object.values(plugins).filter(
69
+ (plugin) => plugin.scope === scope
70
+ );
198
71
  }
199
- //# sourceMappingURL=index.js.map
72
+ export {
73
+ getPlugin,
74
+ getPlugins,
75
+ registerPlugin,
76
+ unregisterPlugin
77
+ };
78
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["applyFilters","doAction","plugins","pluginsIcon","registerPlugin","name","settings","console","error","test","render","scope","icon","unregisterPlugin","oldPlugin","getPlugin","getPlugins","Object","values","filter","plugin"],"sources":["@wordpress/plugins/src/api/index.ts"],"sourcesContent":["/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */\n/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { applyFilters, doAction } from '@wordpress/hooks';\nimport { plugins as pluginsIcon } from '@wordpress/icons';\nimport type { IconType } from '@wordpress/components';\n\n/**\n * Defined behavior of a plugin type.\n */\nexport interface WPPlugin {\n\t/**\n\t * A string identifying the plugin. Must be unique across all registered plugins.\n\t */\n\tname: string;\n\n\t/**\n\t * An icon to be shown in the UI. It can be a slug of the Dashicon, or an\n\t * element (or function returning an element) if you choose to render your\n\t * own SVG.\n\t */\n\ticon?: IconType;\n\n\t/**\n\t * A component containing the UI elements to be rendered.\n\t */\n\trender: ComponentType;\n\n\t/**\n\t * The optional scope to be used when rendering inside a plugin area.\n\t * No scope by default.\n\t */\n\tscope?: string;\n}\n\ntype PluginSettings = Omit< WPPlugin, 'name' >;\n\n/**\n * Plugin definitions keyed by plugin name.\n */\nconst plugins = {} as Record< string, WPPlugin >;\n\n/**\n * Registers a plugin to the editor.\n *\n * @param name A string identifying the plugin. Must be\n * unique across all registered plugins.\n * @param settings The settings for this plugin.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var Fragment = wp.element.Fragment;\n * var PluginSidebar = wp.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": "AASA,SAAS,cAAc,gBAAgB;AACvC,SAAS,WAAW,mBAAmB;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,aAAW;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;AAAA,IACN,GAAG;AAAA,EACJ;AAEA,WAAU,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,WAAU,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": []
7
+ }
@@ -1,3 +1,8 @@
1
- export { default as PluginArea } from './plugin-area';
2
- export { usePluginContext, withPluginContext } from './plugin-context';
3
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./plugin-area";
2
+ import { usePluginContext, withPluginContext } from "./plugin-context";
3
+ export {
4
+ default2 as PluginArea,
5
+ usePluginContext,
6
+ withPluginContext
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","PluginArea","usePluginContext","withPluginContext"],"sources":["@wordpress/plugins/src/components/index.ts"],"sourcesContent":["export { default as PluginArea } from './plugin-area';\nexport { usePluginContext, withPluginContext } from './plugin-context';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,eAAe;AACrD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,kBAAkB","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,SAAoB,WAAXA,gBAA6B;AACtC,SAAS,kBAAkB,yBAAyB;",
6
+ "names": ["default"]
7
+ }