@mjhls/mjh-framework 1.0.881 → 1.0.883-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -168
- package/dist/cjs/AD.js +1 -1
- package/dist/cjs/AD300x250.js +11 -11
- package/dist/cjs/AD300x250x600.js +11 -11
- package/dist/cjs/AD728x90.js +12 -12
- package/dist/cjs/ADFloatingFooter.js +10 -10
- package/dist/cjs/ADFooter.js +3 -3
- package/dist/cjs/ADGutter.js +10 -10
- package/dist/cjs/{ADInfeed-4f661172.js → ADInfeed-2e48af77.js} +1 -1
- package/dist/cjs/ADSkyscraper.js +10 -10
- package/dist/cjs/ADSponsoredResources.js +10 -10
- package/dist/cjs/ADWebcast.js +10 -10
- package/dist/cjs/ADWelcome.js +10 -10
- package/dist/cjs/{ADlgInfeed-6242e5b5.js → ADlgInfeed-c39c7131.js} +1 -1
- package/dist/cjs/AccordionPanel.js +4 -4
- package/dist/cjs/AdSlot.js +10 -10
- package/dist/cjs/AdSlotsProvider.js +903 -10
- package/dist/cjs/AlgoliaSearch.js +264 -391
- package/dist/cjs/AlphabeticList.js +6 -6
- package/dist/cjs/ArticleCarousel.js +6 -6
- package/dist/cjs/ArticleProgramLandingPage.js +25 -25
- package/dist/cjs/ArticleSeriesLandingPage.js +22 -22
- package/dist/cjs/ArticleSeriesListing.js +16 -16
- package/dist/cjs/Auth.js +1297 -469
- package/dist/cjs/AuthWrapper.js +390 -1697
- package/dist/cjs/{AuthorComponent-421d5ec1.js → AuthorComponent-02e827ae.js} +1 -1
- package/dist/cjs/Beam.js +5 -5
- package/dist/cjs/{BlockContent-bac780ac.js → BlockContent-091a991f.js} +1 -1
- package/dist/cjs/Breadcrumbs.js +3 -3
- package/dist/cjs/CMEDeck.js +12 -12
- package/dist/cjs/Column2.js +6 -6
- package/dist/cjs/Column3.js +14 -14
- package/dist/cjs/ConferenceArticleCard.js +20 -20
- package/dist/cjs/DeckContent.js +30 -30
- package/dist/cjs/DeckQueue.js +19 -19
- package/dist/cjs/DeckQueuePaginated.js +339 -0
- package/dist/cjs/{Dfp-ab12cd55.js → Dfp-f492f985.js} +8 -8
- package/dist/cjs/EventsDeck.js +31 -31
- package/dist/cjs/ExternalResources.js +25 -25
- package/dist/cjs/Feature.js +6 -6
- package/dist/cjs/ForbesHero.js +6 -6
- package/dist/cjs/GridContent.js +27 -27
- package/dist/cjs/GridHero.js +7 -7
- package/dist/cjs/GroupDeck.js +6 -6
- package/dist/cjs/HamMagazine.js +23 -23
- package/dist/cjs/Hero.js +5 -5
- package/dist/cjs/HighlightenVideo.js +1 -1
- package/dist/cjs/HorizontalArticleListing.js +24 -24
- package/dist/cjs/HorizontalHero.js +6 -6
- package/dist/cjs/IssueContentDeck.js +6 -6
- package/dist/cjs/IssueDeck.js +8 -8
- package/dist/cjs/IssueLanding.js +58 -58
- package/dist/cjs/KMTracker.js +15 -15
- package/dist/cjs/LeftNav.js +10 -10
- package/dist/cjs/MasterDeck.js +30 -30
- package/dist/cjs/MasterDeckPaginated.js +443 -0
- package/dist/cjs/MediaSeriesCard-c6a6bfd3.js +9411 -0
- package/dist/cjs/MediaSeriesLanding.js +53 -9534
- package/dist/cjs/MediaSeriesLandingPaginated.js +521 -0
- package/dist/cjs/NavDvm.js +5 -5
- package/dist/cjs/NavMagazine.js +22 -22
- package/dist/cjs/NavNative.js +19 -19
- package/dist/cjs/OncliveHero.js +6 -5
- package/dist/cjs/OncliveLargeHero.js +7 -7
- package/dist/cjs/PageFilter.js +3 -3
- package/dist/cjs/Pagination-f3ef7bc1.js +59 -0
- package/dist/cjs/PartnerDetailListing.js +1233 -160
- package/dist/cjs/PdfDownload.js +1 -1
- package/dist/cjs/PopUpModal.js +3 -3
- package/dist/cjs/PubSection.js +19 -19
- package/dist/cjs/PubToc.js +5 -5
- package/dist/cjs/PublicationDeck.js +5 -5
- package/dist/cjs/PublicationLanding.js +34 -34
- package/dist/cjs/QueueDeckExpanded.js +21 -21
- package/dist/cjs/QueueDeckExpandedPaginated.js +1377 -0
- package/dist/cjs/RecentNews.js +1 -1
- package/dist/cjs/RelatedContent.js +33 -33
- package/dist/cjs/RelatedTopicsDropdown.js +10 -10
- package/dist/cjs/Search.js +3 -3
- package/dist/cjs/Segment.js +4 -4
- package/dist/cjs/SeriesListingDeck.js +10 -10
- package/dist/cjs/{SeriesSlider-372e418f.js → SeriesSlider-49b81b0b.js} +11 -11
- package/dist/cjs/SideFooter.js +8 -8
- package/dist/cjs/{SocialSearchComponent-80a2130a.js → SocialSearchComponent-e8477ca3.js} +7 -7
- package/dist/cjs/TaxonomyCard.js +6 -6
- package/dist/cjs/TaxonomyDescription.js +24 -24
- package/dist/cjs/TemplateNormal.js +16 -16
- package/dist/cjs/ThumbnailCard.js +5 -5
- package/dist/cjs/Ustream.js +10 -10
- package/dist/cjs/VerticalHero.js +5 -5
- package/dist/cjs/VideoProgramLandingPage.js +25 -25
- package/dist/cjs/VideoSeriesCard.js +9 -9
- package/dist/cjs/VideoSeriesFilter.js +5 -5
- package/dist/cjs/VideoSeriesLandingPage.js +23 -23
- package/dist/cjs/VideoSeriesListing.js +16 -16
- package/dist/cjs/View.js +63 -63
- package/dist/cjs/YahooHero.js +7 -7
- package/dist/cjs/YoutubeGroup.js +14 -14
- package/dist/cjs/{_is-array-bd978497.js → _is-array-aa52fa1e.js} +1 -1
- package/dist/cjs/{_iter-detect-ee3d4802.js → _iter-detect-05795553.js} +1 -1
- package/dist/cjs/{_object-sap-fee50a62.js → _object-sap-171b9ea5.js} +1 -1
- package/dist/cjs/{_object-to-array-18379aba.js → _object-to-array-9bac8737.js} +1 -1
- package/dist/cjs/{asyncToGenerator-15014394.js → asyncToGenerator-df19209d.js} +3 -3
- package/dist/cjs/{brightcove-react-player-loader.es-05029198.js → brightcove-react-player-loader.es-156bd4d6.js} +3 -4
- package/dist/cjs/{core.get-iterator-method-5cb3af28.js → core.get-iterator-method-f3c44602.js} +2 -2
- package/dist/cjs/{debounce-6191c8ee.js → debounce-529c8d06.js} +1 -1
- package/dist/cjs/{define-property-530a5e9e.js → define-property-21887c62.js} +1 -1
- package/dist/cjs/{defineProperty-5ca424cd.js → defineProperty-77a37684.js} +1 -1
- package/dist/cjs/{entities-fb0c6568.js → entities-310b46ee.js} +0 -4
- package/dist/cjs/{extends-1d905ddb.js → extends-eed4f016.js} +1 -1
- package/dist/cjs/faundadb.js +5 -5
- package/dist/cjs/getRelatedArticle.js +4 -4
- package/dist/cjs/getRootDocGroup.js +4 -4
- package/dist/cjs/getSerializers.js +24 -24
- package/dist/cjs/{getTargeting-41f2f52d.js → getTargeting-8874437b.js} +11 -11
- package/dist/cjs/getTargeting.js +5 -5
- package/dist/cjs/{index-79eed652.js → index-3294d3bc.js} +40 -39
- package/dist/cjs/{index-d3451292.js → index-396089c0.js} +510 -514
- package/dist/cjs/{index-ff69979f.js → index-be0c82be.js} +22 -28
- package/dist/cjs/{index-53e27416.js → index-e2e62963.js} +9 -25
- package/dist/cjs/{index.es-e9d84959.js → index.es-9110add6.js} +5 -23
- package/dist/cjs/{index.esm-bf016399.js → index.esm-4d410430.js} +3 -2
- package/dist/cjs/{index.esm-974f47d9.js → index.esm-90433435.js} +15 -6
- package/dist/cjs/{index.esm-44f3e2d0.js → index.esm-e32d3e8e.js} +6 -3
- package/dist/cjs/{index.esm-05850a2f.js → index.esm-ff47db6f.js} +12 -5
- package/dist/cjs/index.js +41 -43
- package/dist/cjs/inherits-8d29278d.js +110 -0
- package/dist/cjs/{inherits-337c73a7.js → inherits-cba9c846.js} +7 -7
- package/dist/cjs/{keys-91f31941.js → keys-d207942e.js} +2 -2
- package/dist/cjs/{lodash-b5e0d5f6.js → lodash-fc2922d0.js} +30 -127
- package/dist/cjs/main-02daeefe.js +862 -0
- package/dist/cjs/{md5-e1ca5797.js → md5-5039b1a6.js} +1 -1
- package/dist/cjs/{moment-ca3bd9fb.js → moment-575fe24c.js} +8 -10
- package/dist/cjs/{slicedToArray-0a78cdf3.js → slicedToArray-f6d4eaa8.js} +2 -2
- package/dist/cjs/{stringify-13405ce2.js → stringify-bbc68047.js} +1 -1
- package/dist/cjs/timeDifferenceCalc.js +1 -1
- package/dist/cjs/{toConsumableArray-39fd0757.js → toConsumableArray-c9b8a0d0.js} +2 -2
- package/dist/cjs/{toNumber-f2f8744b.js → toNumber-36d1e7e5.js} +4 -39
- package/dist/cjs/{typeof-3dd6d3df.js → typeof-5f52cf64.js} +3 -3
- package/dist/cjs/urlFor.js +4 -4
- package/dist/cjs/{ustream-api-5619c1fa.js → ustream-api-9ebe112f.js} +4 -4
- package/dist/cjs/{web.dom.iterable-a9359910.js → web.dom.iterable-e34bf324.js} +1 -1
- package/dist/esm/AD.js +1 -1
- package/dist/esm/AD300x250.js +11 -11
- package/dist/esm/AD300x250x600.js +11 -11
- package/dist/esm/AD728x90.js +12 -12
- package/dist/esm/ADFloatingFooter.js +10 -10
- package/dist/esm/ADFooter.js +3 -3
- package/dist/esm/ADGutter.js +10 -10
- package/dist/esm/{ADInfeed-7db96917.js → ADInfeed-d767ebe2.js} +3 -3
- package/dist/esm/ADSkyscraper.js +10 -10
- package/dist/esm/ADSponsoredResources.js +10 -10
- package/dist/esm/ADWebcast.js +10 -10
- package/dist/esm/ADWelcome.js +10 -10
- package/dist/esm/{ADlgInfeed-a3931e68.js → ADlgInfeed-cee95aa2.js} +1 -1
- package/dist/esm/AccordionPanel.js +4 -4
- package/dist/esm/AdSlot.js +10 -10
- package/dist/esm/AdSlotsProvider.js +905 -13
- package/dist/esm/AlgoliaSearch.js +32 -159
- package/dist/esm/AlphabeticList.js +6 -6
- package/dist/esm/ArticleCarousel.js +6 -6
- package/dist/esm/ArticleProgramLandingPage.js +25 -25
- package/dist/esm/ArticleSeriesLandingPage.js +22 -22
- package/dist/esm/ArticleSeriesListing.js +18 -18
- package/dist/esm/Auth.js +1297 -469
- package/dist/esm/AuthWrapper.js +385 -1692
- package/dist/esm/{AuthorComponent-2277b67c.js → AuthorComponent-e6f95c2f.js} +1 -1
- package/dist/esm/Beam.js +5 -5
- package/dist/esm/{BlockContent-ea93e8f7.js → BlockContent-e9b4ddcf.js} +1 -1
- package/dist/esm/Breadcrumbs.js +3 -3
- package/dist/esm/CMEDeck.js +12 -12
- package/dist/esm/Column1.js +4 -4
- package/dist/esm/Column2.js +11 -11
- package/dist/esm/Column3.js +20 -20
- package/dist/esm/ConferenceArticleCard.js +20 -20
- package/dist/esm/DeckContent.js +45 -45
- package/dist/esm/DeckQueue.js +37 -37
- package/dist/esm/DeckQueuePaginated.js +333 -0
- package/dist/esm/{Dfp-d6a5629f.js → Dfp-f867d061.js} +5 -5
- package/dist/esm/EventsDeck.js +57 -57
- package/dist/esm/ExternalResources.js +27 -27
- package/dist/esm/Feature.js +6 -6
- package/dist/esm/ForbesHero.js +6 -6
- package/dist/esm/GridContent.js +71 -71
- package/dist/esm/GridHero.js +7 -7
- package/dist/esm/GroupDeck.js +6 -6
- package/dist/esm/HamMagazine.js +26 -26
- package/dist/esm/Hero.js +5 -5
- package/dist/esm/HighlightenVideo.js +1 -1
- package/dist/esm/HorizontalArticleListing.js +24 -24
- package/dist/esm/HorizontalHero.js +6 -6
- package/dist/esm/IssueContentDeck.js +20 -20
- package/dist/esm/IssueDeck.js +30 -30
- package/dist/esm/IssueLanding.js +58 -58
- package/dist/esm/KMTracker.js +15 -15
- package/dist/esm/LeftNav.js +10 -10
- package/dist/esm/MasterDeck.js +33 -33
- package/dist/esm/MasterDeckPaginated.js +437 -0
- package/dist/esm/MediaSeriesCard-1dd7eae8.js +9403 -0
- package/dist/esm/MediaSeriesLanding.js +53 -9533
- package/dist/esm/MediaSeriesLandingPaginated.js +516 -0
- package/dist/esm/NavDvm.js +8 -8
- package/dist/esm/NavMagazine.js +25 -25
- package/dist/esm/NavNative.js +24 -24
- package/dist/esm/OncliveHero.js +6 -5
- package/dist/esm/OncliveLargeHero.js +7 -7
- package/dist/esm/PageFilter.js +3 -3
- package/dist/esm/Pagination-a24855d4.js +54 -0
- package/dist/esm/PartnerDetailListing.js +1234 -161
- package/dist/esm/PdfDownload.js +1 -1
- package/dist/esm/PopUpModal.js +3 -3
- package/dist/esm/PubSection.js +19 -19
- package/dist/esm/PubToc.js +5 -5
- package/dist/esm/PublicationDeck.js +23 -23
- package/dist/esm/PublicationLanding.js +56 -56
- package/dist/esm/QueueDeckExpanded.js +21 -21
- package/dist/esm/QueueDeckExpandedPaginated.js +1371 -0
- package/dist/esm/RecentNews.js +1 -1
- package/dist/esm/RelatedContent.js +33 -33
- package/dist/esm/RelatedTopicsDropdown.js +10 -10
- package/dist/esm/RolesDeck.js +12 -12
- package/dist/esm/Search.js +5 -5
- package/dist/esm/Segment.js +4 -4
- package/dist/esm/SeriesListingDeck.js +10 -10
- package/dist/esm/{SeriesSlider-88c4133d.js → SeriesSlider-ce19fa25.js} +11 -11
- package/dist/esm/SideFooter.js +8 -8
- package/dist/esm/{SocialSearchComponent-7f3d6531.js → SocialSearchComponent-dca69151.js} +10 -10
- package/dist/esm/TaxonomyCard.js +22 -22
- package/dist/esm/TaxonomyDescription.js +24 -24
- package/dist/esm/TemplateNormal.js +19 -19
- package/dist/esm/ThumbnailCard.js +5 -5
- package/dist/esm/Ustream.js +10 -10
- package/dist/esm/VerticalHero.js +5 -5
- package/dist/esm/VideoProgramLandingPage.js +30 -30
- package/dist/esm/VideoSeriesCard.js +8 -8
- package/dist/esm/VideoSeriesFilter.js +5 -5
- package/dist/esm/VideoSeriesLandingPage.js +22 -22
- package/dist/esm/VideoSeriesListing.js +19 -19
- package/dist/esm/View.js +38 -38
- package/dist/esm/YahooHero.js +7 -7
- package/dist/esm/YoutubeGroup.js +14 -14
- package/dist/esm/{_is-array-8914b83f.js → _is-array-4df618a6.js} +1 -1
- package/dist/esm/{_iter-detect-13e31915.js → _iter-detect-130ee549.js} +1 -1
- package/dist/esm/{_object-sap-fc9da7e8.js → _object-sap-8b8ea5a9.js} +1 -1
- package/dist/esm/{_object-to-array-ee8f6d98.js → _object-to-array-c54dd835.js} +1 -1
- package/dist/esm/{asyncToGenerator-40371743.js → asyncToGenerator-7bf8bc4d.js} +3 -3
- package/dist/esm/{brightcove-react-player-loader.es-e761d404.js → brightcove-react-player-loader.es-83f53e4e.js} +3 -4
- package/dist/esm/{core.get-iterator-method-0fb60d94.js → core.get-iterator-method-86d4db69.js} +2 -2
- package/dist/esm/{debounce-89969f66.js → debounce-9207d8ee.js} +1 -1
- package/dist/esm/{define-property-73034847.js → define-property-6d26cb48.js} +1 -1
- package/dist/esm/{defineProperty-e66a2c7c.js → defineProperty-d7d9b577.js} +1 -1
- package/dist/esm/{entities-731f3fdb.js → entities-7cc3bf45.js} +0 -4
- package/dist/esm/{extends-9a61581c.js → extends-5b1796d4.js} +1 -1
- package/dist/esm/faundadb.js +5 -5
- package/dist/esm/getRelatedArticle.js +4 -4
- package/dist/esm/getRootDocGroup.js +4 -4
- package/dist/esm/getSerializers.js +24 -24
- package/dist/esm/{getTargeting-e6820763.js → getTargeting-277c801e.js} +11 -11
- package/dist/esm/getTargeting.js +5 -5
- package/dist/esm/{index-f7fdcc91.js → index-73819142.js} +22 -28
- package/dist/esm/{index-637e8f49.js → index-aaa2dae0.js} +10 -25
- package/dist/esm/{index-cf149780.js → index-d1476645.js} +529 -533
- package/dist/esm/{index-511bdaa5.js → index-ef6d5dcf.js} +40 -39
- package/dist/esm/{index.es-a6137319.js → index.es-29c1cef5.js} +5 -23
- package/dist/esm/{index.esm-3fdda599.js → index.esm-29e48d38.js} +15 -6
- package/dist/esm/{index.esm-a8ff922c.js → index.esm-cf08bf18.js} +12 -5
- package/dist/esm/{index.esm-c6715e80.js → index.esm-f8aaeeeb.js} +6 -3
- package/dist/esm/{index.esm-ed50151c.js → index.esm-fd746768.js} +3 -2
- package/dist/esm/index.js +46 -48
- package/dist/esm/{inherits-eeaf6740.js → inherits-2409637d.js} +4 -4
- package/dist/esm/inherits-77d5e4fc.js +101 -0
- package/dist/esm/{keys-a5ffafe7.js → keys-69989821.js} +2 -2
- package/dist/esm/{lodash-a818d390.js → lodash-17fdfebb.js} +30 -127
- package/dist/esm/main-c0612122.js +851 -0
- package/dist/esm/{md5-4e42248e.js → md5-9be0e905.js} +1 -1
- package/dist/esm/{moment-b6f49411.js → moment-e2f9b20c.js} +8 -10
- package/dist/esm/{slicedToArray-9c3bb613.js → slicedToArray-67a08c9c.js} +2 -2
- package/dist/esm/{stringify-ebc16384.js → stringify-70b72959.js} +1 -1
- package/dist/esm/timeDifferenceCalc.js +1 -1
- package/dist/esm/{toConsumableArray-e333293f.js → toConsumableArray-32282905.js} +2 -2
- package/dist/esm/{toNumber-e3dcad26.js → toNumber-2f7a84cd.js} +4 -39
- package/dist/esm/{typeof-938ae770.js → typeof-c05a82ba.js} +3 -3
- package/dist/esm/urlFor.js +4 -4
- package/dist/esm/{ustream-api-d325d196.js → ustream-api-4c4fe0ba.js} +4 -4
- package/dist/esm/{web.dom.iterable-6b037ff9.js → web.dom.iterable-f8f967cd.js} +1 -1
- package/package.json +112 -112
- package/dist/cjs/main-bc7d4bf8.js +0 -972
- package/dist/esm/main-ede573ee.js +0 -961
package/dist/esm/Auth.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './core.get-iterator-method-
|
|
1
|
+
import { a as commonjsGlobal } from './_commonjsHelpers-0c4b6f40.js';
|
|
2
|
+
import './core.get-iterator-method-86d4db69.js';
|
|
3
3
|
import './_library-528f1934.js';
|
|
4
|
-
import './_iter-detect-
|
|
4
|
+
import './_iter-detect-130ee549.js';
|
|
5
5
|
import './_object-pie-33c40e79.js';
|
|
6
|
-
import { _ as _extends } from './extends-
|
|
7
|
-
import './web.dom.iterable-
|
|
8
|
-
import React__default, { useEffect, useState } from 'react';
|
|
6
|
+
import { _ as _extends } from './extends-5b1796d4.js';
|
|
7
|
+
import './web.dom.iterable-f8f967cd.js';
|
|
8
|
+
import React__default, { useEffect, useLayoutEffect, createContext, useContext, useRef, useDebugValue, useState, useCallback, useMemo } from 'react';
|
|
9
9
|
import Router from 'next/router';
|
|
10
|
-
import { _ as _slicedToArray, a as _getIterator } from './slicedToArray-
|
|
11
|
-
import { _ as _JSON$stringify } from './stringify-
|
|
12
|
-
import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-
|
|
10
|
+
import { _ as _slicedToArray, a as _getIterator } from './slicedToArray-67a08c9c.js';
|
|
11
|
+
import { _ as _JSON$stringify } from './stringify-70b72959.js';
|
|
12
|
+
import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-7bf8bc4d.js';
|
|
13
13
|
import { Col, Form, Button, Spinner } from 'react-bootstrap';
|
|
14
14
|
import { u as util } from './util-7700fc59.js';
|
|
15
15
|
import { s as serialize_1, p as parse_1 } from './index-db3bb315.js';
|
|
16
|
-
import useSWR from 'swr';
|
|
17
16
|
import Local from 'passport-local';
|
|
18
17
|
import mysql from 'mysql';
|
|
19
|
-
import { m as md5 } from './md5-
|
|
18
|
+
import { m as md5 } from './md5-9be0e905.js';
|
|
20
19
|
|
|
21
20
|
var returnFormField = function returnFormField(_ref) {
|
|
22
21
|
var name = _ref.name,
|
|
@@ -134,6 +133,1055 @@ var returnFormField = function returnFormField(_ref) {
|
|
|
134
133
|
}
|
|
135
134
|
};
|
|
136
135
|
|
|
136
|
+
var has = Object.prototype.hasOwnProperty;
|
|
137
|
+
|
|
138
|
+
function dequal(foo, bar) {
|
|
139
|
+
var ctor, len;
|
|
140
|
+
if (foo === bar) return true;
|
|
141
|
+
|
|
142
|
+
if (foo && bar && (ctor=foo.constructor) === bar.constructor) {
|
|
143
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
144
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
145
|
+
|
|
146
|
+
if (ctor === Array) {
|
|
147
|
+
if ((len=foo.length) === bar.length) {
|
|
148
|
+
while (len-- && dequal(foo[len], bar[len]));
|
|
149
|
+
}
|
|
150
|
+
return len === -1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!ctor || typeof foo === 'object') {
|
|
154
|
+
len = 0;
|
|
155
|
+
for (ctor in foo) {
|
|
156
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
157
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
158
|
+
}
|
|
159
|
+
return Object.keys(bar).length === len;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return foo !== foo && bar !== bar;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// use WeakMap to store the object->key mapping
|
|
167
|
+
// so the objects can be garbage collected.
|
|
168
|
+
// WeakMap uses a hashtable under the hood, so the lookup
|
|
169
|
+
// complexity is almost O(1).
|
|
170
|
+
var table = new WeakMap();
|
|
171
|
+
// counter of the key
|
|
172
|
+
var counter = 0;
|
|
173
|
+
// hashes an array of objects and returns a string
|
|
174
|
+
function hash(args) {
|
|
175
|
+
if (!args.length)
|
|
176
|
+
return '';
|
|
177
|
+
var key = 'arg';
|
|
178
|
+
for (var i = 0; i < args.length; ++i) {
|
|
179
|
+
if (args[i] === null) {
|
|
180
|
+
key += '@null';
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
var _hash = void 0;
|
|
184
|
+
if (typeof args[i] !== 'object' && typeof args[i] !== 'function') {
|
|
185
|
+
// need to consider the case that args[i] is a string:
|
|
186
|
+
// args[i] _hash
|
|
187
|
+
// "undefined" -> '"undefined"'
|
|
188
|
+
// undefined -> 'undefined'
|
|
189
|
+
// 123 -> '123'
|
|
190
|
+
// "null" -> '"null"'
|
|
191
|
+
if (typeof args[i] === 'string') {
|
|
192
|
+
_hash = '"' + args[i] + '"';
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
_hash = String(args[i]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
if (!table.has(args[i])) {
|
|
200
|
+
_hash = counter;
|
|
201
|
+
table.set(args[i], counter++);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
_hash = table.get(args[i]);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
key += '@' + _hash;
|
|
208
|
+
}
|
|
209
|
+
return key;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var Cache = /** @class */ (function () {
|
|
213
|
+
function Cache(initialData) {
|
|
214
|
+
if (initialData === void 0) { initialData = {}; }
|
|
215
|
+
this.cache = new Map(Object.entries(initialData));
|
|
216
|
+
this.subs = [];
|
|
217
|
+
}
|
|
218
|
+
Cache.prototype.get = function (key) {
|
|
219
|
+
var _key = this.serializeKey(key)[0];
|
|
220
|
+
return this.cache.get(_key);
|
|
221
|
+
};
|
|
222
|
+
Cache.prototype.set = function (key, value) {
|
|
223
|
+
var _key = this.serializeKey(key)[0];
|
|
224
|
+
this.cache.set(_key, value);
|
|
225
|
+
this.notify();
|
|
226
|
+
};
|
|
227
|
+
Cache.prototype.keys = function () {
|
|
228
|
+
return Array.from(this.cache.keys());
|
|
229
|
+
};
|
|
230
|
+
Cache.prototype.has = function (key) {
|
|
231
|
+
var _key = this.serializeKey(key)[0];
|
|
232
|
+
return this.cache.has(_key);
|
|
233
|
+
};
|
|
234
|
+
Cache.prototype.clear = function () {
|
|
235
|
+
this.cache.clear();
|
|
236
|
+
this.notify();
|
|
237
|
+
};
|
|
238
|
+
Cache.prototype.delete = function (key) {
|
|
239
|
+
var _key = this.serializeKey(key)[0];
|
|
240
|
+
this.cache.delete(_key);
|
|
241
|
+
this.notify();
|
|
242
|
+
};
|
|
243
|
+
// TODO: introduce namespace for the cache
|
|
244
|
+
Cache.prototype.serializeKey = function (key) {
|
|
245
|
+
var args = null;
|
|
246
|
+
if (typeof key === 'function') {
|
|
247
|
+
try {
|
|
248
|
+
key = key();
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
// dependencies not ready
|
|
252
|
+
key = '';
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (Array.isArray(key)) {
|
|
256
|
+
// args array
|
|
257
|
+
args = key;
|
|
258
|
+
key = hash(key);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
// convert null to ''
|
|
262
|
+
key = String(key || '');
|
|
263
|
+
}
|
|
264
|
+
var errorKey = key ? 'err@' + key : '';
|
|
265
|
+
var isValidatingKey = key ? 'validating@' + key : '';
|
|
266
|
+
return [key, args, errorKey, isValidatingKey];
|
|
267
|
+
};
|
|
268
|
+
Cache.prototype.subscribe = function (listener) {
|
|
269
|
+
var _this = this;
|
|
270
|
+
if (typeof listener !== 'function') {
|
|
271
|
+
throw new Error('Expected the listener to be a function.');
|
|
272
|
+
}
|
|
273
|
+
var isSubscribed = true;
|
|
274
|
+
this.subs.push(listener);
|
|
275
|
+
return function () {
|
|
276
|
+
if (!isSubscribed)
|
|
277
|
+
return;
|
|
278
|
+
isSubscribed = false;
|
|
279
|
+
var index = _this.subs.indexOf(listener);
|
|
280
|
+
if (index > -1) {
|
|
281
|
+
_this.subs[index] = _this.subs[_this.subs.length - 1];
|
|
282
|
+
_this.subs.length--;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
// Notify Cache subscribers about a change in the cache
|
|
287
|
+
Cache.prototype.notify = function () {
|
|
288
|
+
for (var _i = 0, _a = this.subs; _i < _a.length; _i++) {
|
|
289
|
+
var listener = _a[_i];
|
|
290
|
+
listener();
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
return Cache;
|
|
294
|
+
}());
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Due to bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
|
|
298
|
+
* it's not reliable to detect if the browser is currently online or offline
|
|
299
|
+
* based on `navigator.onLine`.
|
|
300
|
+
* As a work around, we always assume it's online on first load, and change
|
|
301
|
+
* the status upon `online` or `offline` events.
|
|
302
|
+
*/
|
|
303
|
+
var online = true;
|
|
304
|
+
var isOnline = function () { return online; };
|
|
305
|
+
var isDocumentVisible = function () {
|
|
306
|
+
if (typeof document !== 'undefined' &&
|
|
307
|
+
document.visibilityState !== undefined) {
|
|
308
|
+
return document.visibilityState !== 'hidden';
|
|
309
|
+
}
|
|
310
|
+
// always assume it's visible
|
|
311
|
+
return true;
|
|
312
|
+
};
|
|
313
|
+
var fetcher = function (url) { return fetch(url).then(function (res) { return res.json(); }); };
|
|
314
|
+
var registerOnFocus = function (cb) {
|
|
315
|
+
if (typeof window !== 'undefined' &&
|
|
316
|
+
window.addEventListener !== undefined &&
|
|
317
|
+
typeof document !== 'undefined' &&
|
|
318
|
+
document.addEventListener !== undefined) {
|
|
319
|
+
// focus revalidate
|
|
320
|
+
document.addEventListener('visibilitychange', function () { return cb(); }, false);
|
|
321
|
+
window.addEventListener('focus', function () { return cb(); }, false);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
var registerOnReconnect = function (cb) {
|
|
325
|
+
if (typeof window !== 'undefined' && window.addEventListener !== undefined) {
|
|
326
|
+
// reconnect revalidate
|
|
327
|
+
window.addEventListener('online', function () {
|
|
328
|
+
online = true;
|
|
329
|
+
cb();
|
|
330
|
+
}, false);
|
|
331
|
+
// nothing to revalidate, just update the status
|
|
332
|
+
window.addEventListener('offline', function () { return (online = false); }, false);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
var webPreset = {
|
|
336
|
+
isOnline: isOnline,
|
|
337
|
+
isDocumentVisible: isDocumentVisible,
|
|
338
|
+
fetcher: fetcher,
|
|
339
|
+
registerOnFocus: registerOnFocus,
|
|
340
|
+
registerOnReconnect: registerOnReconnect
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
344
|
+
__assign = Object.assign || function(t) {
|
|
345
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
346
|
+
s = arguments[i];
|
|
347
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
348
|
+
t[p] = s[p];
|
|
349
|
+
}
|
|
350
|
+
return t;
|
|
351
|
+
};
|
|
352
|
+
return __assign.apply(this, arguments);
|
|
353
|
+
};
|
|
354
|
+
// cache
|
|
355
|
+
var cache = new Cache();
|
|
356
|
+
// error retry
|
|
357
|
+
function onErrorRetry(_, __, config, revalidate, opts) {
|
|
358
|
+
if (!config.isDocumentVisible()) {
|
|
359
|
+
// if it's hidden, stop
|
|
360
|
+
// it will auto revalidate when focus
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (typeof config.errorRetryCount === 'number' &&
|
|
364
|
+
opts.retryCount > config.errorRetryCount) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
// exponential backoff
|
|
368
|
+
var count = Math.min(opts.retryCount, 8);
|
|
369
|
+
var timeout = ~~((Math.random() + 0.5) * (1 << count)) * config.errorRetryInterval;
|
|
370
|
+
setTimeout(revalidate, timeout, opts);
|
|
371
|
+
}
|
|
372
|
+
// client side: need to adjust the config
|
|
373
|
+
// based on the browser status
|
|
374
|
+
// slow connection (<= 70Kbps)
|
|
375
|
+
var slowConnection = typeof window !== 'undefined' &&
|
|
376
|
+
// @ts-ignore
|
|
377
|
+
navigator['connection'] &&
|
|
378
|
+
// @ts-ignore
|
|
379
|
+
['slow-2g', '2g'].indexOf(navigator['connection'].effectiveType) !== -1;
|
|
380
|
+
// config
|
|
381
|
+
var defaultConfig = __assign({
|
|
382
|
+
// events
|
|
383
|
+
onLoadingSlow: function () { }, onSuccess: function () { }, onError: function () { }, onErrorRetry: onErrorRetry, errorRetryInterval: (slowConnection ? 10 : 5) * 1000, focusThrottleInterval: 5 * 1000, dedupingInterval: 2 * 1000, loadingTimeout: (slowConnection ? 5 : 3) * 1000, refreshInterval: 0, revalidateOnFocus: true, revalidateOnReconnect: true, refreshWhenHidden: false, refreshWhenOffline: false, shouldRetryOnError: true, suspense: false, compare: dequal, isPaused: function () { return false; } }, webPreset);
|
|
384
|
+
|
|
385
|
+
var IS_SERVER = typeof window === 'undefined' ||
|
|
386
|
+
// @ts-ignore
|
|
387
|
+
!!(typeof Deno !== 'undefined' && Deno && Deno.version && Deno.version.deno);
|
|
388
|
+
// polyfill for requestAnimationFrame
|
|
389
|
+
var rAF = IS_SERVER
|
|
390
|
+
? null
|
|
391
|
+
: window['requestAnimationFrame']
|
|
392
|
+
? function (f) { return window['requestAnimationFrame'](f); }
|
|
393
|
+
: function (f) { return setTimeout(f, 1); };
|
|
394
|
+
// React currently throws a warning when using useLayoutEffect on the server.
|
|
395
|
+
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
396
|
+
// useLayoutEffect in the browser.
|
|
397
|
+
var useIsomorphicLayoutEffect = IS_SERVER ? useEffect : useLayoutEffect;
|
|
398
|
+
|
|
399
|
+
var SWRConfigContext = createContext({});
|
|
400
|
+
SWRConfigContext.displayName = 'SWRConfigContext';
|
|
401
|
+
|
|
402
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
403
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
404
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
405
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
406
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
407
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
408
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
412
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
413
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
414
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
415
|
+
function step(op) {
|
|
416
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
417
|
+
while (_) try {
|
|
418
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
419
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
420
|
+
switch (op[0]) {
|
|
421
|
+
case 0: case 1: t = op; break;
|
|
422
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
423
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
424
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
425
|
+
default:
|
|
426
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
427
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
428
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
429
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
430
|
+
if (t[2]) _.ops.pop();
|
|
431
|
+
_.trys.pop(); continue;
|
|
432
|
+
}
|
|
433
|
+
op = body.call(thisArg, _);
|
|
434
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
435
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
// global state managers
|
|
439
|
+
var CONCURRENT_PROMISES = {};
|
|
440
|
+
var CONCURRENT_PROMISES_TS = {};
|
|
441
|
+
var FOCUS_REVALIDATORS = {};
|
|
442
|
+
var RECONNECT_REVALIDATORS = {};
|
|
443
|
+
var CACHE_REVALIDATORS = {};
|
|
444
|
+
var MUTATION_TS = {};
|
|
445
|
+
var MUTATION_END_TS = {};
|
|
446
|
+
// generate strictly increasing timestamps
|
|
447
|
+
var now = (function () {
|
|
448
|
+
var ts = 0;
|
|
449
|
+
return function () { return ++ts; };
|
|
450
|
+
})();
|
|
451
|
+
// setup DOM events listeners for `focus` and `reconnect` actions
|
|
452
|
+
if (!IS_SERVER) {
|
|
453
|
+
var revalidate_1 = function (revalidators) {
|
|
454
|
+
if (!defaultConfig.isDocumentVisible() || !defaultConfig.isOnline())
|
|
455
|
+
return;
|
|
456
|
+
for (var key in revalidators) {
|
|
457
|
+
if (revalidators[key][0])
|
|
458
|
+
revalidators[key][0]();
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
if (typeof defaultConfig.registerOnFocus === 'function') {
|
|
462
|
+
defaultConfig.registerOnFocus(function () { return revalidate_1(FOCUS_REVALIDATORS); });
|
|
463
|
+
}
|
|
464
|
+
if (typeof defaultConfig.registerOnReconnect === 'function') {
|
|
465
|
+
defaultConfig.registerOnReconnect(function () { return revalidate_1(RECONNECT_REVALIDATORS); });
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
var trigger = function (_key, shouldRevalidate) {
|
|
469
|
+
if (shouldRevalidate === void 0) { shouldRevalidate = true; }
|
|
470
|
+
// we are ignoring the second argument which correspond to the arguments
|
|
471
|
+
// the fetcher will receive when key is an array
|
|
472
|
+
var _a = cache.serializeKey(_key), key = _a[0], keyErr = _a[2], keyValidating = _a[3];
|
|
473
|
+
if (!key)
|
|
474
|
+
return Promise.resolve();
|
|
475
|
+
var updaters = CACHE_REVALIDATORS[key];
|
|
476
|
+
if (key && updaters) {
|
|
477
|
+
var currentData = cache.get(key);
|
|
478
|
+
var currentError = cache.get(keyErr);
|
|
479
|
+
var currentIsValidating = cache.get(keyValidating);
|
|
480
|
+
var promises = [];
|
|
481
|
+
for (var i = 0; i < updaters.length; ++i) {
|
|
482
|
+
promises.push(updaters[i](shouldRevalidate, currentData, currentError, currentIsValidating, i > 0));
|
|
483
|
+
}
|
|
484
|
+
// return new updated value
|
|
485
|
+
return Promise.all(promises).then(function () { return cache.get(key); });
|
|
486
|
+
}
|
|
487
|
+
return Promise.resolve(cache.get(key));
|
|
488
|
+
};
|
|
489
|
+
var broadcastState = function (key, data, error, isValidating) {
|
|
490
|
+
var updaters = CACHE_REVALIDATORS[key];
|
|
491
|
+
if (key && updaters) {
|
|
492
|
+
for (var i = 0; i < updaters.length; ++i) {
|
|
493
|
+
updaters[i](false, data, error, isValidating);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
var mutate = function (_key, _data, shouldRevalidate) {
|
|
498
|
+
if (shouldRevalidate === void 0) { shouldRevalidate = true; }
|
|
499
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
500
|
+
var _a, key, keyErr, beforeMutationTs, beforeConcurrentPromisesTs, data, error, isAsyncMutation, err_1, shouldAbort, updaters, promises, i;
|
|
501
|
+
return __generator(this, function (_b) {
|
|
502
|
+
switch (_b.label) {
|
|
503
|
+
case 0:
|
|
504
|
+
_a = cache.serializeKey(_key), key = _a[0], keyErr = _a[2];
|
|
505
|
+
if (!key)
|
|
506
|
+
return [2 /*return*/];
|
|
507
|
+
// if there is no new data to update, let's just revalidate the key
|
|
508
|
+
if (typeof _data === 'undefined')
|
|
509
|
+
return [2 /*return*/, trigger(_key, shouldRevalidate)
|
|
510
|
+
// update global timestamps
|
|
511
|
+
];
|
|
512
|
+
// update global timestamps
|
|
513
|
+
MUTATION_TS[key] = now() - 1;
|
|
514
|
+
MUTATION_END_TS[key] = 0;
|
|
515
|
+
beforeMutationTs = MUTATION_TS[key];
|
|
516
|
+
beforeConcurrentPromisesTs = CONCURRENT_PROMISES_TS[key];
|
|
517
|
+
isAsyncMutation = false;
|
|
518
|
+
if (_data && typeof _data === 'function') {
|
|
519
|
+
// `_data` is a function, call it passing current cache value
|
|
520
|
+
try {
|
|
521
|
+
_data = _data(cache.get(key));
|
|
522
|
+
}
|
|
523
|
+
catch (err) {
|
|
524
|
+
// if `_data` function throws an error synchronously, it shouldn't be cached
|
|
525
|
+
_data = undefined;
|
|
526
|
+
error = err;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (!(_data && typeof _data.then === 'function')) return [3 /*break*/, 5];
|
|
530
|
+
// `_data` is a promise
|
|
531
|
+
isAsyncMutation = true;
|
|
532
|
+
_b.label = 1;
|
|
533
|
+
case 1:
|
|
534
|
+
_b.trys.push([1, 3, , 4]);
|
|
535
|
+
return [4 /*yield*/, _data];
|
|
536
|
+
case 2:
|
|
537
|
+
data = _b.sent();
|
|
538
|
+
return [3 /*break*/, 4];
|
|
539
|
+
case 3:
|
|
540
|
+
err_1 = _b.sent();
|
|
541
|
+
error = err_1;
|
|
542
|
+
return [3 /*break*/, 4];
|
|
543
|
+
case 4: return [3 /*break*/, 6];
|
|
544
|
+
case 5:
|
|
545
|
+
data = _data;
|
|
546
|
+
_b.label = 6;
|
|
547
|
+
case 6:
|
|
548
|
+
shouldAbort = function () {
|
|
549
|
+
// check if other mutations have occurred since we've started this mutation
|
|
550
|
+
if (beforeMutationTs !== MUTATION_TS[key] ||
|
|
551
|
+
beforeConcurrentPromisesTs !== CONCURRENT_PROMISES_TS[key]) {
|
|
552
|
+
if (error)
|
|
553
|
+
throw error;
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
// if there's a race we don't update cache or broadcast change, just return the data
|
|
558
|
+
if (shouldAbort())
|
|
559
|
+
return [2 /*return*/, data];
|
|
560
|
+
if (typeof data !== 'undefined') {
|
|
561
|
+
// update cached data
|
|
562
|
+
cache.set(key, data);
|
|
563
|
+
}
|
|
564
|
+
// always update or reset the error
|
|
565
|
+
cache.set(keyErr, error);
|
|
566
|
+
// reset the timestamp to mark the mutation has ended
|
|
567
|
+
MUTATION_END_TS[key] = now() - 1;
|
|
568
|
+
if (!isAsyncMutation) {
|
|
569
|
+
// we skip broadcasting if there's another mutation happened synchronously
|
|
570
|
+
if (shouldAbort())
|
|
571
|
+
return [2 /*return*/, data];
|
|
572
|
+
}
|
|
573
|
+
updaters = CACHE_REVALIDATORS[key];
|
|
574
|
+
if (updaters) {
|
|
575
|
+
promises = [];
|
|
576
|
+
for (i = 0; i < updaters.length; ++i) {
|
|
577
|
+
promises.push(updaters[i](!!shouldRevalidate, data, error, undefined, i > 0));
|
|
578
|
+
}
|
|
579
|
+
// return new updated value
|
|
580
|
+
return [2 /*return*/, Promise.all(promises).then(function () {
|
|
581
|
+
if (error)
|
|
582
|
+
throw error;
|
|
583
|
+
return cache.get(key);
|
|
584
|
+
})];
|
|
585
|
+
}
|
|
586
|
+
// throw error or return data to be used by caller of mutate
|
|
587
|
+
if (error)
|
|
588
|
+
throw error;
|
|
589
|
+
return [2 /*return*/, data];
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
function useSWR() {
|
|
595
|
+
var _this = this;
|
|
596
|
+
var args = [];
|
|
597
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
598
|
+
args[_i] = arguments[_i];
|
|
599
|
+
}
|
|
600
|
+
var _key = args[0];
|
|
601
|
+
var config = Object.assign({}, defaultConfig, useContext(SWRConfigContext), args.length > 2
|
|
602
|
+
? args[2]
|
|
603
|
+
: args.length === 2 && typeof args[1] === 'object'
|
|
604
|
+
? args[1]
|
|
605
|
+
: {});
|
|
606
|
+
// in typescript args.length > 2 is not same as args.lenth === 3
|
|
607
|
+
// we do a safe type assertion here
|
|
608
|
+
// args.length === 3
|
|
609
|
+
var fn = (args.length > 2
|
|
610
|
+
? args[1]
|
|
611
|
+
: args.length === 2 && typeof args[1] === 'function'
|
|
612
|
+
? args[1]
|
|
613
|
+
: /**
|
|
614
|
+
pass fn as null will disable revalidate
|
|
615
|
+
https://paco.sh/blog/shared-hook-state-with-swr
|
|
616
|
+
*/
|
|
617
|
+
args[1] === null
|
|
618
|
+
? args[1]
|
|
619
|
+
: config.fetcher);
|
|
620
|
+
// we assume `key` as the identifier of the request
|
|
621
|
+
// `key` can change but `fn` shouldn't
|
|
622
|
+
// (because `revalidate` only depends on `key`)
|
|
623
|
+
// `keyErr` is the cache key for error objects
|
|
624
|
+
var _a = cache.serializeKey(_key), key = _a[0], fnArgs = _a[1], keyErr = _a[2], keyValidating = _a[3];
|
|
625
|
+
var configRef = useRef(config);
|
|
626
|
+
useIsomorphicLayoutEffect(function () {
|
|
627
|
+
configRef.current = config;
|
|
628
|
+
});
|
|
629
|
+
var willRevalidateOnMount = function () {
|
|
630
|
+
return (config.revalidateOnMount ||
|
|
631
|
+
(!config.initialData && config.revalidateOnMount === undefined));
|
|
632
|
+
};
|
|
633
|
+
var resolveData = function () {
|
|
634
|
+
var cachedData = cache.get(key);
|
|
635
|
+
return typeof cachedData === 'undefined' ? config.initialData : cachedData;
|
|
636
|
+
};
|
|
637
|
+
var resolveIsValidating = function () {
|
|
638
|
+
return !!cache.get(keyValidating) || (key && willRevalidateOnMount());
|
|
639
|
+
};
|
|
640
|
+
var initialData = resolveData();
|
|
641
|
+
var initialError = cache.get(keyErr);
|
|
642
|
+
var initialIsValidating = resolveIsValidating();
|
|
643
|
+
// if a state is accessed (data, error or isValidating),
|
|
644
|
+
// we add the state to dependencies so if the state is
|
|
645
|
+
// updated in the future, we can trigger a rerender
|
|
646
|
+
var stateDependencies = useRef({
|
|
647
|
+
data: false,
|
|
648
|
+
error: false,
|
|
649
|
+
isValidating: false
|
|
650
|
+
});
|
|
651
|
+
var stateRef = useRef({
|
|
652
|
+
data: initialData,
|
|
653
|
+
error: initialError,
|
|
654
|
+
isValidating: initialIsValidating
|
|
655
|
+
});
|
|
656
|
+
// display the data label in the React DevTools next to SWR hooks
|
|
657
|
+
useDebugValue(stateRef.current.data);
|
|
658
|
+
var rerender = useState({})[1];
|
|
659
|
+
var dispatch = useCallback(function (payload) {
|
|
660
|
+
var shouldUpdateState = false;
|
|
661
|
+
for (var k in payload) {
|
|
662
|
+
// @ts-ignore
|
|
663
|
+
if (stateRef.current[k] === payload[k]) {
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
// @ts-ignore
|
|
667
|
+
stateRef.current[k] = payload[k];
|
|
668
|
+
// @ts-ignore
|
|
669
|
+
if (stateDependencies.current[k]) {
|
|
670
|
+
shouldUpdateState = true;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (shouldUpdateState) {
|
|
674
|
+
// if component is unmounted, should skip rerender
|
|
675
|
+
// if component is not mounted, should skip rerender
|
|
676
|
+
if (unmountedRef.current || !initialMountedRef.current)
|
|
677
|
+
return;
|
|
678
|
+
rerender({});
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
// config.suspense isn't allowed to change during the lifecycle
|
|
682
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
683
|
+
[]);
|
|
684
|
+
// error ref inside revalidate (is last request errored?)
|
|
685
|
+
var unmountedRef = useRef(false);
|
|
686
|
+
var keyRef = useRef(key);
|
|
687
|
+
// check if component is mounted in suspense mode
|
|
688
|
+
var initialMountedRef = useRef(false);
|
|
689
|
+
// do unmount check for callbacks
|
|
690
|
+
var eventsCallback = useCallback(function (event) {
|
|
691
|
+
var _a;
|
|
692
|
+
var params = [];
|
|
693
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
694
|
+
params[_i - 1] = arguments[_i];
|
|
695
|
+
}
|
|
696
|
+
if (unmountedRef.current)
|
|
697
|
+
return;
|
|
698
|
+
if (!initialMountedRef.current)
|
|
699
|
+
return;
|
|
700
|
+
if (key !== keyRef.current)
|
|
701
|
+
return;
|
|
702
|
+
// @ts-ignore
|
|
703
|
+
(_a = configRef.current)[event].apply(_a, params);
|
|
704
|
+
}, [key]);
|
|
705
|
+
var boundMutate = useCallback(function (data, shouldRevalidate) {
|
|
706
|
+
return mutate(keyRef.current, data, shouldRevalidate);
|
|
707
|
+
}, []);
|
|
708
|
+
var addRevalidator = function (revalidators, callback) {
|
|
709
|
+
if (!revalidators[key]) {
|
|
710
|
+
revalidators[key] = [callback];
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
revalidators[key].push(callback);
|
|
714
|
+
}
|
|
715
|
+
return function () {
|
|
716
|
+
var keyedRevalidators = revalidators[key];
|
|
717
|
+
var index = keyedRevalidators.indexOf(callback);
|
|
718
|
+
if (index >= 0) {
|
|
719
|
+
// O(1): faster than splice
|
|
720
|
+
keyedRevalidators[index] =
|
|
721
|
+
keyedRevalidators[keyedRevalidators.length - 1];
|
|
722
|
+
keyedRevalidators.pop();
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
};
|
|
726
|
+
// start a revalidation
|
|
727
|
+
var revalidate = useCallback(function (revalidateOpts) {
|
|
728
|
+
if (revalidateOpts === void 0) { revalidateOpts = {}; }
|
|
729
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
730
|
+
var _a, retryCount, _b, dedupe, loading, shouldDeduping, newData, startAt, newState, err_2;
|
|
731
|
+
return __generator(this, function (_c) {
|
|
732
|
+
switch (_c.label) {
|
|
733
|
+
case 0:
|
|
734
|
+
if (!key || !fn)
|
|
735
|
+
return [2 /*return*/, false];
|
|
736
|
+
if (unmountedRef.current)
|
|
737
|
+
return [2 /*return*/, false];
|
|
738
|
+
if (configRef.current.isPaused())
|
|
739
|
+
return [2 /*return*/, false];
|
|
740
|
+
_a = revalidateOpts.retryCount, retryCount = _a === void 0 ? 0 : _a, _b = revalidateOpts.dedupe, dedupe = _b === void 0 ? false : _b;
|
|
741
|
+
loading = true;
|
|
742
|
+
shouldDeduping = typeof CONCURRENT_PROMISES[key] !== 'undefined' && dedupe;
|
|
743
|
+
_c.label = 1;
|
|
744
|
+
case 1:
|
|
745
|
+
_c.trys.push([1, 6, , 7]);
|
|
746
|
+
dispatch({
|
|
747
|
+
isValidating: true
|
|
748
|
+
});
|
|
749
|
+
cache.set(keyValidating, true);
|
|
750
|
+
if (!shouldDeduping) {
|
|
751
|
+
// also update other hooks
|
|
752
|
+
broadcastState(key, stateRef.current.data, stateRef.current.error, true);
|
|
753
|
+
}
|
|
754
|
+
newData = void 0;
|
|
755
|
+
startAt = void 0;
|
|
756
|
+
if (!shouldDeduping) return [3 /*break*/, 3];
|
|
757
|
+
// there's already an ongoing request,
|
|
758
|
+
// this one needs to be deduplicated.
|
|
759
|
+
startAt = CONCURRENT_PROMISES_TS[key];
|
|
760
|
+
return [4 /*yield*/, CONCURRENT_PROMISES[key]];
|
|
761
|
+
case 2:
|
|
762
|
+
newData = _c.sent();
|
|
763
|
+
return [3 /*break*/, 5];
|
|
764
|
+
case 3:
|
|
765
|
+
// if no cache being rendered currently (it shows a blank page),
|
|
766
|
+
// we trigger the loading slow event.
|
|
767
|
+
if (config.loadingTimeout && !cache.get(key)) {
|
|
768
|
+
setTimeout(function () {
|
|
769
|
+
if (loading)
|
|
770
|
+
eventsCallback('onLoadingSlow', key, config);
|
|
771
|
+
}, config.loadingTimeout);
|
|
772
|
+
}
|
|
773
|
+
if (fnArgs !== null) {
|
|
774
|
+
CONCURRENT_PROMISES[key] = fn.apply(void 0, fnArgs);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
CONCURRENT_PROMISES[key] = fn(key);
|
|
778
|
+
}
|
|
779
|
+
CONCURRENT_PROMISES_TS[key] = startAt = now();
|
|
780
|
+
return [4 /*yield*/, CONCURRENT_PROMISES[key]];
|
|
781
|
+
case 4:
|
|
782
|
+
newData = _c.sent();
|
|
783
|
+
setTimeout(function () {
|
|
784
|
+
delete CONCURRENT_PROMISES[key];
|
|
785
|
+
delete CONCURRENT_PROMISES_TS[key];
|
|
786
|
+
}, config.dedupingInterval);
|
|
787
|
+
// trigger the success event,
|
|
788
|
+
// only do this for the original request.
|
|
789
|
+
eventsCallback('onSuccess', newData, key, config);
|
|
790
|
+
_c.label = 5;
|
|
791
|
+
case 5:
|
|
792
|
+
// if there're other ongoing request(s), started after the current one,
|
|
793
|
+
// we need to ignore the current one to avoid possible race conditions:
|
|
794
|
+
// req1------------------>res1 (current one)
|
|
795
|
+
// req2---------------->res2
|
|
796
|
+
// the request that fired later will always be kept.
|
|
797
|
+
if (CONCURRENT_PROMISES_TS[key] > startAt) {
|
|
798
|
+
return [2 /*return*/, false];
|
|
799
|
+
}
|
|
800
|
+
// if there're other mutations(s), overlapped with the current revalidation:
|
|
801
|
+
// case 1:
|
|
802
|
+
// req------------------>res
|
|
803
|
+
// mutate------>end
|
|
804
|
+
// case 2:
|
|
805
|
+
// req------------>res
|
|
806
|
+
// mutate------>end
|
|
807
|
+
// case 3:
|
|
808
|
+
// req------------------>res
|
|
809
|
+
// mutate-------...---------->
|
|
810
|
+
// we have to ignore the revalidation result (res) because it's no longer fresh.
|
|
811
|
+
// meanwhile, a new revalidation should be triggered when the mutation ends.
|
|
812
|
+
if (MUTATION_TS[key] &&
|
|
813
|
+
// case 1
|
|
814
|
+
(startAt <= MUTATION_TS[key] ||
|
|
815
|
+
// case 2
|
|
816
|
+
startAt <= MUTATION_END_TS[key] ||
|
|
817
|
+
// case 3
|
|
818
|
+
MUTATION_END_TS[key] === 0)) {
|
|
819
|
+
dispatch({ isValidating: false });
|
|
820
|
+
return [2 /*return*/, false];
|
|
821
|
+
}
|
|
822
|
+
cache.set(keyErr, undefined);
|
|
823
|
+
cache.set(keyValidating, false);
|
|
824
|
+
newState = {
|
|
825
|
+
isValidating: false
|
|
826
|
+
};
|
|
827
|
+
if (typeof stateRef.current.error !== 'undefined') {
|
|
828
|
+
// we don't have an error
|
|
829
|
+
newState.error = undefined;
|
|
830
|
+
}
|
|
831
|
+
if (!config.compare(stateRef.current.data, newData)) {
|
|
832
|
+
// deep compare to avoid extra re-render
|
|
833
|
+
// data changed
|
|
834
|
+
newState.data = newData;
|
|
835
|
+
}
|
|
836
|
+
if (!config.compare(cache.get(key), newData)) {
|
|
837
|
+
cache.set(key, newData);
|
|
838
|
+
}
|
|
839
|
+
// merge the new state
|
|
840
|
+
dispatch(newState);
|
|
841
|
+
if (!shouldDeduping) {
|
|
842
|
+
// also update other hooks
|
|
843
|
+
broadcastState(key, newData, newState.error, false);
|
|
844
|
+
}
|
|
845
|
+
return [3 /*break*/, 7];
|
|
846
|
+
case 6:
|
|
847
|
+
err_2 = _c.sent();
|
|
848
|
+
delete CONCURRENT_PROMISES[key];
|
|
849
|
+
delete CONCURRENT_PROMISES_TS[key];
|
|
850
|
+
if (configRef.current.isPaused()) {
|
|
851
|
+
dispatch({
|
|
852
|
+
isValidating: false
|
|
853
|
+
});
|
|
854
|
+
return [2 /*return*/, false];
|
|
855
|
+
}
|
|
856
|
+
cache.set(keyErr, err_2);
|
|
857
|
+
// get a new error
|
|
858
|
+
// don't use deep equal for errors
|
|
859
|
+
if (stateRef.current.error !== err_2) {
|
|
860
|
+
// we keep the stale data
|
|
861
|
+
dispatch({
|
|
862
|
+
isValidating: false,
|
|
863
|
+
error: err_2
|
|
864
|
+
});
|
|
865
|
+
if (!shouldDeduping) {
|
|
866
|
+
// also broadcast to update other hooks
|
|
867
|
+
broadcastState(key, undefined, err_2, false);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
// events and retry
|
|
871
|
+
eventsCallback('onError', err_2, key, config);
|
|
872
|
+
if (config.shouldRetryOnError) {
|
|
873
|
+
// when retrying, we always enable deduping
|
|
874
|
+
eventsCallback('onErrorRetry', err_2, key, config, revalidate, {
|
|
875
|
+
retryCount: retryCount + 1,
|
|
876
|
+
dedupe: true
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
return [3 /*break*/, 7];
|
|
880
|
+
case 7:
|
|
881
|
+
loading = false;
|
|
882
|
+
return [2 /*return*/, true];
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
},
|
|
887
|
+
// dispatch is immutable, and `eventsCallback`, `fnArgs`, `keyErr`, and `keyValidating` are based on `key`,
|
|
888
|
+
// so we can them from the deps array.
|
|
889
|
+
//
|
|
890
|
+
// FIXME:
|
|
891
|
+
// `fn` and `config` might be changed during the lifecycle,
|
|
892
|
+
// but they might be changed every render like this.
|
|
893
|
+
// useSWR('key', () => fetch('/api/'), { suspense: true })
|
|
894
|
+
// So we omit the values from the deps array
|
|
895
|
+
// even though it might cause unexpected behaviors.
|
|
896
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
897
|
+
[key]);
|
|
898
|
+
// mounted (client side rendering)
|
|
899
|
+
useIsomorphicLayoutEffect(function () {
|
|
900
|
+
if (!key)
|
|
901
|
+
return undefined;
|
|
902
|
+
// after `key` updates, we need to mark it as mounted
|
|
903
|
+
unmountedRef.current = false;
|
|
904
|
+
var isUpdating = initialMountedRef.current;
|
|
905
|
+
initialMountedRef.current = true;
|
|
906
|
+
// after the component is mounted (hydrated),
|
|
907
|
+
// we need to update the data from the cache
|
|
908
|
+
// and trigger a revalidation
|
|
909
|
+
var currentHookData = stateRef.current.data;
|
|
910
|
+
var latestKeyedData = resolveData();
|
|
911
|
+
// update the state if the key changed (not the inital render) or cache updated
|
|
912
|
+
keyRef.current = key;
|
|
913
|
+
if (!config.compare(currentHookData, latestKeyedData)) {
|
|
914
|
+
dispatch({ data: latestKeyedData });
|
|
915
|
+
}
|
|
916
|
+
// revalidate with deduping
|
|
917
|
+
var softRevalidate = function () { return revalidate({ dedupe: true }); };
|
|
918
|
+
// trigger a revalidation
|
|
919
|
+
if (isUpdating || willRevalidateOnMount()) {
|
|
920
|
+
if (typeof latestKeyedData !== 'undefined' && !IS_SERVER) {
|
|
921
|
+
// delay revalidate if there's cache
|
|
922
|
+
// to not block the rendering
|
|
923
|
+
// @ts-ignore it's safe to use requestAnimationFrame in browser
|
|
924
|
+
rAF(softRevalidate);
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
softRevalidate();
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
var pending = false;
|
|
931
|
+
var onFocus = function () {
|
|
932
|
+
if (pending || !configRef.current.revalidateOnFocus)
|
|
933
|
+
return;
|
|
934
|
+
pending = true;
|
|
935
|
+
softRevalidate();
|
|
936
|
+
setTimeout(function () { return (pending = false); }, configRef.current.focusThrottleInterval);
|
|
937
|
+
};
|
|
938
|
+
var onReconnect = function () {
|
|
939
|
+
if (configRef.current.revalidateOnReconnect) {
|
|
940
|
+
softRevalidate();
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
// register global cache update listener
|
|
944
|
+
var onUpdate = function (shouldRevalidate, updatedData, updatedError, updatedIsValidating, dedupe) {
|
|
945
|
+
if (shouldRevalidate === void 0) { shouldRevalidate = true; }
|
|
946
|
+
if (dedupe === void 0) { dedupe = true; }
|
|
947
|
+
// update hook state
|
|
948
|
+
var newState = {};
|
|
949
|
+
var needUpdate = false;
|
|
950
|
+
if (typeof updatedData !== 'undefined' &&
|
|
951
|
+
!config.compare(stateRef.current.data, updatedData)) {
|
|
952
|
+
newState.data = updatedData;
|
|
953
|
+
needUpdate = true;
|
|
954
|
+
}
|
|
955
|
+
// always update error
|
|
956
|
+
// because it can be `undefined`
|
|
957
|
+
if (stateRef.current.error !== updatedError) {
|
|
958
|
+
newState.error = updatedError;
|
|
959
|
+
needUpdate = true;
|
|
960
|
+
}
|
|
961
|
+
if (typeof updatedIsValidating !== 'undefined' &&
|
|
962
|
+
stateRef.current.isValidating !== updatedIsValidating) {
|
|
963
|
+
newState.isValidating = updatedIsValidating;
|
|
964
|
+
needUpdate = true;
|
|
965
|
+
}
|
|
966
|
+
if (needUpdate) {
|
|
967
|
+
dispatch(newState);
|
|
968
|
+
}
|
|
969
|
+
if (shouldRevalidate) {
|
|
970
|
+
if (dedupe) {
|
|
971
|
+
return softRevalidate();
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
return revalidate();
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return false;
|
|
978
|
+
};
|
|
979
|
+
var unsubFocus = addRevalidator(FOCUS_REVALIDATORS, onFocus);
|
|
980
|
+
var unsubReconnect = addRevalidator(RECONNECT_REVALIDATORS, onReconnect);
|
|
981
|
+
var unsubUpdate = addRevalidator(CACHE_REVALIDATORS, onUpdate);
|
|
982
|
+
return function () {
|
|
983
|
+
// cleanup
|
|
984
|
+
dispatch = function () { return null; };
|
|
985
|
+
// mark it as unmounted
|
|
986
|
+
unmountedRef.current = true;
|
|
987
|
+
unsubFocus();
|
|
988
|
+
unsubReconnect();
|
|
989
|
+
unsubUpdate();
|
|
990
|
+
};
|
|
991
|
+
}, [key, revalidate]);
|
|
992
|
+
useIsomorphicLayoutEffect(function () {
|
|
993
|
+
var timer = null;
|
|
994
|
+
var tick = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
995
|
+
return __generator(this, function (_a) {
|
|
996
|
+
switch (_a.label) {
|
|
997
|
+
case 0:
|
|
998
|
+
if (!(!stateRef.current.error &&
|
|
999
|
+
(configRef.current.refreshWhenHidden ||
|
|
1000
|
+
configRef.current.isDocumentVisible()) &&
|
|
1001
|
+
(configRef.current.refreshWhenOffline || configRef.current.isOnline()))) return [3 /*break*/, 2];
|
|
1002
|
+
// only revalidate when the page is visible
|
|
1003
|
+
// if API request errored, we stop polling in this round
|
|
1004
|
+
// and let the error retry function handle it
|
|
1005
|
+
return [4 /*yield*/, revalidate({ dedupe: true })];
|
|
1006
|
+
case 1:
|
|
1007
|
+
// only revalidate when the page is visible
|
|
1008
|
+
// if API request errored, we stop polling in this round
|
|
1009
|
+
// and let the error retry function handle it
|
|
1010
|
+
_a.sent();
|
|
1011
|
+
_a.label = 2;
|
|
1012
|
+
case 2:
|
|
1013
|
+
// Read the latest refreshInterval
|
|
1014
|
+
if (configRef.current.refreshInterval && timer) {
|
|
1015
|
+
timer = setTimeout(tick, configRef.current.refreshInterval);
|
|
1016
|
+
}
|
|
1017
|
+
return [2 /*return*/];
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
}); };
|
|
1021
|
+
if (configRef.current.refreshInterval) {
|
|
1022
|
+
timer = setTimeout(tick, configRef.current.refreshInterval);
|
|
1023
|
+
}
|
|
1024
|
+
return function () {
|
|
1025
|
+
if (timer) {
|
|
1026
|
+
clearTimeout(timer);
|
|
1027
|
+
timer = null;
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
}, [
|
|
1031
|
+
config.refreshInterval,
|
|
1032
|
+
config.refreshWhenHidden,
|
|
1033
|
+
config.refreshWhenOffline,
|
|
1034
|
+
revalidate
|
|
1035
|
+
]);
|
|
1036
|
+
// suspense
|
|
1037
|
+
var latestData;
|
|
1038
|
+
var latestError;
|
|
1039
|
+
if (config.suspense) {
|
|
1040
|
+
// in suspense mode, we can't return empty state
|
|
1041
|
+
// (it should be suspended)
|
|
1042
|
+
// try to get data and error from cache
|
|
1043
|
+
latestData = cache.get(key);
|
|
1044
|
+
latestError = cache.get(keyErr);
|
|
1045
|
+
if (typeof latestData === 'undefined') {
|
|
1046
|
+
latestData = initialData;
|
|
1047
|
+
}
|
|
1048
|
+
if (typeof latestError === 'undefined') {
|
|
1049
|
+
latestError = initialError;
|
|
1050
|
+
}
|
|
1051
|
+
if (typeof latestData === 'undefined' &&
|
|
1052
|
+
typeof latestError === 'undefined') {
|
|
1053
|
+
// need to start the request if it hasn't
|
|
1054
|
+
if (!CONCURRENT_PROMISES[key]) {
|
|
1055
|
+
// trigger revalidate immediately
|
|
1056
|
+
// to get the promise
|
|
1057
|
+
// in this revalidate, should not rerender
|
|
1058
|
+
revalidate();
|
|
1059
|
+
}
|
|
1060
|
+
if (CONCURRENT_PROMISES[key] &&
|
|
1061
|
+
typeof CONCURRENT_PROMISES[key].then === 'function') {
|
|
1062
|
+
// if it is a promise
|
|
1063
|
+
throw CONCURRENT_PROMISES[key];
|
|
1064
|
+
}
|
|
1065
|
+
// it's a value, return it directly (override)
|
|
1066
|
+
latestData = CONCURRENT_PROMISES[key];
|
|
1067
|
+
}
|
|
1068
|
+
if (typeof latestData === 'undefined' && latestError) {
|
|
1069
|
+
// in suspense mode, throw error if there's no content
|
|
1070
|
+
throw latestError;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
// define returned state
|
|
1074
|
+
// can be memorized since the state is a ref
|
|
1075
|
+
var memoizedState = useMemo(function () {
|
|
1076
|
+
// revalidate will be deprecated in the 1.x release
|
|
1077
|
+
// because mutate() covers the same use case of revalidate().
|
|
1078
|
+
// This remains only for backward compatibility
|
|
1079
|
+
var state = { revalidate: revalidate, mutate: boundMutate };
|
|
1080
|
+
Object.defineProperties(state, {
|
|
1081
|
+
error: {
|
|
1082
|
+
// `key` might be changed in the upcoming hook re-render,
|
|
1083
|
+
// but the previous state will stay
|
|
1084
|
+
// so we need to match the latest key and data (fallback to `initialData`)
|
|
1085
|
+
get: function () {
|
|
1086
|
+
stateDependencies.current.error = true;
|
|
1087
|
+
if (config.suspense) {
|
|
1088
|
+
return latestError;
|
|
1089
|
+
}
|
|
1090
|
+
return keyRef.current === key ? stateRef.current.error : initialError;
|
|
1091
|
+
},
|
|
1092
|
+
enumerable: true
|
|
1093
|
+
},
|
|
1094
|
+
data: {
|
|
1095
|
+
get: function () {
|
|
1096
|
+
stateDependencies.current.data = true;
|
|
1097
|
+
if (config.suspense) {
|
|
1098
|
+
return latestData;
|
|
1099
|
+
}
|
|
1100
|
+
return keyRef.current === key ? stateRef.current.data : initialData;
|
|
1101
|
+
},
|
|
1102
|
+
enumerable: true
|
|
1103
|
+
},
|
|
1104
|
+
isValidating: {
|
|
1105
|
+
get: function () {
|
|
1106
|
+
stateDependencies.current.isValidating = true;
|
|
1107
|
+
return key ? stateRef.current.isValidating : false;
|
|
1108
|
+
},
|
|
1109
|
+
enumerable: true
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
return state;
|
|
1113
|
+
// `config.suspense` isn't allowed to change during the lifecycle.
|
|
1114
|
+
// `boundMutate` is immutable, and the immutability of `revalidate` depends on `key`
|
|
1115
|
+
// so we can omit them from the deps array,
|
|
1116
|
+
// but we put it to enable react-hooks/exhaustive-deps rule.
|
|
1117
|
+
// `initialData` and `initialError` are not initial values
|
|
1118
|
+
// because they are changed during the lifecycle
|
|
1119
|
+
// so we should add them in the deps array.
|
|
1120
|
+
}, [
|
|
1121
|
+
revalidate,
|
|
1122
|
+
initialData,
|
|
1123
|
+
initialError,
|
|
1124
|
+
boundMutate,
|
|
1125
|
+
key,
|
|
1126
|
+
config.suspense,
|
|
1127
|
+
latestError,
|
|
1128
|
+
latestData
|
|
1129
|
+
]);
|
|
1130
|
+
return memoizedState;
|
|
1131
|
+
}
|
|
1132
|
+
Object.defineProperty(SWRConfigContext.Provider, 'default', {
|
|
1133
|
+
value: defaultConfig
|
|
1134
|
+
});
|
|
1135
|
+
var SWRConfig = SWRConfigContext.Provider;
|
|
1136
|
+
|
|
1137
|
+
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1138
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1139
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1140
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1141
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1142
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1143
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1146
|
+
var __generator$1 = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
1147
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1148
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1149
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1150
|
+
function step(op) {
|
|
1151
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1152
|
+
while (_) try {
|
|
1153
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1154
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1155
|
+
switch (op[0]) {
|
|
1156
|
+
case 0: case 1: t = op; break;
|
|
1157
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
1158
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1159
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1160
|
+
default:
|
|
1161
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1162
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1163
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1164
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1165
|
+
if (t[2]) _.ops.pop();
|
|
1166
|
+
_.trys.pop(); continue;
|
|
1167
|
+
}
|
|
1168
|
+
op = body.call(thisArg, _);
|
|
1169
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1170
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
1174
|
+
var t = {};
|
|
1175
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1176
|
+
t[p] = s[p];
|
|
1177
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1178
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1179
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1180
|
+
t[p[i]] = s[p[i]];
|
|
1181
|
+
}
|
|
1182
|
+
return t;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
137
1185
|
var _this = undefined;
|
|
138
1186
|
|
|
139
1187
|
var dataHandler = function () {
|
|
@@ -1330,7 +2378,7 @@ var isArguments = function isArguments(value) {
|
|
|
1330
2378
|
var keysShim;
|
|
1331
2379
|
if (!Object.keys) {
|
|
1332
2380
|
// modified from https://github.com/es-shims/es5-shim
|
|
1333
|
-
var has = Object.prototype.hasOwnProperty;
|
|
2381
|
+
var has$1 = Object.prototype.hasOwnProperty;
|
|
1334
2382
|
var toStr$1 = Object.prototype.toString;
|
|
1335
2383
|
var isArgs = isArguments; // eslint-disable-line global-require
|
|
1336
2384
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
@@ -1379,7 +2427,7 @@ if (!Object.keys) {
|
|
|
1379
2427
|
if (typeof window === 'undefined') { return false; }
|
|
1380
2428
|
for (var k in window) {
|
|
1381
2429
|
try {
|
|
1382
|
-
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
|
2430
|
+
if (!excludedKeys['$' + k] && has$1.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
|
1383
2431
|
try {
|
|
1384
2432
|
equalsConstructorPrototype(window[k]);
|
|
1385
2433
|
} catch (e) {
|
|
@@ -1416,7 +2464,7 @@ if (!Object.keys) {
|
|
|
1416
2464
|
}
|
|
1417
2465
|
|
|
1418
2466
|
var skipProto = hasProtoEnumBug && isFunction;
|
|
1419
|
-
if (isString && object.length > 0 && !has.call(object, 0)) {
|
|
2467
|
+
if (isString && object.length > 0 && !has$1.call(object, 0)) {
|
|
1420
2468
|
for (var i = 0; i < object.length; ++i) {
|
|
1421
2469
|
theKeys.push(String(i));
|
|
1422
2470
|
}
|
|
@@ -1428,7 +2476,7 @@ if (!Object.keys) {
|
|
|
1428
2476
|
}
|
|
1429
2477
|
} else {
|
|
1430
2478
|
for (var name in object) {
|
|
1431
|
-
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
|
|
2479
|
+
if (!(skipProto && name === 'prototype') && has$1.call(object, name)) {
|
|
1432
2480
|
theKeys.push(String(name));
|
|
1433
2481
|
}
|
|
1434
2482
|
}
|
|
@@ -1438,7 +2486,7 @@ if (!Object.keys) {
|
|
|
1438
2486
|
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
|
1439
2487
|
|
|
1440
2488
|
for (var k = 0; k < dontEnums.length; ++k) {
|
|
1441
|
-
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
|
|
2489
|
+
if (!(skipConstructor && dontEnums[k] === 'constructor') && has$1.call(object, dontEnums[k])) {
|
|
1442
2490
|
theKeys.push(dontEnums[k]);
|
|
1443
2491
|
}
|
|
1444
2492
|
}
|
|
@@ -1535,6 +2583,59 @@ defineProperties.supportsDescriptors = !!supportsDescriptors;
|
|
|
1535
2583
|
|
|
1536
2584
|
var defineProperties_1 = defineProperties;
|
|
1537
2585
|
|
|
2586
|
+
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
2587
|
+
var shams = function hasSymbols() {
|
|
2588
|
+
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
|
2589
|
+
if (typeof Symbol.iterator === 'symbol') { return true; }
|
|
2590
|
+
|
|
2591
|
+
var obj = {};
|
|
2592
|
+
var sym = Symbol('test');
|
|
2593
|
+
var symObj = Object(sym);
|
|
2594
|
+
if (typeof sym === 'string') { return false; }
|
|
2595
|
+
|
|
2596
|
+
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
|
2597
|
+
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
|
2598
|
+
|
|
2599
|
+
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
2600
|
+
// if (sym instanceof Symbol) { return false; }
|
|
2601
|
+
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
2602
|
+
// if (!(symObj instanceof Symbol)) { return false; }
|
|
2603
|
+
|
|
2604
|
+
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
2605
|
+
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
2606
|
+
|
|
2607
|
+
var symVal = 42;
|
|
2608
|
+
obj[sym] = symVal;
|
|
2609
|
+
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
|
|
2610
|
+
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
|
2611
|
+
|
|
2612
|
+
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
|
2613
|
+
|
|
2614
|
+
var syms = Object.getOwnPropertySymbols(obj);
|
|
2615
|
+
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
|
2616
|
+
|
|
2617
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
|
2618
|
+
|
|
2619
|
+
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
2620
|
+
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
2621
|
+
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
return true;
|
|
2625
|
+
};
|
|
2626
|
+
|
|
2627
|
+
var origSymbol = commonjsGlobal.Symbol;
|
|
2628
|
+
|
|
2629
|
+
|
|
2630
|
+
var hasSymbols$1 = function hasNativeSymbols() {
|
|
2631
|
+
if (typeof origSymbol !== 'function') { return false; }
|
|
2632
|
+
if (typeof Symbol !== 'function') { return false; }
|
|
2633
|
+
if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
|
2634
|
+
if (typeof Symbol('bar') !== 'symbol') { return false; }
|
|
2635
|
+
|
|
2636
|
+
return shams();
|
|
2637
|
+
};
|
|
2638
|
+
|
|
1538
2639
|
/* eslint no-invalid-this: 1 */
|
|
1539
2640
|
|
|
1540
2641
|
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
@@ -1588,74 +2689,15 @@ var implementation$1 = function bind(that) {
|
|
|
1588
2689
|
|
|
1589
2690
|
var functionBind = Function.prototype.bind || implementation$1;
|
|
1590
2691
|
|
|
1591
|
-
/*
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
var obj = {};
|
|
1597
|
-
var sym = Symbol('test');
|
|
1598
|
-
var symObj = Object(sym);
|
|
1599
|
-
if (typeof sym === 'string') { return false; }
|
|
1600
|
-
|
|
1601
|
-
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
|
1602
|
-
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
|
1603
|
-
|
|
1604
|
-
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
1605
|
-
// if (sym instanceof Symbol) { return false; }
|
|
1606
|
-
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
1607
|
-
// if (!(symObj instanceof Symbol)) { return false; }
|
|
1608
|
-
|
|
1609
|
-
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
1610
|
-
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
1611
|
-
|
|
1612
|
-
var symVal = 42;
|
|
1613
|
-
obj[sym] = symVal;
|
|
1614
|
-
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
|
|
1615
|
-
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
|
1616
|
-
|
|
1617
|
-
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
|
1618
|
-
|
|
1619
|
-
var syms = Object.getOwnPropertySymbols(obj);
|
|
1620
|
-
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
|
1621
|
-
|
|
1622
|
-
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
|
1623
|
-
|
|
1624
|
-
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
1625
|
-
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
1626
|
-
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
return true;
|
|
1630
|
-
};
|
|
1631
|
-
|
|
1632
|
-
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
var hasSymbols$1 = function hasNativeSymbols() {
|
|
1636
|
-
if (typeof origSymbol !== 'function') { return false; }
|
|
1637
|
-
if (typeof Symbol !== 'function') { return false; }
|
|
1638
|
-
if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
|
1639
|
-
if (typeof Symbol('bar') !== 'symbol') { return false; }
|
|
1640
|
-
|
|
1641
|
-
return shams();
|
|
1642
|
-
};
|
|
1643
|
-
|
|
1644
|
-
var src = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
2692
|
+
/* globals
|
|
2693
|
+
Atomics,
|
|
2694
|
+
SharedArrayBuffer,
|
|
2695
|
+
*/
|
|
1645
2696
|
|
|
1646
2697
|
var undefined$1;
|
|
1647
2698
|
|
|
1648
|
-
var $SyntaxError = SyntaxError;
|
|
1649
|
-
var $Function = Function;
|
|
1650
2699
|
var $TypeError = TypeError;
|
|
1651
2700
|
|
|
1652
|
-
// eslint-disable-next-line consistent-return
|
|
1653
|
-
var getEvalledConstructor = function (expressionSyntax) {
|
|
1654
|
-
try {
|
|
1655
|
-
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
1656
|
-
} catch (e) {}
|
|
1657
|
-
};
|
|
1658
|
-
|
|
1659
2701
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
1660
2702
|
if ($gOPD) {
|
|
1661
2703
|
try {
|
|
@@ -1665,9 +2707,7 @@ if ($gOPD) {
|
|
|
1665
2707
|
}
|
|
1666
2708
|
}
|
|
1667
2709
|
|
|
1668
|
-
var throwTypeError = function () {
|
|
1669
|
-
throw new $TypeError();
|
|
1670
|
-
};
|
|
2710
|
+
var throwTypeError = function () { throw new $TypeError(); };
|
|
1671
2711
|
var ThrowTypeError = $gOPD
|
|
1672
2712
|
? (function () {
|
|
1673
2713
|
try {
|
|
@@ -1688,351 +2728,203 @@ var ThrowTypeError = $gOPD
|
|
|
1688
2728
|
var hasSymbols$2 = hasSymbols$1();
|
|
1689
2729
|
|
|
1690
2730
|
var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
|
|
1691
|
-
|
|
1692
|
-
var
|
|
2731
|
+
var generatorFunction = undefined$1;
|
|
2732
|
+
var asyncFunction = undefined$1;
|
|
2733
|
+
var asyncGenFunction = undefined$1;
|
|
1693
2734
|
|
|
1694
2735
|
var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
|
|
1695
2736
|
|
|
1696
2737
|
var INTRINSICS = {
|
|
1697
|
-
'%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
|
|
1698
2738
|
'%Array%': Array,
|
|
1699
2739
|
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
|
|
2740
|
+
'%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer.prototype,
|
|
1700
2741
|
'%ArrayIteratorPrototype%': hasSymbols$2 ? getProto([][Symbol.iterator]()) : undefined$1,
|
|
2742
|
+
'%ArrayPrototype%': Array.prototype,
|
|
2743
|
+
'%ArrayProto_entries%': Array.prototype.entries,
|
|
2744
|
+
'%ArrayProto_forEach%': Array.prototype.forEach,
|
|
2745
|
+
'%ArrayProto_keys%': Array.prototype.keys,
|
|
2746
|
+
'%ArrayProto_values%': Array.prototype.values,
|
|
1701
2747
|
'%AsyncFromSyncIteratorPrototype%': undefined$1,
|
|
1702
|
-
'%AsyncFunction%':
|
|
1703
|
-
'%
|
|
1704
|
-
'%
|
|
1705
|
-
'%
|
|
2748
|
+
'%AsyncFunction%': asyncFunction,
|
|
2749
|
+
'%AsyncFunctionPrototype%': undefined$1,
|
|
2750
|
+
'%AsyncGenerator%': undefined$1,
|
|
2751
|
+
'%AsyncGeneratorFunction%': asyncGenFunction,
|
|
2752
|
+
'%AsyncGeneratorPrototype%': undefined$1,
|
|
2753
|
+
'%AsyncIteratorPrototype%': undefined$1,
|
|
1706
2754
|
'%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
|
|
1707
|
-
'%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
|
|
1708
2755
|
'%Boolean%': Boolean,
|
|
2756
|
+
'%BooleanPrototype%': Boolean.prototype,
|
|
1709
2757
|
'%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
|
|
2758
|
+
'%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$1 : DataView.prototype,
|
|
1710
2759
|
'%Date%': Date,
|
|
2760
|
+
'%DatePrototype%': Date.prototype,
|
|
1711
2761
|
'%decodeURI%': decodeURI,
|
|
1712
2762
|
'%decodeURIComponent%': decodeURIComponent,
|
|
1713
2763
|
'%encodeURI%': encodeURI,
|
|
1714
2764
|
'%encodeURIComponent%': encodeURIComponent,
|
|
1715
2765
|
'%Error%': Error,
|
|
2766
|
+
'%ErrorPrototype%': Error.prototype,
|
|
1716
2767
|
'%eval%': eval, // eslint-disable-line no-eval
|
|
1717
2768
|
'%EvalError%': EvalError,
|
|
2769
|
+
'%EvalErrorPrototype%': EvalError.prototype,
|
|
1718
2770
|
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
|
|
2771
|
+
'%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array.prototype,
|
|
1719
2772
|
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
|
|
1720
|
-
'%
|
|
1721
|
-
'%Function%':
|
|
1722
|
-
'%
|
|
2773
|
+
'%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array.prototype,
|
|
2774
|
+
'%Function%': Function,
|
|
2775
|
+
'%FunctionPrototype%': Function.prototype,
|
|
2776
|
+
'%Generator%': undefined$1,
|
|
2777
|
+
'%GeneratorFunction%': generatorFunction,
|
|
2778
|
+
'%GeneratorPrototype%': undefined$1,
|
|
1723
2779
|
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
|
|
2780
|
+
'%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array.prototype,
|
|
1724
2781
|
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
|
|
2782
|
+
'%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$1 : Int8Array.prototype,
|
|
1725
2783
|
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
|
|
2784
|
+
'%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array.prototype,
|
|
1726
2785
|
'%isFinite%': isFinite,
|
|
1727
2786
|
'%isNaN%': isNaN,
|
|
1728
2787
|
'%IteratorPrototype%': hasSymbols$2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
|
|
1729
2788
|
'%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
|
|
2789
|
+
'%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$1,
|
|
1730
2790
|
'%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
|
|
1731
2791
|
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
|
|
2792
|
+
'%MapPrototype%': typeof Map === 'undefined' ? undefined$1 : Map.prototype,
|
|
1732
2793
|
'%Math%': Math,
|
|
1733
2794
|
'%Number%': Number,
|
|
2795
|
+
'%NumberPrototype%': Number.prototype,
|
|
1734
2796
|
'%Object%': Object,
|
|
2797
|
+
'%ObjectPrototype%': Object.prototype,
|
|
2798
|
+
'%ObjProto_toString%': Object.prototype.toString,
|
|
2799
|
+
'%ObjProto_valueOf%': Object.prototype.valueOf,
|
|
1735
2800
|
'%parseFloat%': parseFloat,
|
|
1736
2801
|
'%parseInt%': parseInt,
|
|
1737
2802
|
'%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
|
|
2803
|
+
'%PromisePrototype%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype,
|
|
2804
|
+
'%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype.then,
|
|
2805
|
+
'%Promise_all%': typeof Promise === 'undefined' ? undefined$1 : Promise.all,
|
|
2806
|
+
'%Promise_reject%': typeof Promise === 'undefined' ? undefined$1 : Promise.reject,
|
|
2807
|
+
'%Promise_resolve%': typeof Promise === 'undefined' ? undefined$1 : Promise.resolve,
|
|
1738
2808
|
'%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
|
|
1739
2809
|
'%RangeError%': RangeError,
|
|
2810
|
+
'%RangeErrorPrototype%': RangeError.prototype,
|
|
1740
2811
|
'%ReferenceError%': ReferenceError,
|
|
2812
|
+
'%ReferenceErrorPrototype%': ReferenceError.prototype,
|
|
1741
2813
|
'%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
|
|
1742
2814
|
'%RegExp%': RegExp,
|
|
2815
|
+
'%RegExpPrototype%': RegExp.prototype,
|
|
1743
2816
|
'%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
|
|
1744
2817
|
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
|
|
2818
|
+
'%SetPrototype%': typeof Set === 'undefined' ? undefined$1 : Set.prototype,
|
|
1745
2819
|
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
|
|
2820
|
+
'%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer.prototype,
|
|
1746
2821
|
'%String%': String,
|
|
1747
2822
|
'%StringIteratorPrototype%': hasSymbols$2 ? getProto(''[Symbol.iterator]()) : undefined$1,
|
|
2823
|
+
'%StringPrototype%': String.prototype,
|
|
1748
2824
|
'%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
|
|
1749
|
-
'%
|
|
2825
|
+
'%SymbolPrototype%': hasSymbols$2 ? Symbol.prototype : undefined$1,
|
|
2826
|
+
'%SyntaxError%': SyntaxError,
|
|
2827
|
+
'%SyntaxErrorPrototype%': SyntaxError.prototype,
|
|
1750
2828
|
'%ThrowTypeError%': ThrowTypeError,
|
|
1751
2829
|
'%TypedArray%': TypedArray,
|
|
2830
|
+
'%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined$1,
|
|
1752
2831
|
'%TypeError%': $TypeError,
|
|
2832
|
+
'%TypeErrorPrototype%': $TypeError.prototype,
|
|
1753
2833
|
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
|
|
2834
|
+
'%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array.prototype,
|
|
1754
2835
|
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
|
|
2836
|
+
'%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray.prototype,
|
|
1755
2837
|
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
|
|
2838
|
+
'%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array.prototype,
|
|
1756
2839
|
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
|
|
2840
|
+
'%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array.prototype,
|
|
1757
2841
|
'%URIError%': URIError,
|
|
2842
|
+
'%URIErrorPrototype%': URIError.prototype,
|
|
1758
2843
|
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
|
|
1759
|
-
'%
|
|
1760
|
-
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
var doEval = function doEval(name) {
|
|
1764
|
-
var value;
|
|
1765
|
-
if (name === '%AsyncFunction%') {
|
|
1766
|
-
value = getEvalledConstructor('async function () {}');
|
|
1767
|
-
} else if (name === '%GeneratorFunction%') {
|
|
1768
|
-
value = getEvalledConstructor('function* () {}');
|
|
1769
|
-
} else if (name === '%AsyncGeneratorFunction%') {
|
|
1770
|
-
value = getEvalledConstructor('async function* () {}');
|
|
1771
|
-
} else if (name === '%AsyncGenerator%') {
|
|
1772
|
-
var fn = doEval('%AsyncGeneratorFunction%');
|
|
1773
|
-
if (fn) {
|
|
1774
|
-
value = fn.prototype;
|
|
1775
|
-
}
|
|
1776
|
-
} else if (name === '%AsyncIteratorPrototype%') {
|
|
1777
|
-
var gen = doEval('%AsyncGenerator%');
|
|
1778
|
-
if (gen) {
|
|
1779
|
-
value = getProto(gen.prototype);
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
INTRINSICS[name] = value;
|
|
1784
|
-
|
|
1785
|
-
return value;
|
|
2844
|
+
'%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap.prototype,
|
|
2845
|
+
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
|
|
2846
|
+
'%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet.prototype
|
|
1786
2847
|
};
|
|
1787
2848
|
|
|
1788
|
-
|
|
1789
|
-
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
1790
|
-
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
1791
|
-
'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
|
1792
|
-
'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
|
1793
|
-
'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
|
1794
|
-
'%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
|
1795
|
-
'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
|
1796
|
-
'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
|
1797
|
-
'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
|
1798
|
-
'%BooleanPrototype%': ['Boolean', 'prototype'],
|
|
1799
|
-
'%DataViewPrototype%': ['DataView', 'prototype'],
|
|
1800
|
-
'%DatePrototype%': ['Date', 'prototype'],
|
|
1801
|
-
'%ErrorPrototype%': ['Error', 'prototype'],
|
|
1802
|
-
'%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
|
1803
|
-
'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
|
1804
|
-
'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
|
1805
|
-
'%FunctionPrototype%': ['Function', 'prototype'],
|
|
1806
|
-
'%Generator%': ['GeneratorFunction', 'prototype'],
|
|
1807
|
-
'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
|
1808
|
-
'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
|
1809
|
-
'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
|
1810
|
-
'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
|
1811
|
-
'%JSONParse%': ['JSON', 'parse'],
|
|
1812
|
-
'%JSONStringify%': ['JSON', 'stringify'],
|
|
1813
|
-
'%MapPrototype%': ['Map', 'prototype'],
|
|
1814
|
-
'%NumberPrototype%': ['Number', 'prototype'],
|
|
1815
|
-
'%ObjectPrototype%': ['Object', 'prototype'],
|
|
1816
|
-
'%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
|
1817
|
-
'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
|
1818
|
-
'%PromisePrototype%': ['Promise', 'prototype'],
|
|
1819
|
-
'%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
|
1820
|
-
'%Promise_all%': ['Promise', 'all'],
|
|
1821
|
-
'%Promise_reject%': ['Promise', 'reject'],
|
|
1822
|
-
'%Promise_resolve%': ['Promise', 'resolve'],
|
|
1823
|
-
'%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
|
1824
|
-
'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
|
1825
|
-
'%RegExpPrototype%': ['RegExp', 'prototype'],
|
|
1826
|
-
'%SetPrototype%': ['Set', 'prototype'],
|
|
1827
|
-
'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
|
1828
|
-
'%StringPrototype%': ['String', 'prototype'],
|
|
1829
|
-
'%SymbolPrototype%': ['Symbol', 'prototype'],
|
|
1830
|
-
'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
|
1831
|
-
'%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
|
1832
|
-
'%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
|
1833
|
-
'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
|
1834
|
-
'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
|
1835
|
-
'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
|
1836
|
-
'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
|
1837
|
-
'%URIErrorPrototype%': ['URIError', 'prototype'],
|
|
1838
|
-
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
1839
|
-
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
var $concat = functionBind.call(Function.call, Array.prototype.concat);
|
|
1845
|
-
var $spliceApply = functionBind.call(Function.apply, Array.prototype.splice);
|
|
2849
|
+
|
|
1846
2850
|
var $replace = functionBind.call(Function.call, String.prototype.replace);
|
|
1847
|
-
var $strSlice = functionBind.call(Function.call, String.prototype.slice);
|
|
1848
2851
|
|
|
1849
2852
|
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
|
|
1850
2853
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
1851
2854
|
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
|
|
1852
2855
|
var stringToPath = function stringToPath(string) {
|
|
1853
|
-
var first = $strSlice(string, 0, 1);
|
|
1854
|
-
var last = $strSlice(string, -1);
|
|
1855
|
-
if (first === '%' && last !== '%') {
|
|
1856
|
-
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
1857
|
-
} else if (last === '%' && first !== '%') {
|
|
1858
|
-
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
1859
|
-
}
|
|
1860
2856
|
var result = [];
|
|
1861
2857
|
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
1862
|
-
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
2858
|
+
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
|
|
1863
2859
|
});
|
|
1864
2860
|
return result;
|
|
1865
2861
|
};
|
|
1866
2862
|
/* end adaptation */
|
|
1867
2863
|
|
|
1868
2864
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
if (src(LEGACY_ALIASES, intrinsicName)) {
|
|
1872
|
-
alias = LEGACY_ALIASES[intrinsicName];
|
|
1873
|
-
intrinsicName = '%' + alias[0] + '%';
|
|
2865
|
+
if (!(name in INTRINSICS)) {
|
|
2866
|
+
throw new SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
1874
2867
|
}
|
|
1875
2868
|
|
|
1876
|
-
if
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
value = doEval(intrinsicName);
|
|
1880
|
-
}
|
|
1881
|
-
if (typeof value === 'undefined' && !allowMissing) {
|
|
1882
|
-
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
return {
|
|
1886
|
-
alias: alias,
|
|
1887
|
-
name: intrinsicName,
|
|
1888
|
-
value: value
|
|
1889
|
-
};
|
|
2869
|
+
// istanbul ignore if // hopefully this is impossible to test :-)
|
|
2870
|
+
if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) {
|
|
2871
|
+
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
1890
2872
|
}
|
|
1891
2873
|
|
|
1892
|
-
|
|
2874
|
+
return INTRINSICS[name];
|
|
1893
2875
|
};
|
|
1894
2876
|
|
|
1895
|
-
var
|
|
2877
|
+
var GetIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
1896
2878
|
if (typeof name !== 'string' || name.length === 0) {
|
|
1897
|
-
throw new
|
|
2879
|
+
throw new TypeError('intrinsic name must be a non-empty string');
|
|
1898
2880
|
}
|
|
1899
2881
|
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
1900
|
-
throw new
|
|
2882
|
+
throw new TypeError('"allowMissing" argument must be a boolean');
|
|
1901
2883
|
}
|
|
1902
2884
|
|
|
1903
2885
|
var parts = stringToPath(name);
|
|
1904
|
-
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
1905
|
-
|
|
1906
|
-
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
1907
|
-
var intrinsicRealName = intrinsic.name;
|
|
1908
|
-
var value = intrinsic.value;
|
|
1909
|
-
var skipFurtherCaching = false;
|
|
1910
|
-
|
|
1911
|
-
var alias = intrinsic.alias;
|
|
1912
|
-
if (alias) {
|
|
1913
|
-
intrinsicBaseName = alias[0];
|
|
1914
|
-
$spliceApply(parts, $concat([0, 1], alias));
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
1918
|
-
var part = parts[i];
|
|
1919
|
-
var first = $strSlice(part, 0, 1);
|
|
1920
|
-
var last = $strSlice(part, -1);
|
|
1921
|
-
if (
|
|
1922
|
-
(
|
|
1923
|
-
(first === '"' || first === "'" || first === '`')
|
|
1924
|
-
|| (last === '"' || last === "'" || last === '`')
|
|
1925
|
-
)
|
|
1926
|
-
&& first !== last
|
|
1927
|
-
) {
|
|
1928
|
-
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
1929
|
-
}
|
|
1930
|
-
if (part === 'constructor' || !isOwn) {
|
|
1931
|
-
skipFurtherCaching = true;
|
|
1932
|
-
}
|
|
1933
2886
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
if (src(INTRINSICS, intrinsicRealName)) {
|
|
1938
|
-
value = INTRINSICS[intrinsicRealName];
|
|
1939
|
-
} else if (value != null) {
|
|
1940
|
-
if (!(part in value)) {
|
|
1941
|
-
if (!allowMissing) {
|
|
1942
|
-
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
1943
|
-
}
|
|
1944
|
-
return void undefined$1;
|
|
1945
|
-
}
|
|
2887
|
+
var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
|
|
2888
|
+
for (var i = 1; i < parts.length; i += 1) {
|
|
2889
|
+
if (value != null) {
|
|
1946
2890
|
if ($gOPD && (i + 1) >= parts.length) {
|
|
1947
|
-
var desc = $gOPD(value,
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
// By convention, when a data property is converted to an accessor
|
|
1951
|
-
// property to emulate a data property that does not suffer from
|
|
1952
|
-
// the override mistake, that accessor's getter is marked with
|
|
1953
|
-
// an `originalValue` property. Here, when we detect this, we
|
|
1954
|
-
// uphold the illusion by pretending to see that original data
|
|
1955
|
-
// property, i.e., returning the value rather than the getter
|
|
1956
|
-
// itself.
|
|
1957
|
-
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
1958
|
-
value = desc.get;
|
|
1959
|
-
} else {
|
|
1960
|
-
value = value[part];
|
|
2891
|
+
var desc = $gOPD(value, parts[i]);
|
|
2892
|
+
if (!allowMissing && !(parts[i] in value)) {
|
|
2893
|
+
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
1961
2894
|
}
|
|
2895
|
+
value = desc ? (desc.get || desc.value) : value[parts[i]];
|
|
1962
2896
|
} else {
|
|
1963
|
-
|
|
1964
|
-
value = value[part];
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
if (isOwn && !skipFurtherCaching) {
|
|
1968
|
-
INTRINSICS[intrinsicRealName] = value;
|
|
2897
|
+
value = value[parts[i]];
|
|
1969
2898
|
}
|
|
1970
2899
|
}
|
|
1971
2900
|
}
|
|
1972
2901
|
return value;
|
|
1973
2902
|
};
|
|
1974
2903
|
|
|
1975
|
-
var
|
|
2904
|
+
var $Function = GetIntrinsic('%Function%');
|
|
2905
|
+
var $apply = $Function.apply;
|
|
2906
|
+
var $call = $Function.call;
|
|
1976
2907
|
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
var $apply = getIntrinsic('%Function.prototype.apply%');
|
|
1981
|
-
var $call = getIntrinsic('%Function.prototype.call%');
|
|
1982
|
-
var $reflectApply = getIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
|
|
1983
|
-
|
|
1984
|
-
var $gOPD = getIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
1985
|
-
var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
|
|
1986
|
-
var $max = getIntrinsic('%Math.max%');
|
|
1987
|
-
|
|
1988
|
-
if ($defineProperty) {
|
|
1989
|
-
try {
|
|
1990
|
-
$defineProperty({}, 'a', { value: 1 });
|
|
1991
|
-
} catch (e) {
|
|
1992
|
-
// IE 8 has a broken defineProperty
|
|
1993
|
-
$defineProperty = null;
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
module.exports = function callBind(originalFunction) {
|
|
1998
|
-
var func = $reflectApply(functionBind, $call, arguments);
|
|
1999
|
-
if ($gOPD && $defineProperty) {
|
|
2000
|
-
var desc = $gOPD(func, 'length');
|
|
2001
|
-
if (desc.configurable) {
|
|
2002
|
-
// original length, plus the receiver, minus any additional arguments (after the receiver)
|
|
2003
|
-
$defineProperty(
|
|
2004
|
-
func,
|
|
2005
|
-
'length',
|
|
2006
|
-
{ value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
|
|
2007
|
-
);
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
return func;
|
|
2908
|
+
var callBind = function callBind() {
|
|
2909
|
+
return functionBind.apply($call, arguments);
|
|
2011
2910
|
};
|
|
2012
2911
|
|
|
2013
|
-
var
|
|
2014
|
-
return
|
|
2912
|
+
var apply = function applyBind() {
|
|
2913
|
+
return functionBind.apply($apply, arguments);
|
|
2015
2914
|
};
|
|
2915
|
+
callBind.apply = apply;
|
|
2016
2916
|
|
|
2017
|
-
|
|
2018
|
-
$defineProperty(module.exports, 'apply', { value: applyBind });
|
|
2019
|
-
} else {
|
|
2020
|
-
module.exports.apply = applyBind;
|
|
2021
|
-
}
|
|
2022
|
-
});
|
|
2023
|
-
var callBind_1 = callBind.apply;
|
|
2024
|
-
|
|
2025
|
-
var $indexOf = callBind(getIntrinsic('String.prototype.indexOf'));
|
|
2917
|
+
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
2026
2918
|
|
|
2027
2919
|
var callBound = function callBoundIntrinsic(name, allowMissing) {
|
|
2028
|
-
var intrinsic =
|
|
2029
|
-
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')
|
|
2920
|
+
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
|
2921
|
+
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) {
|
|
2030
2922
|
return callBind(intrinsic);
|
|
2031
2923
|
}
|
|
2032
2924
|
return intrinsic;
|
|
2033
2925
|
};
|
|
2034
2926
|
|
|
2035
|
-
var $defineProperty =
|
|
2927
|
+
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
2036
2928
|
|
|
2037
2929
|
if ($defineProperty) {
|
|
2038
2930
|
try {
|
|
@@ -2074,13 +2966,15 @@ var DefineOwnProperty = function DefineOwnProperty(IsDataDescriptor, SameValue,
|
|
|
2074
2966
|
return true;
|
|
2075
2967
|
};
|
|
2076
2968
|
|
|
2077
|
-
var
|
|
2078
|
-
|
|
2969
|
+
var src = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
2970
|
+
|
|
2971
|
+
var $TypeError$1 = GetIntrinsic('%TypeError%');
|
|
2972
|
+
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
|
2079
2973
|
|
|
2080
2974
|
|
|
2081
2975
|
|
|
2082
2976
|
var predicates = {
|
|
2083
|
-
// https://
|
|
2977
|
+
// https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
|
|
2084
2978
|
'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
|
|
2085
2979
|
if (Type(Desc) !== 'Object') {
|
|
2086
2980
|
return false;
|
|
@@ -2112,14 +3006,14 @@ var predicates = {
|
|
|
2112
3006
|
var assertRecord = function assertRecord(Type, recordType, argumentName, value) {
|
|
2113
3007
|
var predicate = predicates[recordType];
|
|
2114
3008
|
if (typeof predicate !== 'function') {
|
|
2115
|
-
throw new $SyntaxError
|
|
3009
|
+
throw new $SyntaxError('unknown record type: ' + recordType);
|
|
2116
3010
|
}
|
|
2117
3011
|
if (!predicate(Type, value)) {
|
|
2118
3012
|
throw new $TypeError$1(argumentName + ' must be a ' + recordType);
|
|
2119
3013
|
}
|
|
2120
3014
|
};
|
|
2121
3015
|
|
|
2122
|
-
// https://
|
|
3016
|
+
// https://www.ecma-international.org/ecma-262/5.1/#sec-8
|
|
2123
3017
|
|
|
2124
3018
|
var Type = function Type(x) {
|
|
2125
3019
|
if (x === null) {
|
|
@@ -2142,19 +3036,16 @@ var Type = function Type(x) {
|
|
|
2142
3036
|
}
|
|
2143
3037
|
};
|
|
2144
3038
|
|
|
2145
|
-
// https://
|
|
3039
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-tostring
|
|
2146
3040
|
|
|
2147
3041
|
var Type$1 = function Type$1(x) {
|
|
2148
3042
|
if (typeof x === 'symbol') {
|
|
2149
3043
|
return 'Symbol';
|
|
2150
3044
|
}
|
|
2151
|
-
if (typeof x === 'bigint') {
|
|
2152
|
-
return 'BigInt';
|
|
2153
|
-
}
|
|
2154
3045
|
return Type(x);
|
|
2155
3046
|
};
|
|
2156
3047
|
|
|
2157
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
|
|
3048
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
|
|
2158
3049
|
|
|
2159
3050
|
var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
|
|
2160
3051
|
if (typeof Desc === 'undefined') {
|
|
@@ -2185,7 +3076,7 @@ var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
|
|
|
2185
3076
|
return obj;
|
|
2186
3077
|
};
|
|
2187
3078
|
|
|
2188
|
-
var $gOPD$1 =
|
|
3079
|
+
var $gOPD$1 = GetIntrinsic('%Object.getOwnPropertyDescriptor%');
|
|
2189
3080
|
if ($gOPD$1) {
|
|
2190
3081
|
try {
|
|
2191
3082
|
$gOPD$1([], 'length');
|
|
@@ -2197,85 +3088,65 @@ if ($gOPD$1) {
|
|
|
2197
3088
|
|
|
2198
3089
|
var getOwnPropertyDescriptor = $gOPD$1;
|
|
2199
3090
|
|
|
2200
|
-
var $Array =
|
|
3091
|
+
var $Array = GetIntrinsic('%Array%');
|
|
2201
3092
|
|
|
2202
3093
|
// eslint-disable-next-line global-require
|
|
2203
3094
|
var toStr$4 = !$Array.isArray && callBound('Object.prototype.toString');
|
|
2204
3095
|
|
|
2205
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-isarray
|
|
3096
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-isarray
|
|
2206
3097
|
|
|
2207
3098
|
var IsArray = $Array.isArray || function IsArray(argument) {
|
|
2208
3099
|
return toStr$4(argument) === '[object Array]';
|
|
2209
3100
|
};
|
|
2210
3101
|
|
|
2211
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-ispropertykey
|
|
3102
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-ispropertykey
|
|
2212
3103
|
|
|
2213
3104
|
var IsPropertyKey = function IsPropertyKey(argument) {
|
|
2214
3105
|
return typeof argument === 'string' || typeof argument === 'symbol';
|
|
2215
3106
|
};
|
|
2216
3107
|
|
|
2217
|
-
var
|
|
2218
|
-
var
|
|
2219
|
-
var has$1;
|
|
2220
|
-
var $exec;
|
|
2221
|
-
var isRegexMarker;
|
|
2222
|
-
var badStringifier;
|
|
2223
|
-
|
|
2224
|
-
if (hasToStringTag) {
|
|
2225
|
-
has$1 = callBound('Object.prototype.hasOwnProperty');
|
|
2226
|
-
$exec = callBound('RegExp.prototype.exec');
|
|
2227
|
-
isRegexMarker = {};
|
|
3108
|
+
var regexExec = RegExp.prototype.exec;
|
|
3109
|
+
var gOPD = Object.getOwnPropertyDescriptor;
|
|
2228
3110
|
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
toString: throwRegexMarker,
|
|
2234
|
-
valueOf: throwRegexMarker
|
|
2235
|
-
};
|
|
3111
|
+
var tryRegexExecCall = function tryRegexExec(value) {
|
|
3112
|
+
try {
|
|
3113
|
+
var lastIndex = value.lastIndex;
|
|
3114
|
+
value.lastIndex = 0; // eslint-disable-line no-param-reassign
|
|
2236
3115
|
|
|
2237
|
-
|
|
2238
|
-
|
|
3116
|
+
regexExec.call(value);
|
|
3117
|
+
return true;
|
|
3118
|
+
} catch (e) {
|
|
3119
|
+
return false;
|
|
3120
|
+
} finally {
|
|
3121
|
+
value.lastIndex = lastIndex; // eslint-disable-line no-param-reassign
|
|
2239
3122
|
}
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
var $toString = callBound('Object.prototype.toString');
|
|
2243
|
-
var gOPD = Object.getOwnPropertyDescriptor;
|
|
3123
|
+
};
|
|
3124
|
+
var toStr$5 = Object.prototype.toString;
|
|
2244
3125
|
var regexClass = '[object RegExp]';
|
|
3126
|
+
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
2245
3127
|
|
|
2246
|
-
var isRegex =
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
var descriptor = gOPD(value, 'lastIndex');
|
|
2254
|
-
var hasLastIndexDataProperty = descriptor && has$1(descriptor, 'value');
|
|
2255
|
-
if (!hasLastIndexDataProperty) {
|
|
2256
|
-
return false;
|
|
2257
|
-
}
|
|
3128
|
+
var isRegex = function isRegex(value) {
|
|
3129
|
+
if (!value || typeof value !== 'object') {
|
|
3130
|
+
return false;
|
|
3131
|
+
}
|
|
3132
|
+
if (!hasToStringTag) {
|
|
3133
|
+
return toStr$5.call(value) === regexClass;
|
|
3134
|
+
}
|
|
2258
3135
|
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
}
|
|
3136
|
+
var descriptor = gOPD(value, 'lastIndex');
|
|
3137
|
+
var hasLastIndexDataProperty = descriptor && src(descriptor, 'value');
|
|
3138
|
+
if (!hasLastIndexDataProperty) {
|
|
3139
|
+
return false;
|
|
2264
3140
|
}
|
|
2265
|
-
: function isRegex(value) {
|
|
2266
|
-
// In older browsers, typeof regex incorrectly returns 'function'
|
|
2267
|
-
if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
|
|
2268
|
-
return false;
|
|
2269
|
-
}
|
|
2270
3141
|
|
|
2271
|
-
|
|
2272
|
-
|
|
3142
|
+
return tryRegexExecCall(value);
|
|
3143
|
+
};
|
|
2273
3144
|
|
|
2274
|
-
// http://
|
|
3145
|
+
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.2
|
|
2275
3146
|
|
|
2276
3147
|
var ToBoolean = function ToBoolean(value) { return !!value; };
|
|
2277
3148
|
|
|
2278
|
-
var $match =
|
|
3149
|
+
var $match = GetIntrinsic('%Symbol.match%', true);
|
|
2279
3150
|
|
|
2280
3151
|
|
|
2281
3152
|
|
|
@@ -2297,27 +3168,6 @@ var IsRegExp = function IsRegExp(argument) {
|
|
|
2297
3168
|
};
|
|
2298
3169
|
|
|
2299
3170
|
var fnToStr = Function.prototype.toString;
|
|
2300
|
-
var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
|
|
2301
|
-
var badArrayLike;
|
|
2302
|
-
var isCallableMarker;
|
|
2303
|
-
if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
|
|
2304
|
-
try {
|
|
2305
|
-
badArrayLike = Object.defineProperty({}, 'length', {
|
|
2306
|
-
get: function () {
|
|
2307
|
-
throw isCallableMarker;
|
|
2308
|
-
}
|
|
2309
|
-
});
|
|
2310
|
-
isCallableMarker = {};
|
|
2311
|
-
// eslint-disable-next-line no-throw-literal
|
|
2312
|
-
reflectApply(function () { throw 42; }, null, badArrayLike);
|
|
2313
|
-
} catch (_) {
|
|
2314
|
-
if (_ !== isCallableMarker) {
|
|
2315
|
-
reflectApply = null;
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
} else {
|
|
2319
|
-
reflectApply = null;
|
|
2320
|
-
}
|
|
2321
3171
|
|
|
2322
3172
|
var constructorRegex = /^\s*class\b/;
|
|
2323
3173
|
var isES6ClassFn = function isES6ClassFunction(value) {
|
|
@@ -2338,48 +3188,32 @@ var tryFunctionObject = function tryFunctionToStr(value) {
|
|
|
2338
3188
|
return false;
|
|
2339
3189
|
}
|
|
2340
3190
|
};
|
|
2341
|
-
var toStr$
|
|
3191
|
+
var toStr$6 = Object.prototype.toString;
|
|
2342
3192
|
var fnClass = '[object Function]';
|
|
2343
3193
|
var genClass = '[object GeneratorFunction]';
|
|
2344
3194
|
var hasToStringTag$1 = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
2345
|
-
/* globals document: false */
|
|
2346
|
-
var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {};
|
|
2347
|
-
|
|
2348
|
-
var isCallable = reflectApply
|
|
2349
|
-
? function isCallable(value) {
|
|
2350
|
-
if (value === documentDotAll) { return true; }
|
|
2351
|
-
if (!value) { return false; }
|
|
2352
|
-
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
|
|
2353
|
-
if (typeof value === 'function' && !value.prototype) { return true; }
|
|
2354
|
-
try {
|
|
2355
|
-
reflectApply(value, null, badArrayLike);
|
|
2356
|
-
} catch (e) {
|
|
2357
|
-
if (e !== isCallableMarker) { return false; }
|
|
2358
|
-
}
|
|
2359
|
-
return !isES6ClassFn(value);
|
|
2360
|
-
}
|
|
2361
|
-
: function isCallable(value) {
|
|
2362
|
-
if (value === documentDotAll) { return true; }
|
|
2363
|
-
if (!value) { return false; }
|
|
2364
|
-
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
|
|
2365
|
-
if (typeof value === 'function' && !value.prototype) { return true; }
|
|
2366
|
-
if (hasToStringTag$1) { return tryFunctionObject(value); }
|
|
2367
|
-
if (isES6ClassFn(value)) { return false; }
|
|
2368
|
-
var strClass = toStr$5.call(value);
|
|
2369
|
-
return strClass === fnClass || strClass === genClass;
|
|
2370
|
-
};
|
|
2371
3195
|
|
|
2372
|
-
|
|
3196
|
+
var isCallable = function isCallable(value) {
|
|
3197
|
+
if (!value) { return false; }
|
|
3198
|
+
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
|
|
3199
|
+
if (typeof value === 'function' && !value.prototype) { return true; }
|
|
3200
|
+
if (hasToStringTag$1) { return tryFunctionObject(value); }
|
|
3201
|
+
if (isES6ClassFn(value)) { return false; }
|
|
3202
|
+
var strClass = toStr$6.call(value);
|
|
3203
|
+
return strClass === fnClass || strClass === genClass;
|
|
3204
|
+
};
|
|
3205
|
+
|
|
3206
|
+
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
|
|
2373
3207
|
|
|
2374
3208
|
var IsCallable = isCallable;
|
|
2375
3209
|
|
|
2376
|
-
var $TypeError$2 =
|
|
3210
|
+
var $TypeError$2 = GetIntrinsic('%TypeError%');
|
|
2377
3211
|
|
|
2378
3212
|
|
|
2379
3213
|
|
|
2380
3214
|
|
|
2381
3215
|
|
|
2382
|
-
// https://
|
|
3216
|
+
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.5
|
|
2383
3217
|
|
|
2384
3218
|
var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
|
|
2385
3219
|
if (Type$1(Obj) !== 'Object') {
|
|
@@ -2402,7 +3236,7 @@ var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
|
|
|
2402
3236
|
if (src(Obj, 'get')) {
|
|
2403
3237
|
var getter = Obj.get;
|
|
2404
3238
|
if (typeof getter !== 'undefined' && !IsCallable(getter)) {
|
|
2405
|
-
throw new
|
|
3239
|
+
throw new TypeError('getter must be a function');
|
|
2406
3240
|
}
|
|
2407
3241
|
desc['[[Get]]'] = getter;
|
|
2408
3242
|
}
|
|
@@ -2420,7 +3254,7 @@ var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
|
|
|
2420
3254
|
return desc;
|
|
2421
3255
|
};
|
|
2422
3256
|
|
|
2423
|
-
var $TypeError$3 =
|
|
3257
|
+
var $TypeError$3 = GetIntrinsic('%TypeError%');
|
|
2424
3258
|
|
|
2425
3259
|
|
|
2426
3260
|
|
|
@@ -2434,7 +3268,7 @@ var $isEnumerable$1 = callBound('Object.prototype.propertyIsEnumerable');
|
|
|
2434
3268
|
|
|
2435
3269
|
|
|
2436
3270
|
|
|
2437
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
|
|
3271
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
|
|
2438
3272
|
|
|
2439
3273
|
var OrdinaryGetOwnProperty = function OrdinaryGetOwnProperty(O, P) {
|
|
2440
3274
|
if (Type$1(O) !== 'Object') {
|
|
@@ -2460,7 +3294,7 @@ var OrdinaryGetOwnProperty = function OrdinaryGetOwnProperty(O, P) {
|
|
|
2460
3294
|
return ToPropertyDescriptor(getOwnPropertyDescriptor(O, P));
|
|
2461
3295
|
};
|
|
2462
3296
|
|
|
2463
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
|
|
3297
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
|
|
2464
3298
|
|
|
2465
3299
|
var IsDataDescriptor = function IsDataDescriptor(Desc) {
|
|
2466
3300
|
if (typeof Desc === 'undefined') {
|
|
@@ -2480,14 +3314,14 @@ var isPrimitive = function isPrimitive(value) {
|
|
|
2480
3314
|
return value === null || (typeof value !== 'function' && typeof value !== 'object');
|
|
2481
3315
|
};
|
|
2482
3316
|
|
|
2483
|
-
var $Object =
|
|
3317
|
+
var $Object = GetIntrinsic('%Object%');
|
|
2484
3318
|
|
|
2485
3319
|
|
|
2486
3320
|
|
|
2487
3321
|
var $preventExtensions = $Object.preventExtensions;
|
|
2488
3322
|
var $isExtensible = $Object.isExtensible;
|
|
2489
3323
|
|
|
2490
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-isextensible-o
|
|
3324
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-isextensible-o
|
|
2491
3325
|
|
|
2492
3326
|
var IsExtensible = $preventExtensions
|
|
2493
3327
|
? function IsExtensible(obj) {
|
|
@@ -2501,7 +3335,7 @@ var _isNaN = Number.isNaN || function isNaN(a) {
|
|
|
2501
3335
|
return a !== a;
|
|
2502
3336
|
};
|
|
2503
3337
|
|
|
2504
|
-
// http://
|
|
3338
|
+
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.12
|
|
2505
3339
|
|
|
2506
3340
|
var SameValue = function SameValue(x, y) {
|
|
2507
3341
|
if (x === y) { // 0 === -0, but they are not identical.
|
|
@@ -2511,7 +3345,7 @@ var SameValue = function SameValue(x, y) {
|
|
|
2511
3345
|
return _isNaN(x) && _isNaN(y);
|
|
2512
3346
|
};
|
|
2513
3347
|
|
|
2514
|
-
var $TypeError$4 =
|
|
3348
|
+
var $TypeError$4 = GetIntrinsic('%TypeError%');
|
|
2515
3349
|
|
|
2516
3350
|
|
|
2517
3351
|
|
|
@@ -2523,7 +3357,7 @@ var $TypeError$4 = getIntrinsic('%TypeError%');
|
|
|
2523
3357
|
|
|
2524
3358
|
|
|
2525
3359
|
|
|
2526
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty
|
|
3360
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-createdataproperty
|
|
2527
3361
|
|
|
2528
3362
|
var CreateDataProperty = function CreateDataProperty(O, P, V) {
|
|
2529
3363
|
if (Type$1(O) !== 'Object') {
|
|
@@ -2533,8 +3367,8 @@ var CreateDataProperty = function CreateDataProperty(O, P, V) {
|
|
|
2533
3367
|
throw new $TypeError$4('Assertion failed: IsPropertyKey(P) is not true');
|
|
2534
3368
|
}
|
|
2535
3369
|
var oldDesc = OrdinaryGetOwnProperty(O, P);
|
|
2536
|
-
var extensible =
|
|
2537
|
-
var immutable = oldDesc && (!oldDesc
|
|
3370
|
+
var extensible = oldDesc || IsExtensible(O);
|
|
3371
|
+
var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
|
|
2538
3372
|
if (immutable || !extensible) {
|
|
2539
3373
|
return false;
|
|
2540
3374
|
}
|
|
@@ -2553,9 +3387,9 @@ var CreateDataProperty = function CreateDataProperty(O, P, V) {
|
|
|
2553
3387
|
);
|
|
2554
3388
|
};
|
|
2555
3389
|
|
|
2556
|
-
var $TypeError$5 =
|
|
3390
|
+
var $TypeError$5 = GetIntrinsic('%TypeError%');
|
|
2557
3391
|
|
|
2558
|
-
// http://
|
|
3392
|
+
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.10
|
|
2559
3393
|
|
|
2560
3394
|
var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
|
|
2561
3395
|
if (value == null) {
|
|
@@ -2566,11 +3400,11 @@ var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
|
|
|
2566
3400
|
|
|
2567
3401
|
var RequireObjectCoercible = CheckObjectCoercible;
|
|
2568
3402
|
|
|
2569
|
-
var $Object$1 =
|
|
3403
|
+
var $Object$1 = GetIntrinsic('%Object%');
|
|
2570
3404
|
|
|
2571
3405
|
|
|
2572
3406
|
|
|
2573
|
-
// https://ecma-international.org/ecma-262/6.0/#sec-toobject
|
|
3407
|
+
// https://www.ecma-international.org/ecma-262/6.0/#sec-toobject
|
|
2574
3408
|
|
|
2575
3409
|
var ToObject = function ToObject(value) {
|
|
2576
3410
|
RequireObjectCoercible(value);
|
|
@@ -2580,10 +3414,10 @@ var ToObject = function ToObject(value) {
|
|
|
2580
3414
|
var $gOPD$2 = Object.getOwnPropertyDescriptor;
|
|
2581
3415
|
var $getOwnNames = Object.getOwnPropertyNames;
|
|
2582
3416
|
var $getSymbols = Object.getOwnPropertySymbols;
|
|
2583
|
-
var $concat
|
|
3417
|
+
var $concat = callBound('Array.prototype.concat');
|
|
2584
3418
|
var $reduce = callBound('Array.prototype.reduce');
|
|
2585
3419
|
var getAll = $getSymbols ? function (obj) {
|
|
2586
|
-
return $concat
|
|
3420
|
+
return $concat($getOwnNames(obj), $getSymbols(obj));
|
|
2587
3421
|
} : $getOwnNames;
|
|
2588
3422
|
|
|
2589
3423
|
var isES5 = IsCallable($gOPD$2) && IsCallable($getOwnNames);
|
|
@@ -2622,19 +3456,13 @@ var shim = function shimGetOwnPropertyDescriptors() {
|
|
|
2622
3456
|
return polyfill$1;
|
|
2623
3457
|
};
|
|
2624
3458
|
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
defineProperties_1(bound, {
|
|
3459
|
+
defineProperties_1(implementation$2, {
|
|
2628
3460
|
getPolyfill: polyfill,
|
|
2629
3461
|
implementation: implementation$2,
|
|
2630
3462
|
shim: shim
|
|
2631
3463
|
});
|
|
2632
3464
|
|
|
2633
|
-
var object_getownpropertydescriptors =
|
|
2634
|
-
|
|
2635
|
-
// TODO; semver-major: remove
|
|
2636
|
-
|
|
2637
|
-
var callBound$1 = callBound;
|
|
3465
|
+
var object_getownpropertydescriptors = implementation$2;
|
|
2638
3466
|
|
|
2639
3467
|
var isES5$1 = typeof Object.defineProperty === 'function'
|
|
2640
3468
|
&& typeof Object.defineProperties === 'function';
|
|
@@ -2653,14 +3481,14 @@ if (typeof Promise !== 'function') {
|
|
|
2653
3481
|
|
|
2654
3482
|
|
|
2655
3483
|
|
|
2656
|
-
var $slice = callBound
|
|
2657
|
-
var $concat$
|
|
2658
|
-
var $forEach = callBound
|
|
3484
|
+
var $slice = callBound('Array.prototype.slice');
|
|
3485
|
+
var $concat$1 = callBound('Array.prototype.concat');
|
|
3486
|
+
var $forEach = callBound('Array.prototype.forEach');
|
|
2659
3487
|
|
|
2660
|
-
var hasSymbols$
|
|
3488
|
+
var hasSymbols$3 = hasSymbols$1();
|
|
2661
3489
|
|
|
2662
|
-
var kCustomPromisifiedSymbol = hasSymbols$
|
|
2663
|
-
var kCustomPromisifyArgsSymbol = hasSymbols$
|
|
3490
|
+
var kCustomPromisifiedSymbol = hasSymbols$3 ? Symbol('util.promisify.custom') : null;
|
|
3491
|
+
var kCustomPromisifyArgsSymbol = hasSymbols$3 ? Symbol('customPromisifyArgs') : null;
|
|
2664
3492
|
|
|
2665
3493
|
var implementation$3 = function promisify(orig) {
|
|
2666
3494
|
if (typeof orig !== 'function') {
|
|
@@ -2670,7 +3498,7 @@ var implementation$3 = function promisify(orig) {
|
|
|
2670
3498
|
throw error;
|
|
2671
3499
|
}
|
|
2672
3500
|
|
|
2673
|
-
if (hasSymbols$
|
|
3501
|
+
if (hasSymbols$3 && orig[kCustomPromisifiedSymbol]) {
|
|
2674
3502
|
var customFunction = orig[kCustomPromisifiedSymbol];
|
|
2675
3503
|
if (typeof customFunction !== 'function') {
|
|
2676
3504
|
throw new TypeError('The [util.promisify.custom] property must be a function');
|
|
@@ -2692,7 +3520,7 @@ var implementation$3 = function promisify(orig) {
|
|
|
2692
3520
|
var args = $slice(arguments);
|
|
2693
3521
|
var self = this; // eslint-disable-line no-invalid-this
|
|
2694
3522
|
return new Promise(function (resolve, reject) {
|
|
2695
|
-
orig.apply(self, $concat$
|
|
3523
|
+
orig.apply(self, $concat$1(args, function (err) {
|
|
2696
3524
|
var values = arguments.length > 1 ? $slice(arguments, 1) : [];
|
|
2697
3525
|
if (err) {
|
|
2698
3526
|
reject(err);
|