PageSourceSearch

https://www.tromso.kommune.no/modules/contrib/gutenberg/js/vendor/gutenberg/server-side-render/index.js?tm8d37

js tromso.kommune.no collected 2026-10-02 04:21:01 UTC 14,659 bytes, 441 lines download raw bytes

1/******/ (() => { // webpackBootstrap
2/******/ 	"use strict";
3/******/ 	var __webpack_modules__ = ({
4
5/***/ 5619:
6/***/ ((module) => {
7
8
9
10// do not edit .js files directly - edit src/index.jst
11
12
13  var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
14
15
16module.exports = function equal(a, b) {
17  if (a === b) return true;
18
19  if (a && b && typeof a == 'object' && typeof b == 'object') {
20    if (a.constructor !== b.constructor) return false;
21
22    var length, i, keys;
23    if (Array.isArray(a)) {
24      length = a.length;
25      if (length != b.length) return false;
26      for (i = length; i-- !== 0;)
27        if (!equal(a[i], b[i])) return false;
28      return true;
29    }
30
31
32    if ((a instanceof Map) && (b instanceof Map)) {
33      if (a.size !== b.size) return false;
34      for (i of a.entries())
35        if (!b.has(i[0])) return false;
36      for (i of a.entries())
37        if (!equal(i[1], b.get(i[0]))) return false;
38      return true;
39    }
40
41    if ((a instanceof Set) && (b instanceof Set)) {
42      if (a.size !== b.size) return false;
43      for (i of a.entries())
44        if (!b.has(i[0])) return false;
45      return true;
46    }
47
48    if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
49      length = a.length;
50      if (length != b.length) return false;
51      for (i = length; i-- !== 0;)
52        if (a[i] !== b[i]) return false;
53      return true;
54    }
55
56
57    if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
58    if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
59    if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
60
61    keys = Object.keys(a);
62    length = keys.length;
63    if (length !== Object.keys(b).length) return false;
64
65    for (i = length; i-- !== 0;)
66      if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
67
68    for (i = length; i-- !== 0;) {
69      var key = keys[i];
70
71      if (!equal(a[key], b[key])) return false;
72    }
73
74    return true;
75  }
76
77  // true if both NaN, false otherwise
78  return a!==a && b!==b;
79};
80
81
82/***/ })
83
84/******/ 	});
85/************************************************************************/
86/******/ 	// The module cache
87/******/ 	var __webpack_module_cache__ = {};
88/******/ 	
89/******/ 	// The require function
90/******/ 	function __webpack_require__(moduleId) {
91/******/ 		// Check if module is in cache
92/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
93/******/ 		if (cachedModule !== undefined) {
94/******/ 			return cachedModule.exports;
95/******/ 		}
96/******/ 		// Create a new module (and put it into the cache)
97/******/ 		var module = __webpack_module_cache__[moduleId] = {
98/******/ 			// no module.id needed
99/******/ 			// no module.loaded needed
100/******/ 			exports: {}
101/******/ 		};
102/******/ 	
103/******/ 		// Execute the module function
104/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
105/******/ 	
106/******/ 		// Return the exports of the module
107/******/ 		return module.exports;
108/******/ 	}
109/******/ 	
110/************************************************************************/
111/******/ 	/* webpack/runtime/compat get default export */
112/******/ 	(() => {
113/******/ 		// getDefaultExport function for compatibility with non-harmony modules
114/******/ 		__webpack_require__.n = (module) => {
115/******/ 			var getter = module && module.__esModule ?
116/******/ 				() => (module['default']) :
117/******/ 				() => (module);
118/******/ 			__webpack_require__.d(getter, { a: getter });
119/******/ 			return getter;
120/******/ 		};
121/******/ 	})();
122/******/ 	
123/******/ 	/* webpack/runtime/define property getters */
124/******/ 	(() => {
125/******/ 		// define getter functions for harmony exports
126/******/ 		__webpack_require__.d = (exports, definition) => {
127/******/ 			for(var key in definition) {
128/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
129/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
130/******/ 				}
131/******/ 			}
132/******/ 		};
133/******/ 	})();
134/******/ 	
135/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
136/******/ 	(() => {
137/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
138/******/ 	})();
139/******/ 	
140/************************************************************************/
141var __webpack_exports__ = {};
142// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
143(() => {
144
145// EXPORTS
146__webpack_require__.d(__webpack_exports__, {
147  "default": () => (/* binding */ build_module)
148});
149
150;
150// CONCATENATED MODULE: external ["wp","element"]
151const external_wp_element_namespaceObject = window["wp"]["element"];
152;// CONCATENATED MODULE: external ["wp","data"]
153const external_wp_data_namespaceObject = window["wp"]["data"];
154// EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
155var es6 = __webpack_require__(5619);
156var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
157;// CONCATENATED MODULE: external ["wp","compose"]
158const external_wp_compose_namespaceObject = window["wp"]["compose"];
159;// CONCATENATED MODULE: external ["wp","i18n"]
160const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
161;// CONCATENATED MODULE: external ["wp","apiFetch"]
162const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
163var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
164;// CONCATENATED MODULE: external ["wp","url"]
165const external_wp_url_namespaceObject = window["wp"]["url"];
166;// CONCATENATED MODULE: external ["wp","components"]
167const external_wp_components_namespaceObject = window["wp"]["components"];
168;// CONCATENATED MODULE: external ["wp","blocks"]
169const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
170;// CONCATENATED MODULE: ./packages/server-side-render/build-module/server-side-render.js
171
172/**
173 * External dependencies
174 */
175
176
177/**
178 * WordPress dependencies
179 */
180
181
182
183
184
185
186
187const EMPTY_OBJECT = {};
188function rendererPath(block, attributes = null, urlQueryArgs = {}) {
189  return (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-renderer/${block}`, {
190    context: 'edit',
191    ...(null !== attributes ? {
192      attributes
193    } : {}),
194    ...urlQueryArgs
195  });
196}
197function removeBlockSupportAttributes(attributes) {
198  const {
199    backgroundColor,
200    borderColor,
201    fontFamily,
202    fontSize,
203    gradient,
204    textColor,
205    className,
206    ...restAttributes
207  } = attributes;
208  const {
209    border,
210    color,
211    elements,
212    spacing,
213    typography,
214    ...restStyles
215  } = attributes?.style || EMPTY_OBJECT;
216  return {
217    ...restAttributes,
218    style: restStyles
219  };
220}
221function DefaultEmptyResponsePlaceholder({
222  className
223}) {
224  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
225    className: className
226  }, (0,external_wp_i18n_namespaceObject.__)('Block rendered as empty.'));
227}
228function DefaultErrorResponsePlaceholder({
229  response,
230  className
231}) {
232  const errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
233  // translators: %s: error message describing the problem
234  (0,external_wp_i18n_namespaceObject.__)('Error loading block: %s'), response.errorMsg);
235  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
236    className: className
237  }, errorMessage);
238}
239function DefaultLoadingResponsePlaceholder({
240  children,
241  showLoader
242}) {
243  return (0,external_wp_element_namespaceObject.createElement)("div", {
244    style: {
245      position: 'relative'
246    }
247  }, showLoader && (0,external_wp_element_namespaceObject.createElement)("div", {
248    style: {
249      position: 'absolute',
250      top: '50%',
251      left: '50%',
252      marginTop: '-9px',
253      marginLeft: '-9px'
254    }
255  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
256    style: {
257      opacity: showLoader ? '0.3' : 1
258    }
259  }, children));
260}
261function ServerSideRender(props) {
262  const {
263    attributes,
264    block,
265    className,
266    httpMethod = 'GET',
267    urlQueryArgs,
268    skipBlockSupportAttributes = false,
269    EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder,
270    ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder,
271    LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder
272  } = props;
273  const isMountedRef = (0,external_wp_element_namespaceObject.useRef)(true);
274  const [showLoader, setShowLoader] = (0,external_wp_element_namespaceObject.useState)(false);
275  const fetchRequestRef = (0,external_wp_element_namespaceObject.useRef)();
276  const [response, setResponse] = (0,external_wp_element_namespaceObject.useState)(null);
277  const prevProps = (0,external_wp_compose_namespaceObject.usePrevious)(props);
278  const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
279  function fetchData() {
280    var _sanitizedAttributes, _sanitizedAttributes2;
281    if (!isMountedRef.current) {
282      return;
283    }
284    setIsLoading(true);
285    let sanitizedAttributes = attributes && (0,external_wp_blocks_namespaceObject.__experimentalSanitizeBlockAttributes)(block, attributes);
286    if (skipBlockSupportAttributes) {
287      sanitizedAttributes = removeBlockSupportAttributes(sanitizedAttributes);
288    }
289
290    // If httpMethod is 'POST', send the attributes in the request body instead of the URL.
291    // This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
292    const isPostRequest = 'POST' === httpMethod;
293    const urlAttributes = isPostRequest ? null : (_sanitizedAttributes = sanitizedAttributes) !== null && _sanitizedAttributes !== void 0 ? _sanitizedAttributes : null;
294    const path = rendererPath(block, urlAttributes, urlQueryArgs);
295    const data = isPostRequest ? {
296      attributes: (_sanitizedAttributes2 = sanitizedAttributes) !== null && _sanitizedAttributes2 !== void 0 ? _sanitizedAttributes2 : null
297    } : null;
298
299    // Store the latest fetch request so that when we process it, we can
300    // check if it is the current request, to avoid race conditions on slow networks.
301    const fetchRequest = fetchRequestRef.current = external_wp_apiFetch_default()({
302      path,
303      data,
304      method: isPostRequest ? 'POST' : 'GET'
305    }).then(fetchResponse => {
306      if (isMountedRef.current && fetchRequest === fetchRequestRef.current && fetchResponse) {
307        setResponse(fetchResponse.rendered);
308      }
309    }).catch(error => {
310      if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
311        setResponse({
312          error: true,
313          errorMsg: error.message
314        });
315      }
316    }).finally(() => {
317      if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
318        setIsLoading(false);
319      }
320    });
321    return fetchRequest;
322  }
323  const debouncedFetchData = (0,external_wp_compose_namespaceObject.useDebounce)(fetchData, 500);
324
325  // When the component unmounts, set isMountedRef to false. This will
326  // let the async fetch callbacks know when to stop.
327  (0,external_wp_element_namespaceObject.useEffect)(() => () => {
328    isMountedRef.current = false;
329  }, []);
330  (0,external_wp_element_namespaceObject.useEffect)(() => {
331    // Don't debounce the first fetch. This ensures that the first render
332    // shows data as soon as possible.
333    if (prevProps === undefined) {
334      fetchData();
335    } else if (!es6_default()(prevProps, props)) {
336      debouncedFetchData();
337    }
338  });
339
340  /**
341   * Effect to handle showing the loading placeholder.
342   * Show it only if there is no previous response or
343   * the request takes more than one second.
344   */
345  (0,external_wp_element_namespaceObject.useEffect)(() => {
346    if (!isLoading) {
347      return;
348    }
349    const timeout = setTimeout(() => {
350      setShowLoader(true);
351    }, 1000);
352    return () => clearTimeout(timeout);
353  }, [isLoading]);
354  const hasResponse = !!response;
355  const hasEmptyResponse = response === '';
356  const hasError = response?.error;
357  if (isLoading) {
358    return (0,external_wp_element_namespaceObject.createElement)(LoadingResponsePlaceholder, {
359      ...props,
360      showLoader: showLoader
361    }, hasResponse && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
362      className: className
363    }, response));
364  }
365  if (hasEmptyResponse || !hasResponse) {
366    return (0,external_wp_element_namespaceObject.createElement)(EmptyResponsePlaceholder, {
367      ...props
368    });
369  }
370  if (hasError) {
371    return (0,external_wp_element_namespaceObject.createElement)(ErrorResponsePlaceholder, {
372      response: response,
373      ...props
374    });
375  }
376  return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
377    className: className
378  }, response);
379}
380
381;// CONCATENATED MODULE: ./packages/server-side-render/build-module/index.js
382
383/**
384 * WordPress dependencies
385 */
386
387
388
389/**
390 * Internal dependencies
391 */
392
393
394/**
395 * Constants
396 */
397const build_module_EMPTY_OBJECT = {};
398const ExportedServerSideRender = (0,external_wp_data_namespaceObject.withSelect)(select => {
399  // FIXME: @wordpress/server-side-render should not depend on @wordpress/editor.
400  // It is used by blocks that can be loaded into a *non-post* block editor.
401  // eslint-disable-next-line @wordpress/data-no-store-string-literals
402  const coreEditorSelect = select('core/editor');
403  if (coreEditorSelect) {
404    const currentPostId = coreEditorSelect.getCurrentPostId();
405    // For templates and template parts we use a custom ID format.
406    // Since they aren't real posts, we don't want to use their ID
407    // for server-side rendering. Since they use a string based ID,
408    // we can assume real post IDs are numbers.
409    if (currentPostId && typeof currentPostId === 'number') {
410      return {
411        currentPostId
412      };
413    }
414  }
415  return build_module_EMPTY_OBJECT;
416})(({
417  urlQueryArgs = build_module_EMPTY_OBJECT,
418  currentPostId,
419  ...props
420}) => {
421  const newUrlQueryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => {
422    if (!currentPostId) {
423      return urlQueryArgs;
424    }
425    return {
426      post_id: currentPostId,
427      ...urlQueryArgs
428    };
429  }, [currentPostId, urlQueryArgs]);
430  return (0,external_wp_element_namespaceObject.createElement)(ServerSideRender, {
431    urlQueryArgs: newUrlQueryArgs,
432    ...props
433  });
434});
435/* harmony default export */ const build_module = (ExportedServerSideRender);
436
437})();
438
439(window.wp = window.wp || {}).serverSideRender = __webpack_exports__["default"];
440/******/ })()
441;

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.