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