UNPKG

react-simple-read-more

Version:

simple readmore library which allows you to hide your long description with read more and read less button

1,182 lines (1,155 loc) 1.48 MB
// modules are defined as an array // [ module function, map of requires ] // // map of requires is short require name -> numeric require // // anything defined in a previous bundle is accessed via the // orig method which is the require for previous bundles (function ( modules, entry, mainEntry, parcelRequireName, externals, distDir, publicUrl, devServer ) { /* eslint-disable no-undef */ var globalObject = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; /* eslint-enable no-undef */ // Save the require from previous bundle to this closure if any var previousRequire = typeof globalObject[parcelRequireName] === 'function' && globalObject[parcelRequireName]; var importMap = previousRequire.i || {}; var cache = previousRequire.cache || {}; // Do not use `require` to prevent Webpack from trying to bundle this call var nodeRequire = typeof module !== 'undefined' && typeof module.require === 'function' && module.require.bind(module); function newRequire(name, jumped) { if (!cache[name]) { if (!modules[name]) { if (externals[name]) { return externals[name]; } // if we cannot find the module within our internal map or // cache jump to the current global require ie. the last bundle // that was added to the page. var currentRequire = typeof globalObject[parcelRequireName] === 'function' && globalObject[parcelRequireName]; if (!jumped && currentRequire) { return currentRequire(name, true); } // If there are other bundles on this page the require from the // previous one is saved to 'previousRequire'. Repeat this as // many times as there are bundles until the module is found or // we exhaust the require chain. if (previousRequire) { return previousRequire(name, true); } // Try the node require function if it exists. if (nodeRequire && typeof name === 'string') { return nodeRequire(name); } var err = new Error("Cannot find module '" + name + "'"); err.code = 'MODULE_NOT_FOUND'; throw err; } localRequire.resolve = resolve; localRequire.cache = {}; var module = (cache[name] = new newRequire.Module(name)); modules[name][0].call( module.exports, localRequire, module, module.exports, globalObject ); } return cache[name].exports; function localRequire(x) { var res = localRequire.resolve(x); if (res === false) { return {}; } // Synthesize a module to follow re-exports. if (Array.isArray(res)) { var m = {__esModule: true}; res.forEach(function (v) { var key = v[0]; var id = v[1]; var exp = v[2] || v[0]; var x = newRequire(id); if (key === '*') { Object.keys(x).forEach(function (key) { if ( key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(m, key) ) { return; } Object.defineProperty(m, key, { enumerable: true, get: function () { return x[key]; }, }); }); } else if (exp === '*') { Object.defineProperty(m, key, { enumerable: true, value: x, }); } else { Object.defineProperty(m, key, { enumerable: true, get: function () { if (exp === 'default') { return x.__esModule ? x.default : x; } return x[exp]; }, }); } }); return m; } return newRequire(res); } function resolve(x) { var id = modules[name][1][x]; return id != null ? id : x; } } function Module(moduleName) { this.id = moduleName; this.bundle = newRequire; this.require = nodeRequire; this.exports = {}; } newRequire.isParcelRequire = true; newRequire.Module = Module; newRequire.modules = modules; newRequire.cache = cache; newRequire.parent = previousRequire; newRequire.distDir = distDir; newRequire.publicUrl = publicUrl; newRequire.devServer = devServer; newRequire.i = importMap; newRequire.register = function (id, exports) { modules[id] = [ function (require, module) { module.exports = exports; }, {}, ]; }; // Only insert newRequire.load when it is actually used. // The code in this file is linted against ES5, so dynamic import is not allowed. // INSERT_LOAD_HERE Object.defineProperty(newRequire, 'root', { get: function () { return globalObject[parcelRequireName]; }, }); globalObject[parcelRequireName] = newRequire; for (var i = 0; i < entry.length; i++) { newRequire(entry[i]); } if (mainEntry) { // Expose entry point to Node, AMD or browser globals // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js var mainExports = newRequire(mainEntry); // CommonJS if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = mainExports; // RequireJS } else if (typeof define === 'function' && define.amd) { define(function () { return mainExports; }); } } })({"ozci6":[function(require,module,exports,__globalThis) { var global = arguments[3]; var HMR_HOST = null; var HMR_PORT = null; var HMR_SERVER_PORT = 1234; var HMR_SECURE = false; var HMR_ENV_HASH = "439701173a9199ea"; var HMR_USE_SSE = false; module.bundle.HMR_BUNDLE_ID = "bb7f08362f061e96"; "use strict"; /* global HMR_HOST, HMR_PORT, HMR_SERVER_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */ /*:: import type { HMRAsset, HMRMessage, } from '@parcel/reporter-dev-server/src/HMRServer.js'; interface ParcelRequire { (string): mixed; cache: {|[string]: ParcelModule|}; hotData: {|[string]: mixed|}; Module: any; parent: ?ParcelRequire; isParcelRequire: true; modules: {|[string]: [Function, {|[string]: string|}]|}; HMR_BUNDLE_ID: string; root: ParcelRequire; } interface ParcelModule { hot: {| data: mixed, accept(cb: (Function) => void): void, dispose(cb: (mixed) => void): void, // accept(deps: Array<string> | string, cb: (Function) => void): void, // decline(): void, _acceptCallbacks: Array<(Function) => void>, _disposeCallbacks: Array<(mixed) => void>, |}; } interface ExtensionContext { runtime: {| reload(): void, getURL(url: string): string; getManifest(): {manifest_version: number, ...}; |}; } declare var module: {bundle: ParcelRequire, ...}; declare var HMR_HOST: string; declare var HMR_PORT: string; declare var HMR_SERVER_PORT: string; declare var HMR_ENV_HASH: string; declare var HMR_SECURE: boolean; declare var HMR_USE_SSE: boolean; declare var chrome: ExtensionContext; declare var browser: ExtensionContext; declare var __parcel__import__: (string) => Promise<void>; declare var __parcel__importScripts__: (string) => Promise<void>; declare var globalThis: typeof self; declare var ServiceWorkerGlobalScope: Object; */ var OVERLAY_ID = '__parcel__error__overlay__'; var OldModule = module.bundle.Module; function Module(moduleName) { OldModule.call(this, moduleName); this.hot = { data: module.bundle.hotData[moduleName], _acceptCallbacks: [], _disposeCallbacks: [], accept: function(fn) { this._acceptCallbacks.push(fn || function() {}); }, dispose: function(fn) { this._disposeCallbacks.push(fn); } }; module.bundle.hotData[moduleName] = undefined; } module.bundle.Module = Module; module.bundle.hotData = {}; var checkedAssets /*: {|[string]: boolean|} */ , disposedAssets /*: {|[string]: boolean|} */ , assetsToDispose /*: Array<[ParcelRequire, string]> */ , assetsToAccept /*: Array<[ParcelRequire, string]> */ , bundleNotFound = false; function getHostname() { return HMR_HOST || (typeof location !== 'undefined' && location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost'); } function getPort() { return HMR_PORT || (typeof location !== 'undefined' ? location.port : HMR_SERVER_PORT); } // eslint-disable-next-line no-redeclare let WebSocket = globalThis.WebSocket; if (!WebSocket && typeof module.bundle.root === 'function') try { // eslint-disable-next-line no-global-assign WebSocket = module.bundle.root('ws'); } catch { // ignore. } var hostname = getHostname(); var port = getPort(); var protocol = HMR_SECURE || typeof location !== 'undefined' && location.protocol === 'https:' && ![ 'localhost', '127.0.0.1', '0.0.0.0' ].includes(hostname) ? 'wss' : 'ws'; // eslint-disable-next-line no-redeclare var parent = module.bundle.parent; if (!parent || !parent.isParcelRequire) { // Web extension context var extCtx = typeof browser === 'undefined' ? typeof chrome === 'undefined' ? null : chrome : browser; // Safari doesn't support sourceURL in error stacks. // eval may also be disabled via CSP, so do a quick check. var supportsSourceURL = false; try { (0, eval)('throw new Error("test"); //# sourceURL=test.js'); } catch (err) { supportsSourceURL = err.stack.includes('test.js'); } var ws; if (HMR_USE_SSE) ws = new EventSource('/__parcel_hmr'); else try { // If we're running in the dev server's node runner, listen for messages on the parent port. let { workerData, parentPort } = module.bundle.root('node:worker_threads') /*: any*/ ; if (workerData !== null && workerData !== void 0 && workerData.__parcel) { parentPort.on('message', async (message)=>{ try { await handleMessage(message); parentPort.postMessage('updated'); } catch { parentPort.postMessage('restart'); } }); // After the bundle has finished running, notify the dev server that the HMR update is complete. queueMicrotask(()=>parentPort.postMessage('ready')); } } catch { if (typeof WebSocket !== 'undefined') try { ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/'); } catch (err) { // Ignore cloudflare workers error. if (err.message && !err.message.includes('Disallowed operation called within global scope')) console.error(err.message); } } if (ws) { // $FlowFixMe ws.onmessage = async function(event /*: {data: string, ...} */ ) { var data /*: HMRMessage */ = JSON.parse(event.data); await handleMessage(data); }; if (ws instanceof WebSocket) { ws.onerror = function(e) { if (e.message) console.error(e.message); }; ws.onclose = function() { console.warn("[parcel] \uD83D\uDEA8 Connection to the HMR server was lost"); }; } } } async function handleMessage(data /*: HMRMessage */ ) { checkedAssets = {} /*: {|[string]: boolean|} */ ; disposedAssets = {} /*: {|[string]: boolean|} */ ; assetsToAccept = []; assetsToDispose = []; bundleNotFound = false; if (data.type === 'reload') fullReload(); else if (data.type === 'update') { // Remove error overlay if there is one if (typeof document !== 'undefined') removeErrorOverlay(); let assets = data.assets; // Handle HMR Update let handled = assets.every((asset)=>{ return asset.type === 'css' || asset.type === 'js' && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle); }); // Dispatch a custom event in case a bundle was not found. This might mean // an asset on the server changed and we should reload the page. This event // gives the client an opportunity to refresh without losing state // (e.g. via React Server Components). If e.preventDefault() is not called, // we will trigger a full page reload. if (handled && bundleNotFound && assets.some((a)=>a.envHash !== HMR_ENV_HASH) && typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') handled = !window.dispatchEvent(new CustomEvent('parcelhmrreload', { cancelable: true })); if (handled) { console.clear(); // Dispatch custom event so other runtimes (e.g React Refresh) are aware. if (typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') window.dispatchEvent(new CustomEvent('parcelhmraccept')); await hmrApplyUpdates(assets); hmrDisposeQueue(); // Run accept callbacks. This will also re-execute other disposed assets in topological order. let processedAssets = {}; for(let i = 0; i < assetsToAccept.length; i++){ let id = assetsToAccept[i][1]; if (!processedAssets[id]) { hmrAccept(assetsToAccept[i][0], id); processedAssets[id] = true; } } } else fullReload(); } if (data.type === 'error') { // Log parcel errors to console for (let ansiDiagnostic of data.diagnostics.ansi){ let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack; console.error("\uD83D\uDEA8 [parcel]: " + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n')); } if (typeof document !== 'undefined') { // Render the fancy html overlay removeErrorOverlay(); var overlay = createErrorOverlay(data.diagnostics.html); // $FlowFixMe document.body.appendChild(overlay); } } } function removeErrorOverlay() { var overlay = document.getElementById(OVERLAY_ID); if (overlay) { overlay.remove(); console.log("[parcel] \u2728 Error resolved"); } } function createErrorOverlay(diagnostics) { var overlay = document.createElement('div'); overlay.id = OVERLAY_ID; let errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">'; for (let diagnostic of diagnostics){ let stack = diagnostic.frames.length ? diagnostic.frames.reduce((p, frame)=>{ return `${p} <a href="${protocol === 'wss' ? 'https' : 'http'}://${hostname}:${port}/__parcel_launch_editor?file=${encodeURIComponent(frame.location)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${frame.location}</a> ${frame.code}`; }, '') : diagnostic.stack; errorHTML += ` <div> <div style="font-size: 18px; font-weight: bold; margin-top: 20px;"> \u{1F6A8} ${diagnostic.message} </div> <pre>${stack}</pre> <div> ${diagnostic.hints.map((hint)=>"<div>\uD83D\uDCA1 " + hint + '</div>').join('')} </div> ${diagnostic.documentation ? `<div>\u{1F4DD} <a style="color: violet" href="${diagnostic.documentation}" target="_blank">Learn more</a></div>` : ''} </div> `; } errorHTML += '</div>'; overlay.innerHTML = errorHTML; return overlay; } function fullReload() { if (typeof location !== 'undefined' && 'reload' in location) location.reload(); else if (typeof extCtx !== 'undefined' && extCtx && extCtx.runtime && extCtx.runtime.reload) extCtx.runtime.reload(); else try { let { workerData, parentPort } = module.bundle.root('node:worker_threads') /*: any*/ ; if (workerData !== null && workerData !== void 0 && workerData.__parcel) parentPort.postMessage('restart'); } catch (err) { console.error("[parcel] \u26A0\uFE0F An HMR update was not accepted. Please restart the process."); } } function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ { var modules = bundle.modules; if (!modules) return []; var parents = []; var k, d, dep; for(k in modules)for(d in modules[k][1]){ dep = modules[k][1][d]; if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) parents.push([ bundle, k ]); } if (bundle.parent) parents = parents.concat(getParents(bundle.parent, id)); return parents; } function updateLink(link) { var href = link.getAttribute('href'); if (!href) return; var newLink = link.cloneNode(); newLink.onload = function() { if (link.parentNode !== null) // $FlowFixMe link.parentNode.removeChild(link); }; newLink.setAttribute('href', // $FlowFixMe href.split('?')[0] + '?' + Date.now()); // $FlowFixMe link.parentNode.insertBefore(newLink, link.nextSibling); } var cssTimeout = null; function reloadCSS() { if (cssTimeout || typeof document === 'undefined') return; cssTimeout = setTimeout(function() { var links = document.querySelectorAll('link[rel="stylesheet"]'); for(var i = 0; i < links.length; i++){ // $FlowFixMe[incompatible-type] var href /*: string */ = links[i].getAttribute('href'); var hostname = getHostname(); var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort()); var absolute = /^https?:\/\//i.test(href) && href.indexOf(location.origin) !== 0 && !servedFromHMRServer; if (!absolute) updateLink(links[i]); } cssTimeout = null; }, 50); } function hmrDownload(asset) { if (asset.type === 'js') { if (typeof document !== 'undefined') { let script = document.createElement('script'); script.src = asset.url + '?t=' + Date.now(); if (asset.outputFormat === 'esmodule') script.type = 'module'; return new Promise((resolve, reject)=>{ var _document$head; script.onload = ()=>resolve(script); script.onerror = reject; (_document$head = document.head) === null || _document$head === void 0 || _document$head.appendChild(script); }); } else if (typeof importScripts === 'function') { // Worker scripts if (asset.outputFormat === 'esmodule') return import(asset.url + '?t=' + Date.now()); else return new Promise((resolve, reject)=>{ try { importScripts(asset.url + '?t=' + Date.now()); resolve(); } catch (err) { reject(err); } }); } } } async function hmrApplyUpdates(assets) { global.parcelHotUpdate = Object.create(null); let scriptsToRemove; try { // If sourceURL comments aren't supported in eval, we need to load // the update from the dev server over HTTP so that stack traces // are correct in errors/logs. This is much slower than eval, so // we only do it if needed (currently just Safari). // https://bugs.webkit.org/show_bug.cgi?id=137297 // This path is also taken if a CSP disallows eval. if (!supportsSourceURL) { let promises = assets.map((asset)=>{ var _hmrDownload; return (_hmrDownload = hmrDownload(asset)) === null || _hmrDownload === void 0 ? void 0 : _hmrDownload.catch((err)=>{ // Web extension fix if (extCtx && extCtx.runtime && extCtx.runtime.getManifest().manifest_version == 3 && typeof ServiceWorkerGlobalScope != 'undefined' && global instanceof ServiceWorkerGlobalScope) { extCtx.runtime.reload(); return; } throw err; }); }); scriptsToRemove = await Promise.all(promises); } assets.forEach(function(asset) { hmrApply(module.bundle.root, asset); }); } finally{ delete global.parcelHotUpdate; if (scriptsToRemove) scriptsToRemove.forEach((script)=>{ if (script) { var _document$head2; (_document$head2 = document.head) === null || _document$head2 === void 0 || _document$head2.removeChild(script); } }); } } function hmrApply(bundle /*: ParcelRequire */ , asset /*: HMRAsset */ ) { var modules = bundle.modules; if (!modules) return; if (asset.type === 'css') reloadCSS(); else if (asset.type === 'js') { let deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID]; if (deps) { if (modules[asset.id]) { // Remove dependencies that are removed and will become orphaned. // This is necessary so that if the asset is added back again, the cache is gone, and we prevent a full page reload. let oldDeps = modules[asset.id][1]; for(let dep in oldDeps)if (!deps[dep] || deps[dep] !== oldDeps[dep]) { let id = oldDeps[dep]; let parents = getParents(module.bundle.root, id); if (parents.length === 1) hmrDelete(module.bundle.root, id); } } if (supportsSourceURL) // Global eval. We would use `new Function` here but browser // support for source maps is better with eval. (0, eval)(asset.output); // $FlowFixMe let fn = global.parcelHotUpdate[asset.id]; modules[asset.id] = [ fn, deps ]; } // Always traverse to the parent bundle, even if we already replaced the asset in this bundle. // This is required in case modules are duplicated. We need to ensure all instances have the updated code. if (bundle.parent) hmrApply(bundle.parent, asset); } } function hmrDelete(bundle, id) { let modules = bundle.modules; if (!modules) return; if (modules[id]) { // Collect dependencies that will become orphaned when this module is deleted. let deps = modules[id][1]; let orphans = []; for(let dep in deps){ let parents = getParents(module.bundle.root, deps[dep]); if (parents.length === 1) orphans.push(deps[dep]); } // Delete the module. This must be done before deleting dependencies in case of circular dependencies. delete modules[id]; delete bundle.cache[id]; // Now delete the orphans. orphans.forEach((id)=>{ hmrDelete(module.bundle.root, id); }); } else if (bundle.parent) hmrDelete(bundle.parent, id); } function hmrAcceptCheck(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) { checkedAssets = {}; if (hmrAcceptCheckOne(bundle, id, depsByBundle)) return true; // Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload. let parents = getParents(module.bundle.root, id); let accepted = false; while(parents.length > 0){ let v = parents.shift(); let a = hmrAcceptCheckOne(v[0], v[1], null); if (a) // If this parent accepts, stop traversing upward, but still consider siblings. accepted = true; else if (a !== null) { // Otherwise, queue the parents in the next level upward. let p = getParents(module.bundle.root, v[1]); if (p.length === 0) { // If there are no parents, then we've reached an entry without accepting. Reload. accepted = false; break; } parents.push(...p); } } return accepted; } function hmrAcceptCheckOne(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) { var modules = bundle.modules; if (!modules) return; if (depsByBundle && !depsByBundle[bundle.HMR_BUNDLE_ID]) { // If we reached the root bundle without finding where the asset should go, // there's nothing to do. Mark as "accepted" so we don't reload the page. if (!bundle.parent) { bundleNotFound = true; return true; } return hmrAcceptCheckOne(bundle.parent, id, depsByBundle); } if (checkedAssets[id]) return null; checkedAssets[id] = true; var cached = bundle.cache[id]; if (!cached) return true; assetsToDispose.push([ bundle, id ]); if (cached && cached.hot && cached.hot._acceptCallbacks.length) { assetsToAccept.push([ bundle, id ]); return true; } return false; } function hmrDisposeQueue() { // Dispose all old assets. for(let i = 0; i < assetsToDispose.length; i++){ let id = assetsToDispose[i][1]; if (!disposedAssets[id]) { hmrDispose(assetsToDispose[i][0], id); disposedAssets[id] = true; } } assetsToDispose = []; } function hmrDispose(bundle /*: ParcelRequire */ , id /*: string */ ) { var cached = bundle.cache[id]; bundle.hotData[id] = {}; if (cached && cached.hot) cached.hot.data = bundle.hotData[id]; if (cached && cached.hot && cached.hot._disposeCallbacks.length) cached.hot._disposeCallbacks.forEach(function(cb) { cb(bundle.hotData[id]); }); delete bundle.cache[id]; } function hmrAccept(bundle /*: ParcelRequire */ , id /*: string */ ) { // Execute the module. bundle(id); // Run the accept callbacks in the new version of the module. var cached = bundle.cache[id]; if (cached && cached.hot && cached.hot._acceptCallbacks.length) { let assetsToAlsoAccept = []; cached.hot._acceptCallbacks.forEach(function(cb) { let additionalAssets = cb(function() { return getParents(module.bundle.root, id); }); if (Array.isArray(additionalAssets) && additionalAssets.length) assetsToAlsoAccept.push(...additionalAssets); }); if (assetsToAlsoAccept.length) { let handled = assetsToAlsoAccept.every(function(a) { return hmrAcceptCheck(a[0], a[1]); }); if (!handled) return fullReload(); hmrDisposeQueue(); } } } },{}],"4NnGE":[function(require,module,exports,__globalThis) { var $parcel$ReactRefreshHelpers$4b53 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js"); $parcel$ReactRefreshHelpers$4b53.init(); var prevRefreshReg = globalThis.$RefreshReg$; var prevRefreshSig = globalThis.$RefreshSig$; $parcel$ReactRefreshHelpers$4b53.prelude(module); try { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); var _react = require("react"); var _reactDefault = parcelHelpers.interopDefault(_react); var _client = require("react-dom/client"); var _appJsx = require("./App.jsx"); var _appJsxDefault = parcelHelpers.interopDefault(_appJsx); const root = (0, _client.createRoot)(document.getElementById('root')); root.render(/*#__PURE__*/ (0, _reactDefault.default).createElement((0, _appJsxDefault.default), null)); $parcel$ReactRefreshHelpers$4b53.postlude(module); } finally { globalThis.$RefreshReg$ = prevRefreshReg; globalThis.$RefreshSig$ = prevRefreshSig; } },{"react":"jMk1U","react-dom/client":"hrvwu","./App.jsx":"aoToo","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"jMk1U":[function(require,module,exports,__globalThis) { 'use strict'; module.exports = require("a569817e6ea559f6"); },{"a569817e6ea559f6":"ghslp"}],"ghslp":[function(require,module,exports,__globalThis) { /** * @license React * react.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; (function() { 'use strict'; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === 'function') __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); var ReactVersion = '18.3.1'; // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. var REACT_ELEMENT_TYPE = Symbol.for('react.element'); var REACT_PORTAL_TYPE = Symbol.for('react.portal'); var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); var REACT_CONTEXT_TYPE = Symbol.for('react.context'); var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); var REACT_MEMO_TYPE = Symbol.for('react.memo'); var REACT_LAZY_TYPE = Symbol.for('react.lazy'); var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; function getIteratorFn(maybeIterable) { if (maybeIterable === null || typeof maybeIterable !== 'object') return null; var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; if (typeof maybeIterator === 'function') return maybeIterator; return null; } /** * Keeps track of the current dispatcher. */ var ReactCurrentDispatcher = { /** * @internal * @type {ReactComponent} */ current: null }; /** * Keeps track of the current batch's configuration such as how long an update * should suspend for if it needs to. */ var ReactCurrentBatchConfig = { transition: null }; var ReactCurrentActQueue = { current: null, // Used to reproduce behavior of `batchedUpdates` in legacy mode. isBatchingLegacy: false, didScheduleLegacyUpdate: false }; /** * Keeps track of the current owner. * * The current owner is the component who should own any components that are * currently being constructed. */ var ReactCurrentOwner = { /** * @internal * @type {ReactComponent} */ current: null }; var ReactDebugCurrentFrame = {}; var currentExtraStackFrame = null; function setExtraStackFrame(stack) { currentExtraStackFrame = stack; } ReactDebugCurrentFrame.setExtraStackFrame = function(stack) { currentExtraStackFrame = stack; }; // Stack implementation injected by the current renderer. ReactDebugCurrentFrame.getCurrentStack = null; ReactDebugCurrentFrame.getStackAddendum = function() { var stack = ''; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) stack += currentExtraStackFrame; // Delegate to the injected renderer-specific implementation var impl = ReactDebugCurrentFrame.getCurrentStack; if (impl) stack += impl() || ''; return stack; }; // ----------------------------------------------------------------------------- var enableScopeAPI = false; // Experimental Create Event Handle API. var enableCacheElement = false; var enableTransitionTracing = false; // No known bugs, but needs performance testing var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber // stuff. Intended to enable React core members to more easily debug scheduling // issues in DEV builds. var enableDebugTracing = false; // Track which Fiber(s) schedule render work. var ReactSharedInternals = { ReactCurrentDispatcher: ReactCurrentDispatcher, ReactCurrentBatchConfig: ReactCurrentBatchConfig, ReactCurrentOwner: ReactCurrentOwner }; ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; // by calls to these methods by a Babel plugin. // // In PROD (or in packages without access to React internals), // they are left as they are instead. function warn(format) { for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)args[_key - 1] = arguments[_key]; printWarning('warn', format, args); } function error(format) { for(var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++)args[_key2 - 1] = arguments[_key2]; printWarning('error', format, args); } function printWarning(level, format, args) { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== '') { format += '%s'; args = args.concat([ stack ]); } // eslint-disable-next-line react-internal/safe-string-coercion var argsWithFormat = args.map(function(item) { return String(item); }); // Careful: RN currently depends on this prefix argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it // breaks IE9: https://github.com/facebook/react/issues/13610 // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], console, argsWithFormat); } var didWarnStateUpdateForUnmountedComponent = {}; function warnNoop(publicInstance, callerName) { var _constructor = publicInstance.constructor; var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; var warningKey = componentName + "." + callerName; if (didWarnStateUpdateForUnmountedComponent[warningKey]) return; error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, componentName); didWarnStateUpdateForUnmountedComponent[warningKey] = true; } /** * This is the abstract API for an update queue. */ var ReactNoopUpdateQueue = { /** * Checks whether or not this composite component is mounted. * @param {ReactClass} publicInstance The instance we want to test. * @return {boolean} True if mounted, false otherwise. * @protected * @final */ isMounted: function(publicInstance) { return false; }, /** * Forces an update. This should only be invoked when it is known with * certainty that we are **not** in a DOM transaction. * * You may want to call this when you know that some deeper aspect of the * component's state has changed but `setState` was not called. * * This will not invoke `shouldComponentUpdate`, but it will invoke * `componentWillUpdate` and `componentDidUpdate`. * * @param {ReactClass} publicInstance The instance that should rerender. * @param {?function} callback Called after component is updated. * @param {?string} callerName name of the calling function in the public API. * @internal */ enqueueForceUpdate: function(publicInstance, callback, callerName) { warnNoop(publicInstance, 'forceUpdate'); }, /** * Replaces all of the state. Always use this or `setState` to mutate state. * You should treat `this.state` as immutable. * * There is no guarantee that `this.state` will be immediately updated, so * accessing `this.state` after calling this method may return the old value. * * @param {ReactClass} publicInstance The instance that should rerender. * @param {object} completeState Next state. * @param {?function} callback Called after component is updated. * @param {?string} callerName name of the calling function in the public API. * @internal */ enqueueReplaceState: function(publicInstance, completeState, callback, callerName) { warnNoop(publicInstance, 'replaceState'); }, /** * Sets a subset of the state. This only exists because _pendingState is * internal. This provides a merging strategy that is not available to deep * properties which is confusing. TODO: Expose pendingState or don't use it * during the merge. * * @param {ReactClass} publicInstance The instance that should rerender. * @param {object} partialState Next partial state to be merged with state. * @param {?function} callback Called after component is updated. * @param {?string} Name of the calling function in the public API. * @internal */ enqueueSetState: function(publicInstance, partialState, callback, callerName) { warnNoop(publicInstance, 'setState'); } }; var assign = Object.assign; var emptyObject = {}; Object.freeze(emptyObject); /** * Base class helpers for the updating state of a component. */ function Component(props, context, updater) { this.props = props; this.context = context; // If a component has string refs, we will assign a different object later. this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the // renderer. this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; /** * Sets a subset of the state. Always use this to mutate * state. You should treat `this.state` as immutable. * * There is no guarantee that `this.state` will be immediately updated, so * accessing `this.state` after calling this method may return the old value. * * There is no guarantee that calls to `setState` will run synchronously, * as they may eventually be batched together. You can provide an optional * callback that will be executed when the call to setState is actually * completed. * * When a function is provided to setState, it will be called at some point in * the future (not synchronously). It will be called with the up to date * component arguments (state, props, context). These values can be different * from this.* because your function may be called after receiveProps but before * shouldComponentUpdate, and this new state, props, and context will not yet be * assigned to this. * * @param {object|function} partialState Next partial state or function to * produce next partial state to be merged with current state. * @param {?function} callback Called after state is updated. * @final * @protected */ Component.prototype.setState = function(partialState, callback) { if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."); this.updater.enqueueSetState(this, partialState, callback, 'setState'); }; /** * Forces an update. This should only be invoked when it is known with * certainty that we are **not** in a DOM transaction. * * You may want to call this when you know that some deeper aspect of the * component's state has changed but `setState` was not called. * * This will not invoke `shouldComponentUpdate`, but it will invoke * `componentWillUpdate` and `componentDidUpdate`. * * @param {?function} callback Called after update is complete. * @final * @protected */ Component.prototype.forceUpdate = function(callback) { this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); }; var deprecatedAPIs = { isMounted: [ 'isMounted', "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks." ], replaceState: [ 'replaceState', "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)." ] }; var defineDeprecationWarning = function(methodName, info) { Object.defineProperty(Component.prototype, methodName, { get: function() { warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); return undefined; } }); }; for(var fnName in deprecatedAPIs)if (deprecatedAPIs.hasOwnProperty(fnName)) defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); function ComponentDummy() {} ComponentDummy.prototype = Component.prototype; /** * Convenience component with default shallow equality check for sCU. */ function PureComponent(props, context, updater) { this.props = props; this.context = context; // If a component has string refs, we will assign a different object later. this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; } var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. assign(pureComponentPrototype, Component.prototype); pureComponentPrototype.isPureReactComponent = true; // an immutable object with a single mutable value function createRef() { var refObject = { current: null }; Object.seal(refObject); return refObject; } var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare function isArray(a) { return isArrayImpl(a); } /* * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol * and Temporal.* types. See https://github.com/facebook/react/pull/22064. * * The functions in this module will throw an easier-to-understand, * easier-to-debug exception with a clear errors message message explaining the * problem. (Instead of a confusing exception thrown inside the implementation * of the `value` object). */ // $FlowFixMe only called in DEV, so void return is not possible. function typeName(value) { // toStringTag is needed for namespaced types like Temporal.Instant var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; return type; } // $FlowFixMe only called in DEV, so void return is not possible. function willCoercionThrow(value) { try { testStringCoercion(value); return false; } catch (e) { return true; } } function testStringCoercion(value) { // If you ended up here by following an exception call stack, here's what's // happened: you supplied an object or symbol value to React (as a prop, key, // DOM attribute, CSS property, string ref, etc.) and when React tried to // coerce it to a string using `'' + value`, an exception was thrown. // // The most common types that will cause this exception are `Symbol` instances // and Temporal objects like `Temporal.Instant`. But any object that has a // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this // exception. (Library authors do this to prevent users from using built-in // numeric operators like `+` or comparison operators like `>=` because custom // methods are needed to perform accurate arithmetic or comparison.) // // To fix the problem, coerce this object or symbol value to a string before // passing it to React. The most reliable way is usually `String(value)`. // // To find which value is throwing, check the browser or debugger console. // Before this exception was thrown, there should be `console.error` output // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the // problem and how that type was used: key, atrribute, input value prop, etc. // In most cases, this console output also shows the component and its // ancestor components where the exception happened. // // eslint-disable-next-line react-internal/safe-string-coercion return '' + value; } function checkKeyStringCoercion(value) { if (willCoercionThrow(value)) { error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value)); return testStringCoercion(value); // throw (to help callers find troubleshooting comments) } } function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; if (displayName) return displayName; var functionName = innerType.displayName || innerType.name || ''; return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; } // Keep in sync with react-reconciler/getComponentNameFromFiber function getContextName(type) { return type.displayName || 'Context'; } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. function getComponentNameFromType(type) { if (type == null) // Host root, text node or just invalid type. return null; if (typeof type.tag === 'number') error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."); if (typeof type === 'function') return type.displayName || type.name || null; if (typeof type === 'string') return type; switch(type){ case REACT_FRAGMENT_TYPE: return 'Fragment'; case REACT_PORTAL_TYPE: return 'Portal'; case REACT_PROFILER_TYPE: return 'Profiler'; case REACT_STRICT_MODE_TYPE: return 'StrictMode'; case REACT_SUSPENSE_TYPE: return 'Suspense'; case REACT_SUSPENSE_LIST_TYPE: return 'SuspenseList'; } if (typeof type === 'object') switch(type.$$typeof){ case REACT_CONTEXT_TYPE: var context = type; return getContextName(context) + '.Consumer'; case REACT_PROVIDER_TYPE: var provider = type; return getContextName(provider._context) + '.Provider'; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, 'ForwardRef'); case REACT_MEMO_TYPE: var outerName = type.displayName || null; if (outerName !== null) return outerName; return getComponentNameFromType(type.type) || 'Memo'; case REACT_LAZY_TYPE: var lazyComponent = type; var payload = lazyComponent._payload; var init = lazyComponent._init; try { return getComponentNameFromType(init(payload)); } catch (x) { return null; } } return null; } var hasOwnProperty = Object.prototype.hasOwnProperty; var RESERVED_PROPS = { key: true, ref: true, __self: true, __source: true }; var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; didWarnAboutStringRefs = {}; function hasValidRef(config) { if (hasOwnProperty.call(config, 'ref')) { var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; if (getter && getter.isReactWarning) return false; } return config.ref !== undefined; } function hasValidKey(config) { if (hasOwnProperty.call(config, 'key')) { var getter = Object.getOwnPropertyDescriptor(config, 'key').get; if (getter && getter.isReactWarning) return false; } return config.key !== undefined; } function defineKeyPropWarningGetter(props, displayName) { var warnAboutAccessingKey = function() { if (!specialPropKeyWarningShown) { specialPropKeyWarningShown = true; error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName); } }; warnAboutAccessingKey.isReac