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