PageSourceSearch

https://www.tku.edu.tw/tku/wp-includes/js/dist/server-side-render.js?ver=75db96a643c7c526dd9b

js tku.edu.tw collected 2026-10-02 09:49:37 UTC 14,756 bytes, 454 lines download raw bytes

1/******/ (function() { // webpackBootstrap
2/******/ 	"use strict";
3/******/ 	var __webpack_modules__ = ({
4
5/***/ 5619:
6/***/ (function(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/******/ 	!function() {
113/******/ 		// getDefaultExport function for compatibility with non-harmony modules
114/******/ 		__webpack_require__.n = function(module) {
115/******/ 			var getter = module && module.__esModule ?
116/******/ 				function() { return module['default']; } :
117/******/ 				function() { return module; };
118/******/ 			__webpack_require__.d(getter, { a: getter });
119/******/ 			return getter;
120/******/ 		};
121/******/ 	}();
122/******/ 	
123/******/ 	/* webpack/runtime/define property getters */
124/******/ 	!function() {
125/******/ 		// define getter functions for harmony exports
126/******/ 		__webpack_require__.d = function(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/******/ 	!function() {
137/******/ 		__webpack_require__.o = function(obj, prop) { return 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!function() {
144
145// EXPORTS
146__webpack_require__.d(__webpack_exports__, {
147  "default": function() { return /* binding */ build_module; }
148});
149
150;
150// CONCATENATED MODULE: external ["wp","element"]
151var external_wp_element_namespaceObject = window["wp"]["element"];
152;// CONCATENATED MODULE: external ["wp","data"]
153var 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"]
158var external_wp_compose_namespaceObject = window["wp"]["compose"];
159;// CONCATENATED MODULE: external ["wp","i18n"]
160var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
161;// CONCATENATED MODULE: external ["wp","apiFetch"]
162var 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"]
165var external_wp_url_namespaceObject = window["wp"]["url"];
166;// CONCATENATED MODULE: external ["wp","components"]
167var external_wp_components_namespaceObject = window["wp"]["components"];
168;// CONCATENATED MODULE: external ["wp","blocks"]
169var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
170;// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js
171
172
173/**
174 * External dependencies
175 */
176
177/**
178 * WordPress dependencies
179 */
180
181
182
183
184
185
186
187
188const EMPTY_OBJECT = {};
189function rendererPath(block, attributes = null, urlQueryArgs = {}) {
190  return (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-renderer/${block}`, {
191    context: 'edit',
192    ...(null !== attributes ? {
193      attributes
194    } : {}),
195    ...urlQueryArgs
196  });
197}
198function removeBlockSupportAttributes(attributes) {
199  const {
200    backgroundColor,
201    borderColor,
202    fontFamily,
203    fontSize,
204    gradient,
205    textColor,
206    className,
207    ...restAttributes
208  } = attributes;
209  const {
210    border,
211    color,
212    elements,
213    spacing,
214    typography,
215    ...restStyles
216  } = attributes?.style || EMPTY_OBJECT;
217  return { ...restAttributes,
218    style: restStyles
219  };
220}
221
222function DefaultEmptyResponsePlaceholder({
223  className
224}) {
225  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
226    className: className
227  }, (0,external_wp_i18n_namespaceObject.__)('Block rendered as empty.'));
228}
229
230function DefaultErrorResponsePlaceholder({
231  response,
232  className
233}) {
234  const errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: error message describing the problem
235  (0,external_wp_i18n_namespaceObject.__)('Error loading block: %s'), response.errorMsg);
236  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
237    className: className
238  }, errorMessage);
239}
240
241function DefaultLoadingResponsePlaceholder({
242  children,
243  showLoader
244}) {
245  return (0,external_wp_element_namespaceObject.createElement)("div", {
246    style: {
247      position: 'relative'
248    }
249  }, showLoader && (0,external_wp_element_namespaceObject.createElement)("div", {
250    style: {
251      position: 'absolute',
252      top: '50%',
253      left: '50%',
254      marginTop: '-9px',
255      marginLeft: '-9px'
256    }
257  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
258    style: {
259      opacity: showLoader ? '0.3' : 1
260    }
261  }, children));
262}
263
264function ServerSideRender(props) {
265  const {
266    attributes,
267    block,
268    className,
269    httpMethod = 'GET',
270    urlQueryArgs,
271    skipBlockSupportAttributes = false,
272    EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder,
273    ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder,
274    LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder
275  } = props;
276  const isMountedRef = (0,external_wp_element_namespaceObject.useRef)(true);
277  const [showLoader, setShowLoader] = (0,external_wp_element_namespaceObject.useState)(false);
278  const fetchRequestRef = (0,external_wp_element_namespaceObject.useRef)();
279  const [response, setResponse] = (0,external_wp_element_namespaceObject.useState)(null);
280  const prevProps = (0,external_wp_compose_namespaceObject.usePrevious)(props);
281  const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
282
283  function fetchData() {
284    var _sanitizedAttributes, _sanitizedAttributes2;
285
286    if (!isMountedRef.current) {
287      return;
288    }
289
290    setIsLoading(true);
291
292    let sanitizedAttributes = attributes && (0,external_wp_blocks_namespaceObject.__experimentalSanitizeBlockAttributes)(block, attributes);
293
294    if (skipBlockSupportAttributes) {
295      sanitizedAttributes = removeBlockSupportAttributes(sanitizedAttributes);
296    } // If httpMethod is 'POST', send the attributes in the request body instead of the URL.
297    // This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
298
299
300    const isPostRequest = 'POST' === httpMethod;
301    const urlAttributes = isPostRequest ? null : (_sanitizedAttributes = sanitizedAttributes) !== null && _sanitizedAttributes !== void 0 ? _sanitizedAttributes : null;
302    const path = rendererPath(block, urlAttributes, urlQueryArgs);
303    const data = isPostRequest ? {
304      attributes: (_sanitizedAttributes2 = sanitizedAttributes) !== null && _sanitizedAttributes2 !== void 0 ? _sanitizedAttributes2 : null
305    } : null; // Store the latest fetch request so that when we process it, we can
306    // check if it is the current request, to avoid race conditions on slow networks.
307
308    const fetchRequest = fetchRequestRef.current = external_wp_apiFetch_default()({
309      path,
310      data,
311      method: isPostRequest ? 'POST' : 'GET'
312    }).then(fetchResponse => {
313      if (isMountedRef.current && fetchRequest === fetchRequestRef.current && fetchResponse) {
314        setResponse(fetchResponse.rendered);
315      }
316    }).catch(error => {
317      if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
318        setResponse({
319          error: true,
320          errorMsg: error.message
321        });
322      }
323    }).finally(() => {
324      if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
325        setIsLoading(false);
326      }
327    });
328    return fetchRequest;
329  }
330
331  const debouncedFetchData = (0,external_wp_compose_namespaceObject.useDebounce)(fetchData, 500); // When the component unmounts, set isMountedRef to false. This will
332  // let the async fetch callbacks know when to stop.
333
334  (0,external_wp_element_namespaceObject.useEffect)(() => () => {
335    isMountedRef.current = false;
336  }, []);
337  (0,external_wp_element_namespaceObject.useEffect)(() => {
338    // Don't debounce the first fetch. This ensures that the first render
339    // shows data as soon as possible.
340    if (prevProps === undefined) {
341      fetchData();
342    } else if (!es6_default()(prevProps, props)) {
343      debouncedFetchData();
344    }
345  });
346  /**
347   * Effect to handle showing the loading placeholder.
348   * Show it only if there is no previous response or
349   * the request takes more than one second.
350   */
351
352  (0,external_wp_element_namespaceObject.useEffect)(() => {
353    if (!isLoading) {
354      return;
355    }
356
357    const timeout = setTimeout(() => {
358      setShowLoader(true);
359    }, 1000);
360    return () => clearTimeout(timeout);
361  }, [isLoading]);
362  const hasResponse = !!response;
363  const hasEmptyResponse = response === '';
364  const hasError = response?.error;
365
366  if (isLoading) {
367    return (0,external_wp_element_namespaceObject.createElement)(LoadingResponsePlaceholder, { ...props,
368      showLoader: showLoader
369    }, hasResponse && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
370      className: className
371    }, response));
372  }
373
374  if (hasEmptyResponse || !hasResponse) {
375    return (0,external_wp_element_namespaceObject.createElement)(EmptyResponsePlaceholder, { ...props
376    });
377  }
378
379  if (hasError) {
380    return (0,external_wp_element_namespaceObject.createElement)(ErrorResponsePlaceholder, {
381      response: response,
382      ...props
383    });
384  }
385
386  return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
387    className: className
388  }, response);
389}
390
391;// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/index.js
392
393
394/**
395 * WordPress dependencies
396 */
397
398
399/**
400 * Internal dependencies
401 */
402
403
404/**
405 * Constants
406 */
407
408const build_module_EMPTY_OBJECT = {};
409const ExportedServerSideRender = (0,external_wp_data_namespaceObject.withSelect)(select => {
410  // FIXME: @wordpress/server-side-render should not depend on @wordpress/editor.
411  // It is used by blocks that can be loaded into a *non-post* block editor.
412  // eslint-disable-next-line @wordpress/data-no-store-string-literals
413  const coreEditorSelect = select('core/editor');
414
415  if (coreEditorSelect) {
416    const currentPostId = coreEditorSelect.getCurrentPostId(); // For templates and template parts we use a custom ID format.
417    // Since they aren't real posts, we don't want to use their ID
418    // for server-side rendering. Since they use a string based ID,
419    // we can assume real post IDs are numbers.
420
421    if (currentPostId && typeof currentPostId === 'number') {
422      return {
423        currentPostId
424      };
425    }
426  }
427
428  return build_module_EMPTY_OBJECT;
429})(({
430  urlQueryArgs = build_module_EMPTY_OBJECT,
431  currentPostId,
432  ...props
433}) => {
434  const newUrlQueryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => {
435    if (!currentPostId) {
436      return urlQueryArgs;
437    }
438
439    return {
440      post_id: currentPostId,
441      ...urlQueryArgs
442    };
443  }, [currentPostId, urlQueryArgs]);
444  return (0,external_wp_element_namespaceObject.createElement)(ServerSideRender, {
445    urlQueryArgs: newUrlQueryArgs,
446    ...props
447  });
448});
449/* harmony default export */ var build_module = (ExportedServerSideRender);
450
451}();
452(window.wp = window.wp || {}).serverSideRender = __webpack_exports__["default"];
453/******/ })()
454;

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.