[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ var __webpack_modules__ = ({ 4 5 /***/ 7734: 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 16 module.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 /************************************************************************/ 141 var __webpack_exports__ = {}; 142 143 // EXPORTS 144 __webpack_require__.d(__webpack_exports__, { 145 "default": () => (/* binding */ build_module) 146 }); 147 148 ;// external ["wp","element"] 149 const external_wp_element_namespaceObject = window["wp"]["element"]; 150 ;// external ["wp","data"] 151 const external_wp_data_namespaceObject = window["wp"]["data"]; 152 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js 153 var es6 = __webpack_require__(7734); 154 var es6_default = /*#__PURE__*/__webpack_require__.n(es6); 155 ;// external ["wp","compose"] 156 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 157 ;// external ["wp","i18n"] 158 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 159 ;// external ["wp","apiFetch"] 160 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 161 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 162 ;// external ["wp","url"] 163 const external_wp_url_namespaceObject = window["wp"]["url"]; 164 ;// external ["wp","components"] 165 const external_wp_components_namespaceObject = window["wp"]["components"]; 166 ;// external ["wp","blocks"] 167 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 168 ;// external "ReactJSXRuntime" 169 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 170 ;// ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js 171 /** 172 * External dependencies 173 */ 174 175 176 /** 177 * WordPress dependencies 178 */ 179 180 181 182 183 184 185 186 187 188 const EMPTY_OBJECT = {}; 189 function 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 } 198 function 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 { 218 ...restAttributes, 219 style: restStyles 220 }; 221 } 222 function DefaultEmptyResponsePlaceholder({ 223 className 224 }) { 225 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 226 className: className, 227 children: (0,external_wp_i18n_namespaceObject.__)('Block rendered as empty.') 228 }); 229 } 230 function DefaultErrorResponsePlaceholder({ 231 response, 232 className 233 }) { 234 const errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 235 // translators: %s: error message describing the problem 236 (0,external_wp_i18n_namespaceObject.__)('Error loading block: %s'), response.errorMsg); 237 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 238 className: className, 239 children: errorMessage 240 }); 241 } 242 function DefaultLoadingResponsePlaceholder({ 243 children, 244 showLoader 245 }) { 246 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 247 style: { 248 position: 'relative' 249 }, 250 children: [showLoader && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 251 style: { 252 position: 'absolute', 253 top: '50%', 254 left: '50%', 255 marginTop: '-9px', 256 marginLeft: '-9px' 257 }, 258 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) 259 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 260 style: { 261 opacity: showLoader ? '0.3' : 1 262 }, 263 children: children 264 })] 265 }); 266 } 267 function ServerSideRender(props) { 268 const { 269 attributes, 270 block, 271 className, 272 httpMethod = 'GET', 273 urlQueryArgs, 274 skipBlockSupportAttributes = false, 275 EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder, 276 ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder, 277 LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder 278 } = props; 279 const isMountedRef = (0,external_wp_element_namespaceObject.useRef)(false); 280 const [showLoader, setShowLoader] = (0,external_wp_element_namespaceObject.useState)(false); 281 const fetchRequestRef = (0,external_wp_element_namespaceObject.useRef)(); 282 const [response, setResponse] = (0,external_wp_element_namespaceObject.useState)(null); 283 const prevProps = (0,external_wp_compose_namespaceObject.usePrevious)(props); 284 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false); 285 function fetchData() { 286 var _sanitizedAttributes, _sanitizedAttributes2; 287 if (!isMountedRef.current) { 288 return; 289 } 290 setIsLoading(true); 291 292 // Schedule showing the Spinner after 1 second. 293 const timeout = setTimeout(() => { 294 setShowLoader(true); 295 }, 1000); 296 let sanitizedAttributes = attributes && (0,external_wp_blocks_namespaceObject.__experimentalSanitizeBlockAttributes)(block, attributes); 297 if (skipBlockSupportAttributes) { 298 sanitizedAttributes = removeBlockSupportAttributes(sanitizedAttributes); 299 } 300 301 // If httpMethod is 'POST', send the attributes in the request body instead of the URL. 302 // This allows sending a larger attributes object than in a GET request, where the attributes are in the URL. 303 const isPostRequest = 'POST' === httpMethod; 304 const urlAttributes = isPostRequest ? null : (_sanitizedAttributes = sanitizedAttributes) !== null && _sanitizedAttributes !== void 0 ? _sanitizedAttributes : null; 305 const path = rendererPath(block, urlAttributes, urlQueryArgs); 306 const data = isPostRequest ? { 307 attributes: (_sanitizedAttributes2 = sanitizedAttributes) !== null && _sanitizedAttributes2 !== void 0 ? _sanitizedAttributes2 : null 308 } : null; 309 310 // Store the latest fetch request so that when we process it, we can 311 // check if it is the current request, to avoid race conditions on slow networks. 312 const fetchRequest = fetchRequestRef.current = external_wp_apiFetch_default()({ 313 path, 314 data, 315 method: isPostRequest ? 'POST' : 'GET' 316 }).then(fetchResponse => { 317 if (isMountedRef.current && fetchRequest === fetchRequestRef.current && fetchResponse) { 318 setResponse(fetchResponse.rendered); 319 } 320 }).catch(error => { 321 if (isMountedRef.current && fetchRequest === fetchRequestRef.current) { 322 setResponse({ 323 error: true, 324 errorMsg: error.message 325 }); 326 } 327 }).finally(() => { 328 if (isMountedRef.current && fetchRequest === fetchRequestRef.current) { 329 setIsLoading(false); 330 // Cancel the timeout to show the Spinner. 331 setShowLoader(false); 332 clearTimeout(timeout); 333 } 334 }); 335 return fetchRequest; 336 } 337 const debouncedFetchData = (0,external_wp_compose_namespaceObject.useDebounce)(fetchData, 500); 338 339 // When the component unmounts, set isMountedRef to false. This will 340 // let the async fetch callbacks know when to stop. 341 (0,external_wp_element_namespaceObject.useEffect)(() => { 342 isMountedRef.current = true; 343 return () => { 344 isMountedRef.current = false; 345 }; 346 }, []); 347 (0,external_wp_element_namespaceObject.useEffect)(() => { 348 // Don't debounce the first fetch. This ensures that the first render 349 // shows data as soon as possible. 350 if (prevProps === undefined) { 351 fetchData(); 352 } else if (!es6_default()(prevProps, props)) { 353 debouncedFetchData(); 354 } 355 }); 356 const hasResponse = !!response; 357 const hasEmptyResponse = response === ''; 358 const hasError = response?.error; 359 if (isLoading) { 360 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LoadingResponsePlaceholder, { 361 ...props, 362 showLoader: showLoader, 363 children: hasResponse && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, { 364 className: className, 365 children: response 366 }) 367 }); 368 } 369 if (hasEmptyResponse || !hasResponse) { 370 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyResponsePlaceholder, { 371 ...props 372 }); 373 } 374 if (hasError) { 375 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ErrorResponsePlaceholder, { 376 response: response, 377 ...props 378 }); 379 } 380 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, { 381 className: className, 382 children: response 383 }); 384 } 385 386 ;// ./node_modules/@wordpress/server-side-render/build-module/index.js 387 /** 388 * WordPress dependencies 389 */ 390 391 392 393 /** 394 * Internal dependencies 395 */ 396 397 398 /** 399 * Constants 400 */ 401 402 const build_module_EMPTY_OBJECT = {}; 403 const ExportedServerSideRender = (0,external_wp_data_namespaceObject.withSelect)(select => { 404 // FIXME: @wordpress/server-side-render should not depend on @wordpress/editor. 405 // It is used by blocks that can be loaded into a *non-post* block editor. 406 // eslint-disable-next-line @wordpress/data-no-store-string-literals 407 const coreEditorSelect = select('core/editor'); 408 if (coreEditorSelect) { 409 const currentPostId = coreEditorSelect.getCurrentPostId(); 410 // For templates and template parts we use a custom ID format. 411 // Since they aren't real posts, we don't want to use their ID 412 // for server-side rendering. Since they use a string based ID, 413 // we can assume real post IDs are numbers. 414 if (currentPostId && typeof currentPostId === 'number') { 415 return { 416 currentPostId 417 }; 418 } 419 } 420 return build_module_EMPTY_OBJECT; 421 })(({ 422 urlQueryArgs = build_module_EMPTY_OBJECT, 423 currentPostId, 424 ...props 425 }) => { 426 const newUrlQueryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => { 427 if (!currentPostId) { 428 return urlQueryArgs; 429 } 430 return { 431 post_id: currentPostId, 432 ...urlQueryArgs 433 }; 434 }, [currentPostId, urlQueryArgs]); 435 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ServerSideRender, { 436 urlQueryArgs: newUrlQueryArgs, 437 ...props 438 }); 439 }); 440 /* harmony default export */ const build_module = (ExportedServerSideRender); 441 442 (window.wp = window.wp || {}).serverSideRender = __webpack_exports__["default"]; 443 /******/ })() 444 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Dec 22 08:20:01 2024 | Cross-referenced by PHPXref |