PageSourceSearch

https://www.tromsobadet.no/modules/contrib/gutenberg/js/vendor/gutenberg/plugins/index.js?tm02zf

js tromsobadet.no collected 2026-10-06 22:42:39 UTC 17,696 bytes, 642 lines download raw bytes

1/******/ (() => { // webpackBootstrap
2/******/ 	"use strict";
3/******/ 	// The require scope
4/******/ 	var __webpack_require__ = {};
5/******/ 	
6/************************************************************************/
7/******/ 	/* webpack/runtime/compat get default export */
8/******/ 	(() => {
9/******/ 		// getDefaultExport function for compatibility with non-harmony modules
10/******/ 		__webpack_require__.n = (module) => {
11/******/ 			var getter = module && module.__esModule ?
12/******/ 				() => (module['default']) :
13/******/ 				() => (module);
14/******/ 			__webpack_require__.d(getter, { a: getter });
15/******/ 			return getter;
16/******/ 		};
17/******/ 	})();
18/******/ 	
19/******/ 	/* webpack/runtime/define property getters */
20/******/ 	(() => {
21/******/ 		// define getter functions for harmony exports
22/******/ 		__webpack_require__.d = (exports, definition) => {
23/******/ 			for(var key in definition) {
24/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26/******/ 				}
27/******/ 			}
28/******/ 		};
29/******/ 	})();
30/******/ 	
31/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
32/******/ 	(() => {
33/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34/******/ 	})();
35/******/ 	
36/******/ 	/* webpack/runtime/make namespace object */
37/******/ 	(() => {
38/******/ 		// define __esModule on exports
39/******/ 		__webpack_require__.r = (exports) => {
40/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42/******/ 			}
43/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
44/******/ 		};
45/******/ 	})();
46/******/ 	
47/************************************************************************/
48var __webpack_exports__ = {};
49// ESM COMPAT FLAG
50__webpack_require__.r(__webpack_exports__);
51
52// EXPORTS
53__webpack_require__.d(__webpack_exports__, {
54  "PluginArea": () => (/* reexport */ plugin_area),
55  "getPlugin": () => (/* reexport */ getPlugin),
56  "getPlugins": () => (/* reexport */ getPlugins),
57  "registerPlugin": () => (/* reexport */ registerPlugin),
58  "unregisterPlugin": () => (/* reexport */ unregisterPlugin),
59  "usePluginContext": () => (/* reexport */ usePluginContext),
60  "withPluginContext": () => (/* reexport */ withPluginContext)
61});
62
63;// CONCATENATED MODULE: external ["wp","element"]
64const external_wp_element_namespaceObject = window["wp"]["element"];
65;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
66/**
67 * Memize options object.
68 *
69 * @typedef MemizeOptions
70 *
71 * @property {number} [maxSize] Maximum size of the cache.
72 */
73
74/**
75 * Internal cache entry.
76 *
77 * @typedef MemizeCacheNode
78 *
79 * @property {?MemizeCacheNode|undefined} [prev] Previous node.
80 * @property {?MemizeCacheNode|undefined} [next] Next node.
81 * @property {Array<*>}                   args   Function arguments for cache
82 *                                               entry.
83 * @property {*}                          val    Function result.
84 */
85
86/**
87 * Properties of the enhanced function for controlling cache.
88 *
89 * @typedef MemizeMemoizedFunction
90 *
91 * @property {()=>void} clear Clear the cache.
92 */
93
94/**
95 * Accepts a function to be memoized, and returns a new memoized function, with
96 * optional options.
97 *
98 * @template {(...args: any[]) => any} F
99 *
100 * @param {F}             fn        Function to memoize.
101 * @param {MemizeOptions} [options] Options object.
102 *
103 * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
104 */
105function memize(fn, options) {
106	var size = 0;
107
108	/** @type {?MemizeCacheNode|undefined} */
109	var head;
110
111	/** @type {?MemizeCacheNode|undefined} */
112	var tail;
113
114	options = options || {};
115
116	function memoized(/* ...args */) {
117		var node = head,
118			len = arguments.length,
119			args,
120			i;
121
122		searchCache: while (node) {
123			// Perform a shallow equality test to confirm that whether the node
124			// under test is a candidate for the arguments passed. Two arrays
125			// are shallowly equal if their length matches and each entry is
126			// strictly equal between the two sets. Avoid abstracting to a
127			// function which could incur an arguments leaking deoptimization.
128
129			// Check whether node arguments match arguments length
130			if (node.args.length !== arguments.length) {
131				node = node.next;
132				continue;
133			}
134
135			// Check whether node arguments match arguments values
136			for (i = 0; i < len; i++) {
137				if (node.args[i] !== arguments[i]) {
138					node = node.next;
139					continue searchCache;
140				}
141			}
142
143			// At this point we can assume we've found a match
144
145			// Surface matched node to head if not already
146			if (node !== head) {
147				// As tail, shift to previous. Must only shift if not also
148				// head, since if both head and tail, there is no previous.
149				if (node === tail) {
150					tail = node.prev;
151				}
152
153				// Adjust siblings to point to each other. If node was tail,
154				// this also handles new tail's empty `next` assignment.
155				/** @type {MemizeCacheNode} */ (node.prev).next = node.next;
156				if (node.next) {
157					node.next.prev = node.prev;
158				}
159
160				node.next = head;
161				node.prev = null;
162				/** @type {MemizeCacheNode} */ (head).prev = node;
163				head = node;
164			}
165
166			// Return immediately
167			return node.val;
168		}
169
170		// No cached value found. Continue to insertion phase:
171
172		// Create a copy of arguments (avoid leaking deoptimization)
173		args = new Array(len);
174		for (i = 0; i < len; i++) {
175			args[i] = arguments[i];
176		}
177
178		node = {
179			args: args,
180
181			// Generate the result from original function
182			val: fn.apply(null, args),
183		};
184
185		// Don't need to check whether node is already head, since it would
186		// have been returned above already if it was
187
188		// Shift existing head down list
189		if (head) {
190			head.prev = node;
191			node.next = head;
192		} else {
193			// If no head, follows that there's no tail (at initial or reset)
194			tail = node;
195		}
196
197		// Trim tail if we're reached max size and are pending cache insertion
198		if (size === /** @type {MemizeOptions} */ (options).maxSize) {
199			tail = /** @type {MemizeCacheNode} */ (tail).prev;
200			/** @type {MemizeCacheNode} */ (tail).next = null;
201		} else {
202			size++;
203		}
204
205		head = node;
206
207		return node.val;
208	}
209
210	memoized.clear = function () {
211		head = null;
212		tail = null;
213		size = 0;
214	};
215
216	// Ignore reason: There's not a clear solution to create an intersection of
217	// the function with additional properties, where the goal is to retain the
218	// function signature of the incoming argument and add control properties
219	// on the return value.
220
221	// @ts-ignore
222	return memoized;
223}
224
225
226
227;// CONCATENATED MODULE: external ["wp","hooks"]
228const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
229;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
230const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
231var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
232;// CONCATENATED MODULE: external ["wp","compose"]
233const external_wp_compose_namespaceObject = window["wp"]["compose"];
234;// CONCATENATED MODULE: ./packages/plugins/build-module/components/plugin-context/index.js
235
236/**
237 * WordPress dependencies
238 */
239
240
241
242/**
243 * Internal dependencies
244 */
245
246const Context = (0,external_wp_element_namespaceObject.createContext)({
247  name: null,
248  icon: null
249});
250const PluginContextProvider = Context.Provider;
251
252/**
253 * A hook that returns the plugin context.
254 *
255 * @return {PluginContext} Plugin context
256 */
257function usePluginContext() {
258  return (0,external_wp_element_namespaceObject.useContext)(Context);
259}
260
261/**
262 * A Higher Order Component used to inject Plugin context to the
263 * wrapped component.
264 *
265 * @param  mapContextToProps Function called on every context change,
266 *                           expected to return object of props to
267 *                           merge with the component's own props.
268 *
269 * @return {WPComponent} Enhanced component with injected context as props.
270 */
271const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
272  return props => (0,external_wp_element_namespaceObject.createElement)(Context.Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, {
273    ...props,
274    ...mapContextToProps(context, props)
275  }));
276}, 'withPluginContext');
277
278;// CONCATENATED MODULE: ./packages/plugins/build-module/components/plugin-error-boundary/index.js
279/**
280 * WordPress dependencies
281 */
282
283class PluginErrorBoundary extends external_wp_element_namespaceObject.Component {
284  /**
285   * @param {Object} props
286   */
287  constructor(props) {
288    super(props);
289    this.state = {
290      hasError: false
291    };
292  }
293  static getDerivedStateFromError() {
294    return {
295      hasError: true
296    };
297  }
298
299  /**
300   * @param {Error} error Error object passed by React.
301   */
302  componentDidCatch(error) {
303    const {
304      name,
305      onError
306    } = this.props;
307    if (onError) {
308      onError(name, error);
309    }
310  }
311  render() {
312    if (!this.state.hasError) {
313      return this.props.children;
314    }
315    return null;
316  }
317}
318
319;// CONCATENATED MODULE: external ["wp","primitives"]
320const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
321;// CONCATENATED MODULE: ./packages/icons/build-module/library/plugins.js
322
323/**
324 * WordPress dependencies
325 */
326
327const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
328  xmlns: "http://www.w3.org/2000/svg",
329  viewBox: "0 0 24 24"
330}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
331  d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"
332}));
333/* harmony default export */ const library_plugins = (plugins);
334
335;// CONCATENATED MODULE: ./packages/plugins/build-module/api/index.js
336/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
337
338/**
339 * WordPress dependencies
340 */
341
342
343/**
344 * Plugin definitions keyed by plugin name.
345 */
346const api_plugins = {};
347
348/**
349 * Registers a plugin to the editor.
350 *
351 * @param name     A string identifying the plugin. Must be
352 *                 unique across all registered plugins.
353 * @param settings The settings for this plugin.
354 *
355 * @example
356 * ```js
357 * // Using ES5 syntax
358 * var el = wp.element.createElement;
359 * var Fragment = wp.element.Fragment;
360 * var PluginSidebar = wp.editPost.PluginSidebar;
361 * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
362 * var registerPlugin = wp.plugins.registerPlugin;
363 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
364 *
365 * function Component() {
366 * 	return el(
367 * 		Fragment,
368 * 		{},
369 * 		el(
370 * 			PluginSidebarMoreMenuItem,
371 * 			{
372 * 				target: 'sidebar-name',
373 * 			},
374 * 			'My Sidebar'
375 * 		),
376 * 		el(
377 * 			PluginSidebar,
378 * 			{
379 * 				name: 'sidebar-name',
380 * 				title: 'My Sidebar',
381 * 			},
382 * 			'Content of the sidebar'
383 * 		)
384 * 	);
385 * }
386 * registerPlugin( 'plugin-name', {
387 * 	icon: moreIcon,
388 * 	render: Component,
389 * 	scope: 'my-page',
390 * } );
391 * ```
392 *
393 * @example
394 * ```js
395 * // Using ESNext syntax
396 * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
397 * import { registerPlugin } from '@wordpress/plugins';
398 * import { more } from '@wordpress/icons';
399 *
400 * const Component = () => (
401 * 	<>
402 * 		<PluginSidebarMoreMenuItem
403 * 			target="sidebar-name"
404 * 		>
405 * 			My Sidebar
406 * 		</PluginSidebarMoreMenuItem>
407 * 		<PluginSidebar
408 * 			name="sidebar-name"
409 * 			title="My Sidebar"
410 * 		>
411 * 			Content of the sidebar
412 * 		</PluginSidebar>
413 * 	</>
414 * );
415 *
416 * registerPlugin( 'plugin-name', {
417 * 	icon: more,
418 * 	render: Component,
419 * 	scope: 'my-page',
420 * } );
421 * ```
422 *
423 * @return The final plugin settings object.
424 */
425function registerPlugin(name, settings) {
426  if (typeof settings !== 'object') {
427    console.error('No settings object provided!');
428    return null;
429  }
430  if (typeof name !== 'string') {
431    console.error('Plugin name must be string.');
432    return null;
433  }
434  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
435    console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
436    return null;
437  }
438  if (api_plugins[name]) {
439    console.error(`Plugin "${name}" is already registered.`);
440  }
441  settings = (0,external_wp_hooks_namespaceObject.applyFilters)('plugins.registerPlugin', settings, name);
442  const {
443    render,
444    scope
445  } = settings;
446  if (typeof render !== 'function') {
447    console.error('The "render" property must be specified and must be a valid function.');
448    return null;
449  }
450  if (scope) {
451    if (typeof scope !== 'string') {
452      console.error('Plugin scope must be string.');
453      return null;
454    }
455    if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
456      console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
457      return null;
458    }
459  }
460  api_plugins[name] = {
461    name,
462    icon: library_plugins,
463    ...settings
464  };
465  (0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginRegistered', settings, name);
466  return settings;
467}
468
469/**
470 * Unregisters a plugin by name.
471 *
472 * @param name Plugin name.
473 *
474 * @example
475 * ```js
476 * // Using ES5 syntax
477 * var unregisterPlugin = wp.plugins.unregisterPlugin;
478 *
479 * unregisterPlugin( 'plugin-name' );
480 * ```
481 *
482 * @example
483 * ```js
484 * // Using ESNext syntax
485 * import { unregisterPlugin } from '@wordpress/plugins';
486 *
487 * unregisterPlugin( 'plugin-name' );
488 * ```
489 *
490 * @return The previous plugin settings object, if it has been
491 *         successfully unregistered; otherwise `undefined`.
492 */
493function unregisterPlugin(name) {
494  if (!api_plugins[name]) {
495    console.error('Plugin "' + name + '" is not registered.');
496    return;
497  }
498  const oldPlugin = api_plugins[name];
499  delete api_plugins[name];
500  (0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginUnregistered', oldPlugin, name);
501  return oldPlugin;
502}
503
504/**
505 * Returns a registered plugin settings.
506 *
507 * @param name Plugin name.
508 *
509 * @return Plugin setting.
510 */
511function getPlugin(name) {
512  return api_plugins[name];
513}
514
515/**
516 * Returns all registered plugins without a scope or for a given scope.
517 *
518 * @param scope The scope to be used when rendering inside
519 *              a plugin area. No scope by default.
520 *
521 * @return The list of plugins without a scope or for a given scope.
522 */
523function getPlugins(scope) {
524  return Object.values(api_plugins).filter(plugin => plugin.scope === scope);
525}
526
527;// CONCATENATED MODULE: ./packages/plugins/build-module/components/plugin-area/index.js
528
529/**
530 * External dependencies
531 */
532
533
534/**
535 * WordPress dependencies
536 */
537
538
539
540
541/**
542 * Internal dependencies
543 */
544
545
546
547const getPluginContext = memize((icon, name) => ({
548  icon,
549  name
550}));
551
552/**
553 * A component that renders all plugin fills in a hidden div.
554 *
555 * @param  props
556 * @param  props.scope
557 * @param  props.onError
558 * @example
559 * ```js
560 * // Using ES5 syntax
561 * var el = wp.element.createElement;
562 * var PluginArea = wp.plugins.PluginArea;
563 *
564 * function Layout() {
565 * 	return el(
566 * 		'div',
567 * 		{ scope: 'my-page' },
568 * 		'Content of the page',
569 * 		PluginArea
570 * 	);
571 * }
572 * ```
573 *
574 * @example
575 * ```js
576 * // Using ESNext syntax
577 * import { PluginArea } from '@wordpress/plugins';
578 *
579 * const Layout = () => (
580 * 	<div>
581 * 		Content of the page
582 * 		<PluginArea scope="my-page" />
583 * 	</div>
584 * );
585 * ```
586 *
587 * @return {WPComponent} The component to be rendered.
588 */
589function PluginArea({
590  scope,
591  onError
592}) {
593  const store = (0,external_wp_element_namespaceObject.useMemo)(() => {
594    let lastValue = [];
595    return {
596      subscribe(listener) {
597        (0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
598        (0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
599        return () => {
600          (0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
601          (0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
602        };
603      },
604      getValue() {
605        const nextValue = getPlugins(scope);
606        if (!external_wp_isShallowEqual_default()(lastValue, nextValue)) {
607          lastValue = nextValue;
608        }
609        return lastValue;
610      }
611    };
612  }, [scope]);
613  const plugins = (0,external_wp_element_namespaceObject.useSyncExternalStore)(store.subscribe, store.getValue);
614  return (0,external_wp_element_namespaceObject.createElement)("div", {
615    style: {
616      display: 'none'
617    }
618  }, plugins.map(({
619    icon,
620    name,
621    render: Plugin
622  }) => (0,external_wp_element_namespaceObject.createElement)(PluginContextProvider, {
623    key: name,
624    value: getPluginContext(icon, name)
625  }, (0,external_wp_element_namespaceObject.createElement)(PluginErrorBoundary, {
626    name: name,
627    onError: onError
628  }, (0,external_wp_element_namespaceObject.createElement)(Plugin, null)))));
629}
630/* harmony default export */ const plugin_area = (PluginArea);
631
632;// CONCATENATED MODULE: ./packages/plugins/build-module/components/index.js
633
634
635
636;// CONCATENATED MODULE: ./packages/plugins/build-module/index.js
637
638
639
640(window.wp = window.wp || {}).plugins = __webpack_exports__;
641/******/ })()
642;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.