| 23322 | * rather than having to wait for at least one async tick. |
| 23323 | */ var _syncModuleCache = typeof WeakMap !== "undefined" ? new WeakMap() : undefined; |
| 23324 | function asAsync(options) { |
| 23325 | var Async1 = /** @class */ function(_super) { |
| 23326 | (0, _tslib.__extends)(Async, _super); |
| 23327 | function Async() { |
| 23328 | var _this = _super !== null && _super.apply(this, arguments) || this; |
| 23329 | _this.state = { |
| 23330 | Component: _syncModuleCache ? _syncModuleCache.get(options.load) : undefined |
| 23331 | }; |
| 23332 | return _this; |
| 23333 | } |
| 23334 | Async.prototype.render = function() { |
| 23335 | // Typescript issue: the rest can't be pulled without the any cast, as TypeScript fails with rest on generics. |
| 23336 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 23337 | var _a = this.props, forwardedRef = _a.forwardedRef, Placeholder = _a.asyncPlaceholder, rest = (0, _tslib.__rest)(_a, [ |
| 23338 | "forwardedRef", |
| 23339 | "asyncPlaceholder" |
| 23340 | ]); |
| 23341 | var Component = this.state.Component; |
| 23342 | return Component ? _react.createElement(Component, (0, _tslib.__assign)((0, _tslib.__assign)({}, rest), { |
| 23343 | ref: forwardedRef |
| 23344 | })) : Placeholder ? _react.createElement(Placeholder, null) : null; |
| 23345 | }; |
| 23346 | Async.prototype.componentDidMount = function() { |
| 23347 | var _this = this; |
| 23348 | var Component = this.state.Component; |
| 23349 | if (!Component) options.load().then(function(LoadedComponent) { |
| 23350 | if (LoadedComponent) { |
| 23351 | // Cache component for future reference. |
| 23352 | _syncModuleCache && _syncModuleCache.set(options.load, LoadedComponent); |
| 23353 | // Set state. |
| 23354 | _this.setState({ |
| 23355 | Component: LoadedComponent |
| 23356 | }, options.onLoad); |
| 23357 | } |
| 23358 | }).catch(options.onError); |
| 23359 | }; |
| 23360 | return Async; |
| 23361 | }(_react.Component); |
| 23362 | return _react.forwardRef(function(props, ref) { |
| 23363 | return _react.createElement(Async1, (0, _tslib.__assign)({}, props, { |
| 23364 | forwardedRef: ref |
| 23365 | })); |
| 23366 | }); |
| 23367 | } |
| 23368 | |
| 23369 | },{"tslib":"01Tx1","react":"8ePka","@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"gVsq2":[function(require,module,exports) { |
| 23370 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |