658 lines
22 KiB
JavaScript
658 lines
22 KiB
JavaScript
this["wp"] = this["wp"] || {}; this["wp"]["serverSideRender"] =
|
|
/******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = 483);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ 0:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["element"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["i18n"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 11:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["compose"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 12:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
var arrayWithHoles = __webpack_require__(38);
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
function _iterableToArrayLimit(arr, i) {
|
|
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
|
|
|
|
if (_i == null) return;
|
|
var _arr = [];
|
|
var _n = true;
|
|
var _d = false;
|
|
|
|
var _s, _e;
|
|
|
|
try {
|
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
_arr.push(_s.value);
|
|
|
|
if (i && _arr.length === i) break;
|
|
}
|
|
} catch (err) {
|
|
_d = true;
|
|
_e = err;
|
|
} finally {
|
|
try {
|
|
if (!_n && _i["return"] != null) _i["return"]();
|
|
} finally {
|
|
if (_d) throw _e;
|
|
}
|
|
}
|
|
|
|
return _arr;
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
var unsupportedIterableToArray = __webpack_require__(28);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
var nonIterableRest = __webpack_require__(39);
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
|
|
|
|
|
|
|
|
function _slicedToArray(arr, i) {
|
|
return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 14:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; });
|
|
/* harmony import */ var _objectWithoutPropertiesLoose_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(45);
|
|
|
|
function _objectWithoutProperties(source, excluded) {
|
|
if (source == null) return {};
|
|
var target = Object(_objectWithoutPropertiesLoose_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(source, excluded);
|
|
var key, i;
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
|
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
key = sourceSymbolKeys[i];
|
|
if (excluded.indexOf(key) >= 0) continue;
|
|
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
|
|
return target;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["lodash"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 24:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
|
|
function _arrayLikeToArray(arr, len) {
|
|
if (len == null || len > arr.length) len = arr.length;
|
|
|
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
arr2[i] = arr[i];
|
|
}
|
|
|
|
return arr2;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 28:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
|
|
/* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
|
|
|
|
function _unsupportedIterableToArray(o, minLen) {
|
|
if (!o) return;
|
|
if (typeof o === "string") return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 29:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["url"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["components"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 35:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["deprecated"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 38:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
|
|
function _arrayWithHoles(arr) {
|
|
if (Array.isArray(arr)) return arr;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 39:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
|
|
function _nonIterableRest() {
|
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["data"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 45:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutPropertiesLoose; });
|
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
if (source == null) return {};
|
|
var target = {};
|
|
var sourceKeys = Object.keys(source);
|
|
var key, i;
|
|
|
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
key = sourceKeys[i];
|
|
if (excluded.indexOf(key) >= 0) continue;
|
|
target[key] = source[key];
|
|
}
|
|
|
|
return target;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 483:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// ESM COMPAT FLAG
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
|
|
var esm_extends = __webpack_require__(8);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
var defineProperty = __webpack_require__(5);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(14);
|
|
|
|
// EXTERNAL MODULE: external ["wp","element"]
|
|
var external_wp_element_ = __webpack_require__(0);
|
|
|
|
// EXTERNAL MODULE: external ["wp","data"]
|
|
var external_wp_data_ = __webpack_require__(4);
|
|
|
|
// EXTERNAL MODULE: external ["wp","deprecated"]
|
|
var external_wp_deprecated_ = __webpack_require__(35);
|
|
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
|
var slicedToArray = __webpack_require__(12);
|
|
|
|
// EXTERNAL MODULE: external "lodash"
|
|
var external_lodash_ = __webpack_require__(2);
|
|
|
|
// EXTERNAL MODULE: external ["wp","compose"]
|
|
var external_wp_compose_ = __webpack_require__(11);
|
|
|
|
// EXTERNAL MODULE: external ["wp","i18n"]
|
|
var external_wp_i18n_ = __webpack_require__(1);
|
|
|
|
// EXTERNAL MODULE: external ["wp","apiFetch"]
|
|
var external_wp_apiFetch_ = __webpack_require__(50);
|
|
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_);
|
|
|
|
// EXTERNAL MODULE: external ["wp","url"]
|
|
var external_wp_url_ = __webpack_require__(29);
|
|
|
|
// EXTERNAL MODULE: external ["wp","components"]
|
|
var external_wp_components_ = __webpack_require__(3);
|
|
|
|
// EXTERNAL MODULE: external ["wp","blocks"]
|
|
var external_wp_blocks_ = __webpack_require__(9);
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js
|
|
|
|
|
|
|
|
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function rendererPath(block) {
|
|
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
var urlQueryArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
return Object(external_wp_url_["addQueryArgs"])("/wp/v2/block-renderer/".concat(block), _objectSpread(_objectSpread({
|
|
context: 'edit'
|
|
}, null !== attributes ? {
|
|
attributes: attributes
|
|
} : {}), urlQueryArgs));
|
|
}
|
|
|
|
function DefaultEmptyResponsePlaceholder(_ref) {
|
|
var className = _ref.className;
|
|
return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
|
|
className: className
|
|
}, Object(external_wp_i18n_["__"])('Block rendered as empty.'));
|
|
}
|
|
|
|
function DefaultErrorResponsePlaceholder(_ref2) {
|
|
var response = _ref2.response,
|
|
className = _ref2.className;
|
|
var errorMessage = Object(external_wp_i18n_["sprintf"])( // translators: %s: error message describing the problem
|
|
Object(external_wp_i18n_["__"])('Error loading block: %s'), response.errorMsg);
|
|
return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
|
|
className: className
|
|
}, errorMessage);
|
|
}
|
|
|
|
function DefaultLoadingResponsePlaceholder(_ref3) {
|
|
var className = _ref3.className;
|
|
return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
|
|
className: className
|
|
}, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null));
|
|
}
|
|
|
|
function ServerSideRender(props) {
|
|
var attributes = props.attributes,
|
|
block = props.block,
|
|
className = props.className,
|
|
_props$httpMethod = props.httpMethod,
|
|
httpMethod = _props$httpMethod === void 0 ? 'GET' : _props$httpMethod,
|
|
urlQueryArgs = props.urlQueryArgs,
|
|
_props$EmptyResponseP = props.EmptyResponsePlaceholder,
|
|
EmptyResponsePlaceholder = _props$EmptyResponseP === void 0 ? DefaultEmptyResponsePlaceholder : _props$EmptyResponseP,
|
|
_props$ErrorResponseP = props.ErrorResponsePlaceholder,
|
|
ErrorResponsePlaceholder = _props$ErrorResponseP === void 0 ? DefaultErrorResponsePlaceholder : _props$ErrorResponseP,
|
|
_props$LoadingRespons = props.LoadingResponsePlaceholder,
|
|
LoadingResponsePlaceholder = _props$LoadingRespons === void 0 ? DefaultLoadingResponsePlaceholder : _props$LoadingRespons;
|
|
var isMountedRef = Object(external_wp_element_["useRef"])(true);
|
|
var fetchRequestRef = Object(external_wp_element_["useRef"])();
|
|
|
|
var _useState = Object(external_wp_element_["useState"])(null),
|
|
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
|
|
response = _useState2[0],
|
|
setResponse = _useState2[1];
|
|
|
|
var prevProps = Object(external_wp_compose_["usePrevious"])(props);
|
|
|
|
function fetchData() {
|
|
if (!isMountedRef.current) {
|
|
return;
|
|
}
|
|
|
|
if (null !== response) {
|
|
setResponse(null);
|
|
}
|
|
|
|
var sanitizedAttributes = attributes && Object(external_wp_blocks_["__experimentalSanitizeBlockAttributes"])(block, attributes); // If httpMethod is 'POST', send the attributes in the request body instead of the URL.
|
|
// This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
|
|
|
|
|
|
var isPostRequest = 'POST' === httpMethod;
|
|
var urlAttributes = isPostRequest ? null : sanitizedAttributes !== null && sanitizedAttributes !== void 0 ? sanitizedAttributes : null;
|
|
var path = rendererPath(block, urlAttributes, urlQueryArgs);
|
|
var data = isPostRequest ? {
|
|
attributes: sanitizedAttributes !== null && sanitizedAttributes !== void 0 ? sanitizedAttributes : null
|
|
} : null; // Store the latest fetch request so that when we process it, we can
|
|
// check if it is the current request, to avoid race conditions on slow networks.
|
|
|
|
var fetchRequest = fetchRequestRef.current = external_wp_apiFetch_default()({
|
|
path: path,
|
|
data: data,
|
|
method: isPostRequest ? 'POST' : 'GET'
|
|
}).then(function (fetchResponse) {
|
|
if (isMountedRef.current && fetchRequest === fetchRequestRef.current && fetchResponse) {
|
|
setResponse(fetchResponse.rendered);
|
|
}
|
|
}).catch(function (error) {
|
|
if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
|
|
setResponse({
|
|
error: true,
|
|
errorMsg: error.message
|
|
});
|
|
}
|
|
});
|
|
return fetchRequest;
|
|
}
|
|
|
|
var debouncedFetchData = Object(external_wp_compose_["useDebounce"])(fetchData, 500); // When the component unmounts, set isMountedRef to false. This will
|
|
// let the async fetch callbacks know when to stop.
|
|
|
|
Object(external_wp_element_["useEffect"])(function () {
|
|
return function () {
|
|
isMountedRef.current = false;
|
|
};
|
|
}, []);
|
|
Object(external_wp_element_["useEffect"])(function () {
|
|
// Don't debounce the first fetch. This ensures that the first render
|
|
// shows data as soon as possible
|
|
if (prevProps === undefined) {
|
|
fetchData();
|
|
} else if (!Object(external_lodash_["isEqual"])(prevProps, props)) {
|
|
debouncedFetchData();
|
|
}
|
|
});
|
|
|
|
if (response === '') {
|
|
return Object(external_wp_element_["createElement"])(EmptyResponsePlaceholder, props);
|
|
} else if (!response) {
|
|
return Object(external_wp_element_["createElement"])(LoadingResponsePlaceholder, props);
|
|
} else if (response.error) {
|
|
return Object(external_wp_element_["createElement"])(ErrorResponsePlaceholder, Object(esm_extends["a" /* default */])({
|
|
response: response
|
|
}, props));
|
|
}
|
|
|
|
return Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], {
|
|
className: className
|
|
}, response);
|
|
}
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/index.js
|
|
|
|
|
|
|
|
|
|
|
|
function build_module_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function build_module_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { build_module_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { build_module_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
|
|
/**
|
|
* Constants
|
|
*/
|
|
|
|
var EMPTY_OBJECT = {};
|
|
var ExportedServerSideRender = Object(external_wp_data_["withSelect"])(function (select) {
|
|
var coreEditorSelect = select('core/editor');
|
|
|
|
if (coreEditorSelect) {
|
|
var currentPostId = coreEditorSelect.getCurrentPostId(); // For templates and template parts we use a custom ID format.
|
|
// Since they aren't real posts, we don't want to use their ID
|
|
// for server-side rendering. Since they use a string based ID,
|
|
// we can assume real post IDs are numbers.
|
|
|
|
if (currentPostId && typeof currentPostId.id === 'number') {
|
|
return {
|
|
currentPostId: currentPostId
|
|
};
|
|
}
|
|
}
|
|
|
|
return EMPTY_OBJECT;
|
|
})(function (_ref) {
|
|
var _ref$urlQueryArgs = _ref.urlQueryArgs,
|
|
urlQueryArgs = _ref$urlQueryArgs === void 0 ? EMPTY_OBJECT : _ref$urlQueryArgs,
|
|
currentPostId = _ref.currentPostId,
|
|
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["urlQueryArgs", "currentPostId"]);
|
|
|
|
var newUrlQueryArgs = Object(external_wp_element_["useMemo"])(function () {
|
|
if (!currentPostId) {
|
|
return urlQueryArgs;
|
|
}
|
|
|
|
return build_module_objectSpread({
|
|
post_id: currentPostId
|
|
}, urlQueryArgs);
|
|
}, [currentPostId, urlQueryArgs]);
|
|
return Object(external_wp_element_["createElement"])(ServerSideRender, Object(esm_extends["a" /* default */])({
|
|
urlQueryArgs: newUrlQueryArgs
|
|
}, props));
|
|
});
|
|
|
|
if (window && window.wp && window.wp.components) {
|
|
window.wp.components.ServerSideRender = Object(external_wp_element_["forwardRef"])(function (props, ref) {
|
|
external_wp_deprecated_default()('wp.components.ServerSideRender', {
|
|
since: '5.3',
|
|
alternative: 'wp.serverSideRender'
|
|
});
|
|
return Object(external_wp_element_["createElement"])(ExportedServerSideRender, Object(esm_extends["a" /* default */])({}, props, {
|
|
ref: ref
|
|
}));
|
|
});
|
|
}
|
|
|
|
/* harmony default export */ var build_module = __webpack_exports__["default"] = (ExportedServerSideRender);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
|
|
function _defineProperty(obj, key, value) {
|
|
if (key in obj) {
|
|
Object.defineProperty(obj, key, {
|
|
value: value,
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true
|
|
});
|
|
} else {
|
|
obj[key] = value;
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 50:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["apiFetch"]; }());
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8:
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
|
|
function _extends() {
|
|
_extends = Object.assign || function (target) {
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
var source = arguments[i];
|
|
|
|
for (var key in source) {
|
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
return target;
|
|
};
|
|
|
|
return _extends.apply(this, arguments);
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9:
|
|
/***/ (function(module, exports) {
|
|
|
|
(function() { module.exports = window["wp"]["blocks"]; }());
|
|
|
|
/***/ })
|
|
|
|
/******/ })["default"]; |