@bigbinary/neeto-commons-frontend 3.0.6 → 3.0.7
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/{constants.cjs.js → cjs/constants/index.js} +11 -10
- package/cjs/constants/index.js.map +1 -0
- package/cjs/cypress-utils/commands.js +276 -0
- package/cjs/cypress-utils/commands.js.map +1 -0
- package/cjs/cypress-utils/constants/index.js +14 -0
- package/cjs/cypress-utils/constants/index.js.map +1 -0
- package/cjs/cypress-utils/constants/routes.js +40 -0
- package/cjs/cypress-utils/constants/routes.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/common.js +103 -0
- package/cjs/cypress-utils/constants/selectors/common.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/editor.js +29 -0
- package/cjs/cypress-utils/constants/selectors/editor.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/ipRestriction.js +19 -0
- package/cjs/cypress-utils/constants/selectors/ipRestriction.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/login.js +21 -0
- package/cjs/cypress-utils/constants/selectors/login.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/member.js +65 -0
- package/cjs/cypress-utils/constants/selectors/member.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/navigation.js +28 -0
- package/cjs/cypress-utils/constants/selectors/navigation.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/roles.js +24 -0
- package/cjs/cypress-utils/constants/selectors/roles.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/signUp.js +23 -0
- package/cjs/cypress-utils/constants/selectors/signUp.js.map +1 -0
- package/cjs/cypress-utils/constants/selectors/tags.js +31 -0
- package/cjs/cypress-utils/constants/selectors/tags.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/common.js +40 -0
- package/cjs/cypress-utils/constants/texts/common.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/member.js +68 -0
- package/cjs/cypress-utils/constants/texts/member.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/navigation.js +24 -0
- package/cjs/cypress-utils/constants/texts/navigation.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/roles.js +25 -0
- package/cjs/cypress-utils/constants/texts/roles.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/signUp.js +14 -0
- package/cjs/cypress-utils/constants/texts/signUp.js.map +1 -0
- package/cjs/cypress-utils/constants/texts/tags.js +28 -0
- package/cjs/cypress-utils/constants/texts/tags.js.map +1 -0
- package/cjs/cypress-utils/fixtures/fake.js +177 -0
- package/cjs/cypress-utils/fixtures/fake.js.map +1 -0
- package/cjs/cypress-utils/index.js +226 -0
- package/cjs/cypress-utils/index.js.map +1 -0
- package/cjs/cypress-utils/utils/authentication.js +45 -0
- package/cjs/cypress-utils/utils/authentication.js.map +1 -0
- package/cjs/cypress-utils/utils/common.js +92 -0
- package/cjs/cypress-utils/utils/common.js.map +1 -0
- package/cjs/cypress-utils/utils/date.js +28 -0
- package/cjs/cypress-utils/utils/date.js.map +1 -0
- package/cjs/cypress-utils/utils/email.js +165 -0
- package/cjs/cypress-utils/utils/email.js.map +1 -0
- package/cjs/cypress-utils/utils/member.js +352 -0
- package/cjs/cypress-utils/utils/member.js.map +1 -0
- package/cjs/cypress-utils/utils/navigation.js +208 -0
- package/cjs/cypress-utils/utils/navigation.js.map +1 -0
- package/cjs/cypress-utils/utils/organization.js +109 -0
- package/cjs/cypress-utils/utils/organization.js.map +1 -0
- package/cjs/cypress-utils/utils/validation.js +17 -0
- package/cjs/cypress-utils/utils/validation.js.map +1 -0
- package/cjs/initializers/axios/index.js +199 -0
- package/cjs/initializers/axios/index.js.map +1 -0
- package/cjs/initializers/axios/paramsSerializer.js +27 -0
- package/cjs/initializers/axios/paramsSerializer.js.map +1 -0
- package/cjs/initializers/constants.js +17 -0
- package/cjs/initializers/constants.js.map +1 -0
- package/cjs/initializers/globalProps.js +15 -0
- package/cjs/initializers/globalProps.js.map +1 -0
- package/cjs/initializers/i18n.js +68 -0
- package/cjs/initializers/i18n.js.map +1 -0
- package/cjs/initializers/index.js +51 -0
- package/cjs/initializers/index.js.map +1 -0
- package/cjs/initializers/logger.js +17 -0
- package/cjs/initializers/logger.js.map +1 -0
- package/cjs/initializers/reactDevTools.js +26 -0
- package/cjs/initializers/reactDevTools.js.map +1 -0
- package/cjs/initializers/utils/customFormatters.js +43 -0
- package/cjs/initializers/utils/customFormatters.js.map +1 -0
- package/cjs/initializers/utils/customPostProcessors.js +21 -0
- package/cjs/initializers/utils/customPostProcessors.js.map +1 -0
- package/cjs/initializers/utils.js +37 -0
- package/cjs/initializers/utils.js.map +1 -0
- package/cjs/react-utils/BrowserPushNotifications/devices.js +26 -0
- package/cjs/react-utils/BrowserPushNotifications/devices.js.map +1 -0
- package/cjs/react-utils/BrowserPushNotifications/index.js +19 -0
- package/cjs/react-utils/BrowserPushNotifications/index.js.map +1 -0
- package/cjs/react-utils/BrowserPushNotifications/pushHelper.js +116 -0
- package/cjs/react-utils/BrowserPushNotifications/pushHelper.js.map +1 -0
- package/cjs/react-utils/BrowserPushNotifications/registerServiceWorker.js +146 -0
- package/cjs/react-utils/BrowserPushNotifications/registerServiceWorker.js.map +1 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +153 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/constants.js +9 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/constants.js.map +1 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/index.js +59 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/index.js.map +1 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/utils.js +17 -0
- package/cjs/react-utils/HoneybadgerErrorBoundary/utils.js.map +1 -0
- package/cjs/react-utils/PrivateRoute.js +80 -0
- package/cjs/react-utils/PrivateRoute.js.map +1 -0
- package/cjs/react-utils/constants/constants.js +11 -0
- package/cjs/react-utils/constants/constants.js.map +1 -0
- package/cjs/react-utils/constants/index.js +28 -0
- package/cjs/react-utils/constants/index.js.map +1 -0
- package/cjs/react-utils/constants/query.js +11 -0
- package/cjs/react-utils/constants/query.js.map +1 -0
- package/cjs/react-utils/index.js +242 -0
- package/cjs/react-utils/index.js.map +1 -0
- package/cjs/react-utils/metaClick.js +16 -0
- package/cjs/react-utils/metaClick.js.map +1 -0
- package/cjs/react-utils/useDebounce.js +28 -0
- package/cjs/react-utils/useDebounce.js.map +1 -0
- package/cjs/react-utils/useDisplayErrorPage.js +23 -0
- package/cjs/react-utils/useDisplayErrorPage.js.map +1 -0
- package/cjs/react-utils/useFetchNeetoApps/apis/neeto_apps.js +17 -0
- package/cjs/react-utils/useFetchNeetoApps/apis/neeto_apps.js.map +1 -0
- package/cjs/react-utils/useFetchNeetoApps/index.js +14 -0
- package/cjs/react-utils/useFetchNeetoApps/index.js.map +1 -0
- package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +27 -0
- package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -0
- package/cjs/react-utils/useFieldSubmit.js +33 -0
- package/cjs/react-utils/useFieldSubmit.js.map +1 -0
- package/cjs/react-utils/useFuncDebounce.js +27 -0
- package/cjs/react-utils/useFuncDebounce.js.map +1 -0
- package/cjs/react-utils/useHotKeys/constants.js +36 -0
- package/cjs/react-utils/useHotKeys/constants.js.map +1 -0
- package/cjs/react-utils/useHotKeys/index.js +14 -0
- package/cjs/react-utils/useHotKeys/index.js.map +1 -0
- package/cjs/react-utils/useHotKeys/useHotKeys.js +65 -0
- package/cjs/react-utils/useHotKeys/useHotKeys.js.map +1 -0
- package/cjs/react-utils/useHotKeys/utils.js +37 -0
- package/cjs/react-utils/useHotKeys/utils.js.map +1 -0
- package/cjs/react-utils/useIsElementVisibleInDom/index.js +14 -0
- package/cjs/react-utils/useIsElementVisibleInDom/index.js.map +1 -0
- package/cjs/react-utils/useIsElementVisibleInDom/useForceUpdate.js +23 -0
- package/cjs/react-utils/useIsElementVisibleInDom/useForceUpdate.js.map +1 -0
- package/cjs/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js +34 -0
- package/cjs/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js.map +1 -0
- package/cjs/react-utils/useKeyboardShortcutsPaneState.js +36 -0
- package/cjs/react-utils/useKeyboardShortcutsPaneState.js.map +1 -0
- package/cjs/react-utils/useLocalStorage.js +39 -0
- package/cjs/react-utils/useLocalStorage.js.map +1 -0
- package/cjs/react-utils/useMutationWithInvalidation.js +33 -0
- package/cjs/react-utils/useMutationWithInvalidation.js.map +1 -0
- package/cjs/react-utils/useOnClickOutside.js +32 -0
- package/cjs/react-utils/useOnClickOutside.js.map +1 -0
- package/cjs/react-utils/usePersistedQuery.js +59 -0
- package/cjs/react-utils/usePersistedQuery.js.map +1 -0
- package/cjs/react-utils/usePrevious.js +17 -0
- package/cjs/react-utils/usePrevious.js.map +1 -0
- package/cjs/react-utils/useQueryParams.js +15 -0
- package/cjs/react-utils/useQueryParams.js.map +1 -0
- package/cjs/react-utils/useRegisterNavigationCheckpoint.js +43 -0
- package/cjs/react-utils/useRegisterNavigationCheckpoint.js.map +1 -0
- package/cjs/react-utils/useStateWithDependency.js +23 -0
- package/cjs/react-utils/useStateWithDependency.js.map +1 -0
- package/cjs/react-utils/useTimer.js +51 -0
- package/cjs/react-utils/useTimer.js.map +1 -0
- package/cjs/react-utils/useUpdateEffect.js +21 -0
- package/cjs/react-utils/useUpdateEffect.js.map +1 -0
- package/cjs/react-utils/withImmutableActions.js +29 -0
- package/cjs/react-utils/withImmutableActions.js.map +1 -0
- package/cjs/react-utils/withT.js +14 -0
- package/cjs/react-utils/withT.js.map +1 -0
- package/cjs/react-utils/withTitle.js +44 -0
- package/cjs/react-utils/withTitle.js.map +1 -0
- package/cjs/utils/axios.js +17 -0
- package/cjs/utils/axios.js.map +1 -0
- package/cjs/utils/createSubscription.js +22 -0
- package/cjs/utils/createSubscription.js.map +1 -0
- package/cjs/utils/currencyFormat.js +50 -0
- package/cjs/utils/currencyFormat.js.map +1 -0
- package/cjs/utils/datetime.js +69 -0
- package/cjs/utils/datetime.js.map +1 -0
- package/cjs/utils/general.js +193 -0
- package/cjs/utils/general.js.map +1 -0
- package/cjs/utils/index.js +72 -0
- package/cjs/utils/index.js.map +1 -0
- package/cjs/utils/permissions.js +25 -0
- package/cjs/utils/permissions.js.map +1 -0
- package/configs/scripts/getPkgTranslations.js +1 -1
- package/configs/scripts/jsdoc-builder/constants.mjs +1 -1
- package/configs/scripts/jsdoc-builder/index.mjs +1 -1
- package/configs/webpack/rules.js +2 -1
- package/constants/index.js +13 -0
- package/constants/index.js.map +1 -0
- package/cypress-utils/commands.js +268 -0
- package/cypress-utils/commands.js.map +1 -0
- package/cypress-utils/constants/index.js +7 -0
- package/cypress-utils/constants/index.js.map +1 -0
- package/cypress-utils/constants/routes.js +33 -0
- package/cypress-utils/constants/routes.js.map +1 -0
- package/cypress-utils/constants/selectors/common.js +94 -0
- package/cypress-utils/constants/selectors/common.js.map +1 -0
- package/cypress-utils/constants/selectors/editor.js +22 -0
- package/cypress-utils/constants/selectors/editor.js.map +1 -0
- package/cypress-utils/constants/selectors/ipRestriction.js +12 -0
- package/cypress-utils/constants/selectors/ipRestriction.js.map +1 -0
- package/cypress-utils/constants/selectors/login.js +14 -0
- package/cypress-utils/constants/selectors/login.js.map +1 -0
- package/cypress-utils/constants/selectors/member.js +56 -0
- package/cypress-utils/constants/selectors/member.js.map +1 -0
- package/cypress-utils/constants/selectors/navigation.js +20 -0
- package/cypress-utils/constants/selectors/navigation.js.map +1 -0
- package/cypress-utils/constants/selectors/roles.js +17 -0
- package/cypress-utils/constants/selectors/roles.js.map +1 -0
- package/cypress-utils/constants/selectors/signUp.js +16 -0
- package/cypress-utils/constants/selectors/signUp.js.map +1 -0
- package/cypress-utils/constants/selectors/tags.js +23 -0
- package/cypress-utils/constants/selectors/tags.js.map +1 -0
- package/cypress-utils/constants/texts/common.js +33 -0
- package/cypress-utils/constants/texts/common.js.map +1 -0
- package/cypress-utils/constants/texts/member.js +59 -0
- package/cypress-utils/constants/texts/member.js.map +1 -0
- package/cypress-utils/constants/texts/navigation.js +16 -0
- package/cypress-utils/constants/texts/navigation.js.map +1 -0
- package/cypress-utils/constants/texts/roles.js +18 -0
- package/cypress-utils/constants/texts/roles.js.map +1 -0
- package/cypress-utils/constants/texts/signUp.js +7 -0
- package/cypress-utils/constants/texts/signUp.js.map +1 -0
- package/cypress-utils/constants/texts/tags.js +21 -0
- package/cypress-utils/constants/texts/tags.js.map +1 -0
- package/cypress-utils/fixtures/fake.js +171 -0
- package/cypress-utils/fixtures/fake.js.map +1 -0
- package/cypress-utils/index.js +21 -0
- package/cypress-utils/index.js.map +1 -0
- package/cypress-utils/utils/authentication.js +38 -0
- package/cypress-utils/utils/authentication.js.map +1 -0
- package/cypress-utils/utils/common.js +75 -0
- package/cypress-utils/utils/common.js.map +1 -0
- package/cypress-utils/utils/date.js +20 -0
- package/cypress-utils/utils/date.js.map +1 -0
- package/cypress-utils/utils/email.js +156 -0
- package/cypress-utils/utils/email.js.map +1 -0
- package/cypress-utils/utils/member.js +344 -0
- package/cypress-utils/utils/member.js.map +1 -0
- package/cypress-utils/utils/navigation.js +200 -0
- package/cypress-utils/utils/navigation.js.map +1 -0
- package/cypress-utils/utils/organization.js +102 -0
- package/cypress-utils/utils/organization.js.map +1 -0
- package/cypress-utils/utils/validation.js +10 -0
- package/cypress-utils/utils/validation.js.map +1 -0
- package/initializers/axios/index.js +192 -0
- package/initializers/axios/index.js.map +1 -0
- package/initializers/axios/paramsSerializer.js +18 -0
- package/initializers/axios/paramsSerializer.js.map +1 -0
- package/initializers/constants.js +8 -0
- package/initializers/constants.js.map +1 -0
- package/initializers/globalProps.js +8 -0
- package/initializers/globalProps.js.map +1 -0
- package/initializers/i18n.js +61 -0
- package/initializers/i18n.js.map +1 -0
- package/initializers/index.js +28 -0
- package/initializers/index.js.map +1 -0
- package/initializers/logger.js +10 -0
- package/initializers/logger.js.map +1 -0
- package/initializers/reactDevTools.js +19 -0
- package/initializers/reactDevTools.js.map +1 -0
- package/initializers/utils/customFormatters.js +34 -0
- package/initializers/utils/customFormatters.js.map +1 -0
- package/initializers/utils/customPostProcessors.js +14 -0
- package/initializers/utils/customPostProcessors.js.map +1 -0
- package/initializers/utils.js +29 -0
- package/initializers/utils.js.map +1 -0
- package/package.json +51 -158
- package/pure.d.ts +384 -0
- package/react-utils/BrowserPushNotifications/devices.js +18 -0
- package/react-utils/BrowserPushNotifications/devices.js.map +1 -0
- package/react-utils/BrowserPushNotifications/index.js +1 -0
- package/react-utils/BrowserPushNotifications/index.js.map +1 -0
- package/react-utils/BrowserPushNotifications/pushHelper.js +107 -0
- package/react-utils/BrowserPushNotifications/pushHelper.js.map +1 -0
- package/react-utils/BrowserPushNotifications/registerServiceWorker.js +137 -0
- package/react-utils/BrowserPushNotifications/registerServiceWorker.js.map +1 -0
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +144 -0
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -0
- package/react-utils/HoneybadgerErrorBoundary/constants.js +1 -0
- package/react-utils/HoneybadgerErrorBoundary/constants.js.map +1 -0
- package/react-utils/HoneybadgerErrorBoundary/index.js +52 -0
- package/react-utils/HoneybadgerErrorBoundary/index.js.map +1 -0
- package/react-utils/HoneybadgerErrorBoundary/utils.js +9 -0
- package/react-utils/HoneybadgerErrorBoundary/utils.js.map +1 -0
- package/react-utils/PrivateRoute.js +72 -0
- package/react-utils/PrivateRoute.js.map +1 -0
- package/react-utils/constants/constants.js +3 -0
- package/react-utils/constants/constants.js.map +1 -0
- package/react-utils/constants/index.js +3 -0
- package/react-utils/constants/index.js.map +1 -0
- package/react-utils/constants/query.js +4 -0
- package/react-utils/constants/query.js.map +1 -0
- package/react-utils/index.js +33 -0
- package/react-utils/index.js.map +1 -0
- package/react-utils/metaClick.js +8 -0
- package/react-utils/metaClick.js.map +1 -0
- package/react-utils/useDebounce.js +20 -0
- package/react-utils/useDebounce.js.map +1 -0
- package/react-utils/useDisplayErrorPage.js +15 -0
- package/react-utils/useDisplayErrorPage.js.map +1 -0
- package/react-utils/useFetchNeetoApps/apis/neeto_apps.js +9 -0
- package/react-utils/useFetchNeetoApps/apis/neeto_apps.js.map +1 -0
- package/react-utils/useFetchNeetoApps/index.js +1 -0
- package/react-utils/useFetchNeetoApps/index.js.map +1 -0
- package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +19 -0
- package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -0
- package/react-utils/useFieldSubmit.js +26 -0
- package/react-utils/useFieldSubmit.js.map +1 -0
- package/react-utils/useFuncDebounce.js +20 -0
- package/react-utils/useFuncDebounce.js.map +1 -0
- package/react-utils/useHotKeys/constants.js +25 -0
- package/react-utils/useHotKeys/constants.js.map +1 -0
- package/react-utils/useHotKeys/index.js +1 -0
- package/react-utils/useHotKeys/index.js.map +1 -0
- package/react-utils/useHotKeys/useHotKeys.js +57 -0
- package/react-utils/useHotKeys/useHotKeys.js.map +1 -0
- package/react-utils/useHotKeys/utils.js +29 -0
- package/react-utils/useHotKeys/utils.js.map +1 -0
- package/react-utils/useIsElementVisibleInDom/index.js +1 -0
- package/react-utils/useIsElementVisibleInDom/index.js.map +1 -0
- package/react-utils/useIsElementVisibleInDom/useForceUpdate.js +15 -0
- package/react-utils/useIsElementVisibleInDom/useForceUpdate.js.map +1 -0
- package/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js +26 -0
- package/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js.map +1 -0
- package/react-utils/useKeyboardShortcutsPaneState.js +29 -0
- package/react-utils/useKeyboardShortcutsPaneState.js.map +1 -0
- package/react-utils/useLocalStorage.js +31 -0
- package/react-utils/useLocalStorage.js.map +1 -0
- package/react-utils/useMutationWithInvalidation.js +25 -0
- package/react-utils/useMutationWithInvalidation.js.map +1 -0
- package/react-utils/useOnClickOutside.js +25 -0
- package/react-utils/useOnClickOutside.js.map +1 -0
- package/react-utils/usePersistedQuery.js +51 -0
- package/react-utils/usePersistedQuery.js.map +1 -0
- package/react-utils/usePrevious.js +10 -0
- package/react-utils/usePrevious.js.map +1 -0
- package/react-utils/useQueryParams.js +8 -0
- package/react-utils/useQueryParams.js.map +1 -0
- package/react-utils/useRegisterNavigationCheckpoint.js +35 -0
- package/react-utils/useRegisterNavigationCheckpoint.js.map +1 -0
- package/react-utils/useStateWithDependency.js +15 -0
- package/react-utils/useStateWithDependency.js.map +1 -0
- package/react-utils/useTimer.js +43 -0
- package/react-utils/useTimer.js.map +1 -0
- package/react-utils/useUpdateEffect.js +14 -0
- package/react-utils/useUpdateEffect.js.map +1 -0
- package/react-utils/withImmutableActions.js +22 -0
- package/react-utils/withImmutableActions.js.map +1 -0
- package/react-utils/withT.js +7 -0
- package/react-utils/withT.js.map +1 -0
- package/react-utils/withTitle.js +36 -0
- package/react-utils/withTitle.js.map +1 -0
- package/react-utils.d.ts +14 -2
- package/utils/axios.js +10 -0
- package/utils/axios.js.map +1 -0
- package/utils/createSubscription.js +15 -0
- package/utils/createSubscription.js.map +1 -0
- package/utils/currencyFormat.js +42 -0
- package/utils/currencyFormat.js.map +1 -0
- package/utils/datetime.js +60 -0
- package/utils/datetime.js.map +1 -0
- package/utils/general.js +172 -0
- package/utils/general.js.map +1 -0
- package/utils/index.js +7 -0
- package/utils/index.js.map +1 -0
- package/utils/permissions.js +16 -0
- package/utils/permissions.js.map +1 -0
- package/utils.d.ts +18 -2
- package/README.md +0 -173
- package/constants.cjs.js.map +0 -1
- package/constants.js +0 -15
- package/constants.js.map +0 -1
- package/cypress-utils.cjs.js +0 -1819
- package/cypress-utils.cjs.js.map +0 -1
- package/cypress-utils.js +0 -1773
- package/cypress-utils.js.map +0 -1
- package/initializers.cjs.js +0 -2648
- package/initializers.cjs.js.map +0 -1
- package/initializers.js +0 -2634
- package/initializers.js.map +0 -1
- package/react-utils.cjs.js +0 -4915
- package/react-utils.cjs.js.map +0 -1
- package/react-utils.js +0 -4860
- package/react-utils.js.map +0 -1
- package/utils.cjs.js +0 -1280
- package/utils.cjs.js.map +0 -1
- package/utils.js +0 -1248
- package/utils.js.map +0 -1
- /package/{src/translations → translations}/en.json +0 -0
package/react-utils.js
DELETED
|
@@ -1,4860 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import React__default, { useEffect, useState, useDebugValue, useRef, useMemo } from 'react';
|
|
3
|
-
import { Honeybadger, HoneybadgerErrorBoundary as HoneybadgerErrorBoundary$1 } from '@honeybadger-io/react';
|
|
4
|
-
import { Typography, Button } from '@bigbinary/neetoui';
|
|
5
|
-
import { isNil, includes, __, prop, toPairs, mergeLeft, curry, keys, isEmpty, mergeDeepLeft, pick, omit } from 'ramda';
|
|
6
|
-
import { useTranslation, Trans, withTranslation } from 'react-i18next';
|
|
7
|
-
import ErrorPage from '@bigbinary/neeto-molecules/ErrorPage';
|
|
8
|
-
import { Route, Redirect, useLocation } from 'react-router-dom';
|
|
9
|
-
import { isNotPresent } from '@bigbinary/neeto-cist';
|
|
10
|
-
import { usePersistedQuery as usePersistedQuery$1 } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
11
|
-
import axios from 'axios';
|
|
12
|
-
import { getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/utils';
|
|
13
|
-
import { useQuery, useQueryClient, useMutation } from 'react-query';
|
|
14
|
-
import { parse as parse$1 } from 'qs';
|
|
15
|
-
import { Helmet } from 'react-helmet';
|
|
16
|
-
|
|
17
|
-
var IGNORABLE_ERRORS_REGEX = /(window\.requestAnimationFrame|ResizeObserver|ChunkLoadError|window\.webkit\.messageHandlers|Request aborted|Network Error)/;
|
|
18
|
-
|
|
19
|
-
var _path, _path2, _path3, _path4, _path5, _path6;
|
|
20
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
var SvgFallbackComponent = function SvgFallbackComponent(props) {
|
|
22
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
23
|
-
width: 230,
|
|
24
|
-
height: 230,
|
|
25
|
-
viewBox: "0 0 317 320",
|
|
26
|
-
fill: "none",
|
|
27
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
28
|
-
role: "img"
|
|
29
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
30
|
-
d: "M271.071 28.008c-8.563-12.544-25.317-10.81-38.577-10.717-30.899.206-159.103.047-168.105.497-13.866.713-27.79 6.33-30.041 20.132-1.216 7.456-.14 15.427.139 22.94 1.118 30.417 1.953 68.044 5.7 95.148 1.016 7.372 2.35 14.761 6.936 20.853 7.238 9.618 21.581 12.998 33.616 13.2.141.236 110.261 2.828 150.068-.154 11.579-.87 25.682-1.74 33.488-11.652 3.913-4.971 4.246-12.136 5.028-18.171 2.816-21.653 4.695-58.296 7.156-97.59.703-11.222 1.25-24.736-5.408-34.486Zm3.044 27.34c-.082 4.493-3.429 57.629-3.648 60.853-.746 10.901-3.144 45.195-6.244 55.905-3.064 10.571-16.833 13.173-26.189 14.167-7.926.857-15.906 1.35-23.877 1.608-40.911 1.322-129.772 1.044-133.332.949-14.415-.663-30.588-4.888-36.021-19.843a81.026 81.026 0 0 1-3.298-20.918c-2.712-32.616-2.294-42.461-4.372-92.667-.293-7.188-1.76-15.638 1.536-22.356C45.898 18.356 67.727 20.417 81.1 20.27c15.73-.172 149.231-.271 157.495-.338 7.347-.06 15.278-.433 22.12 2.756 12.343 5.744 13.613 20.671 13.399 32.649v.01Z",
|
|
31
|
-
fill: "#2F3941"
|
|
32
|
-
})), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
|
|
33
|
-
d: "M220.642 50.4a1.586 1.586 0 0 0-.415-1.21 1.607 1.607 0 0 0-1.177-.52c-35.537-.183-99.035-.669-135.303-.466a1.056 1.056 0 0 0-.76.238 1.044 1.044 0 0 0-.373.699c-.43 34.284-.24 68.58-.24 102.862 0 1.636.685 2.122 1.643 2.162 45.113 2.049 92.2.763 137.476.91a2.342 2.342 0 0 0 1.518-.675c.405-.403.648-.94.68-1.509-.443-33.909-1.227-68.635-3.049-102.49Zm-2.277.78c1.187 24.763 1.712 49.901 2.264 74.806-45.853 1.664-90.202.658-135.787.522 0-24.642-.313-50.868 0-76.093 43.482.375 89.992.537 133.523.764ZM91.463 151.855l16.27-22.423 18.964.294c-3.709 5.108-12.138 17.321-14.959 22.512-6.749-.114-20.275-.383-20.275-.383Zm42.769.671 15.24-22.699c6.347 0 12.699-.04 19.055-.12-3.627 6.705-10.492 16.8-14.739 22.976-6.51-.007-13.028-.059-19.556-.157Zm42.469.228c5.503-8.232 10.238-15.419 16.186-23.434 6.993-.163 13.993-.365 20.998-.605-4.761 6.22-12.597 17.04-15.361 23.986-7.274.037-14.548.054-21.823.053Z",
|
|
34
|
-
fill: "#2F3941"
|
|
35
|
-
})), _path3 || (_path3 = /*#__PURE__*/React.createElement("path", {
|
|
36
|
-
d: "M153.904 69.903c-3.722-.185-22.748 30.824-20.049 34.788 2.493 3.664 37.821 2.965 39.914 0 2.39-3.436-16.031-34.596-19.865-34.788Zm.745 10.224c.19 2.645.576 11.328.205 13.546-.27 1.633-1.778.747-1.796-.113-.065-4.437-.177-8.883-.27-13.32a.957.957 0 0 1 .224-.699.925.925 0 0 1 1.551.221.973.973 0 0 1 .086.365Zm.707 18.984c-.727 2.011-2.791 1.389-2.791-.259-.057-3.119 3.572-1.901 2.791.26v-.001ZM155.392 199.891c1.926 4.35 9.139 2.15 6.621-3.658a3.653 3.653 0 0 0-2.338-2.083 3.669 3.669 0 0 0-3.092.487c-1.534 1.051-2.876 3.875-1.144 5.376a.499.499 0 0 0 .85-.353c.107-1.148-.119-2.371.838-3.231a2.288 2.288 0 0 1 3.549.378 2.661 2.661 0 0 1-.467 3.601 3.032 3.032 0 0 1-4.019-.994c-.313-.517-1.037-.06-.798.477ZM145.571 226.664c3.876.66 7.809.928 11.739.798 4.292.127 8.604.273 12.894.248a1.103 1.103 0 0 0 0-2.204c-4.29-.174-8.602-.186-12.894-.206a57.817 57.817 0 0 0-11.739.39.508.508 0 0 0 0 .974Z",
|
|
37
|
-
fill: "#2F3941"
|
|
38
|
-
})), _path4 || (_path4 = /*#__PURE__*/React.createElement("path", {
|
|
39
|
-
d: "M290.099 17.651a26.343 26.343 0 0 0-14.443-13.727c-8.184-3.209-17.301-2.702-25.923-2.622-36.725.338-187.491.226-197.868.656a46.93 46.93 0 0 0-23.035 6.39c-15.658 9.89-12.084 26.386-11.458 44.885 1.203 35.566 2.12 79.713 6.107 111.322 1.049 8.324 2.204 16.755 6.676 24.05 7.983 13.016 24.148 17.93 39.357 17.867.586 0 34.396.811 73.168 1.099.06 2.045.465 4.305.694 6.462-.845-.102-23.612.467-30.303 1.419a.956.956 0 0 0-.771.893.982.982 0 0 0 .07.415c-3.429 2.898-6.462 6.492-9.588 9.661-3.848 3.879-7.906 7.645-11.5 11.758a.822.822 0 0 0 1.163 1.163c4.026-3.696 7.685-7.846 11.473-11.786 3.151-3.283 6.762-6.462 9.603-10.051a284.168 284.168 0 0 1 30.012-1.086c.02 1.633-.067 3.567 1.553 4.394.249.132.684.04.731-.3.119-2.158.03-4.322-.266-6.463a20.308 20.308 0 0 0-1.205-6.462c9.037.065 18.32.097 27.494.082a22.04 22.04 0 0 0-.498 11.488.589.589 0 0 0 .558.411.583.583 0 0 0 .558-.411c.323-1.081.516-2.196.575-3.323 5.085.679 9.298.204 22.997 1.059 2.081.132 5.048.161 6.8.151a49.891 49.891 0 0 0 9.03 9.507 126.265 126.265 0 0 0 10.551 9.276c.89.671 1.988-.798 1.188-1.541-3.547-3.244-7.275-6.278-10.814-9.542a93.19 93.19 0 0 0-8.62-8.122.687.687 0 0 0-.296-.8 16.466 16.466 0 0 0-6.571-1.034 303.46 303.46 0 0 0-8.896-.433 119.194 119.194 0 0 0-15.245-.532c.139-2.202.522-4.237.539-6.156 26.179-.057 51.28-.512 67.03-1.762 13.367-1.064 29.723-1.842 38.877-13.173 4.737-5.858 5.182-13.963 6.112-21.166 3.929-30.407 5.575-77.387 8.06-112.188.997-13.655 2.17-28.933-3.676-41.728Zm1.613 31.317c-.146 4.2-3.837 64.939-4.225 70.999-.84 12.757-3.594 52.564-7.069 65.039-3.355 12.052-18.191 15.578-28.953 16.886-9.22 1.123-18.553 1.715-27.836 2.028-47.201 1.6-152.146 1.016-154.02.947-17.12-.746-35.33-6.288-41.204-24.174-2.597-7.906-2.91-16.548-3.567-24.799-2.594-32.741-2.42-43.205-4.722-107.053-.313-8.463-1.814-17.863.596-26.12C26.38 3.355 51.897 4.623 67.642 4.416c18.621-.248 177.824-.437 187.33-.497 8.565-.045 17.791.174 25.046 5.349 12.02 8.565 12.159 26.432 11.694 39.692v.008ZM2.113 306.233c1.504-2.13 36.665-41.756 38.413-43.727a10.606 10.606 0 0 1 9.066-3.728c23.95-.139 47.907-.29 71.857.095 44.688.73 142.992-1.775 146.288-1.74 3.231.032 7.399-.711 9.864 1.66 2.352 2.264 26.674 35.343 35.177 44.204 1.322 1.374 3.407-.716 2.093-2.093-8.324-8.682-29.105-36.658-32.5-40.888a17.18 17.18 0 0 0-4.722-5.016c-4.243-2.115-53.46.465-74.499.942-24.904.57-18.499.127-150.918.092-5.858 0-10.004.249-13.864 5.043-4.439 5.52-35.989 42.114-37.403 44.477-.44.751.663 1.365 1.148.679ZM310.594 315.641c2.172-3.694 6.668-9.738 4.511-10.439-3.336-1.064-312.387 1.784-312.387 1.784s-5.946.154-.249 5.456c5.697 5.301 5.965 6.656 16.25 6.258 10.284-.397 262.609-1.203 269.642-1.091 7.034.112 20.856.37 22.233-1.968Z",
|
|
40
|
-
fill: "#2F3941"
|
|
41
|
-
})), _path5 || (_path5 = /*#__PURE__*/React.createElement("path", {
|
|
42
|
-
d: "M34.938 281.227c-2.187 2.709-11.898 12.69-12.29 15.161a1.074 1.074 0 0 0 .471 1.163c1.328.85 41.622 0 50.602-.032 18.968-.08 153.463.745 156.865.79 2.603.032 4.444-.519 3.169-3.435-4.347-9.942-8.664-19.883-13.081-29.795-1.123-2.513-2.02-2.851-4.722-2.839 0 0-161.347 0-166.45-.059a.918.918 0 0 0-.874.921.92.92 0 0 0 .874.92c31.896.311 159.016-.087 167.966.445.724.045-.248-1.638 13.958 30.395.199.445.147 1.242-2.207 1.3-1.633.034-157.686-.624-193.429-.358-1.899 0-9.956.338-9.897-.14.2-1.6 12.619-14.798 23.217-31.038.365-.559-.497-1.016-.875-.512-.02-.007-8.443 11.098-13.297 17.113ZM238.084 290.689a39.103 39.103 0 0 0 3.124 6.895c.746 1.022 1.243 1.009 2.486 1.049 6.929.216 26.206-.664 45.483-.286 1.275.027 6.532.83 6.463-1.243-.102-3.042-9.343-13.789-22.084-33.67-1.454-2.272-2.08-2.411-4.956-2.284-4.702.199-32.4 1.195-41.541 1.491-1.216.04-1.223 1.934 0 1.894 47.176-1.491 43.545-1.605 43.833-1.422.93.592 1.862 2.879 2.458 3.793 1.33 2.021 17.513 26.115 18.981 28.222.878 1.256.02 1.183-1.739 1.149-1.989-.045-45.168.233-46.573.221-1.739-.022-2.589-3.415-3.3-4.931-9.112-19.476-10.563-22.476-13.054-26.54-.392-.638-1.409-.445-1.131.207 4.36 10.205 7.591 16.5 11.55 25.455ZM285.242 112.053v.445c0 .04.067.04.067 0 0-.147 0-.298.02-.445-.002-.047-.087-.052-.087 0ZM91.163 240.165s131.381-1.695 132.656-1.416c1.275.278-.313 8.776-4.226 8.751-3.912-.025-121.276.922-123.175.171-1.9-.75-7.28-7.478-5.255-7.506Z",
|
|
43
|
-
fill: "#2F3941"
|
|
44
|
-
})), _path6 || (_path6 = /*#__PURE__*/React.createElement("path", {
|
|
45
|
-
d: "M45.82 293.676a.023.023 0 0 0 .014-.01.025.025 0 0 0 .005-.016.027.027 0 0 0-.019-.026.027.027 0 0 0-.014.042.023.023 0 0 0 .014.01ZM220.834 284.323c-2.237-.034-6-.062-10.973-.082-1.198-2.995.522 1.459-4.325-10.759 4.354 0 7.692 0 9.735.025a.767.767 0 0 0 .545-.226.767.767 0 0 0 0-1.09.77.77 0 0 0-.545-.225c-2.09-.03-5.666-.057-10.376-.077-1.134-2.734-1.506-3.154-2.411-3.637a.552.552 0 0 0-.798.319c-.291.832-.328 1.339.355 3.308-8.714-.03-20.504-.047-33.677-.05a23.38 23.38 0 0 0-2.021-4.446.51.51 0 0 0-.566-.224.509.509 0 0 0-.383.472c.033 1.409.199 2.811.497 4.188-11.212 0-23.326 0-35.336.027a706.988 706.988 0 0 0-.186-3.171.582.582 0 0 0-1.161 0 442.255 442.255 0 0 0-.313 3.174c-12.514.017-24.854.045-35.902.079a6.379 6.379 0 0 0-.378-2.835c-.107-.266-.457-.443-.676-.187a6.309 6.309 0 0 0-1.322 3.03c-12.572.042-23.276.094-30.335.154a18.732 18.732 0 0 0 1.8-3.577c.372-1.061-1.22-2.03-1.954-1.128-1.223 1.511-2.374 3.112-3.495 4.742-2.634.03-4.386.062-5.067.095a.503.503 0 0 0-.357.861.503.503 0 0 0 .357.148c1.155.087 2.55.164 4.158.236-5.903 8.771-5.418 7.829-7.526 11.008-3.607.032-5.985.067-6.83.104a.503.503 0 0 0-.505.505.505.505 0 0 0 .505.504c1.39.1 3.4.184 5.94.249a48.466 48.466 0 0 0-3.343 6.094.431.431 0 0 0 .746.433c1.491-2.168 3.149-4.337 4.859-6.462 8.45.191 21.417.268 36.556.28a22.934 22.934 0 0 0-1.295 5.891c-.048.723.89.823 1.242.338a22.61 22.61 0 0 0 2.963-6.214c12.082 0 25.401-.03 38.835-.079a13.904 13.904 0 0 0 .698 6.238.857.857 0 0 0 .746.429.857.857 0 0 0 .746-.429 13.875 13.875 0 0 0 .952-6.251c13.227-.052 26.474-.116 38.666-.171a25.556 25.556 0 0 0 2.281 5.572.781.781 0 0 0 1.442-.392 24.472 24.472 0 0 0-.816-5.193c13.586-.062 25.705-.111 34.797-.114a27.226 27.226 0 0 0 3.362 6.462c.353.47 1.362.41 1.283-.345a25.886 25.886 0 0 0-1.554-6.119c4.439 0 7.974.022 10.37.059a.761.761 0 0 0 .543-.229.766.766 0 0 0 .222-.546.77.77 0 0 0-.775-.766Zm-170.101.139c3.142-3.859 6.303-7.563 8.562-10.853 7.58.248 18.36.358 30.772.4a97.23 97.23 0 0 1-3.278 10.287c-15.024.045-27.84.102-36.056.166Zm38.892-.173c2.341-7.884 2.585-7.954 3.072-10.273 11.167.028 23.527 0 35.999-.057-.562 6.246-.38 6.529-.691 10.247-13.287.02-26.457.048-38.38.083Zm41.303-.087c-.144-3.319.03-4.226-.263-10.253 12.178-.057 24.392-.142 35.668-.221.621 2.423-.107-.639 2.838 10.439-12.059.01-25.167.017-38.243.035Zm41.164-.023c-.072-.248-3.022-10.14-3.122-10.471 13.235-.094 25.019-.181 33.668-.216 1.941 5.087 1.325 3.139 4.136 10.737-9.003-.032-21.099-.047-34.682-.05ZM281.202 286.259c-1.339-.479-2.53-.671-8.326-.591a140.94 140.94 0 0 0-7.491-12.89 25.902 25.902 0 0 0 7.379-.656.778.778 0 0 0 .398-1.209.778.778 0 0 0-.398-.282c-2.98-.66-6.05-.813-9.081-.452a201.697 201.697 0 0 0-2.486-3.634.674.674 0 0 0-1.163.679l1.695 3.022c-4.143.151-10.849.437-15.243.636a24.566 24.566 0 0 0-3.679-4.576.437.437 0 0 0-.251-.114.444.444 0 0 0-.479.539 25.034 25.034 0 0 0 1.613 4.28 45.342 45.342 0 0 0-8.833.763.515.515 0 0 0-.365.489.511.511 0 0 0 .365.488c3.286.677 6.655.86 9.996.542 1.327 2.443 2.833 4.824 4.079 7.126 1.006 1.854 1.953 3.842 2.965 5.798a40.865 40.865 0 0 0-9.527.716.499.499 0 0 0-.405.488.496.496 0 0 0 .405.489c3.549.665 7.169.868 10.769.604a28.675 28.675 0 0 0 3.542 5.078c.37.412.962-.035.868-.498a23.462 23.462 0 0 0-1.452-4.583 1830.64 1830.64 0 0 0 15.658-.134 30.665 30.665 0 0 0 2.662 4.012c.378.497 1.283.248 1.076-.45a29.948 29.948 0 0 0-1.337-3.587 23.018 23.018 0 0 0 7.071-.599.775.775 0 0 0 .542-.756.78.78 0 0 0-.567-.738Zm-26.223-.126c-1.213-2.414-2.63-4.75-3.865-6.989-1.029-1.859-2.068-3.91-3.211-5.911 3.728-.082 8.656-.218 15.263-.4 3.599 6.462 5.696 10.337 7.091 12.882-3.291.047-6.51.157-15.278.408v.01Z",
|
|
46
|
-
fill: "#2F3941"
|
|
47
|
-
})));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var FallbackComponent = function FallbackComponent() {
|
|
51
|
-
var _useTranslation = useTranslation(),
|
|
52
|
-
t = _useTranslation.t;
|
|
53
|
-
useEffect(function () {
|
|
54
|
-
var listener = function listener(e) {
|
|
55
|
-
var _e$target;
|
|
56
|
-
if (isNil(e.state)) return;
|
|
57
|
-
window.location.href = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.location.href;
|
|
58
|
-
};
|
|
59
|
-
window.addEventListener("popstate", listener);
|
|
60
|
-
return function () {
|
|
61
|
-
return window.removeEventListener("popstate", listener);
|
|
62
|
-
};
|
|
63
|
-
}, []);
|
|
64
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
65
|
-
className: "flex h-screen w-full flex-row items-start justify-start"
|
|
66
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
67
|
-
className: "m-auto text-center"
|
|
68
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
69
|
-
className: "m-auto mb-8 flex items-center justify-center"
|
|
70
|
-
}, /*#__PURE__*/React__default.createElement(SvgFallbackComponent, null)), /*#__PURE__*/React__default.createElement(Typography, {
|
|
71
|
-
className: "mb-4",
|
|
72
|
-
component: "h2",
|
|
73
|
-
style: "h2",
|
|
74
|
-
weight: "semibold"
|
|
75
|
-
}, t("neetoCommons.fallbackComponent.somethingWentWrong")), /*#__PURE__*/React__default.createElement(Typography, {
|
|
76
|
-
className: "neeto-ui-text-gray-600 mb-8",
|
|
77
|
-
component: "p",
|
|
78
|
-
style: "body1",
|
|
79
|
-
weight: "normal"
|
|
80
|
-
}, /*#__PURE__*/React__default.createElement(Trans, {
|
|
81
|
-
i18nKey: "neetoCommons.fallbackComponent.description",
|
|
82
|
-
components: {
|
|
83
|
-
reloading: /*#__PURE__*/React__default.createElement(Button, {
|
|
84
|
-
style: "link",
|
|
85
|
-
onClick: function onClick() {
|
|
86
|
-
return window.location.reload();
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
contactus: /*#__PURE__*/React__default.createElement(Button, {
|
|
90
|
-
style: "link",
|
|
91
|
-
onClick: function onClick() {
|
|
92
|
-
var _window$NeetoChat, _window$NeetoChat$con, _window$NeetoChat2, _window$NeetoChat2$co;
|
|
93
|
-
(_window$NeetoChat = window.NeetoChat) === null || _window$NeetoChat === void 0 ? void 0 : (_window$NeetoChat$con = _window$NeetoChat.contextualHelp) === null || _window$NeetoChat$con === void 0 ? void 0 : _window$NeetoChat$con.maximizeWidget();
|
|
94
|
-
(_window$NeetoChat2 = window.NeetoChat) === null || _window$NeetoChat2 === void 0 ? void 0 : (_window$NeetoChat2$co = _window$NeetoChat2.contextualHelp) === null || _window$NeetoChat2$co === void 0 ? void 0 : _window$NeetoChat2$co.openWidget();
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
}))));
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
var attachContext = function attachContext(notice, context) {
|
|
102
|
-
if (notice.context) Object.assign(notice.context, context);else notice.context = context;
|
|
103
|
-
};
|
|
104
|
-
var getSessionReplayUrl = function getSessionReplayUrl() {
|
|
105
|
-
var storage = sessionStorage.getItem("neeto-replay-widget--session");
|
|
106
|
-
var currentTimestamp = new Date().getTime();
|
|
107
|
-
return storage ? "".concat(JSON.parse(storage).url, "?goto=").concat(currentTimestamp) : "";
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/** @type {import("neetocommons/react-utils").HoneybadgerErrorBoundary} */
|
|
111
|
-
var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
|
|
112
|
-
var children = _ref.children,
|
|
113
|
-
_ref$ErrorComponent = _ref.ErrorComponent,
|
|
114
|
-
ErrorComponent = _ref$ErrorComponent === void 0 ? FallbackComponent : _ref$ErrorComponent,
|
|
115
|
-
_ref$filterErrors = _ref.filterErrors,
|
|
116
|
-
filterErrors = _ref$filterErrors === void 0 ? undefined : _ref$filterErrors;
|
|
117
|
-
Honeybadger.beforeNotify(function (notice) {
|
|
118
|
-
var _globalProps$user;
|
|
119
|
-
if (!notice) return false;
|
|
120
|
-
var isIgnorable = IGNORABLE_ERRORS_REGEX.test(notice.message) || notice.stack.includes("chrome-extension://") || (filterErrors === null || filterErrors === void 0 ? void 0 : filterErrors(notice)) === false;
|
|
121
|
-
if (isIgnorable) return false;
|
|
122
|
-
var context = {};
|
|
123
|
-
var user = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email;
|
|
124
|
-
if (user) context.user = user;
|
|
125
|
-
var sessionReplay = getSessionReplayUrl();
|
|
126
|
-
if (sessionReplay) context.sessionReplay = sessionReplay;
|
|
127
|
-
attachContext(notice, context);
|
|
128
|
-
return true;
|
|
129
|
-
});
|
|
130
|
-
var honeybadger = Honeybadger.configure({
|
|
131
|
-
apiKey: globalProps.honeybadgerApiKey,
|
|
132
|
-
environment: globalProps.railsEnv,
|
|
133
|
-
revision: globalProps.honeybadgerRevision,
|
|
134
|
-
developmentEnvironments: ["development", "test"],
|
|
135
|
-
enableUncaught: true,
|
|
136
|
-
async: true,
|
|
137
|
-
breadcrumbsEnabled: true,
|
|
138
|
-
projectRoot: "webpack:///./",
|
|
139
|
-
enableUnhandledRejection: false
|
|
140
|
-
});
|
|
141
|
-
return /*#__PURE__*/React__default.createElement(HoneybadgerErrorBoundary$1, {
|
|
142
|
-
ErrorComponent: ErrorComponent,
|
|
143
|
-
honeybadger: honeybadger
|
|
144
|
-
}, children);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
148
|
-
if (source == null) return {};
|
|
149
|
-
var target = {};
|
|
150
|
-
var sourceKeys = Object.keys(source);
|
|
151
|
-
var key, i;
|
|
152
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
153
|
-
key = sourceKeys[i];
|
|
154
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
155
|
-
target[key] = source[key];
|
|
156
|
-
}
|
|
157
|
-
return target;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function _objectWithoutProperties(source, excluded) {
|
|
161
|
-
if (source == null) return {};
|
|
162
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
163
|
-
var key, i;
|
|
164
|
-
if (Object.getOwnPropertySymbols) {
|
|
165
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
166
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
167
|
-
key = sourceSymbolKeys[i];
|
|
168
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
169
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
170
|
-
target[key] = source[key];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return target;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var _excluded$1 = ["condition", "redirectRoute", "errorPage", "permissions"];
|
|
177
|
-
var PrivateRoute = function PrivateRoute(_ref) {
|
|
178
|
-
var _ref$condition = _ref.condition,
|
|
179
|
-
condition = _ref$condition === void 0 ? globalProps.authenticated : _ref$condition,
|
|
180
|
-
_ref$redirectRoute = _ref.redirectRoute,
|
|
181
|
-
redirectRoute = _ref$redirectRoute === void 0 ? undefined : _ref$redirectRoute,
|
|
182
|
-
_ref$errorPage = _ref.errorPage,
|
|
183
|
-
errorPage = _ref$errorPage === void 0 ? undefined : _ref$errorPage,
|
|
184
|
-
_ref$permissions = _ref.permissions,
|
|
185
|
-
permissions = _ref$permissions === void 0 ? undefined : _ref$permissions,
|
|
186
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
187
|
-
if (condition) {
|
|
188
|
-
if (permissions) {
|
|
189
|
-
return globalProps.permissions.some(includes(__, permissions)) ? /*#__PURE__*/React__default.createElement(Route, props) : errorPage || /*#__PURE__*/React__default.createElement(ErrorPage, {
|
|
190
|
-
status: 403
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return /*#__PURE__*/React__default.createElement(Route, props);
|
|
194
|
-
}
|
|
195
|
-
if (redirectRoute) {
|
|
196
|
-
return /*#__PURE__*/React__default.createElement(Redirect, {
|
|
197
|
-
to: {
|
|
198
|
-
pathname: redirectRoute
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return errorPage || /*#__PURE__*/React__default.createElement(ErrorPage, {
|
|
203
|
-
status: 403
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
function _typeof$1(obj) {
|
|
208
|
-
"@babel/helpers - typeof";
|
|
209
|
-
|
|
210
|
-
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
211
|
-
return typeof obj;
|
|
212
|
-
} : function (obj) {
|
|
213
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
214
|
-
}, _typeof$1(obj);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function _toPrimitive(input, hint) {
|
|
218
|
-
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
219
|
-
var prim = input[Symbol.toPrimitive];
|
|
220
|
-
if (prim !== undefined) {
|
|
221
|
-
var res = prim.call(input, hint || "default");
|
|
222
|
-
if (_typeof$1(res) !== "object") return res;
|
|
223
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
224
|
-
}
|
|
225
|
-
return (hint === "string" ? String : Number)(input);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function _toPropertyKey(arg) {
|
|
229
|
-
var key = _toPrimitive(arg, "string");
|
|
230
|
-
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function _defineProperty(obj, key, value) {
|
|
234
|
-
key = _toPropertyKey(key);
|
|
235
|
-
if (key in obj) {
|
|
236
|
-
Object.defineProperty(obj, key, {
|
|
237
|
-
value: value,
|
|
238
|
-
enumerable: true,
|
|
239
|
-
configurable: true,
|
|
240
|
-
writable: true
|
|
241
|
-
});
|
|
242
|
-
} else {
|
|
243
|
-
obj[key] = value;
|
|
244
|
-
}
|
|
245
|
-
return obj;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var fetch = function fetch() {
|
|
249
|
-
return axios.get("/api/v1/neeto_apps");
|
|
250
|
-
};
|
|
251
|
-
var neetoAppsApi = {
|
|
252
|
-
fetch: fetch
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
var QUERY_KEYS = {
|
|
256
|
-
NEETO_APPS_LIST: "neeto-apps-list"
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
var QUERY_CACHE_NAME_SPACE = "queryCache";
|
|
260
|
-
var NEETO_APPS_LIST_STALE_TIME = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
261
|
-
|
|
262
|
-
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
263
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
264
|
-
var useFetchNeetoApps = function useFetchNeetoApps(options) {
|
|
265
|
-
var _globalProps$user;
|
|
266
|
-
var scopedQueryKey = "".concat(QUERY_KEYS.NEETO_APPS_LIST, "-").concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id);
|
|
267
|
-
var neetoApps = usePersistedQuery$1.getCache(scopedQueryKey);
|
|
268
|
-
return usePersistedQuery$1(scopedQueryKey, neetoAppsApi.fetch, _objectSpread$3({
|
|
269
|
-
staleTime: NEETO_APPS_LIST_STALE_TIME,
|
|
270
|
-
enabled: isNotPresent(neetoApps === null || neetoApps === void 0 ? void 0 : neetoApps.data)
|
|
271
|
-
}, options));
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
275
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
276
|
-
var localStorageQueryCache = {
|
|
277
|
-
set: function set(key, data) {
|
|
278
|
-
var cache = localStorageQueryCache.getAll();
|
|
279
|
-
var newCache = _objectSpread$2(_objectSpread$2({}, cache), {}, _defineProperty({}, key, {
|
|
280
|
-
data: data,
|
|
281
|
-
modifiedAt: Date.now()
|
|
282
|
-
}));
|
|
283
|
-
localStorage.setItem(QUERY_CACHE_NAME_SPACE, JSON.stringify(newCache));
|
|
284
|
-
},
|
|
285
|
-
getAll: function getAll() {
|
|
286
|
-
var cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);
|
|
287
|
-
if (!cache) return {};
|
|
288
|
-
return cache;
|
|
289
|
-
},
|
|
290
|
-
get: function get(key) {
|
|
291
|
-
return localStorageQueryCache.getAll()[key];
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
var isOutdated = function isOutdated(localCache, staleTime) {
|
|
295
|
-
if (isNil(localCache)) return true;
|
|
296
|
-
if (isNil(staleTime)) return false;
|
|
297
|
-
return localCache.modifiedAt <= Date.now() - staleTime;
|
|
298
|
-
};
|
|
299
|
-
var usePersistedQuery = function usePersistedQuery(queryKey, fetch, options) {
|
|
300
|
-
var queryResult = useQuery(queryKey, fetch, options);
|
|
301
|
-
var localCache = localStorageQueryCache.get(queryKey);
|
|
302
|
-
useEffect(function () {
|
|
303
|
-
if (!queryResult.isSuccess) return;
|
|
304
|
-
localStorageQueryCache.set(queryKey, queryResult.data);
|
|
305
|
-
}, [queryKey, queryResult.data, queryResult.isSuccess]);
|
|
306
|
-
if (isOutdated(localCache, options === null || options === void 0 ? void 0 : options.staleTime)) {
|
|
307
|
-
return _objectSpread$2(_objectSpread$2({}, queryResult), {}, {
|
|
308
|
-
isFreshLoading: queryResult.isLoading
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
return _objectSpread$2(_objectSpread$2({}, queryResult), {}, {
|
|
312
|
-
data: queryResult.data || localCache.data,
|
|
313
|
-
isFreshLoading: false
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
usePersistedQuery.getCache = localStorageQueryCache.get;
|
|
317
|
-
|
|
318
|
-
function _arrayWithHoles(arr) {
|
|
319
|
-
if (Array.isArray(arr)) return arr;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function _iterableToArrayLimit(arr, i) {
|
|
323
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
324
|
-
if (null != _i) {
|
|
325
|
-
var _s,
|
|
326
|
-
_e,
|
|
327
|
-
_x,
|
|
328
|
-
_r,
|
|
329
|
-
_arr = [],
|
|
330
|
-
_n = !0,
|
|
331
|
-
_d = !1;
|
|
332
|
-
try {
|
|
333
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
334
|
-
if (Object(_i) !== _i) return;
|
|
335
|
-
_n = !1;
|
|
336
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
337
|
-
} catch (err) {
|
|
338
|
-
_d = !0, _e = err;
|
|
339
|
-
} finally {
|
|
340
|
-
try {
|
|
341
|
-
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
342
|
-
} finally {
|
|
343
|
-
if (_d) throw _e;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return _arr;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function _arrayLikeToArray(arr, len) {
|
|
351
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
352
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
353
|
-
return arr2;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
357
|
-
if (!o) return;
|
|
358
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
359
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
360
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
361
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
362
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function _nonIterableRest() {
|
|
366
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function _slicedToArray(arr, i) {
|
|
370
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
var useDebounce = function useDebounce(value) {
|
|
374
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
375
|
-
var _useState = useState(value),
|
|
376
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
377
|
-
debouncedValue = _useState2[0],
|
|
378
|
-
setDebouncedValue = _useState2[1];
|
|
379
|
-
useEffect(function () {
|
|
380
|
-
var handler = setTimeout(function () {
|
|
381
|
-
setDebouncedValue(value);
|
|
382
|
-
}, delay);
|
|
383
|
-
return function () {
|
|
384
|
-
clearTimeout(handler);
|
|
385
|
-
};
|
|
386
|
-
}, [value]);
|
|
387
|
-
return debouncedValue;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
const createStoreImpl = (createState) => {
|
|
391
|
-
let state;
|
|
392
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
393
|
-
const setState = (partial, replace) => {
|
|
394
|
-
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
395
|
-
if (!Object.is(nextState, state)) {
|
|
396
|
-
const previousState = state;
|
|
397
|
-
state = (replace != null ? replace : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState);
|
|
398
|
-
listeners.forEach((listener) => listener(state, previousState));
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
const getState = () => state;
|
|
402
|
-
const subscribe = (listener) => {
|
|
403
|
-
listeners.add(listener);
|
|
404
|
-
return () => listeners.delete(listener);
|
|
405
|
-
};
|
|
406
|
-
const destroy = () => {
|
|
407
|
-
if ((import.meta.env && import.meta.env.MODE) !== "production") {
|
|
408
|
-
console.warn(
|
|
409
|
-
"[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected."
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
listeners.clear();
|
|
413
|
-
};
|
|
414
|
-
const api = { setState, getState, subscribe, destroy };
|
|
415
|
-
state = createState(setState, getState, api);
|
|
416
|
-
return api;
|
|
417
|
-
};
|
|
418
|
-
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
419
|
-
|
|
420
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
421
|
-
|
|
422
|
-
function getDefaultExportFromCjs (x) {
|
|
423
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
var withSelector = {exports: {}};
|
|
427
|
-
|
|
428
|
-
var withSelector_production_min = {};
|
|
429
|
-
|
|
430
|
-
var shim = {exports: {}};
|
|
431
|
-
|
|
432
|
-
var useSyncExternalStoreShim_production_min = {};
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* @license React
|
|
436
|
-
* use-sync-external-store-shim.production.min.js
|
|
437
|
-
*
|
|
438
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
439
|
-
*
|
|
440
|
-
* This source code is licensed under the MIT license found in the
|
|
441
|
-
* LICENSE file in the root directory of this source tree.
|
|
442
|
-
*/
|
|
443
|
-
|
|
444
|
-
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
445
|
-
|
|
446
|
-
function requireUseSyncExternalStoreShim_production_min () {
|
|
447
|
-
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
448
|
-
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
449
|
-
var e=React__default;function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
450
|
-
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
451
|
-
return useSyncExternalStoreShim_production_min;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
var useSyncExternalStoreShim_development = {};
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* @license React
|
|
458
|
-
* use-sync-external-store-shim.development.js
|
|
459
|
-
*
|
|
460
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
461
|
-
*
|
|
462
|
-
* This source code is licensed under the MIT license found in the
|
|
463
|
-
* LICENSE file in the root directory of this source tree.
|
|
464
|
-
*/
|
|
465
|
-
|
|
466
|
-
var hasRequiredUseSyncExternalStoreShim_development;
|
|
467
|
-
|
|
468
|
-
function requireUseSyncExternalStoreShim_development () {
|
|
469
|
-
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
470
|
-
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
471
|
-
|
|
472
|
-
if (process.env.NODE_ENV !== "production") {
|
|
473
|
-
(function() {
|
|
474
|
-
|
|
475
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
476
|
-
if (
|
|
477
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
478
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
479
|
-
'function'
|
|
480
|
-
) {
|
|
481
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
482
|
-
}
|
|
483
|
-
var React = React__default;
|
|
484
|
-
|
|
485
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
486
|
-
|
|
487
|
-
function error(format) {
|
|
488
|
-
{
|
|
489
|
-
{
|
|
490
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
491
|
-
args[_key2 - 1] = arguments[_key2];
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
printWarning('error', format, args);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function printWarning(level, format, args) {
|
|
500
|
-
// When changing this logic, you might want to also
|
|
501
|
-
// update consoleWithStackDev.www.js as well.
|
|
502
|
-
{
|
|
503
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
504
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
505
|
-
|
|
506
|
-
if (stack !== '') {
|
|
507
|
-
format += '%s';
|
|
508
|
-
args = args.concat([stack]);
|
|
509
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
var argsWithFormat = args.map(function (item) {
|
|
513
|
-
return String(item);
|
|
514
|
-
}); // Careful: RN currently depends on this prefix
|
|
515
|
-
|
|
516
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
517
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
518
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
519
|
-
|
|
520
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
526
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
527
|
-
*/
|
|
528
|
-
function is(x, y) {
|
|
529
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
530
|
-
;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
534
|
-
|
|
535
|
-
// dispatch for CommonJS interop named imports.
|
|
536
|
-
|
|
537
|
-
var useState = React.useState,
|
|
538
|
-
useEffect = React.useEffect,
|
|
539
|
-
useLayoutEffect = React.useLayoutEffect,
|
|
540
|
-
useDebugValue = React.useDebugValue;
|
|
541
|
-
var didWarnOld18Alpha = false;
|
|
542
|
-
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
543
|
-
// because of a very particular set of implementation details and assumptions
|
|
544
|
-
// -- change any one of them and it will break. The most important assumption
|
|
545
|
-
// is that updates are always synchronous, because concurrent rendering is
|
|
546
|
-
// only available in versions of React that also have a built-in
|
|
547
|
-
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
548
|
-
// does not exist.
|
|
549
|
-
//
|
|
550
|
-
// Do not assume that the clever hacks used by this hook also work in general.
|
|
551
|
-
// The point of this shim is to replace the need for hacks by other libraries.
|
|
552
|
-
|
|
553
|
-
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
554
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
555
|
-
// will need to track that themselves and return the correct value
|
|
556
|
-
// from `getSnapshot`.
|
|
557
|
-
getServerSnapshot) {
|
|
558
|
-
{
|
|
559
|
-
if (!didWarnOld18Alpha) {
|
|
560
|
-
if (React.startTransition !== undefined) {
|
|
561
|
-
didWarnOld18Alpha = true;
|
|
562
|
-
|
|
563
|
-
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
} // Read the current snapshot from the store on every render. Again, this
|
|
567
|
-
// breaks the rules of React, and only works here because of specific
|
|
568
|
-
// implementation details, most importantly that updates are
|
|
569
|
-
// always synchronous.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
var value = getSnapshot();
|
|
573
|
-
|
|
574
|
-
{
|
|
575
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
576
|
-
var cachedValue = getSnapshot();
|
|
577
|
-
|
|
578
|
-
if (!objectIs(value, cachedValue)) {
|
|
579
|
-
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
580
|
-
|
|
581
|
-
didWarnUncachedGetSnapshot = true;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
585
|
-
// re-render whenever the subscribed state changes by updating an some
|
|
586
|
-
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
587
|
-
// the current value.
|
|
588
|
-
//
|
|
589
|
-
// Because we don't actually use the state returned by the useState hook, we
|
|
590
|
-
// can save a bit of memory by storing other stuff in that slot.
|
|
591
|
-
//
|
|
592
|
-
// To implement the early bailout, we need to track some things on a mutable
|
|
593
|
-
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
594
|
-
// our useState hook instead.
|
|
595
|
-
//
|
|
596
|
-
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
597
|
-
// new object always fails an equality check.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
var _useState = useState({
|
|
601
|
-
inst: {
|
|
602
|
-
value: value,
|
|
603
|
-
getSnapshot: getSnapshot
|
|
604
|
-
}
|
|
605
|
-
}),
|
|
606
|
-
inst = _useState[0].inst,
|
|
607
|
-
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
608
|
-
// in the layout phase so we can access it during the tearing check that
|
|
609
|
-
// happens on subscribe.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
useLayoutEffect(function () {
|
|
613
|
-
inst.value = value;
|
|
614
|
-
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
615
|
-
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
616
|
-
// this can happen all the time, but even in synchronous mode, an earlier
|
|
617
|
-
// effect may have mutated the store.
|
|
618
|
-
|
|
619
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
620
|
-
// Force a re-render.
|
|
621
|
-
forceUpdate({
|
|
622
|
-
inst: inst
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
}, [subscribe, value, getSnapshot]);
|
|
626
|
-
useEffect(function () {
|
|
627
|
-
// Check for changes right before subscribing. Subsequent changes will be
|
|
628
|
-
// detected in the subscription handler.
|
|
629
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
630
|
-
// Force a re-render.
|
|
631
|
-
forceUpdate({
|
|
632
|
-
inst: inst
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
var handleStoreChange = function () {
|
|
637
|
-
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
638
|
-
// up to the consumer of this library to wrap their subscription event
|
|
639
|
-
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
640
|
-
// the case and print a warning in development?
|
|
641
|
-
// The store changed. Check if the snapshot changed since the last time we
|
|
642
|
-
// read from the store.
|
|
643
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
644
|
-
// Force a re-render.
|
|
645
|
-
forceUpdate({
|
|
646
|
-
inst: inst
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
}; // Subscribe to the store and return a clean-up function.
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
return subscribe(handleStoreChange);
|
|
653
|
-
}, [subscribe]);
|
|
654
|
-
useDebugValue(value);
|
|
655
|
-
return value;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function checkIfSnapshotChanged(inst) {
|
|
659
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
660
|
-
var prevValue = inst.value;
|
|
661
|
-
|
|
662
|
-
try {
|
|
663
|
-
var nextValue = latestGetSnapshot();
|
|
664
|
-
return !objectIs(prevValue, nextValue);
|
|
665
|
-
} catch (error) {
|
|
666
|
-
return true;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
671
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
672
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
673
|
-
// will need to track that themselves and return the correct value
|
|
674
|
-
// from `getSnapshot`.
|
|
675
|
-
return getSnapshot();
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
679
|
-
|
|
680
|
-
var isServerEnvironment = !canUseDOM;
|
|
681
|
-
|
|
682
|
-
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
683
|
-
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
684
|
-
|
|
685
|
-
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
686
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
687
|
-
if (
|
|
688
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
689
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
690
|
-
'function'
|
|
691
|
-
) {
|
|
692
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
})();
|
|
696
|
-
}
|
|
697
|
-
return useSyncExternalStoreShim_development;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
var hasRequiredShim;
|
|
701
|
-
|
|
702
|
-
function requireShim () {
|
|
703
|
-
if (hasRequiredShim) return shim.exports;
|
|
704
|
-
hasRequiredShim = 1;
|
|
705
|
-
(function (module) {
|
|
706
|
-
|
|
707
|
-
if (process.env.NODE_ENV === 'production') {
|
|
708
|
-
module.exports = requireUseSyncExternalStoreShim_production_min();
|
|
709
|
-
} else {
|
|
710
|
-
module.exports = requireUseSyncExternalStoreShim_development();
|
|
711
|
-
}
|
|
712
|
-
} (shim));
|
|
713
|
-
return shim.exports;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* @license React
|
|
718
|
-
* use-sync-external-store-shim/with-selector.production.min.js
|
|
719
|
-
*
|
|
720
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
721
|
-
*
|
|
722
|
-
* This source code is licensed under the MIT license found in the
|
|
723
|
-
* LICENSE file in the root directory of this source tree.
|
|
724
|
-
*/
|
|
725
|
-
|
|
726
|
-
var hasRequiredWithSelector_production_min;
|
|
727
|
-
|
|
728
|
-
function requireWithSelector_production_min () {
|
|
729
|
-
if (hasRequiredWithSelector_production_min) return withSelector_production_min;
|
|
730
|
-
hasRequiredWithSelector_production_min = 1;
|
|
731
|
-
var h=React__default,n=requireShim();function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
|
|
732
|
-
withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
|
|
733
|
-
u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
|
|
734
|
-
return withSelector_production_min;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
var withSelector_development = {};
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* @license React
|
|
741
|
-
* use-sync-external-store-shim/with-selector.development.js
|
|
742
|
-
*
|
|
743
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
744
|
-
*
|
|
745
|
-
* This source code is licensed under the MIT license found in the
|
|
746
|
-
* LICENSE file in the root directory of this source tree.
|
|
747
|
-
*/
|
|
748
|
-
|
|
749
|
-
var hasRequiredWithSelector_development;
|
|
750
|
-
|
|
751
|
-
function requireWithSelector_development () {
|
|
752
|
-
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
753
|
-
hasRequiredWithSelector_development = 1;
|
|
754
|
-
|
|
755
|
-
if (process.env.NODE_ENV !== "production") {
|
|
756
|
-
(function() {
|
|
757
|
-
|
|
758
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
759
|
-
if (
|
|
760
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
761
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
762
|
-
'function'
|
|
763
|
-
) {
|
|
764
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
765
|
-
}
|
|
766
|
-
var React = React__default;
|
|
767
|
-
var shim = requireShim();
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
771
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
772
|
-
*/
|
|
773
|
-
function is(x, y) {
|
|
774
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
775
|
-
;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
779
|
-
|
|
780
|
-
var useSyncExternalStore = shim.useSyncExternalStore;
|
|
781
|
-
|
|
782
|
-
// for CommonJS interop.
|
|
783
|
-
|
|
784
|
-
var useRef = React.useRef,
|
|
785
|
-
useEffect = React.useEffect,
|
|
786
|
-
useMemo = React.useMemo,
|
|
787
|
-
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
788
|
-
|
|
789
|
-
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
790
|
-
// Use this to track the rendered snapshot.
|
|
791
|
-
var instRef = useRef(null);
|
|
792
|
-
var inst;
|
|
793
|
-
|
|
794
|
-
if (instRef.current === null) {
|
|
795
|
-
inst = {
|
|
796
|
-
hasValue: false,
|
|
797
|
-
value: null
|
|
798
|
-
};
|
|
799
|
-
instRef.current = inst;
|
|
800
|
-
} else {
|
|
801
|
-
inst = instRef.current;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
var _useMemo = useMemo(function () {
|
|
805
|
-
// Track the memoized state using closure variables that are local to this
|
|
806
|
-
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
807
|
-
// useRef hook, because that state would be shared across all concurrent
|
|
808
|
-
// copies of the hook/component.
|
|
809
|
-
var hasMemo = false;
|
|
810
|
-
var memoizedSnapshot;
|
|
811
|
-
var memoizedSelection;
|
|
812
|
-
|
|
813
|
-
var memoizedSelector = function (nextSnapshot) {
|
|
814
|
-
if (!hasMemo) {
|
|
815
|
-
// The first time the hook is called, there is no memoized result.
|
|
816
|
-
hasMemo = true;
|
|
817
|
-
memoizedSnapshot = nextSnapshot;
|
|
818
|
-
|
|
819
|
-
var _nextSelection = selector(nextSnapshot);
|
|
820
|
-
|
|
821
|
-
if (isEqual !== undefined) {
|
|
822
|
-
// Even if the selector has changed, the currently rendered selection
|
|
823
|
-
// may be equal to the new selection. We should attempt to reuse the
|
|
824
|
-
// current value if possible, to preserve downstream memoizations.
|
|
825
|
-
if (inst.hasValue) {
|
|
826
|
-
var currentSelection = inst.value;
|
|
827
|
-
|
|
828
|
-
if (isEqual(currentSelection, _nextSelection)) {
|
|
829
|
-
memoizedSelection = currentSelection;
|
|
830
|
-
return currentSelection;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
memoizedSelection = _nextSelection;
|
|
836
|
-
return _nextSelection;
|
|
837
|
-
} // We may be able to reuse the previous invocation's result.
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
// We may be able to reuse the previous invocation's result.
|
|
841
|
-
var prevSnapshot = memoizedSnapshot;
|
|
842
|
-
var prevSelection = memoizedSelection;
|
|
843
|
-
|
|
844
|
-
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
845
|
-
// The snapshot is the same as last time. Reuse the previous selection.
|
|
846
|
-
return prevSelection;
|
|
847
|
-
} // The snapshot has changed, so we need to compute a new selection.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
// The snapshot has changed, so we need to compute a new selection.
|
|
851
|
-
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
852
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
853
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
854
|
-
// out of rendering.
|
|
855
|
-
|
|
856
|
-
// If a custom isEqual function is provided, use that to check if the data
|
|
857
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
858
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
859
|
-
// out of rendering.
|
|
860
|
-
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
861
|
-
return prevSelection;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
memoizedSnapshot = nextSnapshot;
|
|
865
|
-
memoizedSelection = nextSelection;
|
|
866
|
-
return nextSelection;
|
|
867
|
-
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
// Assigning this to a constant so that Flow knows it can't change.
|
|
871
|
-
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
872
|
-
|
|
873
|
-
var getSnapshotWithSelector = function () {
|
|
874
|
-
return memoizedSelector(getSnapshot());
|
|
875
|
-
};
|
|
876
|
-
|
|
877
|
-
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
878
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
879
|
-
};
|
|
880
|
-
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
881
|
-
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
882
|
-
getSelection = _useMemo[0],
|
|
883
|
-
getServerSelection = _useMemo[1];
|
|
884
|
-
|
|
885
|
-
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
886
|
-
useEffect(function () {
|
|
887
|
-
inst.hasValue = true;
|
|
888
|
-
inst.value = value;
|
|
889
|
-
}, [value]);
|
|
890
|
-
useDebugValue(value);
|
|
891
|
-
return value;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
895
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
896
|
-
if (
|
|
897
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
898
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
899
|
-
'function'
|
|
900
|
-
) {
|
|
901
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
})();
|
|
905
|
-
}
|
|
906
|
-
return withSelector_development;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
(function (module) {
|
|
910
|
-
|
|
911
|
-
if (process.env.NODE_ENV === 'production') {
|
|
912
|
-
module.exports = requireWithSelector_production_min();
|
|
913
|
-
} else {
|
|
914
|
-
module.exports = requireWithSelector_development();
|
|
915
|
-
}
|
|
916
|
-
} (withSelector));
|
|
917
|
-
|
|
918
|
-
var useSyncExternalStoreExports = /*@__PURE__*/getDefaultExportFromCjs(withSelector.exports);
|
|
919
|
-
|
|
920
|
-
const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
|
|
921
|
-
function useStore(api, selector = api.getState, equalityFn) {
|
|
922
|
-
const slice = useSyncExternalStoreWithSelector(
|
|
923
|
-
api.subscribe,
|
|
924
|
-
api.getState,
|
|
925
|
-
api.getServerState || api.getState,
|
|
926
|
-
selector,
|
|
927
|
-
equalityFn
|
|
928
|
-
);
|
|
929
|
-
useDebugValue(slice);
|
|
930
|
-
return slice;
|
|
931
|
-
}
|
|
932
|
-
const createImpl = (createState) => {
|
|
933
|
-
if ((import.meta.env && import.meta.env.MODE) !== "production" && typeof createState !== "function") {
|
|
934
|
-
console.warn(
|
|
935
|
-
'[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.'
|
|
936
|
-
);
|
|
937
|
-
}
|
|
938
|
-
const api = typeof createState === "function" ? createStore(createState) : createState;
|
|
939
|
-
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
|
940
|
-
Object.assign(useBoundStore, api);
|
|
941
|
-
return useBoundStore;
|
|
942
|
-
};
|
|
943
|
-
const create$1 = (createState) => createState ? createImpl(createState) : createImpl;
|
|
944
|
-
|
|
945
|
-
var useDisplayErrorPage = function useDisplayErrorPage() {
|
|
946
|
-
return useErrorDisplayStore(prop("showErrorPage"));
|
|
947
|
-
};
|
|
948
|
-
var useErrorDisplayStore = create$1(function () {
|
|
949
|
-
return {
|
|
950
|
-
showErrorPage: false,
|
|
951
|
-
statusCode: 404,
|
|
952
|
-
failedApiUrl: "",
|
|
953
|
-
failedApiPath: ""
|
|
954
|
-
};
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
var useFuncDebounce = function useFuncDebounce(func) {
|
|
958
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
959
|
-
var timer = useRef(null);
|
|
960
|
-
var debouncedFunc = function debouncedFunc() {
|
|
961
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
962
|
-
args[_key] = arguments[_key];
|
|
963
|
-
}
|
|
964
|
-
clearTimeout(timer.current);
|
|
965
|
-
timer.current = setTimeout(function () {
|
|
966
|
-
return func.apply(void 0, args);
|
|
967
|
-
}, delay);
|
|
968
|
-
};
|
|
969
|
-
debouncedFunc.cancel = function () {
|
|
970
|
-
return clearTimeout(timer.current);
|
|
971
|
-
};
|
|
972
|
-
return debouncedFunc;
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
var mousetrap = {exports: {}};
|
|
976
|
-
|
|
977
|
-
/*global define:false */
|
|
978
|
-
|
|
979
|
-
(function (module) {
|
|
980
|
-
/**
|
|
981
|
-
* Copyright 2012-2017 Craig Campbell
|
|
982
|
-
*
|
|
983
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
984
|
-
* you may not use this file except in compliance with the License.
|
|
985
|
-
* You may obtain a copy of the License at
|
|
986
|
-
*
|
|
987
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
988
|
-
*
|
|
989
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
990
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
991
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
992
|
-
* See the License for the specific language governing permissions and
|
|
993
|
-
* limitations under the License.
|
|
994
|
-
*
|
|
995
|
-
* Mousetrap is a simple keyboard shortcut library for Javascript with
|
|
996
|
-
* no external dependencies
|
|
997
|
-
*
|
|
998
|
-
* @version 1.6.5
|
|
999
|
-
* @url craig.is/killing/mice
|
|
1000
|
-
*/
|
|
1001
|
-
(function(window, document, undefined$1) {
|
|
1002
|
-
|
|
1003
|
-
// Check if mousetrap is used inside browser, if not, return
|
|
1004
|
-
if (!window) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* mapping of special keycodes to their corresponding keys
|
|
1010
|
-
*
|
|
1011
|
-
* everything in this dictionary cannot use keypress events
|
|
1012
|
-
* so it has to be here to map to the correct keycodes for
|
|
1013
|
-
* keyup/keydown events
|
|
1014
|
-
*
|
|
1015
|
-
* @type {Object}
|
|
1016
|
-
*/
|
|
1017
|
-
var _MAP = {
|
|
1018
|
-
8: 'backspace',
|
|
1019
|
-
9: 'tab',
|
|
1020
|
-
13: 'enter',
|
|
1021
|
-
16: 'shift',
|
|
1022
|
-
17: 'ctrl',
|
|
1023
|
-
18: 'alt',
|
|
1024
|
-
20: 'capslock',
|
|
1025
|
-
27: 'esc',
|
|
1026
|
-
32: 'space',
|
|
1027
|
-
33: 'pageup',
|
|
1028
|
-
34: 'pagedown',
|
|
1029
|
-
35: 'end',
|
|
1030
|
-
36: 'home',
|
|
1031
|
-
37: 'left',
|
|
1032
|
-
38: 'up',
|
|
1033
|
-
39: 'right',
|
|
1034
|
-
40: 'down',
|
|
1035
|
-
45: 'ins',
|
|
1036
|
-
46: 'del',
|
|
1037
|
-
91: 'meta',
|
|
1038
|
-
93: 'meta',
|
|
1039
|
-
224: 'meta'
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
/**
|
|
1043
|
-
* mapping for special characters so they can support
|
|
1044
|
-
*
|
|
1045
|
-
* this dictionary is only used incase you want to bind a
|
|
1046
|
-
* keyup or keydown event to one of these keys
|
|
1047
|
-
*
|
|
1048
|
-
* @type {Object}
|
|
1049
|
-
*/
|
|
1050
|
-
var _KEYCODE_MAP = {
|
|
1051
|
-
106: '*',
|
|
1052
|
-
107: '+',
|
|
1053
|
-
109: '-',
|
|
1054
|
-
110: '.',
|
|
1055
|
-
111 : '/',
|
|
1056
|
-
186: ';',
|
|
1057
|
-
187: '=',
|
|
1058
|
-
188: ',',
|
|
1059
|
-
189: '-',
|
|
1060
|
-
190: '.',
|
|
1061
|
-
191: '/',
|
|
1062
|
-
192: '`',
|
|
1063
|
-
219: '[',
|
|
1064
|
-
220: '\\',
|
|
1065
|
-
221: ']',
|
|
1066
|
-
222: '\''
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* this is a mapping of keys that require shift on a US keypad
|
|
1071
|
-
* back to the non shift equivelents
|
|
1072
|
-
*
|
|
1073
|
-
* this is so you can use keyup events with these keys
|
|
1074
|
-
*
|
|
1075
|
-
* note that this will only work reliably on US keyboards
|
|
1076
|
-
*
|
|
1077
|
-
* @type {Object}
|
|
1078
|
-
*/
|
|
1079
|
-
var _SHIFT_MAP = {
|
|
1080
|
-
'~': '`',
|
|
1081
|
-
'!': '1',
|
|
1082
|
-
'@': '2',
|
|
1083
|
-
'#': '3',
|
|
1084
|
-
'$': '4',
|
|
1085
|
-
'%': '5',
|
|
1086
|
-
'^': '6',
|
|
1087
|
-
'&': '7',
|
|
1088
|
-
'*': '8',
|
|
1089
|
-
'(': '9',
|
|
1090
|
-
')': '0',
|
|
1091
|
-
'_': '-',
|
|
1092
|
-
'+': '=',
|
|
1093
|
-
':': ';',
|
|
1094
|
-
'\"': '\'',
|
|
1095
|
-
'<': ',',
|
|
1096
|
-
'>': '.',
|
|
1097
|
-
'?': '/',
|
|
1098
|
-
'|': '\\'
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
/**
|
|
1102
|
-
* this is a list of special strings you can use to map
|
|
1103
|
-
* to modifier keys when you specify your keyboard shortcuts
|
|
1104
|
-
*
|
|
1105
|
-
* @type {Object}
|
|
1106
|
-
*/
|
|
1107
|
-
var _SPECIAL_ALIASES = {
|
|
1108
|
-
'option': 'alt',
|
|
1109
|
-
'command': 'meta',
|
|
1110
|
-
'return': 'enter',
|
|
1111
|
-
'escape': 'esc',
|
|
1112
|
-
'plus': '+',
|
|
1113
|
-
'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
|
|
1114
|
-
};
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* variable to store the flipped version of _MAP from above
|
|
1118
|
-
* needed to check if we should use keypress or not when no action
|
|
1119
|
-
* is specified
|
|
1120
|
-
*
|
|
1121
|
-
* @type {Object|undefined}
|
|
1122
|
-
*/
|
|
1123
|
-
var _REVERSE_MAP;
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* loop through the f keys, f1 to f19 and add them to the map
|
|
1127
|
-
* programatically
|
|
1128
|
-
*/
|
|
1129
|
-
for (var i = 1; i < 20; ++i) {
|
|
1130
|
-
_MAP[111 + i] = 'f' + i;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* loop through to map numbers on the numeric keypad
|
|
1135
|
-
*/
|
|
1136
|
-
for (i = 0; i <= 9; ++i) {
|
|
1137
|
-
|
|
1138
|
-
// This needs to use a string cause otherwise since 0 is falsey
|
|
1139
|
-
// mousetrap will never fire for numpad 0 pressed as part of a keydown
|
|
1140
|
-
// event.
|
|
1141
|
-
//
|
|
1142
|
-
// @see https://github.com/ccampbell/mousetrap/pull/258
|
|
1143
|
-
_MAP[i + 96] = i.toString();
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
/**
|
|
1147
|
-
* cross browser add event method
|
|
1148
|
-
*
|
|
1149
|
-
* @param {Element|HTMLDocument} object
|
|
1150
|
-
* @param {string} type
|
|
1151
|
-
* @param {Function} callback
|
|
1152
|
-
* @returns void
|
|
1153
|
-
*/
|
|
1154
|
-
function _addEvent(object, type, callback) {
|
|
1155
|
-
if (object.addEventListener) {
|
|
1156
|
-
object.addEventListener(type, callback, false);
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
object.attachEvent('on' + type, callback);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
* takes the event and returns the key character
|
|
1165
|
-
*
|
|
1166
|
-
* @param {Event} e
|
|
1167
|
-
* @return {string}
|
|
1168
|
-
*/
|
|
1169
|
-
function _characterFromEvent(e) {
|
|
1170
|
-
|
|
1171
|
-
// for keypress events we should return the character as is
|
|
1172
|
-
if (e.type == 'keypress') {
|
|
1173
|
-
var character = String.fromCharCode(e.which);
|
|
1174
|
-
|
|
1175
|
-
// if the shift key is not pressed then it is safe to assume
|
|
1176
|
-
// that we want the character to be lowercase. this means if
|
|
1177
|
-
// you accidentally have caps lock on then your key bindings
|
|
1178
|
-
// will continue to work
|
|
1179
|
-
//
|
|
1180
|
-
// the only side effect that might not be desired is if you
|
|
1181
|
-
// bind something like 'A' cause you want to trigger an
|
|
1182
|
-
// event when capital A is pressed caps lock will no longer
|
|
1183
|
-
// trigger the event. shift+a will though.
|
|
1184
|
-
if (!e.shiftKey) {
|
|
1185
|
-
character = character.toLowerCase();
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
return character;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
// for non keypress events the special maps are needed
|
|
1192
|
-
if (_MAP[e.which]) {
|
|
1193
|
-
return _MAP[e.which];
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
if (_KEYCODE_MAP[e.which]) {
|
|
1197
|
-
return _KEYCODE_MAP[e.which];
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
// if it is not in the special map
|
|
1201
|
-
|
|
1202
|
-
// with keydown and keyup events the character seems to always
|
|
1203
|
-
// come in as an uppercase character whether you are pressing shift
|
|
1204
|
-
// or not. we should make sure it is always lowercase for comparisons
|
|
1205
|
-
return String.fromCharCode(e.which).toLowerCase();
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
/**
|
|
1209
|
-
* checks if two arrays are equal
|
|
1210
|
-
*
|
|
1211
|
-
* @param {Array} modifiers1
|
|
1212
|
-
* @param {Array} modifiers2
|
|
1213
|
-
* @returns {boolean}
|
|
1214
|
-
*/
|
|
1215
|
-
function _modifiersMatch(modifiers1, modifiers2) {
|
|
1216
|
-
return modifiers1.sort().join(',') === modifiers2.sort().join(',');
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
* takes a key event and figures out what the modifiers are
|
|
1221
|
-
*
|
|
1222
|
-
* @param {Event} e
|
|
1223
|
-
* @returns {Array}
|
|
1224
|
-
*/
|
|
1225
|
-
function _eventModifiers(e) {
|
|
1226
|
-
var modifiers = [];
|
|
1227
|
-
|
|
1228
|
-
if (e.shiftKey) {
|
|
1229
|
-
modifiers.push('shift');
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
if (e.altKey) {
|
|
1233
|
-
modifiers.push('alt');
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
if (e.ctrlKey) {
|
|
1237
|
-
modifiers.push('ctrl');
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
if (e.metaKey) {
|
|
1241
|
-
modifiers.push('meta');
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
return modifiers;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
/**
|
|
1248
|
-
* prevents default for this event
|
|
1249
|
-
*
|
|
1250
|
-
* @param {Event} e
|
|
1251
|
-
* @returns void
|
|
1252
|
-
*/
|
|
1253
|
-
function _preventDefault(e) {
|
|
1254
|
-
if (e.preventDefault) {
|
|
1255
|
-
e.preventDefault();
|
|
1256
|
-
return;
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
e.returnValue = false;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
/**
|
|
1263
|
-
* stops propogation for this event
|
|
1264
|
-
*
|
|
1265
|
-
* @param {Event} e
|
|
1266
|
-
* @returns void
|
|
1267
|
-
*/
|
|
1268
|
-
function _stopPropagation(e) {
|
|
1269
|
-
if (e.stopPropagation) {
|
|
1270
|
-
e.stopPropagation();
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
e.cancelBubble = true;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
/**
|
|
1278
|
-
* determines if the keycode specified is a modifier key or not
|
|
1279
|
-
*
|
|
1280
|
-
* @param {string} key
|
|
1281
|
-
* @returns {boolean}
|
|
1282
|
-
*/
|
|
1283
|
-
function _isModifier(key) {
|
|
1284
|
-
return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* reverses the map lookup so that we can look for specific keys
|
|
1289
|
-
* to see what can and can't use keypress
|
|
1290
|
-
*
|
|
1291
|
-
* @return {Object}
|
|
1292
|
-
*/
|
|
1293
|
-
function _getReverseMap() {
|
|
1294
|
-
if (!_REVERSE_MAP) {
|
|
1295
|
-
_REVERSE_MAP = {};
|
|
1296
|
-
for (var key in _MAP) {
|
|
1297
|
-
|
|
1298
|
-
// pull out the numeric keypad from here cause keypress should
|
|
1299
|
-
// be able to detect the keys from the character
|
|
1300
|
-
if (key > 95 && key < 112) {
|
|
1301
|
-
continue;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
if (_MAP.hasOwnProperty(key)) {
|
|
1305
|
-
_REVERSE_MAP[_MAP[key]] = key;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
return _REVERSE_MAP;
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
/**
|
|
1313
|
-
* picks the best action based on the key combination
|
|
1314
|
-
*
|
|
1315
|
-
* @param {string} key - character for key
|
|
1316
|
-
* @param {Array} modifiers
|
|
1317
|
-
* @param {string=} action passed in
|
|
1318
|
-
*/
|
|
1319
|
-
function _pickBestAction(key, modifiers, action) {
|
|
1320
|
-
|
|
1321
|
-
// if no action was picked in we should try to pick the one
|
|
1322
|
-
// that we think would work best for this key
|
|
1323
|
-
if (!action) {
|
|
1324
|
-
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
// modifier keys don't work as expected with keypress,
|
|
1328
|
-
// switch to keydown
|
|
1329
|
-
if (action == 'keypress' && modifiers.length) {
|
|
1330
|
-
action = 'keydown';
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
return action;
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
/**
|
|
1337
|
-
* Converts from a string key combination to an array
|
|
1338
|
-
*
|
|
1339
|
-
* @param {string} combination like "command+shift+l"
|
|
1340
|
-
* @return {Array}
|
|
1341
|
-
*/
|
|
1342
|
-
function _keysFromString(combination) {
|
|
1343
|
-
if (combination === '+') {
|
|
1344
|
-
return ['+'];
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
combination = combination.replace(/\+{2}/g, '+plus');
|
|
1348
|
-
return combination.split('+');
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
* Gets info for a specific key combination
|
|
1353
|
-
*
|
|
1354
|
-
* @param {string} combination key combination ("command+s" or "a" or "*")
|
|
1355
|
-
* @param {string=} action
|
|
1356
|
-
* @returns {Object}
|
|
1357
|
-
*/
|
|
1358
|
-
function _getKeyInfo(combination, action) {
|
|
1359
|
-
var keys;
|
|
1360
|
-
var key;
|
|
1361
|
-
var i;
|
|
1362
|
-
var modifiers = [];
|
|
1363
|
-
|
|
1364
|
-
// take the keys from this pattern and figure out what the actual
|
|
1365
|
-
// pattern is all about
|
|
1366
|
-
keys = _keysFromString(combination);
|
|
1367
|
-
|
|
1368
|
-
for (i = 0; i < keys.length; ++i) {
|
|
1369
|
-
key = keys[i];
|
|
1370
|
-
|
|
1371
|
-
// normalize key names
|
|
1372
|
-
if (_SPECIAL_ALIASES[key]) {
|
|
1373
|
-
key = _SPECIAL_ALIASES[key];
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
// if this is not a keypress event then we should
|
|
1377
|
-
// be smart about using shift keys
|
|
1378
|
-
// this will only work for US keyboards however
|
|
1379
|
-
if (action && action != 'keypress' && _SHIFT_MAP[key]) {
|
|
1380
|
-
key = _SHIFT_MAP[key];
|
|
1381
|
-
modifiers.push('shift');
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
// if this key is a modifier then add it to the list of modifiers
|
|
1385
|
-
if (_isModifier(key)) {
|
|
1386
|
-
modifiers.push(key);
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
// depending on what the key combination is
|
|
1391
|
-
// we will try to pick the best event for it
|
|
1392
|
-
action = _pickBestAction(key, modifiers, action);
|
|
1393
|
-
|
|
1394
|
-
return {
|
|
1395
|
-
key: key,
|
|
1396
|
-
modifiers: modifiers,
|
|
1397
|
-
action: action
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
function _belongsTo(element, ancestor) {
|
|
1402
|
-
if (element === null || element === document) {
|
|
1403
|
-
return false;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
if (element === ancestor) {
|
|
1407
|
-
return true;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
return _belongsTo(element.parentNode, ancestor);
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
function Mousetrap(targetElement) {
|
|
1414
|
-
var self = this;
|
|
1415
|
-
|
|
1416
|
-
targetElement = targetElement || document;
|
|
1417
|
-
|
|
1418
|
-
if (!(self instanceof Mousetrap)) {
|
|
1419
|
-
return new Mousetrap(targetElement);
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
/**
|
|
1423
|
-
* element to attach key events to
|
|
1424
|
-
*
|
|
1425
|
-
* @type {Element}
|
|
1426
|
-
*/
|
|
1427
|
-
self.target = targetElement;
|
|
1428
|
-
|
|
1429
|
-
/**
|
|
1430
|
-
* a list of all the callbacks setup via Mousetrap.bind()
|
|
1431
|
-
*
|
|
1432
|
-
* @type {Object}
|
|
1433
|
-
*/
|
|
1434
|
-
self._callbacks = {};
|
|
1435
|
-
|
|
1436
|
-
/**
|
|
1437
|
-
* direct map of string combinations to callbacks used for trigger()
|
|
1438
|
-
*
|
|
1439
|
-
* @type {Object}
|
|
1440
|
-
*/
|
|
1441
|
-
self._directMap = {};
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
* keeps track of what level each sequence is at since multiple
|
|
1445
|
-
* sequences can start out with the same sequence
|
|
1446
|
-
*
|
|
1447
|
-
* @type {Object}
|
|
1448
|
-
*/
|
|
1449
|
-
var _sequenceLevels = {};
|
|
1450
|
-
|
|
1451
|
-
/**
|
|
1452
|
-
* variable to store the setTimeout call
|
|
1453
|
-
*
|
|
1454
|
-
* @type {null|number}
|
|
1455
|
-
*/
|
|
1456
|
-
var _resetTimer;
|
|
1457
|
-
|
|
1458
|
-
/**
|
|
1459
|
-
* temporary state where we will ignore the next keyup
|
|
1460
|
-
*
|
|
1461
|
-
* @type {boolean|string}
|
|
1462
|
-
*/
|
|
1463
|
-
var _ignoreNextKeyup = false;
|
|
1464
|
-
|
|
1465
|
-
/**
|
|
1466
|
-
* temporary state where we will ignore the next keypress
|
|
1467
|
-
*
|
|
1468
|
-
* @type {boolean}
|
|
1469
|
-
*/
|
|
1470
|
-
var _ignoreNextKeypress = false;
|
|
1471
|
-
|
|
1472
|
-
/**
|
|
1473
|
-
* are we currently inside of a sequence?
|
|
1474
|
-
* type of action ("keyup" or "keydown" or "keypress") or false
|
|
1475
|
-
*
|
|
1476
|
-
* @type {boolean|string}
|
|
1477
|
-
*/
|
|
1478
|
-
var _nextExpectedAction = false;
|
|
1479
|
-
|
|
1480
|
-
/**
|
|
1481
|
-
* resets all sequence counters except for the ones passed in
|
|
1482
|
-
*
|
|
1483
|
-
* @param {Object} doNotReset
|
|
1484
|
-
* @returns void
|
|
1485
|
-
*/
|
|
1486
|
-
function _resetSequences(doNotReset) {
|
|
1487
|
-
doNotReset = doNotReset || {};
|
|
1488
|
-
|
|
1489
|
-
var activeSequences = false,
|
|
1490
|
-
key;
|
|
1491
|
-
|
|
1492
|
-
for (key in _sequenceLevels) {
|
|
1493
|
-
if (doNotReset[key]) {
|
|
1494
|
-
activeSequences = true;
|
|
1495
|
-
continue;
|
|
1496
|
-
}
|
|
1497
|
-
_sequenceLevels[key] = 0;
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
if (!activeSequences) {
|
|
1501
|
-
_nextExpectedAction = false;
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* finds all callbacks that match based on the keycode, modifiers,
|
|
1507
|
-
* and action
|
|
1508
|
-
*
|
|
1509
|
-
* @param {string} character
|
|
1510
|
-
* @param {Array} modifiers
|
|
1511
|
-
* @param {Event|Object} e
|
|
1512
|
-
* @param {string=} sequenceName - name of the sequence we are looking for
|
|
1513
|
-
* @param {string=} combination
|
|
1514
|
-
* @param {number=} level
|
|
1515
|
-
* @returns {Array}
|
|
1516
|
-
*/
|
|
1517
|
-
function _getMatches(character, modifiers, e, sequenceName, combination, level) {
|
|
1518
|
-
var i;
|
|
1519
|
-
var callback;
|
|
1520
|
-
var matches = [];
|
|
1521
|
-
var action = e.type;
|
|
1522
|
-
|
|
1523
|
-
// if there are no events related to this keycode
|
|
1524
|
-
if (!self._callbacks[character]) {
|
|
1525
|
-
return [];
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
// if a modifier key is coming up on its own we should allow it
|
|
1529
|
-
if (action == 'keyup' && _isModifier(character)) {
|
|
1530
|
-
modifiers = [character];
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
// loop through all callbacks for the key that was pressed
|
|
1534
|
-
// and see if any of them match
|
|
1535
|
-
for (i = 0; i < self._callbacks[character].length; ++i) {
|
|
1536
|
-
callback = self._callbacks[character][i];
|
|
1537
|
-
|
|
1538
|
-
// if a sequence name is not specified, but this is a sequence at
|
|
1539
|
-
// the wrong level then move onto the next match
|
|
1540
|
-
if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
|
|
1541
|
-
continue;
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
// if the action we are looking for doesn't match the action we got
|
|
1545
|
-
// then we should keep going
|
|
1546
|
-
if (action != callback.action) {
|
|
1547
|
-
continue;
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
// if this is a keypress event and the meta key and control key
|
|
1551
|
-
// are not pressed that means that we need to only look at the
|
|
1552
|
-
// character, otherwise check the modifiers as well
|
|
1553
|
-
//
|
|
1554
|
-
// chrome will not fire a keypress if meta or control is down
|
|
1555
|
-
// safari will fire a keypress if meta or meta+shift is down
|
|
1556
|
-
// firefox will fire a keypress if meta or control is down
|
|
1557
|
-
if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
|
|
1558
|
-
|
|
1559
|
-
// when you bind a combination or sequence a second time it
|
|
1560
|
-
// should overwrite the first one. if a sequenceName or
|
|
1561
|
-
// combination is specified in this call it does just that
|
|
1562
|
-
//
|
|
1563
|
-
// @todo make deleting its own method?
|
|
1564
|
-
var deleteCombo = !sequenceName && callback.combo == combination;
|
|
1565
|
-
var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
|
|
1566
|
-
if (deleteCombo || deleteSequence) {
|
|
1567
|
-
self._callbacks[character].splice(i, 1);
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
matches.push(callback);
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
return matches;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* actually calls the callback function
|
|
1579
|
-
*
|
|
1580
|
-
* if your callback function returns false this will use the jquery
|
|
1581
|
-
* convention - prevent default and stop propogation on the event
|
|
1582
|
-
*
|
|
1583
|
-
* @param {Function} callback
|
|
1584
|
-
* @param {Event} e
|
|
1585
|
-
* @returns void
|
|
1586
|
-
*/
|
|
1587
|
-
function _fireCallback(callback, e, combo, sequence) {
|
|
1588
|
-
|
|
1589
|
-
// if this event should not happen stop here
|
|
1590
|
-
if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
if (callback(e, combo) === false) {
|
|
1595
|
-
_preventDefault(e);
|
|
1596
|
-
_stopPropagation(e);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* handles a character key event
|
|
1602
|
-
*
|
|
1603
|
-
* @param {string} character
|
|
1604
|
-
* @param {Array} modifiers
|
|
1605
|
-
* @param {Event} e
|
|
1606
|
-
* @returns void
|
|
1607
|
-
*/
|
|
1608
|
-
self._handleKey = function(character, modifiers, e) {
|
|
1609
|
-
var callbacks = _getMatches(character, modifiers, e);
|
|
1610
|
-
var i;
|
|
1611
|
-
var doNotReset = {};
|
|
1612
|
-
var maxLevel = 0;
|
|
1613
|
-
var processedSequenceCallback = false;
|
|
1614
|
-
|
|
1615
|
-
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
|
|
1616
|
-
for (i = 0; i < callbacks.length; ++i) {
|
|
1617
|
-
if (callbacks[i].seq) {
|
|
1618
|
-
maxLevel = Math.max(maxLevel, callbacks[i].level);
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
// loop through matching callbacks for this key event
|
|
1623
|
-
for (i = 0; i < callbacks.length; ++i) {
|
|
1624
|
-
|
|
1625
|
-
// fire for all sequence callbacks
|
|
1626
|
-
// this is because if for example you have multiple sequences
|
|
1627
|
-
// bound such as "g i" and "g t" they both need to fire the
|
|
1628
|
-
// callback for matching g cause otherwise you can only ever
|
|
1629
|
-
// match the first one
|
|
1630
|
-
if (callbacks[i].seq) {
|
|
1631
|
-
|
|
1632
|
-
// only fire callbacks for the maxLevel to prevent
|
|
1633
|
-
// subsequences from also firing
|
|
1634
|
-
//
|
|
1635
|
-
// for example 'a option b' should not cause 'option b' to fire
|
|
1636
|
-
// even though 'option b' is part of the other sequence
|
|
1637
|
-
//
|
|
1638
|
-
// any sequences that do not match here will be discarded
|
|
1639
|
-
// below by the _resetSequences call
|
|
1640
|
-
if (callbacks[i].level != maxLevel) {
|
|
1641
|
-
continue;
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
processedSequenceCallback = true;
|
|
1645
|
-
|
|
1646
|
-
// keep a list of which sequences were matches for later
|
|
1647
|
-
doNotReset[callbacks[i].seq] = 1;
|
|
1648
|
-
_fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
|
|
1649
|
-
continue;
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
// if there were no sequence matches but we are still here
|
|
1653
|
-
// that means this is a regular match so we should fire that
|
|
1654
|
-
if (!processedSequenceCallback) {
|
|
1655
|
-
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
// if the key you pressed matches the type of sequence without
|
|
1660
|
-
// being a modifier (ie "keyup" or "keypress") then we should
|
|
1661
|
-
// reset all sequences that were not matched by this event
|
|
1662
|
-
//
|
|
1663
|
-
// this is so, for example, if you have the sequence "h a t" and you
|
|
1664
|
-
// type "h e a r t" it does not match. in this case the "e" will
|
|
1665
|
-
// cause the sequence to reset
|
|
1666
|
-
//
|
|
1667
|
-
// modifier keys are ignored because you can have a sequence
|
|
1668
|
-
// that contains modifiers such as "enter ctrl+space" and in most
|
|
1669
|
-
// cases the modifier key will be pressed before the next key
|
|
1670
|
-
//
|
|
1671
|
-
// also if you have a sequence such as "ctrl+b a" then pressing the
|
|
1672
|
-
// "b" key will trigger a "keypress" and a "keydown"
|
|
1673
|
-
//
|
|
1674
|
-
// the "keydown" is expected when there is a modifier, but the
|
|
1675
|
-
// "keypress" ends up matching the _nextExpectedAction since it occurs
|
|
1676
|
-
// after and that causes the sequence to reset
|
|
1677
|
-
//
|
|
1678
|
-
// we ignore keypresses in a sequence that directly follow a keydown
|
|
1679
|
-
// for the same character
|
|
1680
|
-
var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
|
|
1681
|
-
if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
|
|
1682
|
-
_resetSequences(doNotReset);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
_ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
/**
|
|
1689
|
-
* handles a keydown event
|
|
1690
|
-
*
|
|
1691
|
-
* @param {Event} e
|
|
1692
|
-
* @returns void
|
|
1693
|
-
*/
|
|
1694
|
-
function _handleKeyEvent(e) {
|
|
1695
|
-
|
|
1696
|
-
// normalize e.which for key events
|
|
1697
|
-
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
|
|
1698
|
-
if (typeof e.which !== 'number') {
|
|
1699
|
-
e.which = e.keyCode;
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
var character = _characterFromEvent(e);
|
|
1703
|
-
|
|
1704
|
-
// no character found then stop
|
|
1705
|
-
if (!character) {
|
|
1706
|
-
return;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
// need to use === for the character check because the character can be 0
|
|
1710
|
-
if (e.type == 'keyup' && _ignoreNextKeyup === character) {
|
|
1711
|
-
_ignoreNextKeyup = false;
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
self.handleKey(character, _eventModifiers(e), e);
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
/**
|
|
1719
|
-
* called to set a 1 second timeout on the specified sequence
|
|
1720
|
-
*
|
|
1721
|
-
* this is so after each key press in the sequence you have 1 second
|
|
1722
|
-
* to press the next key before you have to start over
|
|
1723
|
-
*
|
|
1724
|
-
* @returns void
|
|
1725
|
-
*/
|
|
1726
|
-
function _resetSequenceTimer() {
|
|
1727
|
-
clearTimeout(_resetTimer);
|
|
1728
|
-
_resetTimer = setTimeout(_resetSequences, 1000);
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
/**
|
|
1732
|
-
* binds a key sequence to an event
|
|
1733
|
-
*
|
|
1734
|
-
* @param {string} combo - combo specified in bind call
|
|
1735
|
-
* @param {Array} keys
|
|
1736
|
-
* @param {Function} callback
|
|
1737
|
-
* @param {string=} action
|
|
1738
|
-
* @returns void
|
|
1739
|
-
*/
|
|
1740
|
-
function _bindSequence(combo, keys, callback, action) {
|
|
1741
|
-
|
|
1742
|
-
// start off by adding a sequence level record for this combination
|
|
1743
|
-
// and setting the level to 0
|
|
1744
|
-
_sequenceLevels[combo] = 0;
|
|
1745
|
-
|
|
1746
|
-
/**
|
|
1747
|
-
* callback to increase the sequence level for this sequence and reset
|
|
1748
|
-
* all other sequences that were active
|
|
1749
|
-
*
|
|
1750
|
-
* @param {string} nextAction
|
|
1751
|
-
* @returns {Function}
|
|
1752
|
-
*/
|
|
1753
|
-
function _increaseSequence(nextAction) {
|
|
1754
|
-
return function() {
|
|
1755
|
-
_nextExpectedAction = nextAction;
|
|
1756
|
-
++_sequenceLevels[combo];
|
|
1757
|
-
_resetSequenceTimer();
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
* wraps the specified callback inside of another function in order
|
|
1763
|
-
* to reset all sequence counters as soon as this sequence is done
|
|
1764
|
-
*
|
|
1765
|
-
* @param {Event} e
|
|
1766
|
-
* @returns void
|
|
1767
|
-
*/
|
|
1768
|
-
function _callbackAndReset(e) {
|
|
1769
|
-
_fireCallback(callback, e, combo);
|
|
1770
|
-
|
|
1771
|
-
// we should ignore the next key up if the action is key down
|
|
1772
|
-
// or keypress. this is so if you finish a sequence and
|
|
1773
|
-
// release the key the final key will not trigger a keyup
|
|
1774
|
-
if (action !== 'keyup') {
|
|
1775
|
-
_ignoreNextKeyup = _characterFromEvent(e);
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
// weird race condition if a sequence ends with the key
|
|
1779
|
-
// another sequence begins with
|
|
1780
|
-
setTimeout(_resetSequences, 10);
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
// loop through keys one at a time and bind the appropriate callback
|
|
1784
|
-
// function. for any key leading up to the final one it should
|
|
1785
|
-
// increase the sequence. after the final, it should reset all sequences
|
|
1786
|
-
//
|
|
1787
|
-
// if an action is specified in the original bind call then that will
|
|
1788
|
-
// be used throughout. otherwise we will pass the action that the
|
|
1789
|
-
// next key in the sequence should match. this allows a sequence
|
|
1790
|
-
// to mix and match keypress and keydown events depending on which
|
|
1791
|
-
// ones are better suited to the key provided
|
|
1792
|
-
for (var i = 0; i < keys.length; ++i) {
|
|
1793
|
-
var isFinal = i + 1 === keys.length;
|
|
1794
|
-
var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
|
|
1795
|
-
_bindSingle(keys[i], wrappedCallback, action, combo, i);
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
/**
|
|
1800
|
-
* binds a single keyboard combination
|
|
1801
|
-
*
|
|
1802
|
-
* @param {string} combination
|
|
1803
|
-
* @param {Function} callback
|
|
1804
|
-
* @param {string=} action
|
|
1805
|
-
* @param {string=} sequenceName - name of sequence if part of sequence
|
|
1806
|
-
* @param {number=} level - what part of the sequence the command is
|
|
1807
|
-
* @returns void
|
|
1808
|
-
*/
|
|
1809
|
-
function _bindSingle(combination, callback, action, sequenceName, level) {
|
|
1810
|
-
|
|
1811
|
-
// store a direct mapped reference for use with Mousetrap.trigger
|
|
1812
|
-
self._directMap[combination + ':' + action] = callback;
|
|
1813
|
-
|
|
1814
|
-
// make sure multiple spaces in a row become a single space
|
|
1815
|
-
combination = combination.replace(/\s+/g, ' ');
|
|
1816
|
-
|
|
1817
|
-
var sequence = combination.split(' ');
|
|
1818
|
-
var info;
|
|
1819
|
-
|
|
1820
|
-
// if this pattern is a sequence of keys then run through this method
|
|
1821
|
-
// to reprocess each pattern one key at a time
|
|
1822
|
-
if (sequence.length > 1) {
|
|
1823
|
-
_bindSequence(combination, sequence, callback, action);
|
|
1824
|
-
return;
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
info = _getKeyInfo(combination, action);
|
|
1828
|
-
|
|
1829
|
-
// make sure to initialize array if this is the first time
|
|
1830
|
-
// a callback is added for this key
|
|
1831
|
-
self._callbacks[info.key] = self._callbacks[info.key] || [];
|
|
1832
|
-
|
|
1833
|
-
// remove an existing match if there is one
|
|
1834
|
-
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
|
|
1835
|
-
|
|
1836
|
-
// add this call back to the array
|
|
1837
|
-
// if it is a sequence put it at the beginning
|
|
1838
|
-
// if not put it at the end
|
|
1839
|
-
//
|
|
1840
|
-
// this is important because the way these are processed expects
|
|
1841
|
-
// the sequence ones to come first
|
|
1842
|
-
self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
|
|
1843
|
-
callback: callback,
|
|
1844
|
-
modifiers: info.modifiers,
|
|
1845
|
-
action: info.action,
|
|
1846
|
-
seq: sequenceName,
|
|
1847
|
-
level: level,
|
|
1848
|
-
combo: combination
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
/**
|
|
1853
|
-
* binds multiple combinations to the same callback
|
|
1854
|
-
*
|
|
1855
|
-
* @param {Array} combinations
|
|
1856
|
-
* @param {Function} callback
|
|
1857
|
-
* @param {string|undefined} action
|
|
1858
|
-
* @returns void
|
|
1859
|
-
*/
|
|
1860
|
-
self._bindMultiple = function(combinations, callback, action) {
|
|
1861
|
-
for (var i = 0; i < combinations.length; ++i) {
|
|
1862
|
-
_bindSingle(combinations[i], callback, action);
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
|
|
1866
|
-
// start!
|
|
1867
|
-
_addEvent(targetElement, 'keypress', _handleKeyEvent);
|
|
1868
|
-
_addEvent(targetElement, 'keydown', _handleKeyEvent);
|
|
1869
|
-
_addEvent(targetElement, 'keyup', _handleKeyEvent);
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
/**
|
|
1873
|
-
* binds an event to mousetrap
|
|
1874
|
-
*
|
|
1875
|
-
* can be a single key, a combination of keys separated with +,
|
|
1876
|
-
* an array of keys, or a sequence of keys separated by spaces
|
|
1877
|
-
*
|
|
1878
|
-
* be sure to list the modifier keys first to make sure that the
|
|
1879
|
-
* correct key ends up getting bound (the last key in the pattern)
|
|
1880
|
-
*
|
|
1881
|
-
* @param {string|Array} keys
|
|
1882
|
-
* @param {Function} callback
|
|
1883
|
-
* @param {string=} action - 'keypress', 'keydown', or 'keyup'
|
|
1884
|
-
* @returns void
|
|
1885
|
-
*/
|
|
1886
|
-
Mousetrap.prototype.bind = function(keys, callback, action) {
|
|
1887
|
-
var self = this;
|
|
1888
|
-
keys = keys instanceof Array ? keys : [keys];
|
|
1889
|
-
self._bindMultiple.call(self, keys, callback, action);
|
|
1890
|
-
return self;
|
|
1891
|
-
};
|
|
1892
|
-
|
|
1893
|
-
/**
|
|
1894
|
-
* unbinds an event to mousetrap
|
|
1895
|
-
*
|
|
1896
|
-
* the unbinding sets the callback function of the specified key combo
|
|
1897
|
-
* to an empty function and deletes the corresponding key in the
|
|
1898
|
-
* _directMap dict.
|
|
1899
|
-
*
|
|
1900
|
-
* TODO: actually remove this from the _callbacks dictionary instead
|
|
1901
|
-
* of binding an empty function
|
|
1902
|
-
*
|
|
1903
|
-
* the keycombo+action has to be exactly the same as
|
|
1904
|
-
* it was defined in the bind method
|
|
1905
|
-
*
|
|
1906
|
-
* @param {string|Array} keys
|
|
1907
|
-
* @param {string} action
|
|
1908
|
-
* @returns void
|
|
1909
|
-
*/
|
|
1910
|
-
Mousetrap.prototype.unbind = function(keys, action) {
|
|
1911
|
-
var self = this;
|
|
1912
|
-
return self.bind.call(self, keys, function() {}, action);
|
|
1913
|
-
};
|
|
1914
|
-
|
|
1915
|
-
/**
|
|
1916
|
-
* triggers an event that has already been bound
|
|
1917
|
-
*
|
|
1918
|
-
* @param {string} keys
|
|
1919
|
-
* @param {string=} action
|
|
1920
|
-
* @returns void
|
|
1921
|
-
*/
|
|
1922
|
-
Mousetrap.prototype.trigger = function(keys, action) {
|
|
1923
|
-
var self = this;
|
|
1924
|
-
if (self._directMap[keys + ':' + action]) {
|
|
1925
|
-
self._directMap[keys + ':' + action]({}, keys);
|
|
1926
|
-
}
|
|
1927
|
-
return self;
|
|
1928
|
-
};
|
|
1929
|
-
|
|
1930
|
-
/**
|
|
1931
|
-
* resets the library back to its initial state. this is useful
|
|
1932
|
-
* if you want to clear out the current keyboard shortcuts and bind
|
|
1933
|
-
* new ones - for example if you switch to another page
|
|
1934
|
-
*
|
|
1935
|
-
* @returns void
|
|
1936
|
-
*/
|
|
1937
|
-
Mousetrap.prototype.reset = function() {
|
|
1938
|
-
var self = this;
|
|
1939
|
-
self._callbacks = {};
|
|
1940
|
-
self._directMap = {};
|
|
1941
|
-
return self;
|
|
1942
|
-
};
|
|
1943
|
-
|
|
1944
|
-
/**
|
|
1945
|
-
* should we stop this event before firing off callbacks
|
|
1946
|
-
*
|
|
1947
|
-
* @param {Event} e
|
|
1948
|
-
* @param {Element} element
|
|
1949
|
-
* @return {boolean}
|
|
1950
|
-
*/
|
|
1951
|
-
Mousetrap.prototype.stopCallback = function(e, element) {
|
|
1952
|
-
var self = this;
|
|
1953
|
-
|
|
1954
|
-
// if the element has the class "mousetrap" then no need to stop
|
|
1955
|
-
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
|
|
1956
|
-
return false;
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
if (_belongsTo(element, self.target)) {
|
|
1960
|
-
return false;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
// Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
|
|
1964
|
-
// not the initial event target in the shadow tree. Note that not all events cross the
|
|
1965
|
-
// shadow boundary.
|
|
1966
|
-
// For shadow trees with `mode: 'open'`, the initial event target is the first element in
|
|
1967
|
-
// the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
|
|
1968
|
-
// target cannot be obtained.
|
|
1969
|
-
if ('composedPath' in e && typeof e.composedPath === 'function') {
|
|
1970
|
-
// For open shadow trees, update `element` so that the following check works.
|
|
1971
|
-
var initialEventTarget = e.composedPath()[0];
|
|
1972
|
-
if (initialEventTarget !== e.target) {
|
|
1973
|
-
element = initialEventTarget;
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
// stop for input, select, and textarea
|
|
1978
|
-
return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
|
|
1979
|
-
};
|
|
1980
|
-
|
|
1981
|
-
/**
|
|
1982
|
-
* exposes _handleKey publicly so it can be overwritten by extensions
|
|
1983
|
-
*/
|
|
1984
|
-
Mousetrap.prototype.handleKey = function() {
|
|
1985
|
-
var self = this;
|
|
1986
|
-
return self._handleKey.apply(self, arguments);
|
|
1987
|
-
};
|
|
1988
|
-
|
|
1989
|
-
/**
|
|
1990
|
-
* allow custom key mappings
|
|
1991
|
-
*/
|
|
1992
|
-
Mousetrap.addKeycodes = function(object) {
|
|
1993
|
-
for (var key in object) {
|
|
1994
|
-
if (object.hasOwnProperty(key)) {
|
|
1995
|
-
_MAP[key] = object[key];
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
_REVERSE_MAP = null;
|
|
1999
|
-
};
|
|
2000
|
-
|
|
2001
|
-
/**
|
|
2002
|
-
* Init the global mousetrap functions
|
|
2003
|
-
*
|
|
2004
|
-
* This method is needed to allow the global mousetrap functions to work
|
|
2005
|
-
* now that mousetrap is a constructor function.
|
|
2006
|
-
*/
|
|
2007
|
-
Mousetrap.init = function() {
|
|
2008
|
-
var documentMousetrap = Mousetrap(document);
|
|
2009
|
-
for (var method in documentMousetrap) {
|
|
2010
|
-
if (method.charAt(0) !== '_') {
|
|
2011
|
-
Mousetrap[method] = (function(method) {
|
|
2012
|
-
return function() {
|
|
2013
|
-
return documentMousetrap[method].apply(documentMousetrap, arguments);
|
|
2014
|
-
};
|
|
2015
|
-
} (method));
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
};
|
|
2019
|
-
|
|
2020
|
-
Mousetrap.init();
|
|
2021
|
-
|
|
2022
|
-
// expose mousetrap to the global object
|
|
2023
|
-
window.Mousetrap = Mousetrap;
|
|
2024
|
-
|
|
2025
|
-
// expose as a common js module
|
|
2026
|
-
if (module.exports) {
|
|
2027
|
-
module.exports = Mousetrap;
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
// expose mousetrap as an AMD module
|
|
2031
|
-
if (typeof undefined$1 === 'function' && undefined$1.amd) {
|
|
2032
|
-
undefined$1(function() {
|
|
2033
|
-
return Mousetrap;
|
|
2034
|
-
});
|
|
2035
|
-
}
|
|
2036
|
-
}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
|
|
2037
|
-
} (mousetrap));
|
|
2038
|
-
|
|
2039
|
-
var Mousetrap$1 = mousetrap.exports;
|
|
2040
|
-
|
|
2041
|
-
/**
|
|
2042
|
-
* adds a bindGlobal method to Mousetrap that allows you to
|
|
2043
|
-
* bind specific keyboard shortcuts that will still work
|
|
2044
|
-
* inside a text input field
|
|
2045
|
-
*
|
|
2046
|
-
* usage:
|
|
2047
|
-
* Mousetrap.bindGlobal('ctrl+s', _saveChanges);
|
|
2048
|
-
*/
|
|
2049
|
-
/* global Mousetrap:true */
|
|
2050
|
-
(function(Mousetrap) {
|
|
2051
|
-
var _globalCallbacks = {};
|
|
2052
|
-
var _originalStopCallback = Mousetrap.prototype.stopCallback;
|
|
2053
|
-
|
|
2054
|
-
Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) {
|
|
2055
|
-
var self = this;
|
|
2056
|
-
|
|
2057
|
-
if (self.paused) {
|
|
2058
|
-
return true;
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
|
|
2062
|
-
return false;
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
return _originalStopCallback.call(self, e, element, combo);
|
|
2066
|
-
};
|
|
2067
|
-
|
|
2068
|
-
Mousetrap.prototype.bindGlobal = function(keys, callback, action) {
|
|
2069
|
-
var self = this;
|
|
2070
|
-
self.bind(keys, callback, action);
|
|
2071
|
-
|
|
2072
|
-
if (keys instanceof Array) {
|
|
2073
|
-
for (var i = 0; i < keys.length; i++) {
|
|
2074
|
-
_globalCallbacks[keys[i]] = true;
|
|
2075
|
-
}
|
|
2076
|
-
return;
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
_globalCallbacks[keys] = true;
|
|
2080
|
-
};
|
|
2081
|
-
|
|
2082
|
-
Mousetrap.prototype.unbindGlobal = function(keys, action) {
|
|
2083
|
-
var self = this;
|
|
2084
|
-
self.unbind(keys, action);
|
|
2085
|
-
|
|
2086
|
-
if (keys instanceof Array) {
|
|
2087
|
-
for (var i = 0; i < keys.length; i++) {
|
|
2088
|
-
_globalCallbacks[keys[i]] = false;
|
|
2089
|
-
}
|
|
2090
|
-
return;
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
_globalCallbacks[keys] = false;
|
|
2094
|
-
};
|
|
2095
|
-
|
|
2096
|
-
Mousetrap.init();
|
|
2097
|
-
}) (Mousetrap);
|
|
2098
|
-
|
|
2099
|
-
var MODES = {
|
|
2100
|
-
"default": "default",
|
|
2101
|
-
global: "global",
|
|
2102
|
-
scoped: "scoped"
|
|
2103
|
-
};
|
|
2104
|
-
var DEFAULT_CONFIG = {
|
|
2105
|
-
mode: MODES["default"],
|
|
2106
|
-
unbindOnUnmount: true,
|
|
2107
|
-
enabled: true
|
|
2108
|
-
};
|
|
2109
|
-
var MAC_TO_WINDOWS_KEYS_MAP = {
|
|
2110
|
-
option: "alt",
|
|
2111
|
-
command: "ctrl",
|
|
2112
|
-
"return": "enter",
|
|
2113
|
-
"delete": "backspace"
|
|
2114
|
-
};
|
|
2115
|
-
var OS = {
|
|
2116
|
-
mac: "OS X",
|
|
2117
|
-
windows: "Windows"
|
|
2118
|
-
};
|
|
2119
|
-
var KEY_NAMES = {
|
|
2120
|
-
"delete": "delete",
|
|
2121
|
-
backspace: "backspace"
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
var platform$1 = {exports: {}};
|
|
2125
|
-
|
|
2126
|
-
/*!
|
|
2127
|
-
* Platform.js v1.3.6
|
|
2128
|
-
* Copyright 2014-2020 Benjamin Tan
|
|
2129
|
-
* Copyright 2011-2013 John-David Dalton
|
|
2130
|
-
* Available under MIT license
|
|
2131
|
-
*/
|
|
2132
|
-
|
|
2133
|
-
(function (module, exports) {
|
|
2134
|
-
(function() {
|
|
2135
|
-
|
|
2136
|
-
/** Used to determine if values are of the language type `Object`. */
|
|
2137
|
-
var objectTypes = {
|
|
2138
|
-
'function': true,
|
|
2139
|
-
'object': true
|
|
2140
|
-
};
|
|
2141
|
-
|
|
2142
|
-
/** Used as a reference to the global object. */
|
|
2143
|
-
var root = (objectTypes[typeof window] && window) || this;
|
|
2144
|
-
|
|
2145
|
-
/** Detect free variable `exports`. */
|
|
2146
|
-
var freeExports = exports;
|
|
2147
|
-
|
|
2148
|
-
/** Detect free variable `module`. */
|
|
2149
|
-
var freeModule = module && !module.nodeType && module;
|
|
2150
|
-
|
|
2151
|
-
/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
|
|
2152
|
-
var freeGlobal = freeExports && freeModule && typeof commonjsGlobal == 'object' && commonjsGlobal;
|
|
2153
|
-
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
|
|
2154
|
-
root = freeGlobal;
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
/**
|
|
2158
|
-
* Used as the maximum length of an array-like object.
|
|
2159
|
-
* See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
|
2160
|
-
* for more details.
|
|
2161
|
-
*/
|
|
2162
|
-
var maxSafeInteger = Math.pow(2, 53) - 1;
|
|
2163
|
-
|
|
2164
|
-
/** Regular expression to detect Opera. */
|
|
2165
|
-
var reOpera = /\bOpera/;
|
|
2166
|
-
|
|
2167
|
-
/** Used for native method references. */
|
|
2168
|
-
var objectProto = Object.prototype;
|
|
2169
|
-
|
|
2170
|
-
/** Used to check for own properties of an object. */
|
|
2171
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2172
|
-
|
|
2173
|
-
/** Used to resolve the internal `[[Class]]` of values. */
|
|
2174
|
-
var toString = objectProto.toString;
|
|
2175
|
-
|
|
2176
|
-
/*--------------------------------------------------------------------------*/
|
|
2177
|
-
|
|
2178
|
-
/**
|
|
2179
|
-
* Capitalizes a string value.
|
|
2180
|
-
*
|
|
2181
|
-
* @private
|
|
2182
|
-
* @param {string} string The string to capitalize.
|
|
2183
|
-
* @returns {string} The capitalized string.
|
|
2184
|
-
*/
|
|
2185
|
-
function capitalize(string) {
|
|
2186
|
-
string = String(string);
|
|
2187
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
/**
|
|
2191
|
-
* A utility function to clean up the OS name.
|
|
2192
|
-
*
|
|
2193
|
-
* @private
|
|
2194
|
-
* @param {string} os The OS name to clean up.
|
|
2195
|
-
* @param {string} [pattern] A `RegExp` pattern matching the OS name.
|
|
2196
|
-
* @param {string} [label] A label for the OS.
|
|
2197
|
-
*/
|
|
2198
|
-
function cleanupOS(os, pattern, label) {
|
|
2199
|
-
// Platform tokens are defined at:
|
|
2200
|
-
// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
|
|
2201
|
-
// http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
|
|
2202
|
-
var data = {
|
|
2203
|
-
'10.0': '10',
|
|
2204
|
-
'6.4': '10 Technical Preview',
|
|
2205
|
-
'6.3': '8.1',
|
|
2206
|
-
'6.2': '8',
|
|
2207
|
-
'6.1': 'Server 2008 R2 / 7',
|
|
2208
|
-
'6.0': 'Server 2008 / Vista',
|
|
2209
|
-
'5.2': 'Server 2003 / XP 64-bit',
|
|
2210
|
-
'5.1': 'XP',
|
|
2211
|
-
'5.01': '2000 SP1',
|
|
2212
|
-
'5.0': '2000',
|
|
2213
|
-
'4.0': 'NT',
|
|
2214
|
-
'4.90': 'ME'
|
|
2215
|
-
};
|
|
2216
|
-
// Detect Windows version from platform tokens.
|
|
2217
|
-
if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
|
|
2218
|
-
(data = data[/[\d.]+$/.exec(os)])) {
|
|
2219
|
-
os = 'Windows ' + data;
|
|
2220
|
-
}
|
|
2221
|
-
// Correct character case and cleanup string.
|
|
2222
|
-
os = String(os);
|
|
2223
|
-
|
|
2224
|
-
if (pattern && label) {
|
|
2225
|
-
os = os.replace(RegExp(pattern, 'i'), label);
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
os = format(
|
|
2229
|
-
os.replace(/ ce$/i, ' CE')
|
|
2230
|
-
.replace(/\bhpw/i, 'web')
|
|
2231
|
-
.replace(/\bMacintosh\b/, 'Mac OS')
|
|
2232
|
-
.replace(/_PowerPC\b/i, ' OS')
|
|
2233
|
-
.replace(/\b(OS X) [^ \d]+/i, '$1')
|
|
2234
|
-
.replace(/\bMac (OS X)\b/, '$1')
|
|
2235
|
-
.replace(/\/(\d)/, ' $1')
|
|
2236
|
-
.replace(/_/g, '.')
|
|
2237
|
-
.replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
|
|
2238
|
-
.replace(/\bx86\.64\b/gi, 'x86_64')
|
|
2239
|
-
.replace(/\b(Windows Phone) OS\b/, '$1')
|
|
2240
|
-
.replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
|
|
2241
|
-
.split(' on ')[0]
|
|
2242
|
-
);
|
|
2243
|
-
|
|
2244
|
-
return os;
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
/**
|
|
2248
|
-
* An iteration utility for arrays and objects.
|
|
2249
|
-
*
|
|
2250
|
-
* @private
|
|
2251
|
-
* @param {Array|Object} object The object to iterate over.
|
|
2252
|
-
* @param {Function} callback The function called per iteration.
|
|
2253
|
-
*/
|
|
2254
|
-
function each(object, callback) {
|
|
2255
|
-
var index = -1,
|
|
2256
|
-
length = object ? object.length : 0;
|
|
2257
|
-
|
|
2258
|
-
if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
|
|
2259
|
-
while (++index < length) {
|
|
2260
|
-
callback(object[index], index, object);
|
|
2261
|
-
}
|
|
2262
|
-
} else {
|
|
2263
|
-
forOwn(object, callback);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
/**
|
|
2268
|
-
* Trim and conditionally capitalize string values.
|
|
2269
|
-
*
|
|
2270
|
-
* @private
|
|
2271
|
-
* @param {string} string The string to format.
|
|
2272
|
-
* @returns {string} The formatted string.
|
|
2273
|
-
*/
|
|
2274
|
-
function format(string) {
|
|
2275
|
-
string = trim(string);
|
|
2276
|
-
return /^(?:webOS|i(?:OS|P))/.test(string)
|
|
2277
|
-
? string
|
|
2278
|
-
: capitalize(string);
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
/**
|
|
2282
|
-
* Iterates over an object's own properties, executing the `callback` for each.
|
|
2283
|
-
*
|
|
2284
|
-
* @private
|
|
2285
|
-
* @param {Object} object The object to iterate over.
|
|
2286
|
-
* @param {Function} callback The function executed per own property.
|
|
2287
|
-
*/
|
|
2288
|
-
function forOwn(object, callback) {
|
|
2289
|
-
for (var key in object) {
|
|
2290
|
-
if (hasOwnProperty.call(object, key)) {
|
|
2291
|
-
callback(object[key], key, object);
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
/**
|
|
2297
|
-
* Gets the internal `[[Class]]` of a value.
|
|
2298
|
-
*
|
|
2299
|
-
* @private
|
|
2300
|
-
* @param {*} value The value.
|
|
2301
|
-
* @returns {string} The `[[Class]]`.
|
|
2302
|
-
*/
|
|
2303
|
-
function getClassOf(value) {
|
|
2304
|
-
return value == null
|
|
2305
|
-
? capitalize(value)
|
|
2306
|
-
: toString.call(value).slice(8, -1);
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
/**
|
|
2310
|
-
* Host objects can return type values that are different from their actual
|
|
2311
|
-
* data type. The objects we are concerned with usually return non-primitive
|
|
2312
|
-
* types of "object", "function", or "unknown".
|
|
2313
|
-
*
|
|
2314
|
-
* @private
|
|
2315
|
-
* @param {*} object The owner of the property.
|
|
2316
|
-
* @param {string} property The property to check.
|
|
2317
|
-
* @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
|
|
2318
|
-
*/
|
|
2319
|
-
function isHostType(object, property) {
|
|
2320
|
-
var type = object != null ? typeof object[property] : 'number';
|
|
2321
|
-
return !/^(?:boolean|number|string|undefined)$/.test(type) &&
|
|
2322
|
-
(type == 'object' ? !!object[property] : true);
|
|
2323
|
-
}
|
|
2324
|
-
|
|
2325
|
-
/**
|
|
2326
|
-
* Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
|
|
2327
|
-
*
|
|
2328
|
-
* @private
|
|
2329
|
-
* @param {string} string The string to qualify.
|
|
2330
|
-
* @returns {string} The qualified string.
|
|
2331
|
-
*/
|
|
2332
|
-
function qualify(string) {
|
|
2333
|
-
return String(string).replace(/([ -])(?!$)/g, '$1?');
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
/**
|
|
2337
|
-
* A bare-bones `Array#reduce` like utility function.
|
|
2338
|
-
*
|
|
2339
|
-
* @private
|
|
2340
|
-
* @param {Array} array The array to iterate over.
|
|
2341
|
-
* @param {Function} callback The function called per iteration.
|
|
2342
|
-
* @returns {*} The accumulated result.
|
|
2343
|
-
*/
|
|
2344
|
-
function reduce(array, callback) {
|
|
2345
|
-
var accumulator = null;
|
|
2346
|
-
each(array, function(value, index) {
|
|
2347
|
-
accumulator = callback(accumulator, value, index, array);
|
|
2348
|
-
});
|
|
2349
|
-
return accumulator;
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
/**
|
|
2353
|
-
* Removes leading and trailing whitespace from a string.
|
|
2354
|
-
*
|
|
2355
|
-
* @private
|
|
2356
|
-
* @param {string} string The string to trim.
|
|
2357
|
-
* @returns {string} The trimmed string.
|
|
2358
|
-
*/
|
|
2359
|
-
function trim(string) {
|
|
2360
|
-
return String(string).replace(/^ +| +$/g, '');
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
/*--------------------------------------------------------------------------*/
|
|
2364
|
-
|
|
2365
|
-
/**
|
|
2366
|
-
* Creates a new platform object.
|
|
2367
|
-
*
|
|
2368
|
-
* @memberOf platform
|
|
2369
|
-
* @param {Object|string} [ua=navigator.userAgent] The user agent string or
|
|
2370
|
-
* context object.
|
|
2371
|
-
* @returns {Object} A platform object.
|
|
2372
|
-
*/
|
|
2373
|
-
function parse(ua) {
|
|
2374
|
-
|
|
2375
|
-
/** The environment context object. */
|
|
2376
|
-
var context = root;
|
|
2377
|
-
|
|
2378
|
-
/** Used to flag when a custom context is provided. */
|
|
2379
|
-
var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
|
|
2380
|
-
|
|
2381
|
-
// Juggle arguments.
|
|
2382
|
-
if (isCustomContext) {
|
|
2383
|
-
context = ua;
|
|
2384
|
-
ua = null;
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
|
-
/** Browser navigator object. */
|
|
2388
|
-
var nav = context.navigator || {};
|
|
2389
|
-
|
|
2390
|
-
/** Browser user agent string. */
|
|
2391
|
-
var userAgent = nav.userAgent || '';
|
|
2392
|
-
|
|
2393
|
-
ua || (ua = userAgent);
|
|
2394
|
-
|
|
2395
|
-
/** Used to detect if browser is like Chrome. */
|
|
2396
|
-
var likeChrome = isCustomContext
|
|
2397
|
-
? !!nav.likeChrome
|
|
2398
|
-
: /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
|
|
2399
|
-
|
|
2400
|
-
/** Internal `[[Class]]` value shortcuts. */
|
|
2401
|
-
var objectClass = 'Object',
|
|
2402
|
-
airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
|
|
2403
|
-
enviroClass = isCustomContext ? objectClass : 'Environment',
|
|
2404
|
-
javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
|
|
2405
|
-
phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
|
|
2406
|
-
|
|
2407
|
-
/** Detect Java environments. */
|
|
2408
|
-
var java = /\bJava/.test(javaClass) && context.java;
|
|
2409
|
-
|
|
2410
|
-
/** Detect Rhino. */
|
|
2411
|
-
var rhino = java && getClassOf(context.environment) == enviroClass;
|
|
2412
|
-
|
|
2413
|
-
/** A character to represent alpha. */
|
|
2414
|
-
var alpha = java ? 'a' : '\u03b1';
|
|
2415
|
-
|
|
2416
|
-
/** A character to represent beta. */
|
|
2417
|
-
var beta = java ? 'b' : '\u03b2';
|
|
2418
|
-
|
|
2419
|
-
/** Browser document object. */
|
|
2420
|
-
var doc = context.document || {};
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
* Detect Opera browser (Presto-based).
|
|
2424
|
-
* http://www.howtocreate.co.uk/operaStuff/operaObject.html
|
|
2425
|
-
* http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
|
|
2426
|
-
*/
|
|
2427
|
-
var opera = context.operamini || context.opera;
|
|
2428
|
-
|
|
2429
|
-
/** Opera `[[Class]]`. */
|
|
2430
|
-
var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
|
|
2431
|
-
? operaClass
|
|
2432
|
-
: (opera = null);
|
|
2433
|
-
|
|
2434
|
-
/*------------------------------------------------------------------------*/
|
|
2435
|
-
|
|
2436
|
-
/** Temporary variable used over the script's lifetime. */
|
|
2437
|
-
var data;
|
|
2438
|
-
|
|
2439
|
-
/** The CPU architecture. */
|
|
2440
|
-
var arch = ua;
|
|
2441
|
-
|
|
2442
|
-
/** Platform description array. */
|
|
2443
|
-
var description = [];
|
|
2444
|
-
|
|
2445
|
-
/** Platform alpha/beta indicator. */
|
|
2446
|
-
var prerelease = null;
|
|
2447
|
-
|
|
2448
|
-
/** A flag to indicate that environment features should be used to resolve the platform. */
|
|
2449
|
-
var useFeatures = ua == userAgent;
|
|
2450
|
-
|
|
2451
|
-
/** The browser/environment version. */
|
|
2452
|
-
var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
|
|
2453
|
-
|
|
2454
|
-
/** A flag to indicate if the OS ends with "/ Version" */
|
|
2455
|
-
var isSpecialCasedOS;
|
|
2456
|
-
|
|
2457
|
-
/* Detectable layout engines (order is important). */
|
|
2458
|
-
var layout = getLayout([
|
|
2459
|
-
{ 'label': 'EdgeHTML', 'pattern': 'Edge' },
|
|
2460
|
-
'Trident',
|
|
2461
|
-
{ 'label': 'WebKit', 'pattern': 'AppleWebKit' },
|
|
2462
|
-
'iCab',
|
|
2463
|
-
'Presto',
|
|
2464
|
-
'NetFront',
|
|
2465
|
-
'Tasman',
|
|
2466
|
-
'KHTML',
|
|
2467
|
-
'Gecko'
|
|
2468
|
-
]);
|
|
2469
|
-
|
|
2470
|
-
/* Detectable browser names (order is important). */
|
|
2471
|
-
var name = getName([
|
|
2472
|
-
'Adobe AIR',
|
|
2473
|
-
'Arora',
|
|
2474
|
-
'Avant Browser',
|
|
2475
|
-
'Breach',
|
|
2476
|
-
'Camino',
|
|
2477
|
-
'Electron',
|
|
2478
|
-
'Epiphany',
|
|
2479
|
-
'Fennec',
|
|
2480
|
-
'Flock',
|
|
2481
|
-
'Galeon',
|
|
2482
|
-
'GreenBrowser',
|
|
2483
|
-
'iCab',
|
|
2484
|
-
'Iceweasel',
|
|
2485
|
-
'K-Meleon',
|
|
2486
|
-
'Konqueror',
|
|
2487
|
-
'Lunascape',
|
|
2488
|
-
'Maxthon',
|
|
2489
|
-
{ 'label': 'Microsoft Edge', 'pattern': '(?:Edge|Edg|EdgA|EdgiOS)' },
|
|
2490
|
-
'Midori',
|
|
2491
|
-
'Nook Browser',
|
|
2492
|
-
'PaleMoon',
|
|
2493
|
-
'PhantomJS',
|
|
2494
|
-
'Raven',
|
|
2495
|
-
'Rekonq',
|
|
2496
|
-
'RockMelt',
|
|
2497
|
-
{ 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
|
|
2498
|
-
'SeaMonkey',
|
|
2499
|
-
{ 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
|
|
2500
|
-
'Sleipnir',
|
|
2501
|
-
'SlimBrowser',
|
|
2502
|
-
{ 'label': 'SRWare Iron', 'pattern': 'Iron' },
|
|
2503
|
-
'Sunrise',
|
|
2504
|
-
'Swiftfox',
|
|
2505
|
-
'Vivaldi',
|
|
2506
|
-
'Waterfox',
|
|
2507
|
-
'WebPositive',
|
|
2508
|
-
{ 'label': 'Yandex Browser', 'pattern': 'YaBrowser' },
|
|
2509
|
-
{ 'label': 'UC Browser', 'pattern': 'UCBrowser' },
|
|
2510
|
-
'Opera Mini',
|
|
2511
|
-
{ 'label': 'Opera Mini', 'pattern': 'OPiOS' },
|
|
2512
|
-
'Opera',
|
|
2513
|
-
{ 'label': 'Opera', 'pattern': 'OPR' },
|
|
2514
|
-
'Chromium',
|
|
2515
|
-
'Chrome',
|
|
2516
|
-
{ 'label': 'Chrome', 'pattern': '(?:HeadlessChrome)' },
|
|
2517
|
-
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
|
|
2518
|
-
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
|
|
2519
|
-
{ 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
|
|
2520
|
-
{ 'label': 'IE', 'pattern': 'IEMobile' },
|
|
2521
|
-
{ 'label': 'IE', 'pattern': 'MSIE' },
|
|
2522
|
-
'Safari'
|
|
2523
|
-
]);
|
|
2524
|
-
|
|
2525
|
-
/* Detectable products (order is important). */
|
|
2526
|
-
var product = getProduct([
|
|
2527
|
-
{ 'label': 'BlackBerry', 'pattern': 'BB10' },
|
|
2528
|
-
'BlackBerry',
|
|
2529
|
-
{ 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
|
|
2530
|
-
{ 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
|
|
2531
|
-
{ 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
|
|
2532
|
-
{ 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
|
|
2533
|
-
{ 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
|
|
2534
|
-
{ 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
|
|
2535
|
-
{ 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
|
|
2536
|
-
{ 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
|
|
2537
|
-
{ 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
|
|
2538
|
-
'Google TV',
|
|
2539
|
-
'Lumia',
|
|
2540
|
-
'iPad',
|
|
2541
|
-
'iPod',
|
|
2542
|
-
'iPhone',
|
|
2543
|
-
'Kindle',
|
|
2544
|
-
{ 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
|
|
2545
|
-
'Nexus',
|
|
2546
|
-
'Nook',
|
|
2547
|
-
'PlayBook',
|
|
2548
|
-
'PlayStation Vita',
|
|
2549
|
-
'PlayStation',
|
|
2550
|
-
'TouchPad',
|
|
2551
|
-
'Transformer',
|
|
2552
|
-
{ 'label': 'Wii U', 'pattern': 'WiiU' },
|
|
2553
|
-
'Wii',
|
|
2554
|
-
'Xbox One',
|
|
2555
|
-
{ 'label': 'Xbox 360', 'pattern': 'Xbox' },
|
|
2556
|
-
'Xoom'
|
|
2557
|
-
]);
|
|
2558
|
-
|
|
2559
|
-
/* Detectable manufacturers. */
|
|
2560
|
-
var manufacturer = getManufacturer({
|
|
2561
|
-
'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
|
|
2562
|
-
'Alcatel': {},
|
|
2563
|
-
'Archos': {},
|
|
2564
|
-
'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
|
|
2565
|
-
'Asus': { 'Transformer': 1 },
|
|
2566
|
-
'Barnes & Noble': { 'Nook': 1 },
|
|
2567
|
-
'BlackBerry': { 'PlayBook': 1 },
|
|
2568
|
-
'Google': { 'Google TV': 1, 'Nexus': 1 },
|
|
2569
|
-
'HP': { 'TouchPad': 1 },
|
|
2570
|
-
'HTC': {},
|
|
2571
|
-
'Huawei': {},
|
|
2572
|
-
'Lenovo': {},
|
|
2573
|
-
'LG': {},
|
|
2574
|
-
'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
|
|
2575
|
-
'Motorola': { 'Xoom': 1 },
|
|
2576
|
-
'Nintendo': { 'Wii U': 1, 'Wii': 1 },
|
|
2577
|
-
'Nokia': { 'Lumia': 1 },
|
|
2578
|
-
'Oppo': {},
|
|
2579
|
-
'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
|
|
2580
|
-
'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 },
|
|
2581
|
-
'Xiaomi': { 'Mi': 1, 'Redmi': 1 }
|
|
2582
|
-
});
|
|
2583
|
-
|
|
2584
|
-
/* Detectable operating systems (order is important). */
|
|
2585
|
-
var os = getOS([
|
|
2586
|
-
'Windows Phone',
|
|
2587
|
-
'KaiOS',
|
|
2588
|
-
'Android',
|
|
2589
|
-
'CentOS',
|
|
2590
|
-
{ 'label': 'Chrome OS', 'pattern': 'CrOS' },
|
|
2591
|
-
'Debian',
|
|
2592
|
-
{ 'label': 'DragonFly BSD', 'pattern': 'DragonFly' },
|
|
2593
|
-
'Fedora',
|
|
2594
|
-
'FreeBSD',
|
|
2595
|
-
'Gentoo',
|
|
2596
|
-
'Haiku',
|
|
2597
|
-
'Kubuntu',
|
|
2598
|
-
'Linux Mint',
|
|
2599
|
-
'OpenBSD',
|
|
2600
|
-
'Red Hat',
|
|
2601
|
-
'SuSE',
|
|
2602
|
-
'Ubuntu',
|
|
2603
|
-
'Xubuntu',
|
|
2604
|
-
'Cygwin',
|
|
2605
|
-
'Symbian OS',
|
|
2606
|
-
'hpwOS',
|
|
2607
|
-
'webOS ',
|
|
2608
|
-
'webOS',
|
|
2609
|
-
'Tablet OS',
|
|
2610
|
-
'Tizen',
|
|
2611
|
-
'Linux',
|
|
2612
|
-
'Mac OS X',
|
|
2613
|
-
'Macintosh',
|
|
2614
|
-
'Mac',
|
|
2615
|
-
'Windows 98;',
|
|
2616
|
-
'Windows '
|
|
2617
|
-
]);
|
|
2618
|
-
|
|
2619
|
-
/*------------------------------------------------------------------------*/
|
|
2620
|
-
|
|
2621
|
-
/**
|
|
2622
|
-
* Picks the layout engine from an array of guesses.
|
|
2623
|
-
*
|
|
2624
|
-
* @private
|
|
2625
|
-
* @param {Array} guesses An array of guesses.
|
|
2626
|
-
* @returns {null|string} The detected layout engine.
|
|
2627
|
-
*/
|
|
2628
|
-
function getLayout(guesses) {
|
|
2629
|
-
return reduce(guesses, function(result, guess) {
|
|
2630
|
-
return result || RegExp('\\b' + (
|
|
2631
|
-
guess.pattern || qualify(guess)
|
|
2632
|
-
) + '\\b', 'i').exec(ua) && (guess.label || guess);
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
/**
|
|
2637
|
-
* Picks the manufacturer from an array of guesses.
|
|
2638
|
-
*
|
|
2639
|
-
* @private
|
|
2640
|
-
* @param {Array} guesses An object of guesses.
|
|
2641
|
-
* @returns {null|string} The detected manufacturer.
|
|
2642
|
-
*/
|
|
2643
|
-
function getManufacturer(guesses) {
|
|
2644
|
-
return reduce(guesses, function(result, value, key) {
|
|
2645
|
-
// Lookup the manufacturer by product or scan the UA for the manufacturer.
|
|
2646
|
-
return result || (
|
|
2647
|
-
value[product] ||
|
|
2648
|
-
value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
|
|
2649
|
-
RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
|
|
2650
|
-
) && key;
|
|
2651
|
-
});
|
|
2652
|
-
}
|
|
2653
|
-
|
|
2654
|
-
/**
|
|
2655
|
-
* Picks the browser name from an array of guesses.
|
|
2656
|
-
*
|
|
2657
|
-
* @private
|
|
2658
|
-
* @param {Array} guesses An array of guesses.
|
|
2659
|
-
* @returns {null|string} The detected browser name.
|
|
2660
|
-
*/
|
|
2661
|
-
function getName(guesses) {
|
|
2662
|
-
return reduce(guesses, function(result, guess) {
|
|
2663
|
-
return result || RegExp('\\b' + (
|
|
2664
|
-
guess.pattern || qualify(guess)
|
|
2665
|
-
) + '\\b', 'i').exec(ua) && (guess.label || guess);
|
|
2666
|
-
});
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
/**
|
|
2670
|
-
* Picks the OS name from an array of guesses.
|
|
2671
|
-
*
|
|
2672
|
-
* @private
|
|
2673
|
-
* @param {Array} guesses An array of guesses.
|
|
2674
|
-
* @returns {null|string} The detected OS name.
|
|
2675
|
-
*/
|
|
2676
|
-
function getOS(guesses) {
|
|
2677
|
-
return reduce(guesses, function(result, guess) {
|
|
2678
|
-
var pattern = guess.pattern || qualify(guess);
|
|
2679
|
-
if (!result && (result =
|
|
2680
|
-
RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
|
|
2681
|
-
)) {
|
|
2682
|
-
result = cleanupOS(result, pattern, guess.label || guess);
|
|
2683
|
-
}
|
|
2684
|
-
return result;
|
|
2685
|
-
});
|
|
2686
|
-
}
|
|
2687
|
-
|
|
2688
|
-
/**
|
|
2689
|
-
* Picks the product name from an array of guesses.
|
|
2690
|
-
*
|
|
2691
|
-
* @private
|
|
2692
|
-
* @param {Array} guesses An array of guesses.
|
|
2693
|
-
* @returns {null|string} The detected product name.
|
|
2694
|
-
*/
|
|
2695
|
-
function getProduct(guesses) {
|
|
2696
|
-
return reduce(guesses, function(result, guess) {
|
|
2697
|
-
var pattern = guess.pattern || qualify(guess);
|
|
2698
|
-
if (!result && (result =
|
|
2699
|
-
RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
|
|
2700
|
-
RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
|
|
2701
|
-
RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
|
|
2702
|
-
)) {
|
|
2703
|
-
// Split by forward slash and append product version if needed.
|
|
2704
|
-
if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
|
|
2705
|
-
result[0] += ' ' + result[1];
|
|
2706
|
-
}
|
|
2707
|
-
// Correct character case and cleanup string.
|
|
2708
|
-
guess = guess.label || guess;
|
|
2709
|
-
result = format(result[0]
|
|
2710
|
-
.replace(RegExp(pattern, 'i'), guess)
|
|
2711
|
-
.replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
|
|
2712
|
-
.replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
|
|
2713
|
-
}
|
|
2714
|
-
return result;
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
|
|
2718
|
-
/**
|
|
2719
|
-
* Resolves the version using an array of UA patterns.
|
|
2720
|
-
*
|
|
2721
|
-
* @private
|
|
2722
|
-
* @param {Array} patterns An array of UA patterns.
|
|
2723
|
-
* @returns {null|string} The detected version.
|
|
2724
|
-
*/
|
|
2725
|
-
function getVersion(patterns) {
|
|
2726
|
-
return reduce(patterns, function(result, pattern) {
|
|
2727
|
-
return result || (RegExp(pattern +
|
|
2728
|
-
'(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
|
|
2729
|
-
});
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
/**
|
|
2733
|
-
* Returns `platform.description` when the platform object is coerced to a string.
|
|
2734
|
-
*
|
|
2735
|
-
* @name toString
|
|
2736
|
-
* @memberOf platform
|
|
2737
|
-
* @returns {string} Returns `platform.description` if available, else an empty string.
|
|
2738
|
-
*/
|
|
2739
|
-
function toStringPlatform() {
|
|
2740
|
-
return this.description || '';
|
|
2741
|
-
}
|
|
2742
|
-
|
|
2743
|
-
/*------------------------------------------------------------------------*/
|
|
2744
|
-
|
|
2745
|
-
// Convert layout to an array so we can add extra details.
|
|
2746
|
-
layout && (layout = [layout]);
|
|
2747
|
-
|
|
2748
|
-
// Detect Android products.
|
|
2749
|
-
// Browsers on Android devices typically provide their product IDS after "Android;"
|
|
2750
|
-
// up to "Build" or ") AppleWebKit".
|
|
2751
|
-
// Example:
|
|
2752
|
-
// "Mozilla/5.0 (Linux; Android 8.1.0; Moto G (5) Plus) AppleWebKit/537.36
|
|
2753
|
-
// (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36"
|
|
2754
|
-
if (/\bAndroid\b/.test(os) && !product &&
|
|
2755
|
-
(data = /\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(ua))) {
|
|
2756
|
-
product = trim(data[1])
|
|
2757
|
-
// Replace any language codes (eg. "en-US").
|
|
2758
|
-
.replace(/^[a-z]{2}-[a-z]{2};\s*/i, '')
|
|
2759
|
-
|| null;
|
|
2760
|
-
}
|
|
2761
|
-
// Detect product names that contain their manufacturer's name.
|
|
2762
|
-
if (manufacturer && !product) {
|
|
2763
|
-
product = getProduct([manufacturer]);
|
|
2764
|
-
} else if (manufacturer && product) {
|
|
2765
|
-
product = product
|
|
2766
|
-
.replace(RegExp('^(' + qualify(manufacturer) + ')[-_.\\s]', 'i'), manufacturer + ' ')
|
|
2767
|
-
.replace(RegExp('^(' + qualify(manufacturer) + ')[-_.]?(\\w)', 'i'), manufacturer + ' $2');
|
|
2768
|
-
}
|
|
2769
|
-
// Clean up Google TV.
|
|
2770
|
-
if ((data = /\bGoogle TV\b/.exec(product))) {
|
|
2771
|
-
product = data[0];
|
|
2772
|
-
}
|
|
2773
|
-
// Detect simulators.
|
|
2774
|
-
if (/\bSimulator\b/i.test(ua)) {
|
|
2775
|
-
product = (product ? product + ' ' : '') + 'Simulator';
|
|
2776
|
-
}
|
|
2777
|
-
// Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
|
|
2778
|
-
if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
|
|
2779
|
-
description.push('running in Turbo/Uncompressed mode');
|
|
2780
|
-
}
|
|
2781
|
-
// Detect IE Mobile 11.
|
|
2782
|
-
if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
|
|
2783
|
-
data = parse(ua.replace(/like iPhone OS/, ''));
|
|
2784
|
-
manufacturer = data.manufacturer;
|
|
2785
|
-
product = data.product;
|
|
2786
|
-
}
|
|
2787
|
-
// Detect iOS.
|
|
2788
|
-
else if (/^iP/.test(product)) {
|
|
2789
|
-
name || (name = 'Safari');
|
|
2790
|
-
os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
|
|
2791
|
-
? ' ' + data[1].replace(/_/g, '.')
|
|
2792
|
-
: '');
|
|
2793
|
-
}
|
|
2794
|
-
// Detect Kubuntu.
|
|
2795
|
-
else if (name == 'Konqueror' && /^Linux\b/i.test(os)) {
|
|
2796
|
-
os = 'Kubuntu';
|
|
2797
|
-
}
|
|
2798
|
-
// Detect Android browsers.
|
|
2799
|
-
else if ((manufacturer && manufacturer != 'Google' &&
|
|
2800
|
-
((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
|
|
2801
|
-
(/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
|
|
2802
|
-
name = 'Android Browser';
|
|
2803
|
-
os = /\bAndroid\b/.test(os) ? os : 'Android';
|
|
2804
|
-
}
|
|
2805
|
-
// Detect Silk desktop/accelerated modes.
|
|
2806
|
-
else if (name == 'Silk') {
|
|
2807
|
-
if (!/\bMobi/i.test(ua)) {
|
|
2808
|
-
os = 'Android';
|
|
2809
|
-
description.unshift('desktop mode');
|
|
2810
|
-
}
|
|
2811
|
-
if (/Accelerated *= *true/i.test(ua)) {
|
|
2812
|
-
description.unshift('accelerated');
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
// Detect UC Browser speed mode.
|
|
2816
|
-
else if (name == 'UC Browser' && /\bUCWEB\b/.test(ua)) {
|
|
2817
|
-
description.push('speed mode');
|
|
2818
|
-
}
|
|
2819
|
-
// Detect PaleMoon identifying as Firefox.
|
|
2820
|
-
else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
|
|
2821
|
-
description.push('identifying as Firefox ' + data[1]);
|
|
2822
|
-
}
|
|
2823
|
-
// Detect Firefox OS and products running Firefox.
|
|
2824
|
-
else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
|
|
2825
|
-
os || (os = 'Firefox OS');
|
|
2826
|
-
product || (product = data[1]);
|
|
2827
|
-
}
|
|
2828
|
-
// Detect false positives for Firefox/Safari.
|
|
2829
|
-
else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
|
|
2830
|
-
// Escape the `/` for Firefox 1.
|
|
2831
|
-
if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
|
|
2832
|
-
// Clear name of false positives.
|
|
2833
|
-
name = null;
|
|
2834
|
-
}
|
|
2835
|
-
// Reassign a generic name.
|
|
2836
|
-
if ((data = product || manufacturer || os) &&
|
|
2837
|
-
(product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
|
|
2838
|
-
name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
// Add Chrome version to description for Electron.
|
|
2842
|
-
else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
|
|
2843
|
-
description.push('Chromium ' + data);
|
|
2844
|
-
}
|
|
2845
|
-
// Detect non-Opera (Presto-based) versions (order is important).
|
|
2846
|
-
if (!version) {
|
|
2847
|
-
version = getVersion([
|
|
2848
|
-
'(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)',
|
|
2849
|
-
'Version',
|
|
2850
|
-
qualify(name),
|
|
2851
|
-
'(?:Firefox|Minefield|NetFront)'
|
|
2852
|
-
]);
|
|
2853
|
-
}
|
|
2854
|
-
// Detect stubborn layout engines.
|
|
2855
|
-
if ((data =
|
|
2856
|
-
layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
|
|
2857
|
-
/\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
|
|
2858
|
-
/\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
|
|
2859
|
-
!layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
|
|
2860
|
-
layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
|
|
2861
|
-
)) {
|
|
2862
|
-
layout = [data];
|
|
2863
|
-
}
|
|
2864
|
-
// Detect Windows Phone 7 desktop mode.
|
|
2865
|
-
if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
|
|
2866
|
-
name += ' Mobile';
|
|
2867
|
-
os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
|
|
2868
|
-
description.unshift('desktop mode');
|
|
2869
|
-
}
|
|
2870
|
-
// Detect Windows Phone 8.x desktop mode.
|
|
2871
|
-
else if (/\bWPDesktop\b/i.test(ua)) {
|
|
2872
|
-
name = 'IE Mobile';
|
|
2873
|
-
os = 'Windows Phone 8.x';
|
|
2874
|
-
description.unshift('desktop mode');
|
|
2875
|
-
version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
|
|
2876
|
-
}
|
|
2877
|
-
// Detect IE 11 identifying as other browsers.
|
|
2878
|
-
else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
|
|
2879
|
-
if (name) {
|
|
2880
|
-
description.push('identifying as ' + name + (version ? ' ' + version : ''));
|
|
2881
|
-
}
|
|
2882
|
-
name = 'IE';
|
|
2883
|
-
version = data[1];
|
|
2884
|
-
}
|
|
2885
|
-
// Leverage environment features.
|
|
2886
|
-
if (useFeatures) {
|
|
2887
|
-
// Detect server-side environments.
|
|
2888
|
-
// Rhino has a global function while others have a global object.
|
|
2889
|
-
if (isHostType(context, 'global')) {
|
|
2890
|
-
if (java) {
|
|
2891
|
-
data = java.lang.System;
|
|
2892
|
-
arch = data.getProperty('os.arch');
|
|
2893
|
-
os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
|
|
2894
|
-
}
|
|
2895
|
-
if (rhino) {
|
|
2896
|
-
try {
|
|
2897
|
-
version = context.require('ringo/engine').version.join('.');
|
|
2898
|
-
name = 'RingoJS';
|
|
2899
|
-
} catch(e) {
|
|
2900
|
-
if ((data = context.system) && data.global.system == context.system) {
|
|
2901
|
-
name = 'Narwhal';
|
|
2902
|
-
os || (os = data[0].os || null);
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
2905
|
-
if (!name) {
|
|
2906
|
-
name = 'Rhino';
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
else if (
|
|
2910
|
-
typeof context.process == 'object' && !context.process.browser &&
|
|
2911
|
-
(data = context.process)
|
|
2912
|
-
) {
|
|
2913
|
-
if (typeof data.versions == 'object') {
|
|
2914
|
-
if (typeof data.versions.electron == 'string') {
|
|
2915
|
-
description.push('Node ' + data.versions.node);
|
|
2916
|
-
name = 'Electron';
|
|
2917
|
-
version = data.versions.electron;
|
|
2918
|
-
} else if (typeof data.versions.nw == 'string') {
|
|
2919
|
-
description.push('Chromium ' + version, 'Node ' + data.versions.node);
|
|
2920
|
-
name = 'NW.js';
|
|
2921
|
-
version = data.versions.nw;
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
if (!name) {
|
|
2925
|
-
name = 'Node.js';
|
|
2926
|
-
arch = data.arch;
|
|
2927
|
-
os = data.platform;
|
|
2928
|
-
version = /[\d.]+/.exec(data.version);
|
|
2929
|
-
version = version ? version[0] : null;
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
// Detect Adobe AIR.
|
|
2934
|
-
else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
|
|
2935
|
-
name = 'Adobe AIR';
|
|
2936
|
-
os = data.flash.system.Capabilities.os;
|
|
2937
|
-
}
|
|
2938
|
-
// Detect PhantomJS.
|
|
2939
|
-
else if (getClassOf((data = context.phantom)) == phantomClass) {
|
|
2940
|
-
name = 'PhantomJS';
|
|
2941
|
-
version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
|
|
2942
|
-
}
|
|
2943
|
-
// Detect IE compatibility modes.
|
|
2944
|
-
else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
|
|
2945
|
-
// We're in compatibility mode when the Trident version + 4 doesn't
|
|
2946
|
-
// equal the document mode.
|
|
2947
|
-
version = [version, doc.documentMode];
|
|
2948
|
-
if ((data = +data[1] + 4) != version[1]) {
|
|
2949
|
-
description.push('IE ' + version[1] + ' mode');
|
|
2950
|
-
layout && (layout[1] = '');
|
|
2951
|
-
version[1] = data;
|
|
2952
|
-
}
|
|
2953
|
-
version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
|
|
2954
|
-
}
|
|
2955
|
-
// Detect IE 11 masking as other browsers.
|
|
2956
|
-
else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
|
|
2957
|
-
description.push('masking as ' + name + ' ' + version);
|
|
2958
|
-
name = 'IE';
|
|
2959
|
-
version = '11.0';
|
|
2960
|
-
layout = ['Trident'];
|
|
2961
|
-
os = 'Windows';
|
|
2962
|
-
}
|
|
2963
|
-
os = os && format(os);
|
|
2964
|
-
}
|
|
2965
|
-
// Detect prerelease phases.
|
|
2966
|
-
if (version && (data =
|
|
2967
|
-
/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
|
|
2968
|
-
/(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
|
|
2969
|
-
/\bMinefield\b/i.test(ua) && 'a'
|
|
2970
|
-
)) {
|
|
2971
|
-
prerelease = /b/i.test(data) ? 'beta' : 'alpha';
|
|
2972
|
-
version = version.replace(RegExp(data + '\\+?$'), '') +
|
|
2973
|
-
(prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
|
|
2974
|
-
}
|
|
2975
|
-
// Detect Firefox Mobile.
|
|
2976
|
-
if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS|KaiOS)\b/.test(os)) {
|
|
2977
|
-
name = 'Firefox Mobile';
|
|
2978
|
-
}
|
|
2979
|
-
// Obscure Maxthon's unreliable version.
|
|
2980
|
-
else if (name == 'Maxthon' && version) {
|
|
2981
|
-
version = version.replace(/\.[\d.]+/, '.x');
|
|
2982
|
-
}
|
|
2983
|
-
// Detect Xbox 360 and Xbox One.
|
|
2984
|
-
else if (/\bXbox\b/i.test(product)) {
|
|
2985
|
-
if (product == 'Xbox 360') {
|
|
2986
|
-
os = null;
|
|
2987
|
-
}
|
|
2988
|
-
if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
|
|
2989
|
-
description.unshift('mobile mode');
|
|
2990
|
-
}
|
|
2991
|
-
}
|
|
2992
|
-
// Add mobile postfix.
|
|
2993
|
-
else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
|
|
2994
|
-
(os == 'Windows CE' || /Mobi/i.test(ua))) {
|
|
2995
|
-
name += ' Mobile';
|
|
2996
|
-
}
|
|
2997
|
-
// Detect IE platform preview.
|
|
2998
|
-
else if (name == 'IE' && useFeatures) {
|
|
2999
|
-
try {
|
|
3000
|
-
if (context.external === null) {
|
|
3001
|
-
description.unshift('platform preview');
|
|
3002
|
-
}
|
|
3003
|
-
} catch(e) {
|
|
3004
|
-
description.unshift('embedded');
|
|
3005
|
-
}
|
|
3006
|
-
}
|
|
3007
|
-
// Detect BlackBerry OS version.
|
|
3008
|
-
// http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
|
|
3009
|
-
else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
|
|
3010
|
-
(RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
|
|
3011
|
-
version
|
|
3012
|
-
)) {
|
|
3013
|
-
data = [data, /BB10/.test(ua)];
|
|
3014
|
-
os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
|
|
3015
|
-
version = null;
|
|
3016
|
-
}
|
|
3017
|
-
// Detect Opera identifying/masking itself as another browser.
|
|
3018
|
-
// http://www.opera.com/support/kb/view/843/
|
|
3019
|
-
else if (this != forOwn && product != 'Wii' && (
|
|
3020
|
-
(useFeatures && opera) ||
|
|
3021
|
-
(/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
|
|
3022
|
-
(name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
|
|
3023
|
-
(name == 'IE' && (
|
|
3024
|
-
(os && !/^Win/.test(os) && version > 5.5) ||
|
|
3025
|
-
/\bWindows XP\b/.test(os) && version > 8 ||
|
|
3026
|
-
version == 8 && !/\bTrident\b/.test(ua)
|
|
3027
|
-
))
|
|
3028
|
-
) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
|
|
3029
|
-
// When "identifying", the UA contains both Opera and the other browser's name.
|
|
3030
|
-
data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
|
|
3031
|
-
if (reOpera.test(name)) {
|
|
3032
|
-
if (/\bIE\b/.test(data) && os == 'Mac OS') {
|
|
3033
|
-
os = null;
|
|
3034
|
-
}
|
|
3035
|
-
data = 'identify' + data;
|
|
3036
|
-
}
|
|
3037
|
-
// When "masking", the UA contains only the other browser's name.
|
|
3038
|
-
else {
|
|
3039
|
-
data = 'mask' + data;
|
|
3040
|
-
if (operaClass) {
|
|
3041
|
-
name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
|
|
3042
|
-
} else {
|
|
3043
|
-
name = 'Opera';
|
|
3044
|
-
}
|
|
3045
|
-
if (/\bIE\b/.test(data)) {
|
|
3046
|
-
os = null;
|
|
3047
|
-
}
|
|
3048
|
-
if (!useFeatures) {
|
|
3049
|
-
version = null;
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
layout = ['Presto'];
|
|
3053
|
-
description.push(data);
|
|
3054
|
-
}
|
|
3055
|
-
// Detect WebKit Nightly and approximate Chrome/Safari versions.
|
|
3056
|
-
if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
|
|
3057
|
-
// Correct build number for numeric comparison.
|
|
3058
|
-
// (e.g. "532.5" becomes "532.05")
|
|
3059
|
-
data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
|
|
3060
|
-
// Nightly builds are postfixed with a "+".
|
|
3061
|
-
if (name == 'Safari' && data[1].slice(-1) == '+') {
|
|
3062
|
-
name = 'WebKit Nightly';
|
|
3063
|
-
prerelease = 'alpha';
|
|
3064
|
-
version = data[1].slice(0, -1);
|
|
3065
|
-
}
|
|
3066
|
-
// Clear incorrect browser versions.
|
|
3067
|
-
else if (version == data[1] ||
|
|
3068
|
-
version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
|
|
3069
|
-
version = null;
|
|
3070
|
-
}
|
|
3071
|
-
// Use the full Chrome version when available.
|
|
3072
|
-
data[1] = (/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(ua) || 0)[1];
|
|
3073
|
-
// Detect Blink layout engine.
|
|
3074
|
-
if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
|
|
3075
|
-
layout = ['Blink'];
|
|
3076
|
-
}
|
|
3077
|
-
// Detect JavaScriptCore.
|
|
3078
|
-
// http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
|
|
3079
|
-
if (!useFeatures || (!likeChrome && !data[1])) {
|
|
3080
|
-
layout && (layout[1] = 'like Safari');
|
|
3081
|
-
data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : data < 602 ? 9 : data < 604 ? 10 : data < 606 ? 11 : data < 608 ? 12 : '12');
|
|
3082
|
-
} else {
|
|
3083
|
-
layout && (layout[1] = 'like Chrome');
|
|
3084
|
-
data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
|
|
3085
|
-
}
|
|
3086
|
-
// Add the postfix of ".x" or "+" for approximate versions.
|
|
3087
|
-
layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
|
|
3088
|
-
// Obscure version for some Safari 1-2 releases.
|
|
3089
|
-
if (name == 'Safari' && (!version || parseInt(version) > 45)) {
|
|
3090
|
-
version = data;
|
|
3091
|
-
} else if (name == 'Chrome' && /\bHeadlessChrome/i.test(ua)) {
|
|
3092
|
-
description.unshift('headless');
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
// Detect Opera desktop modes.
|
|
3096
|
-
if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
|
|
3097
|
-
name += ' ';
|
|
3098
|
-
description.unshift('desktop mode');
|
|
3099
|
-
if (data == 'zvav') {
|
|
3100
|
-
name += 'Mini';
|
|
3101
|
-
version = null;
|
|
3102
|
-
} else {
|
|
3103
|
-
name += 'Mobile';
|
|
3104
|
-
}
|
|
3105
|
-
os = os.replace(RegExp(' *' + data + '$'), '');
|
|
3106
|
-
}
|
|
3107
|
-
// Detect Chrome desktop mode.
|
|
3108
|
-
else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
|
|
3109
|
-
description.unshift('desktop mode');
|
|
3110
|
-
name = 'Chrome Mobile';
|
|
3111
|
-
version = null;
|
|
3112
|
-
|
|
3113
|
-
if (/\bOS X\b/.test(os)) {
|
|
3114
|
-
manufacturer = 'Apple';
|
|
3115
|
-
os = 'iOS 4.3+';
|
|
3116
|
-
} else {
|
|
3117
|
-
os = null;
|
|
3118
|
-
}
|
|
3119
|
-
}
|
|
3120
|
-
// Newer versions of SRWare Iron uses the Chrome tag to indicate its version number.
|
|
3121
|
-
else if (/\bSRWare Iron\b/.test(name) && !version) {
|
|
3122
|
-
version = getVersion('Chrome');
|
|
3123
|
-
}
|
|
3124
|
-
// Strip incorrect OS versions.
|
|
3125
|
-
if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
|
|
3126
|
-
ua.indexOf('/' + data + '-') > -1) {
|
|
3127
|
-
os = trim(os.replace(data, ''));
|
|
3128
|
-
}
|
|
3129
|
-
// Ensure OS does not include the browser name.
|
|
3130
|
-
if (os && os.indexOf(name) != -1 && !RegExp(name + ' OS').test(os)) {
|
|
3131
|
-
os = os.replace(RegExp(' *' + qualify(name) + ' *'), '');
|
|
3132
|
-
}
|
|
3133
|
-
// Add layout engine.
|
|
3134
|
-
if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
|
|
3135
|
-
/Browser|Lunascape|Maxthon/.test(name) ||
|
|
3136
|
-
name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
|
|
3137
|
-
/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(name) && layout[1])) {
|
|
3138
|
-
// Don't add layout details to description if they are falsey.
|
|
3139
|
-
(data = layout[layout.length - 1]) && description.push(data);
|
|
3140
|
-
}
|
|
3141
|
-
// Combine contextual information.
|
|
3142
|
-
if (description.length) {
|
|
3143
|
-
description = ['(' + description.join('; ') + ')'];
|
|
3144
|
-
}
|
|
3145
|
-
// Append manufacturer to description.
|
|
3146
|
-
if (manufacturer && product && product.indexOf(manufacturer) < 0) {
|
|
3147
|
-
description.push('on ' + manufacturer);
|
|
3148
|
-
}
|
|
3149
|
-
// Append product to description.
|
|
3150
|
-
if (product) {
|
|
3151
|
-
description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
|
|
3152
|
-
}
|
|
3153
|
-
// Parse the OS into an object.
|
|
3154
|
-
if (os) {
|
|
3155
|
-
data = / ([\d.+]+)$/.exec(os);
|
|
3156
|
-
isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
|
|
3157
|
-
os = {
|
|
3158
|
-
'architecture': 32,
|
|
3159
|
-
'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
|
|
3160
|
-
'version': data ? data[1] : null,
|
|
3161
|
-
'toString': function() {
|
|
3162
|
-
var version = this.version;
|
|
3163
|
-
return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
|
|
3164
|
-
}
|
|
3165
|
-
};
|
|
3166
|
-
}
|
|
3167
|
-
// Add browser/OS architecture.
|
|
3168
|
-
if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
|
|
3169
|
-
if (os) {
|
|
3170
|
-
os.architecture = 64;
|
|
3171
|
-
os.family = os.family.replace(RegExp(' *' + data), '');
|
|
3172
|
-
}
|
|
3173
|
-
if (
|
|
3174
|
-
name && (/\bWOW64\b/i.test(ua) ||
|
|
3175
|
-
(useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
|
|
3176
|
-
) {
|
|
3177
|
-
description.unshift('32-bit');
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
// Chrome 39 and above on OS X is always 64-bit.
|
|
3181
|
-
else if (
|
|
3182
|
-
os && /^OS X/.test(os.family) &&
|
|
3183
|
-
name == 'Chrome' && parseFloat(version) >= 39
|
|
3184
|
-
) {
|
|
3185
|
-
os.architecture = 64;
|
|
3186
|
-
}
|
|
3187
|
-
|
|
3188
|
-
ua || (ua = null);
|
|
3189
|
-
|
|
3190
|
-
/*------------------------------------------------------------------------*/
|
|
3191
|
-
|
|
3192
|
-
/**
|
|
3193
|
-
* The platform object.
|
|
3194
|
-
*
|
|
3195
|
-
* @name platform
|
|
3196
|
-
* @type Object
|
|
3197
|
-
*/
|
|
3198
|
-
var platform = {};
|
|
3199
|
-
|
|
3200
|
-
/**
|
|
3201
|
-
* The platform description.
|
|
3202
|
-
*
|
|
3203
|
-
* @memberOf platform
|
|
3204
|
-
* @type string|null
|
|
3205
|
-
*/
|
|
3206
|
-
platform.description = ua;
|
|
3207
|
-
|
|
3208
|
-
/**
|
|
3209
|
-
* The name of the browser's layout engine.
|
|
3210
|
-
*
|
|
3211
|
-
* The list of common layout engines include:
|
|
3212
|
-
* "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
|
|
3213
|
-
*
|
|
3214
|
-
* @memberOf platform
|
|
3215
|
-
* @type string|null
|
|
3216
|
-
*/
|
|
3217
|
-
platform.layout = layout && layout[0];
|
|
3218
|
-
|
|
3219
|
-
/**
|
|
3220
|
-
* The name of the product's manufacturer.
|
|
3221
|
-
*
|
|
3222
|
-
* The list of manufacturers include:
|
|
3223
|
-
* "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
|
|
3224
|
-
* "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
|
|
3225
|
-
* "Nokia", "Samsung" and "Sony"
|
|
3226
|
-
*
|
|
3227
|
-
* @memberOf platform
|
|
3228
|
-
* @type string|null
|
|
3229
|
-
*/
|
|
3230
|
-
platform.manufacturer = manufacturer;
|
|
3231
|
-
|
|
3232
|
-
/**
|
|
3233
|
-
* The name of the browser/environment.
|
|
3234
|
-
*
|
|
3235
|
-
* The list of common browser names include:
|
|
3236
|
-
* "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
|
|
3237
|
-
* "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
|
|
3238
|
-
* "Opera Mini" and "Opera"
|
|
3239
|
-
*
|
|
3240
|
-
* Mobile versions of some browsers have "Mobile" appended to their name:
|
|
3241
|
-
* eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
|
|
3242
|
-
*
|
|
3243
|
-
* @memberOf platform
|
|
3244
|
-
* @type string|null
|
|
3245
|
-
*/
|
|
3246
|
-
platform.name = name;
|
|
3247
|
-
|
|
3248
|
-
/**
|
|
3249
|
-
* The alpha/beta release indicator.
|
|
3250
|
-
*
|
|
3251
|
-
* @memberOf platform
|
|
3252
|
-
* @type string|null
|
|
3253
|
-
*/
|
|
3254
|
-
platform.prerelease = prerelease;
|
|
3255
|
-
|
|
3256
|
-
/**
|
|
3257
|
-
* The name of the product hosting the browser.
|
|
3258
|
-
*
|
|
3259
|
-
* The list of common products include:
|
|
3260
|
-
*
|
|
3261
|
-
* "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
|
|
3262
|
-
* "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
|
|
3263
|
-
*
|
|
3264
|
-
* @memberOf platform
|
|
3265
|
-
* @type string|null
|
|
3266
|
-
*/
|
|
3267
|
-
platform.product = product;
|
|
3268
|
-
|
|
3269
|
-
/**
|
|
3270
|
-
* The browser's user agent string.
|
|
3271
|
-
*
|
|
3272
|
-
* @memberOf platform
|
|
3273
|
-
* @type string|null
|
|
3274
|
-
*/
|
|
3275
|
-
platform.ua = ua;
|
|
3276
|
-
|
|
3277
|
-
/**
|
|
3278
|
-
* The browser/environment version.
|
|
3279
|
-
*
|
|
3280
|
-
* @memberOf platform
|
|
3281
|
-
* @type string|null
|
|
3282
|
-
*/
|
|
3283
|
-
platform.version = name && version;
|
|
3284
|
-
|
|
3285
|
-
/**
|
|
3286
|
-
* The name of the operating system.
|
|
3287
|
-
*
|
|
3288
|
-
* @memberOf platform
|
|
3289
|
-
* @type Object
|
|
3290
|
-
*/
|
|
3291
|
-
platform.os = os || {
|
|
3292
|
-
|
|
3293
|
-
/**
|
|
3294
|
-
* The CPU architecture the OS is built for.
|
|
3295
|
-
*
|
|
3296
|
-
* @memberOf platform.os
|
|
3297
|
-
* @type number|null
|
|
3298
|
-
*/
|
|
3299
|
-
'architecture': null,
|
|
3300
|
-
|
|
3301
|
-
/**
|
|
3302
|
-
* The family of the OS.
|
|
3303
|
-
*
|
|
3304
|
-
* Common values include:
|
|
3305
|
-
* "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
|
|
3306
|
-
* "Windows XP", "OS X", "Linux", "Ubuntu", "Debian", "Fedora", "Red Hat",
|
|
3307
|
-
* "SuSE", "Android", "iOS" and "Windows Phone"
|
|
3308
|
-
*
|
|
3309
|
-
* @memberOf platform.os
|
|
3310
|
-
* @type string|null
|
|
3311
|
-
*/
|
|
3312
|
-
'family': null,
|
|
3313
|
-
|
|
3314
|
-
/**
|
|
3315
|
-
* The version of the OS.
|
|
3316
|
-
*
|
|
3317
|
-
* @memberOf platform.os
|
|
3318
|
-
* @type string|null
|
|
3319
|
-
*/
|
|
3320
|
-
'version': null,
|
|
3321
|
-
|
|
3322
|
-
/**
|
|
3323
|
-
* Returns the OS string.
|
|
3324
|
-
*
|
|
3325
|
-
* @memberOf platform.os
|
|
3326
|
-
* @returns {string} The OS string.
|
|
3327
|
-
*/
|
|
3328
|
-
'toString': function() { return 'null'; }
|
|
3329
|
-
};
|
|
3330
|
-
|
|
3331
|
-
platform.parse = parse;
|
|
3332
|
-
platform.toString = toStringPlatform;
|
|
3333
|
-
|
|
3334
|
-
if (platform.version) {
|
|
3335
|
-
description.unshift(version);
|
|
3336
|
-
}
|
|
3337
|
-
if (platform.name) {
|
|
3338
|
-
description.unshift(name);
|
|
3339
|
-
}
|
|
3340
|
-
if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
|
|
3341
|
-
description.push(product ? '(' + os + ')' : 'on ' + os);
|
|
3342
|
-
}
|
|
3343
|
-
if (description.length) {
|
|
3344
|
-
platform.description = description.join(' ');
|
|
3345
|
-
}
|
|
3346
|
-
return platform;
|
|
3347
|
-
}
|
|
3348
|
-
|
|
3349
|
-
/*--------------------------------------------------------------------------*/
|
|
3350
|
-
|
|
3351
|
-
// Export platform.
|
|
3352
|
-
var platform = parse();
|
|
3353
|
-
|
|
3354
|
-
// Some AMD build optimizers, like r.js, check for condition patterns like the following:
|
|
3355
|
-
if (freeExports && freeModule) {
|
|
3356
|
-
// Export for CommonJS support.
|
|
3357
|
-
forOwn(platform, function(value, key) {
|
|
3358
|
-
freeExports[key] = value;
|
|
3359
|
-
});
|
|
3360
|
-
}
|
|
3361
|
-
else {
|
|
3362
|
-
// Export to the global object.
|
|
3363
|
-
root.platform = platform;
|
|
3364
|
-
}
|
|
3365
|
-
}.call(commonjsGlobal));
|
|
3366
|
-
} (platform$1, platform$1.exports));
|
|
3367
|
-
|
|
3368
|
-
var platform = platform$1.exports;
|
|
3369
|
-
|
|
3370
|
-
var isMultipleHotkey = function isMultipleHotkey(hotkey) {
|
|
3371
|
-
return Array.isArray(hotkey);
|
|
3372
|
-
};
|
|
3373
|
-
var replaceKeys = function replaceKeys(hotkey, keyName, replaceWith) {
|
|
3374
|
-
return isMultipleHotkey(hotkey) ? hotkey.map(function (item) {
|
|
3375
|
-
return item.replaceAll(keyName, replaceWith);
|
|
3376
|
-
}) : hotkey.replaceAll(keyName, replaceWith);
|
|
3377
|
-
};
|
|
3378
|
-
var convertHotKeyToWindows = function convertHotKeyToWindows(hotkey) {
|
|
3379
|
-
toPairs(MAC_TO_WINDOWS_KEYS_MAP).forEach(function (_ref) {
|
|
3380
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
3381
|
-
macKey = _ref2[0],
|
|
3382
|
-
windowsKey = _ref2[1];
|
|
3383
|
-
hotkey = replaceKeys(hotkey, macKey, windowsKey);
|
|
3384
|
-
});
|
|
3385
|
-
return hotkey;
|
|
3386
|
-
};
|
|
3387
|
-
var convertHotkeyToUsersPlatform = function convertHotkeyToUsersPlatform(hotkey) {
|
|
3388
|
-
var _platformInfo$os, _platformInfo$os$fami;
|
|
3389
|
-
var platformInfo = platform.parse(navigator.userAgent);
|
|
3390
|
-
var isOSX = (_platformInfo$os = platformInfo.os) === null || _platformInfo$os === void 0 ? void 0 : (_platformInfo$os$fami = _platformInfo$os.family) === null || _platformInfo$os$fami === void 0 ? void 0 : _platformInfo$os$fami.includes(OS.mac);
|
|
3391
|
-
if (isOSX) return replaceKeys(hotkey, KEY_NAMES["delete"], KEY_NAMES.backspace);
|
|
3392
|
-
return convertHotKeyToWindows(hotkey);
|
|
3393
|
-
};
|
|
3394
|
-
|
|
3395
|
-
var useHotKeys = function useHotKeys(hotkey, handler, userConfig) {
|
|
3396
|
-
var ref = useRef(null);
|
|
3397
|
-
var convertedHotkey = convertHotkeyToUsersPlatform(hotkey);
|
|
3398
|
-
var config = mergeLeft(userConfig, DEFAULT_CONFIG);
|
|
3399
|
-
if (!handler) {
|
|
3400
|
-
throw new Error("You must provide a handler function to useHotKeys");
|
|
3401
|
-
}
|
|
3402
|
-
useEffect(function () {
|
|
3403
|
-
if (!config.enabled) return undefined;
|
|
3404
|
-
var mousetrapInstance = bindHotKey({
|
|
3405
|
-
mode: config.mode,
|
|
3406
|
-
hotkey: convertedHotkey,
|
|
3407
|
-
handler: handler,
|
|
3408
|
-
ref: ref
|
|
3409
|
-
});
|
|
3410
|
-
return function () {
|
|
3411
|
-
unBindHotKey({
|
|
3412
|
-
mousetrapInstance: mousetrapInstance,
|
|
3413
|
-
mode: config.mode,
|
|
3414
|
-
hotkey: convertedHotkey
|
|
3415
|
-
});
|
|
3416
|
-
};
|
|
3417
|
-
}, [handler, config.mode, convertedHotkey, config]);
|
|
3418
|
-
return config.mode === MODES.scoped ? ref : null;
|
|
3419
|
-
};
|
|
3420
|
-
var bindHotKey = function bindHotKey(_ref) {
|
|
3421
|
-
var mode = _ref.mode,
|
|
3422
|
-
hotkey = _ref.hotkey,
|
|
3423
|
-
handler = _ref.handler,
|
|
3424
|
-
ref = _ref.ref;
|
|
3425
|
-
var mousetrapInstance;
|
|
3426
|
-
switch (mode) {
|
|
3427
|
-
case MODES.global:
|
|
3428
|
-
Mousetrap$1.bindGlobal(hotkey, handler);
|
|
3429
|
-
break;
|
|
3430
|
-
case MODES.scoped:
|
|
3431
|
-
mousetrapInstance = Mousetrap$1(ref.current).bind(hotkey, handler);
|
|
3432
|
-
break;
|
|
3433
|
-
default:
|
|
3434
|
-
mousetrapInstance = Mousetrap$1.bind(hotkey, handler);
|
|
3435
|
-
}
|
|
3436
|
-
return mousetrapInstance;
|
|
3437
|
-
};
|
|
3438
|
-
var unBindHotKey = function unBindHotKey(_ref2) {
|
|
3439
|
-
var mousetrapInstance = _ref2.mousetrapInstance,
|
|
3440
|
-
mode = _ref2.mode,
|
|
3441
|
-
hotkey = _ref2.hotkey;
|
|
3442
|
-
return mode === MODES.global ? Mousetrap$1.unbindGlobal(hotkey) : mousetrapInstance === null || mousetrapInstance === void 0 ? void 0 : mousetrapInstance.unbind(hotkey);
|
|
3443
|
-
};
|
|
3444
|
-
|
|
3445
|
-
var useForceUpdate = function useForceUpdate() {
|
|
3446
|
-
// eslint-disable-next-line react/hook-use-state
|
|
3447
|
-
var _useState = useState(0),
|
|
3448
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3449
|
-
setValue = _useState2[1];
|
|
3450
|
-
return function () {
|
|
3451
|
-
return setValue(function (value) {
|
|
3452
|
-
return value + 1;
|
|
3453
|
-
});
|
|
3454
|
-
};
|
|
3455
|
-
};
|
|
3456
|
-
|
|
3457
|
-
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
3458
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
3459
|
-
var _useState = useState(false),
|
|
3460
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3461
|
-
isIntersecting = _useState2[0],
|
|
3462
|
-
setIsIntersecting = _useState2[1];
|
|
3463
|
-
var forceUpdate = useForceUpdate();
|
|
3464
|
-
useEffect(function () {
|
|
3465
|
-
if (!target) return forceUpdate();
|
|
3466
|
-
var observer = new IntersectionObserver(function (_ref) {
|
|
3467
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
3468
|
-
entry = _ref2[0];
|
|
3469
|
-
return setIsIntersecting(entry.isIntersecting);
|
|
3470
|
-
}, options);
|
|
3471
|
-
observer.observe(target);
|
|
3472
|
-
return function () {
|
|
3473
|
-
return observer.unobserve(target);
|
|
3474
|
-
};
|
|
3475
|
-
}, [target, options]);
|
|
3476
|
-
return isIntersecting;
|
|
3477
|
-
};
|
|
3478
|
-
|
|
3479
|
-
function shallow(objA, objB) {
|
|
3480
|
-
if (Object.is(objA, objB)) {
|
|
3481
|
-
return true;
|
|
3482
|
-
}
|
|
3483
|
-
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
3484
|
-
return false;
|
|
3485
|
-
}
|
|
3486
|
-
if (objA instanceof Map && objB instanceof Map) {
|
|
3487
|
-
if (objA.size !== objB.size)
|
|
3488
|
-
return false;
|
|
3489
|
-
for (const [key, value] of objA) {
|
|
3490
|
-
if (!Object.is(value, objB.get(key))) {
|
|
3491
|
-
return false;
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
return true;
|
|
3495
|
-
}
|
|
3496
|
-
if (objA instanceof Set && objB instanceof Set) {
|
|
3497
|
-
if (objA.size !== objB.size)
|
|
3498
|
-
return false;
|
|
3499
|
-
for (const value of objA) {
|
|
3500
|
-
if (!objB.has(value)) {
|
|
3501
|
-
return false;
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
return true;
|
|
3505
|
-
}
|
|
3506
|
-
const keysA = Object.keys(objA);
|
|
3507
|
-
if (keysA.length !== Object.keys(objB).length) {
|
|
3508
|
-
return false;
|
|
3509
|
-
}
|
|
3510
|
-
for (let i = 0; i < keysA.length; i++) {
|
|
3511
|
-
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
|
3512
|
-
return false;
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
return true;
|
|
3516
|
-
}
|
|
3517
|
-
|
|
3518
|
-
var useKeyboardShortcutsStore = create$1(function (set) {
|
|
3519
|
-
return {
|
|
3520
|
-
isOpen: false,
|
|
3521
|
-
setIsOpen: function setIsOpen(arg) {
|
|
3522
|
-
if (typeof arg === "function") {
|
|
3523
|
-
set(function (state) {
|
|
3524
|
-
return {
|
|
3525
|
-
isOpen: arg(state.isOpen)
|
|
3526
|
-
};
|
|
3527
|
-
});
|
|
3528
|
-
} else {
|
|
3529
|
-
set({
|
|
3530
|
-
isOpen: arg
|
|
3531
|
-
});
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
};
|
|
3535
|
-
});
|
|
3536
|
-
var useKeyboardShortcutsPaneState = function useKeyboardShortcutsPaneState() {
|
|
3537
|
-
return useKeyboardShortcutsStore(function (_ref) {
|
|
3538
|
-
var isOpen = _ref.isOpen,
|
|
3539
|
-
setIsOpen = _ref.setIsOpen;
|
|
3540
|
-
return [isOpen, setIsOpen];
|
|
3541
|
-
}, shallow);
|
|
3542
|
-
};
|
|
3543
|
-
|
|
3544
|
-
var getStorageValue = function getStorageValue(key, defaultValue) {
|
|
3545
|
-
try {
|
|
3546
|
-
var storedValue = localStorage.getItem(key);
|
|
3547
|
-
return storedValue ? JSON.parse(storedValue) : defaultValue;
|
|
3548
|
-
} catch (error) {
|
|
3549
|
-
logger.error(error);
|
|
3550
|
-
return defaultValue;
|
|
3551
|
-
}
|
|
3552
|
-
};
|
|
3553
|
-
var useLocalStorage = function useLocalStorage(key, defaultValue) {
|
|
3554
|
-
var _useState = useState(function () {
|
|
3555
|
-
return getStorageValue(key, defaultValue);
|
|
3556
|
-
}),
|
|
3557
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3558
|
-
storedValue = _useState2[0],
|
|
3559
|
-
setStoredValue = _useState2[1];
|
|
3560
|
-
var setValue = function setValue(value) {
|
|
3561
|
-
if (isNil(value)) {
|
|
3562
|
-
localStorage.removeItem(key);
|
|
3563
|
-
} else {
|
|
3564
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
3565
|
-
}
|
|
3566
|
-
setStoredValue(value);
|
|
3567
|
-
};
|
|
3568
|
-
return [storedValue, setValue];
|
|
3569
|
-
};
|
|
3570
|
-
|
|
3571
|
-
var _excluded = ["keysToInvalidate"],
|
|
3572
|
-
_excluded2 = ["onSuccess"];
|
|
3573
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3574
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3575
|
-
var useMutationWithInvalidation = function useMutationWithInvalidation(mutationFn, _ref) {
|
|
3576
|
-
var keysToInvalidate = _ref.keysToInvalidate,
|
|
3577
|
-
options = _objectWithoutProperties(_ref, _excluded);
|
|
3578
|
-
var queryClient = useQueryClient();
|
|
3579
|
-
var _onSuccess = options.onSuccess,
|
|
3580
|
-
otherOptions = _objectWithoutProperties(options, _excluded2);
|
|
3581
|
-
return useMutation(mutationFn, _objectSpread$1({
|
|
3582
|
-
onSuccess: function onSuccess(data, variables, context) {
|
|
3583
|
-
keysToInvalidate.forEach(function (key) {
|
|
3584
|
-
var keyToInvalidate = typeof key === "function" ? key(data, variables, context) : key;
|
|
3585
|
-
queryClient.invalidateQueries(keyToInvalidate);
|
|
3586
|
-
});
|
|
3587
|
-
_onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(data, variables, context);
|
|
3588
|
-
}
|
|
3589
|
-
}, otherOptions));
|
|
3590
|
-
};
|
|
3591
|
-
|
|
3592
|
-
var useOnClickOutside = function useOnClickOutside(ref, handler) {
|
|
3593
|
-
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
3594
|
-
_ref$enabled = _ref.enabled,
|
|
3595
|
-
enabled = _ref$enabled === void 0 ? true : _ref$enabled;
|
|
3596
|
-
useEffect(function () {
|
|
3597
|
-
var listener = function listener(event) {
|
|
3598
|
-
// Do nothing if clicking ref's element or descendent elements
|
|
3599
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
3600
|
-
return;
|
|
3601
|
-
}
|
|
3602
|
-
handler(event);
|
|
3603
|
-
};
|
|
3604
|
-
if (enabled) {
|
|
3605
|
-
document.addEventListener("mousedown", listener);
|
|
3606
|
-
document.addEventListener("touchstart", listener);
|
|
3607
|
-
}
|
|
3608
|
-
return function () {
|
|
3609
|
-
document.removeEventListener("mousedown", listener);
|
|
3610
|
-
document.removeEventListener("touchstart", listener);
|
|
3611
|
-
};
|
|
3612
|
-
}, [handler, enabled]);
|
|
3613
|
-
};
|
|
3614
|
-
|
|
3615
|
-
var usePrevious = function usePrevious(value) {
|
|
3616
|
-
var ref = useRef(value);
|
|
3617
|
-
useEffect(function () {
|
|
3618
|
-
ref.current = value;
|
|
3619
|
-
}, [value]);
|
|
3620
|
-
return ref.current;
|
|
3621
|
-
};
|
|
3622
|
-
|
|
3623
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3624
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3625
|
-
var useQueryParams = function useQueryParams() {
|
|
3626
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3627
|
-
var location = useLocation();
|
|
3628
|
-
return parse$1(location.search, _objectSpread({
|
|
3629
|
-
ignoreQueryPrefix: true
|
|
3630
|
-
}, options));
|
|
3631
|
-
};
|
|
3632
|
-
|
|
3633
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3634
|
-
try {
|
|
3635
|
-
var info = gen[key](arg);
|
|
3636
|
-
var value = info.value;
|
|
3637
|
-
} catch (error) {
|
|
3638
|
-
reject(error);
|
|
3639
|
-
return;
|
|
3640
|
-
}
|
|
3641
|
-
if (info.done) {
|
|
3642
|
-
resolve(value);
|
|
3643
|
-
} else {
|
|
3644
|
-
Promise.resolve(value).then(_next, _throw);
|
|
3645
|
-
}
|
|
3646
|
-
}
|
|
3647
|
-
function _asyncToGenerator(fn) {
|
|
3648
|
-
return function () {
|
|
3649
|
-
var self = this,
|
|
3650
|
-
args = arguments;
|
|
3651
|
-
return new Promise(function (resolve, reject) {
|
|
3652
|
-
var gen = fn.apply(self, args);
|
|
3653
|
-
function _next(value) {
|
|
3654
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
3655
|
-
}
|
|
3656
|
-
function _throw(err) {
|
|
3657
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3658
|
-
}
|
|
3659
|
-
_next(undefined);
|
|
3660
|
-
});
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
|
|
3664
|
-
var regeneratorRuntime$1 = {exports: {}};
|
|
3665
|
-
|
|
3666
|
-
var _typeof = {exports: {}};
|
|
3667
|
-
|
|
3668
|
-
(function (module) {
|
|
3669
|
-
function _typeof(obj) {
|
|
3670
|
-
"@babel/helpers - typeof";
|
|
3671
|
-
|
|
3672
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
3673
|
-
return typeof obj;
|
|
3674
|
-
} : function (obj) {
|
|
3675
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
3676
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
3677
|
-
}
|
|
3678
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3679
|
-
} (_typeof));
|
|
3680
|
-
|
|
3681
|
-
(function (module) {
|
|
3682
|
-
var _typeof$1 = _typeof.exports["default"];
|
|
3683
|
-
function _regeneratorRuntime() {
|
|
3684
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
3685
|
-
return exports;
|
|
3686
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3687
|
-
var exports = {},
|
|
3688
|
-
Op = Object.prototype,
|
|
3689
|
-
hasOwn = Op.hasOwnProperty,
|
|
3690
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
3691
|
-
obj[key] = desc.value;
|
|
3692
|
-
},
|
|
3693
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
3694
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
3695
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
3696
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
3697
|
-
function define(obj, key, value) {
|
|
3698
|
-
return Object.defineProperty(obj, key, {
|
|
3699
|
-
value: value,
|
|
3700
|
-
enumerable: !0,
|
|
3701
|
-
configurable: !0,
|
|
3702
|
-
writable: !0
|
|
3703
|
-
}), obj[key];
|
|
3704
|
-
}
|
|
3705
|
-
try {
|
|
3706
|
-
define({}, "");
|
|
3707
|
-
} catch (err) {
|
|
3708
|
-
define = function define(obj, key, value) {
|
|
3709
|
-
return obj[key] = value;
|
|
3710
|
-
};
|
|
3711
|
-
}
|
|
3712
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
3713
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
3714
|
-
generator = Object.create(protoGenerator.prototype),
|
|
3715
|
-
context = new Context(tryLocsList || []);
|
|
3716
|
-
return defineProperty(generator, "_invoke", {
|
|
3717
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
3718
|
-
}), generator;
|
|
3719
|
-
}
|
|
3720
|
-
function tryCatch(fn, obj, arg) {
|
|
3721
|
-
try {
|
|
3722
|
-
return {
|
|
3723
|
-
type: "normal",
|
|
3724
|
-
arg: fn.call(obj, arg)
|
|
3725
|
-
};
|
|
3726
|
-
} catch (err) {
|
|
3727
|
-
return {
|
|
3728
|
-
type: "throw",
|
|
3729
|
-
arg: err
|
|
3730
|
-
};
|
|
3731
|
-
}
|
|
3732
|
-
}
|
|
3733
|
-
exports.wrap = wrap;
|
|
3734
|
-
var ContinueSentinel = {};
|
|
3735
|
-
function Generator() {}
|
|
3736
|
-
function GeneratorFunction() {}
|
|
3737
|
-
function GeneratorFunctionPrototype() {}
|
|
3738
|
-
var IteratorPrototype = {};
|
|
3739
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
3740
|
-
return this;
|
|
3741
|
-
});
|
|
3742
|
-
var getProto = Object.getPrototypeOf,
|
|
3743
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
3744
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
3745
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
3746
|
-
function defineIteratorMethods(prototype) {
|
|
3747
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
3748
|
-
define(prototype, method, function (arg) {
|
|
3749
|
-
return this._invoke(method, arg);
|
|
3750
|
-
});
|
|
3751
|
-
});
|
|
3752
|
-
}
|
|
3753
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
3754
|
-
function invoke(method, arg, resolve, reject) {
|
|
3755
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
3756
|
-
if ("throw" !== record.type) {
|
|
3757
|
-
var result = record.arg,
|
|
3758
|
-
value = result.value;
|
|
3759
|
-
return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3760
|
-
invoke("next", value, resolve, reject);
|
|
3761
|
-
}, function (err) {
|
|
3762
|
-
invoke("throw", err, resolve, reject);
|
|
3763
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
3764
|
-
result.value = unwrapped, resolve(result);
|
|
3765
|
-
}, function (error) {
|
|
3766
|
-
return invoke("throw", error, resolve, reject);
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
reject(record.arg);
|
|
3770
|
-
}
|
|
3771
|
-
var previousPromise;
|
|
3772
|
-
defineProperty(this, "_invoke", {
|
|
3773
|
-
value: function value(method, arg) {
|
|
3774
|
-
function callInvokeWithMethodAndArg() {
|
|
3775
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
3776
|
-
invoke(method, arg, resolve, reject);
|
|
3777
|
-
});
|
|
3778
|
-
}
|
|
3779
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
3780
|
-
}
|
|
3781
|
-
});
|
|
3782
|
-
}
|
|
3783
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
3784
|
-
var state = "suspendedStart";
|
|
3785
|
-
return function (method, arg) {
|
|
3786
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
3787
|
-
if ("completed" === state) {
|
|
3788
|
-
if ("throw" === method) throw arg;
|
|
3789
|
-
return doneResult();
|
|
3790
|
-
}
|
|
3791
|
-
for (context.method = method, context.arg = arg;;) {
|
|
3792
|
-
var delegate = context.delegate;
|
|
3793
|
-
if (delegate) {
|
|
3794
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
3795
|
-
if (delegateResult) {
|
|
3796
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
3797
|
-
return delegateResult;
|
|
3798
|
-
}
|
|
3799
|
-
}
|
|
3800
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
3801
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
3802
|
-
context.dispatchException(context.arg);
|
|
3803
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
3804
|
-
state = "executing";
|
|
3805
|
-
var record = tryCatch(innerFn, self, context);
|
|
3806
|
-
if ("normal" === record.type) {
|
|
3807
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
3808
|
-
return {
|
|
3809
|
-
value: record.arg,
|
|
3810
|
-
done: context.done
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
3813
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
3814
|
-
}
|
|
3815
|
-
};
|
|
3816
|
-
}
|
|
3817
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
3818
|
-
var methodName = context.method,
|
|
3819
|
-
method = delegate.iterator[methodName];
|
|
3820
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
3821
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
3822
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
3823
|
-
var info = record.arg;
|
|
3824
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
3825
|
-
}
|
|
3826
|
-
function pushTryEntry(locs) {
|
|
3827
|
-
var entry = {
|
|
3828
|
-
tryLoc: locs[0]
|
|
3829
|
-
};
|
|
3830
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
3831
|
-
}
|
|
3832
|
-
function resetTryEntry(entry) {
|
|
3833
|
-
var record = entry.completion || {};
|
|
3834
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
3835
|
-
}
|
|
3836
|
-
function Context(tryLocsList) {
|
|
3837
|
-
this.tryEntries = [{
|
|
3838
|
-
tryLoc: "root"
|
|
3839
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
3840
|
-
}
|
|
3841
|
-
function values(iterable) {
|
|
3842
|
-
if (iterable) {
|
|
3843
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
3844
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
3845
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
3846
|
-
if (!isNaN(iterable.length)) {
|
|
3847
|
-
var i = -1,
|
|
3848
|
-
next = function next() {
|
|
3849
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
3850
|
-
return next.value = undefined, next.done = !0, next;
|
|
3851
|
-
};
|
|
3852
|
-
return next.next = next;
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
return {
|
|
3856
|
-
next: doneResult
|
|
3857
|
-
};
|
|
3858
|
-
}
|
|
3859
|
-
function doneResult() {
|
|
3860
|
-
return {
|
|
3861
|
-
value: undefined,
|
|
3862
|
-
done: !0
|
|
3863
|
-
};
|
|
3864
|
-
}
|
|
3865
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
3866
|
-
value: GeneratorFunctionPrototype,
|
|
3867
|
-
configurable: !0
|
|
3868
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
3869
|
-
value: GeneratorFunction,
|
|
3870
|
-
configurable: !0
|
|
3871
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
3872
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
3873
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
3874
|
-
}, exports.mark = function (genFun) {
|
|
3875
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
3876
|
-
}, exports.awrap = function (arg) {
|
|
3877
|
-
return {
|
|
3878
|
-
__await: arg
|
|
3879
|
-
};
|
|
3880
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
3881
|
-
return this;
|
|
3882
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
3883
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
3884
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
3885
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
3886
|
-
return result.done ? result.value : iter.next();
|
|
3887
|
-
});
|
|
3888
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
3889
|
-
return this;
|
|
3890
|
-
}), define(Gp, "toString", function () {
|
|
3891
|
-
return "[object Generator]";
|
|
3892
|
-
}), exports.keys = function (val) {
|
|
3893
|
-
var object = Object(val),
|
|
3894
|
-
keys = [];
|
|
3895
|
-
for (var key in object) keys.push(key);
|
|
3896
|
-
return keys.reverse(), function next() {
|
|
3897
|
-
for (; keys.length;) {
|
|
3898
|
-
var key = keys.pop();
|
|
3899
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
3900
|
-
}
|
|
3901
|
-
return next.done = !0, next;
|
|
3902
|
-
};
|
|
3903
|
-
}, exports.values = values, Context.prototype = {
|
|
3904
|
-
constructor: Context,
|
|
3905
|
-
reset: function reset(skipTempReset) {
|
|
3906
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
3907
|
-
},
|
|
3908
|
-
stop: function stop() {
|
|
3909
|
-
this.done = !0;
|
|
3910
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
3911
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
3912
|
-
return this.rval;
|
|
3913
|
-
},
|
|
3914
|
-
dispatchException: function dispatchException(exception) {
|
|
3915
|
-
if (this.done) throw exception;
|
|
3916
|
-
var context = this;
|
|
3917
|
-
function handle(loc, caught) {
|
|
3918
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
3919
|
-
}
|
|
3920
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3921
|
-
var entry = this.tryEntries[i],
|
|
3922
|
-
record = entry.completion;
|
|
3923
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
3924
|
-
if (entry.tryLoc <= this.prev) {
|
|
3925
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
3926
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
3927
|
-
if (hasCatch && hasFinally) {
|
|
3928
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
3929
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
3930
|
-
} else if (hasCatch) {
|
|
3931
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
3932
|
-
} else {
|
|
3933
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
3934
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
3935
|
-
}
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
|
-
},
|
|
3939
|
-
abrupt: function abrupt(type, arg) {
|
|
3940
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3941
|
-
var entry = this.tryEntries[i];
|
|
3942
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
3943
|
-
var finallyEntry = entry;
|
|
3944
|
-
break;
|
|
3945
|
-
}
|
|
3946
|
-
}
|
|
3947
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
3948
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
3949
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
3950
|
-
},
|
|
3951
|
-
complete: function complete(record, afterLoc) {
|
|
3952
|
-
if ("throw" === record.type) throw record.arg;
|
|
3953
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
3954
|
-
},
|
|
3955
|
-
finish: function finish(finallyLoc) {
|
|
3956
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3957
|
-
var entry = this.tryEntries[i];
|
|
3958
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
3959
|
-
}
|
|
3960
|
-
},
|
|
3961
|
-
"catch": function _catch(tryLoc) {
|
|
3962
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3963
|
-
var entry = this.tryEntries[i];
|
|
3964
|
-
if (entry.tryLoc === tryLoc) {
|
|
3965
|
-
var record = entry.completion;
|
|
3966
|
-
if ("throw" === record.type) {
|
|
3967
|
-
var thrown = record.arg;
|
|
3968
|
-
resetTryEntry(entry);
|
|
3969
|
-
}
|
|
3970
|
-
return thrown;
|
|
3971
|
-
}
|
|
3972
|
-
}
|
|
3973
|
-
throw new Error("illegal catch attempt");
|
|
3974
|
-
},
|
|
3975
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
3976
|
-
return this.delegate = {
|
|
3977
|
-
iterator: values(iterable),
|
|
3978
|
-
resultName: resultName,
|
|
3979
|
-
nextLoc: nextLoc
|
|
3980
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
3981
|
-
}
|
|
3982
|
-
}, exports;
|
|
3983
|
-
}
|
|
3984
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3985
|
-
} (regeneratorRuntime$1));
|
|
3986
|
-
|
|
3987
|
-
// TODO(Babel 8): Remove this file.
|
|
3988
|
-
|
|
3989
|
-
var runtime = regeneratorRuntime$1.exports();
|
|
3990
|
-
var regenerator = runtime;
|
|
3991
|
-
|
|
3992
|
-
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
3993
|
-
try {
|
|
3994
|
-
regeneratorRuntime = runtime;
|
|
3995
|
-
} catch (accidentalStrictMode) {
|
|
3996
|
-
if (typeof globalThis === "object") {
|
|
3997
|
-
globalThis.regeneratorRuntime = runtime;
|
|
3998
|
-
} else {
|
|
3999
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
4000
|
-
}
|
|
4001
|
-
}
|
|
4002
|
-
|
|
4003
|
-
// THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
|
|
4004
|
-
var devicesBaseUrl = "/neeto_notifications/api/v1/devices";
|
|
4005
|
-
var create = function create(payload) {
|
|
4006
|
-
return axios.post(devicesBaseUrl, payload);
|
|
4007
|
-
};
|
|
4008
|
-
var destroy = function destroy(deviceId) {
|
|
4009
|
-
return axios["delete"]("".concat(devicesBaseUrl, "/").concat(deviceId));
|
|
4010
|
-
};
|
|
4011
|
-
var devicesApi = {
|
|
4012
|
-
create: create,
|
|
4013
|
-
destroy: destroy
|
|
4014
|
-
};
|
|
4015
|
-
|
|
4016
|
-
// THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE
|
|
4017
|
-
// AND IS USED FOR BROWSER NOTIFICATIONS
|
|
4018
|
-
// CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE
|
|
4019
|
-
|
|
4020
|
-
function urlB64ToUint8Array(base64String) {
|
|
4021
|
-
var padding = "=".repeat((4 - base64String.length % 4) % 4);
|
|
4022
|
-
var base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
|
4023
|
-
var rawData = window.atob(base64);
|
|
4024
|
-
var outputArray = new Uint8Array(rawData.length);
|
|
4025
|
-
for (var i = 0; i < rawData.length; ++i) {
|
|
4026
|
-
outputArray[i] = rawData.charCodeAt(i);
|
|
4027
|
-
}
|
|
4028
|
-
return outputArray;
|
|
4029
|
-
}
|
|
4030
|
-
var subscribeBrowserNotifications = /*#__PURE__*/function () {
|
|
4031
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(vapidPublicKey) {
|
|
4032
|
-
var subscription, permission, sw;
|
|
4033
|
-
return regenerator.wrap(function _callee$(_context) {
|
|
4034
|
-
while (1) switch (_context.prev = _context.next) {
|
|
4035
|
-
case 0:
|
|
4036
|
-
subscription = {};
|
|
4037
|
-
_context.prev = 1;
|
|
4038
|
-
_context.next = 4;
|
|
4039
|
-
return Notification.requestPermission();
|
|
4040
|
-
case 4:
|
|
4041
|
-
permission = _context.sent;
|
|
4042
|
-
if (!(permission !== "denied")) {
|
|
4043
|
-
_context.next = 15;
|
|
4044
|
-
break;
|
|
4045
|
-
}
|
|
4046
|
-
_context.next = 8;
|
|
4047
|
-
return navigator.serviceWorker.register("/serviceworker.js");
|
|
4048
|
-
case 8:
|
|
4049
|
-
_context.next = 10;
|
|
4050
|
-
return navigator.serviceWorker.ready;
|
|
4051
|
-
case 10:
|
|
4052
|
-
sw = _context.sent;
|
|
4053
|
-
_context.next = 13;
|
|
4054
|
-
return sw.pushManager.subscribe({
|
|
4055
|
-
userVisibleOnly: true,
|
|
4056
|
-
applicationServerKey: urlB64ToUint8Array(vapidPublicKey)
|
|
4057
|
-
});
|
|
4058
|
-
case 13:
|
|
4059
|
-
subscription = _context.sent;
|
|
4060
|
-
return _context.abrupt("return", subscription);
|
|
4061
|
-
case 15:
|
|
4062
|
-
logger.error("Notification Permission Denied");
|
|
4063
|
-
_context.next = 21;
|
|
4064
|
-
break;
|
|
4065
|
-
case 18:
|
|
4066
|
-
_context.prev = 18;
|
|
4067
|
-
_context.t0 = _context["catch"](1);
|
|
4068
|
-
logger.error(_context.t0);
|
|
4069
|
-
case 21:
|
|
4070
|
-
return _context.abrupt("return", null);
|
|
4071
|
-
case 22:
|
|
4072
|
-
case "end":
|
|
4073
|
-
return _context.stop();
|
|
4074
|
-
}
|
|
4075
|
-
}, _callee, null, [[1, 18]]);
|
|
4076
|
-
}));
|
|
4077
|
-
return function subscribeBrowserNotifications(_x) {
|
|
4078
|
-
return _ref.apply(this, arguments);
|
|
4079
|
-
};
|
|
4080
|
-
}();
|
|
4081
|
-
var unsubscribeBrowserNotifications = /*#__PURE__*/function () {
|
|
4082
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
4083
|
-
var sw, subscription, res;
|
|
4084
|
-
return regenerator.wrap(function _callee2$(_context2) {
|
|
4085
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
4086
|
-
case 0:
|
|
4087
|
-
_context2.prev = 0;
|
|
4088
|
-
_context2.next = 3;
|
|
4089
|
-
return navigator.serviceWorker.ready;
|
|
4090
|
-
case 3:
|
|
4091
|
-
sw = _context2.sent;
|
|
4092
|
-
_context2.next = 6;
|
|
4093
|
-
return sw.pushManager.getSubscription();
|
|
4094
|
-
case 6:
|
|
4095
|
-
subscription = _context2.sent;
|
|
4096
|
-
if (!subscription) {
|
|
4097
|
-
_context2.next = 12;
|
|
4098
|
-
break;
|
|
4099
|
-
}
|
|
4100
|
-
_context2.next = 10;
|
|
4101
|
-
return subscription.unsubscribe();
|
|
4102
|
-
case 10:
|
|
4103
|
-
res = _context2.sent;
|
|
4104
|
-
logger.error(res);
|
|
4105
|
-
case 12:
|
|
4106
|
-
_context2.next = 17;
|
|
4107
|
-
break;
|
|
4108
|
-
case 14:
|
|
4109
|
-
_context2.prev = 14;
|
|
4110
|
-
_context2.t0 = _context2["catch"](0);
|
|
4111
|
-
logger.error(_context2.t0);
|
|
4112
|
-
case 17:
|
|
4113
|
-
case "end":
|
|
4114
|
-
return _context2.stop();
|
|
4115
|
-
}
|
|
4116
|
-
}, _callee2, null, [[0, 14]]);
|
|
4117
|
-
}));
|
|
4118
|
-
return function unsubscribeBrowserNotifications() {
|
|
4119
|
-
return _ref2.apply(this, arguments);
|
|
4120
|
-
};
|
|
4121
|
-
}();
|
|
4122
|
-
var registerServiceWorker = /*#__PURE__*/function () {
|
|
4123
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(vapidPublicKey) {
|
|
4124
|
-
var res;
|
|
4125
|
-
return regenerator.wrap(function _callee3$(_context3) {
|
|
4126
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
4127
|
-
case 0:
|
|
4128
|
-
if (!(navigator.serviceWorker && vapidPublicKey)) {
|
|
4129
|
-
_context3.next = 5;
|
|
4130
|
-
break;
|
|
4131
|
-
}
|
|
4132
|
-
_context3.next = 3;
|
|
4133
|
-
return subscribeBrowserNotifications(vapidPublicKey);
|
|
4134
|
-
case 3:
|
|
4135
|
-
res = _context3.sent;
|
|
4136
|
-
return _context3.abrupt("return", res);
|
|
4137
|
-
case 5:
|
|
4138
|
-
logger.error("Service worker is not supported in this Browser");
|
|
4139
|
-
return _context3.abrupt("return", null);
|
|
4140
|
-
case 7:
|
|
4141
|
-
case "end":
|
|
4142
|
-
return _context3.stop();
|
|
4143
|
-
}
|
|
4144
|
-
}, _callee3);
|
|
4145
|
-
}));
|
|
4146
|
-
return function registerServiceWorker(_x2) {
|
|
4147
|
-
return _ref3.apply(this, arguments);
|
|
4148
|
-
};
|
|
4149
|
-
}();
|
|
4150
|
-
|
|
4151
|
-
var createBrowserSubscription = /*#__PURE__*/function () {
|
|
4152
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(subscription) {
|
|
4153
|
-
var payload;
|
|
4154
|
-
return regenerator.wrap(function _callee$(_context) {
|
|
4155
|
-
while (1) switch (_context.prev = _context.next) {
|
|
4156
|
-
case 0:
|
|
4157
|
-
if (!subscription) {
|
|
4158
|
-
_context.next = 13;
|
|
4159
|
-
break;
|
|
4160
|
-
}
|
|
4161
|
-
payload = {
|
|
4162
|
-
device: {
|
|
4163
|
-
subscription: subscription,
|
|
4164
|
-
platform: "browser"
|
|
4165
|
-
}
|
|
4166
|
-
};
|
|
4167
|
-
_context.prev = 2;
|
|
4168
|
-
_context.next = 5;
|
|
4169
|
-
return devicesApi.create(payload);
|
|
4170
|
-
case 5:
|
|
4171
|
-
localStorage.setItem("deviceId", JSON.stringify(subscription.toJSON().keys.auth));
|
|
4172
|
-
_context.next = 11;
|
|
4173
|
-
break;
|
|
4174
|
-
case 8:
|
|
4175
|
-
_context.prev = 8;
|
|
4176
|
-
_context.t0 = _context["catch"](2);
|
|
4177
|
-
logger.error("Device registration Failed: ", _context.t0);
|
|
4178
|
-
case 11:
|
|
4179
|
-
_context.next = 14;
|
|
4180
|
-
break;
|
|
4181
|
-
case 13:
|
|
4182
|
-
logger.error("Something went wrong while registering device for browser subscription");
|
|
4183
|
-
case 14:
|
|
4184
|
-
case "end":
|
|
4185
|
-
return _context.stop();
|
|
4186
|
-
}
|
|
4187
|
-
}, _callee, null, [[2, 8]]);
|
|
4188
|
-
}));
|
|
4189
|
-
return function createBrowserSubscription(_x) {
|
|
4190
|
-
return _ref.apply(this, arguments);
|
|
4191
|
-
};
|
|
4192
|
-
}();
|
|
4193
|
-
var destroyBrowserSubscription = /*#__PURE__*/function () {
|
|
4194
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
4195
|
-
var deviceId;
|
|
4196
|
-
return regenerator.wrap(function _callee2$(_context2) {
|
|
4197
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
4198
|
-
case 0:
|
|
4199
|
-
_context2.prev = 0;
|
|
4200
|
-
_context2.next = 3;
|
|
4201
|
-
return unsubscribeBrowserNotifications();
|
|
4202
|
-
case 3:
|
|
4203
|
-
deviceId = JSON.parse(localStorage.getItem("deviceId"));
|
|
4204
|
-
_context2.next = 6;
|
|
4205
|
-
return devicesApi.destroy(deviceId);
|
|
4206
|
-
case 6:
|
|
4207
|
-
localStorage.removeItem("deviceId");
|
|
4208
|
-
_context2.next = 12;
|
|
4209
|
-
break;
|
|
4210
|
-
case 9:
|
|
4211
|
-
_context2.prev = 9;
|
|
4212
|
-
_context2.t0 = _context2["catch"](0);
|
|
4213
|
-
logger.error("Something went wrong while unsubscribing browser notification:", _context2.t0);
|
|
4214
|
-
case 12:
|
|
4215
|
-
case "end":
|
|
4216
|
-
return _context2.stop();
|
|
4217
|
-
}
|
|
4218
|
-
}, _callee2, null, [[0, 9]]);
|
|
4219
|
-
}));
|
|
4220
|
-
return function destroyBrowserSubscription() {
|
|
4221
|
-
return _ref2.apply(this, arguments);
|
|
4222
|
-
};
|
|
4223
|
-
}();
|
|
4224
|
-
var registerBrowserNotifications = /*#__PURE__*/function () {
|
|
4225
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
|
|
4226
|
-
var vapidPublicKey,
|
|
4227
|
-
response,
|
|
4228
|
-
_args3 = arguments;
|
|
4229
|
-
return regenerator.wrap(function _callee3$(_context3) {
|
|
4230
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
4231
|
-
case 0:
|
|
4232
|
-
vapidPublicKey = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.env.VAPID_PUBLIC_KEY;
|
|
4233
|
-
_context3.next = 3;
|
|
4234
|
-
return registerServiceWorker(vapidPublicKey);
|
|
4235
|
-
case 3:
|
|
4236
|
-
response = _context3.sent;
|
|
4237
|
-
_context3.next = 6;
|
|
4238
|
-
return createBrowserSubscription(response);
|
|
4239
|
-
case 6:
|
|
4240
|
-
case "end":
|
|
4241
|
-
return _context3.stop();
|
|
4242
|
-
}
|
|
4243
|
-
}, _callee3);
|
|
4244
|
-
}));
|
|
4245
|
-
return function registerBrowserNotifications() {
|
|
4246
|
-
return _ref3.apply(this, arguments);
|
|
4247
|
-
};
|
|
4248
|
-
}();
|
|
4249
|
-
|
|
4250
|
-
var handleMetaClick = curry(function (history, params, event) {
|
|
4251
|
-
return isMetaKeyPressed(event) ? window.open(params.pathname || params, "_blank") : history.push(params);
|
|
4252
|
-
});
|
|
4253
|
-
var isMetaKeyPressed = function isMetaKeyPressed(event) {
|
|
4254
|
-
return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
|
|
4255
|
-
};
|
|
4256
|
-
|
|
4257
|
-
var withT = function withT(Component, options) {
|
|
4258
|
-
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
4259
|
-
return withTranslation(namespace, options)(Component);
|
|
4260
|
-
};
|
|
4261
|
-
|
|
4262
|
-
var withTitle = function withTitle(Component) {
|
|
4263
|
-
var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
4264
|
-
var PageTitle = function PageTitle(props) {
|
|
4265
|
-
var pageTitle = title ? "".concat(title, " | ").concat(globalProps.appName) : globalProps.appName;
|
|
4266
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Helmet, null, /*#__PURE__*/React__default.createElement("title", null, pageTitle)), /*#__PURE__*/React__default.createElement(Component, props));
|
|
4267
|
-
};
|
|
4268
|
-
return PageTitle;
|
|
4269
|
-
};
|
|
4270
|
-
|
|
4271
|
-
var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
|
|
4272
|
-
return function (partial) {
|
|
4273
|
-
return set(function (previous) {
|
|
4274
|
-
if (typeof partial === "function") partial = partial(previous);
|
|
4275
|
-
var overwrittenActions = keys(partial).filter(function (key) {
|
|
4276
|
-
return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
|
|
4277
|
-
});
|
|
4278
|
-
if (!isEmpty(overwrittenActions)) {
|
|
4279
|
-
throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
|
|
4280
|
-
}
|
|
4281
|
-
return partial;
|
|
4282
|
-
}, false);
|
|
4283
|
-
};
|
|
4284
|
-
};
|
|
4285
|
-
var withImmutableActions = function withImmutableActions(config) {
|
|
4286
|
-
return function (set, get, api) {
|
|
4287
|
-
return config(setWithoutModifyingActions(set), get, api);
|
|
4288
|
-
};
|
|
4289
|
-
};
|
|
4290
|
-
|
|
4291
|
-
/** @type {import("neetocommons/react-utils").ZustandStoreHook} */
|
|
4292
|
-
var useCheckpointStore = create$1(withImmutableActions(function (set) {
|
|
4293
|
-
return {
|
|
4294
|
-
checkpoints: {},
|
|
4295
|
-
setCheckpoint: function setCheckpoint(key, path) {
|
|
4296
|
-
return set(mergeDeepLeft({
|
|
4297
|
-
checkpoints: _defineProperty({}, key, path)
|
|
4298
|
-
}));
|
|
4299
|
-
}
|
|
4300
|
-
};
|
|
4301
|
-
}));
|
|
4302
|
-
var useRegisterNavigationCheckpoint = function useRegisterNavigationCheckpoint(key) {
|
|
4303
|
-
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.pathname + window.location.search;
|
|
4304
|
-
var setCheckpoint = useCheckpointStore(prop("setCheckpoint"));
|
|
4305
|
-
useEffect(function () {
|
|
4306
|
-
setCheckpoint(key, path);
|
|
4307
|
-
}, [key, path]);
|
|
4308
|
-
};
|
|
4309
|
-
var useNavigationCheckpoints = function useNavigationCheckpoints() {
|
|
4310
|
-
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4311
|
-
keys[_key] = arguments[_key];
|
|
4312
|
-
}
|
|
4313
|
-
return useCheckpointStore(function (store) {
|
|
4314
|
-
return pick(keys, store.checkpoints);
|
|
4315
|
-
}, shallow);
|
|
4316
|
-
};
|
|
4317
|
-
|
|
4318
|
-
var useStateWithDependency = function useStateWithDependency(defaultValue) {
|
|
4319
|
-
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [defaultValue];
|
|
4320
|
-
var _useState = useState(defaultValue),
|
|
4321
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
4322
|
-
value = _useState2[0],
|
|
4323
|
-
setValue = _useState2[1];
|
|
4324
|
-
useEffect(function () {
|
|
4325
|
-
setValue(defaultValue);
|
|
4326
|
-
}, dependencies);
|
|
4327
|
-
return [value, setValue];
|
|
4328
|
-
};
|
|
4329
|
-
|
|
4330
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
4331
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
4332
|
-
// generators (like Math.random()).
|
|
4333
|
-
let getRandomValues;
|
|
4334
|
-
const rnds8 = new Uint8Array(16);
|
|
4335
|
-
function rng() {
|
|
4336
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
4337
|
-
if (!getRandomValues) {
|
|
4338
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
4339
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
4340
|
-
|
|
4341
|
-
if (!getRandomValues) {
|
|
4342
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
4343
|
-
}
|
|
4344
|
-
}
|
|
4345
|
-
|
|
4346
|
-
return getRandomValues(rnds8);
|
|
4347
|
-
}
|
|
4348
|
-
|
|
4349
|
-
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
4350
|
-
|
|
4351
|
-
function validate(uuid) {
|
|
4352
|
-
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
4353
|
-
}
|
|
4354
|
-
|
|
4355
|
-
/**
|
|
4356
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
4357
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
4358
|
-
*/
|
|
4359
|
-
|
|
4360
|
-
const byteToHex = [];
|
|
4361
|
-
|
|
4362
|
-
for (let i = 0; i < 256; ++i) {
|
|
4363
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
|
-
function unsafeStringify(arr, offset = 0) {
|
|
4367
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
4368
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
4369
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4372
|
-
function parse(uuid) {
|
|
4373
|
-
if (!validate(uuid)) {
|
|
4374
|
-
throw TypeError('Invalid UUID');
|
|
4375
|
-
}
|
|
4376
|
-
|
|
4377
|
-
let v;
|
|
4378
|
-
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
4379
|
-
|
|
4380
|
-
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
4381
|
-
arr[1] = v >>> 16 & 0xff;
|
|
4382
|
-
arr[2] = v >>> 8 & 0xff;
|
|
4383
|
-
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
4384
|
-
|
|
4385
|
-
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
4386
|
-
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
4387
|
-
|
|
4388
|
-
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
4389
|
-
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
4390
|
-
|
|
4391
|
-
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
4392
|
-
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
4393
|
-
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
4394
|
-
|
|
4395
|
-
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
4396
|
-
arr[11] = v / 0x100000000 & 0xff;
|
|
4397
|
-
arr[12] = v >>> 24 & 0xff;
|
|
4398
|
-
arr[13] = v >>> 16 & 0xff;
|
|
4399
|
-
arr[14] = v >>> 8 & 0xff;
|
|
4400
|
-
arr[15] = v & 0xff;
|
|
4401
|
-
return arr;
|
|
4402
|
-
}
|
|
4403
|
-
|
|
4404
|
-
function stringToBytes(str) {
|
|
4405
|
-
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
4406
|
-
|
|
4407
|
-
const bytes = [];
|
|
4408
|
-
|
|
4409
|
-
for (let i = 0; i < str.length; ++i) {
|
|
4410
|
-
bytes.push(str.charCodeAt(i));
|
|
4411
|
-
}
|
|
4412
|
-
|
|
4413
|
-
return bytes;
|
|
4414
|
-
}
|
|
4415
|
-
|
|
4416
|
-
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
4417
|
-
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
4418
|
-
function v35(name, version, hashfunc) {
|
|
4419
|
-
function generateUUID(value, namespace, buf, offset) {
|
|
4420
|
-
var _namespace;
|
|
4421
|
-
|
|
4422
|
-
if (typeof value === 'string') {
|
|
4423
|
-
value = stringToBytes(value);
|
|
4424
|
-
}
|
|
4425
|
-
|
|
4426
|
-
if (typeof namespace === 'string') {
|
|
4427
|
-
namespace = parse(namespace);
|
|
4428
|
-
}
|
|
4429
|
-
|
|
4430
|
-
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
4431
|
-
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
4432
|
-
} // Compute hash of namespace and value, Per 4.3
|
|
4433
|
-
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
4434
|
-
// hashfunc([...namespace, ... value])`
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
let bytes = new Uint8Array(16 + value.length);
|
|
4438
|
-
bytes.set(namespace);
|
|
4439
|
-
bytes.set(value, namespace.length);
|
|
4440
|
-
bytes = hashfunc(bytes);
|
|
4441
|
-
bytes[6] = bytes[6] & 0x0f | version;
|
|
4442
|
-
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
4443
|
-
|
|
4444
|
-
if (buf) {
|
|
4445
|
-
offset = offset || 0;
|
|
4446
|
-
|
|
4447
|
-
for (let i = 0; i < 16; ++i) {
|
|
4448
|
-
buf[offset + i] = bytes[i];
|
|
4449
|
-
}
|
|
4450
|
-
|
|
4451
|
-
return buf;
|
|
4452
|
-
}
|
|
4453
|
-
|
|
4454
|
-
return unsafeStringify(bytes);
|
|
4455
|
-
} // Function#name is not settable on some platforms (#270)
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
try {
|
|
4459
|
-
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
4460
|
-
} catch (err) {} // For CommonJS default export support
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
generateUUID.DNS = DNS;
|
|
4464
|
-
generateUUID.URL = URL;
|
|
4465
|
-
return generateUUID;
|
|
4466
|
-
}
|
|
4467
|
-
|
|
4468
|
-
/*
|
|
4469
|
-
* Browser-compatible JavaScript MD5
|
|
4470
|
-
*
|
|
4471
|
-
* Modification of JavaScript MD5
|
|
4472
|
-
* https://github.com/blueimp/JavaScript-MD5
|
|
4473
|
-
*
|
|
4474
|
-
* Copyright 2011, Sebastian Tschan
|
|
4475
|
-
* https://blueimp.net
|
|
4476
|
-
*
|
|
4477
|
-
* Licensed under the MIT license:
|
|
4478
|
-
* https://opensource.org/licenses/MIT
|
|
4479
|
-
*
|
|
4480
|
-
* Based on
|
|
4481
|
-
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
|
4482
|
-
* Digest Algorithm, as defined in RFC 1321.
|
|
4483
|
-
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
|
4484
|
-
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
|
4485
|
-
* Distributed under the BSD License
|
|
4486
|
-
* See http://pajhome.org.uk/crypt/md5 for more info.
|
|
4487
|
-
*/
|
|
4488
|
-
function md5(bytes) {
|
|
4489
|
-
if (typeof bytes === 'string') {
|
|
4490
|
-
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
4491
|
-
|
|
4492
|
-
bytes = new Uint8Array(msg.length);
|
|
4493
|
-
|
|
4494
|
-
for (let i = 0; i < msg.length; ++i) {
|
|
4495
|
-
bytes[i] = msg.charCodeAt(i);
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
|
|
4499
|
-
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
|
|
4500
|
-
}
|
|
4501
|
-
/*
|
|
4502
|
-
* Convert an array of little-endian words to an array of bytes
|
|
4503
|
-
*/
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
function md5ToHexEncodedArray(input) {
|
|
4507
|
-
const output = [];
|
|
4508
|
-
const length32 = input.length * 32;
|
|
4509
|
-
const hexTab = '0123456789abcdef';
|
|
4510
|
-
|
|
4511
|
-
for (let i = 0; i < length32; i += 8) {
|
|
4512
|
-
const x = input[i >> 5] >>> i % 32 & 0xff;
|
|
4513
|
-
const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
|
|
4514
|
-
output.push(hex);
|
|
4515
|
-
}
|
|
4516
|
-
|
|
4517
|
-
return output;
|
|
4518
|
-
}
|
|
4519
|
-
/**
|
|
4520
|
-
* Calculate output length with padding and bit length
|
|
4521
|
-
*/
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
function getOutputLength(inputLength8) {
|
|
4525
|
-
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
|
|
4526
|
-
}
|
|
4527
|
-
/*
|
|
4528
|
-
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
|
4529
|
-
*/
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
function wordsToMd5(x, len) {
|
|
4533
|
-
/* append padding */
|
|
4534
|
-
x[len >> 5] |= 0x80 << len % 32;
|
|
4535
|
-
x[getOutputLength(len) - 1] = len;
|
|
4536
|
-
let a = 1732584193;
|
|
4537
|
-
let b = -271733879;
|
|
4538
|
-
let c = -1732584194;
|
|
4539
|
-
let d = 271733878;
|
|
4540
|
-
|
|
4541
|
-
for (let i = 0; i < x.length; i += 16) {
|
|
4542
|
-
const olda = a;
|
|
4543
|
-
const oldb = b;
|
|
4544
|
-
const oldc = c;
|
|
4545
|
-
const oldd = d;
|
|
4546
|
-
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
|
4547
|
-
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
4548
|
-
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
4549
|
-
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
4550
|
-
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
4551
|
-
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
4552
|
-
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
4553
|
-
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
4554
|
-
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
4555
|
-
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
4556
|
-
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
4557
|
-
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
4558
|
-
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
4559
|
-
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
4560
|
-
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
4561
|
-
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
4562
|
-
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
4563
|
-
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
4564
|
-
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
4565
|
-
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
|
4566
|
-
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
4567
|
-
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
4568
|
-
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
4569
|
-
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
4570
|
-
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
4571
|
-
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
4572
|
-
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
4573
|
-
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
4574
|
-
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
4575
|
-
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
4576
|
-
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
4577
|
-
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
4578
|
-
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
4579
|
-
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
4580
|
-
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
4581
|
-
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
4582
|
-
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
4583
|
-
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
4584
|
-
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
4585
|
-
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
4586
|
-
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
4587
|
-
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
|
4588
|
-
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
4589
|
-
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
4590
|
-
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
4591
|
-
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
4592
|
-
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
4593
|
-
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
4594
|
-
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
|
4595
|
-
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
4596
|
-
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
4597
|
-
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
4598
|
-
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
4599
|
-
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
4600
|
-
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
4601
|
-
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
4602
|
-
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
4603
|
-
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
4604
|
-
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
4605
|
-
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
4606
|
-
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
4607
|
-
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
4608
|
-
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
4609
|
-
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
4610
|
-
a = safeAdd(a, olda);
|
|
4611
|
-
b = safeAdd(b, oldb);
|
|
4612
|
-
c = safeAdd(c, oldc);
|
|
4613
|
-
d = safeAdd(d, oldd);
|
|
4614
|
-
}
|
|
4615
|
-
|
|
4616
|
-
return [a, b, c, d];
|
|
4617
|
-
}
|
|
4618
|
-
/*
|
|
4619
|
-
* Convert an array bytes to an array of little-endian words
|
|
4620
|
-
* Characters >255 have their high-byte silently ignored.
|
|
4621
|
-
*/
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
function bytesToWords(input) {
|
|
4625
|
-
if (input.length === 0) {
|
|
4626
|
-
return [];
|
|
4627
|
-
}
|
|
4628
|
-
|
|
4629
|
-
const length8 = input.length * 8;
|
|
4630
|
-
const output = new Uint32Array(getOutputLength(length8));
|
|
4631
|
-
|
|
4632
|
-
for (let i = 0; i < length8; i += 8) {
|
|
4633
|
-
output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
|
|
4634
|
-
}
|
|
4635
|
-
|
|
4636
|
-
return output;
|
|
4637
|
-
}
|
|
4638
|
-
/*
|
|
4639
|
-
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
4640
|
-
* to work around bugs in some JS interpreters.
|
|
4641
|
-
*/
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
function safeAdd(x, y) {
|
|
4645
|
-
const lsw = (x & 0xffff) + (y & 0xffff);
|
|
4646
|
-
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
4647
|
-
return msw << 16 | lsw & 0xffff;
|
|
4648
|
-
}
|
|
4649
|
-
/*
|
|
4650
|
-
* Bitwise rotate a 32-bit number to the left.
|
|
4651
|
-
*/
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
function bitRotateLeft(num, cnt) {
|
|
4655
|
-
return num << cnt | num >>> 32 - cnt;
|
|
4656
|
-
}
|
|
4657
|
-
/*
|
|
4658
|
-
* These functions implement the four basic operations the algorithm uses.
|
|
4659
|
-
*/
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
function md5cmn(q, a, b, x, s, t) {
|
|
4663
|
-
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
|
4664
|
-
}
|
|
4665
|
-
|
|
4666
|
-
function md5ff(a, b, c, d, x, s, t) {
|
|
4667
|
-
return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
|
4668
|
-
}
|
|
4669
|
-
|
|
4670
|
-
function md5gg(a, b, c, d, x, s, t) {
|
|
4671
|
-
return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
|
4672
|
-
}
|
|
4673
|
-
|
|
4674
|
-
function md5hh(a, b, c, d, x, s, t) {
|
|
4675
|
-
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
function md5ii(a, b, c, d, x, s, t) {
|
|
4679
|
-
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
4680
|
-
}
|
|
4681
|
-
|
|
4682
|
-
v35('v3', 0x30, md5);
|
|
4683
|
-
|
|
4684
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
4685
|
-
var native = {
|
|
4686
|
-
randomUUID
|
|
4687
|
-
};
|
|
4688
|
-
|
|
4689
|
-
function v4(options, buf, offset) {
|
|
4690
|
-
if (native.randomUUID && !buf && !options) {
|
|
4691
|
-
return native.randomUUID();
|
|
4692
|
-
}
|
|
4693
|
-
|
|
4694
|
-
options = options || {};
|
|
4695
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
4696
|
-
|
|
4697
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
4698
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
4699
|
-
|
|
4700
|
-
if (buf) {
|
|
4701
|
-
offset = offset || 0;
|
|
4702
|
-
|
|
4703
|
-
for (let i = 0; i < 16; ++i) {
|
|
4704
|
-
buf[offset + i] = rnds[i];
|
|
4705
|
-
}
|
|
4706
|
-
|
|
4707
|
-
return buf;
|
|
4708
|
-
}
|
|
4709
|
-
|
|
4710
|
-
return unsafeStringify(rnds);
|
|
4711
|
-
}
|
|
4712
|
-
|
|
4713
|
-
// Adapted from Chris Veness' SHA1 code at
|
|
4714
|
-
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
4715
|
-
function f(s, x, y, z) {
|
|
4716
|
-
switch (s) {
|
|
4717
|
-
case 0:
|
|
4718
|
-
return x & y ^ ~x & z;
|
|
4719
|
-
|
|
4720
|
-
case 1:
|
|
4721
|
-
return x ^ y ^ z;
|
|
4722
|
-
|
|
4723
|
-
case 2:
|
|
4724
|
-
return x & y ^ x & z ^ y & z;
|
|
4725
|
-
|
|
4726
|
-
case 3:
|
|
4727
|
-
return x ^ y ^ z;
|
|
4728
|
-
}
|
|
4729
|
-
}
|
|
4730
|
-
|
|
4731
|
-
function ROTL(x, n) {
|
|
4732
|
-
return x << n | x >>> 32 - n;
|
|
4733
|
-
}
|
|
4734
|
-
|
|
4735
|
-
function sha1(bytes) {
|
|
4736
|
-
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
4737
|
-
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
4738
|
-
|
|
4739
|
-
if (typeof bytes === 'string') {
|
|
4740
|
-
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
4741
|
-
|
|
4742
|
-
bytes = [];
|
|
4743
|
-
|
|
4744
|
-
for (let i = 0; i < msg.length; ++i) {
|
|
4745
|
-
bytes.push(msg.charCodeAt(i));
|
|
4746
|
-
}
|
|
4747
|
-
} else if (!Array.isArray(bytes)) {
|
|
4748
|
-
// Convert Array-like to Array
|
|
4749
|
-
bytes = Array.prototype.slice.call(bytes);
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
bytes.push(0x80);
|
|
4753
|
-
const l = bytes.length / 4 + 2;
|
|
4754
|
-
const N = Math.ceil(l / 16);
|
|
4755
|
-
const M = new Array(N);
|
|
4756
|
-
|
|
4757
|
-
for (let i = 0; i < N; ++i) {
|
|
4758
|
-
const arr = new Uint32Array(16);
|
|
4759
|
-
|
|
4760
|
-
for (let j = 0; j < 16; ++j) {
|
|
4761
|
-
arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
|
|
4762
|
-
}
|
|
4763
|
-
|
|
4764
|
-
M[i] = arr;
|
|
4765
|
-
}
|
|
4766
|
-
|
|
4767
|
-
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
4768
|
-
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
4769
|
-
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
|
|
4770
|
-
|
|
4771
|
-
for (let i = 0; i < N; ++i) {
|
|
4772
|
-
const W = new Uint32Array(80);
|
|
4773
|
-
|
|
4774
|
-
for (let t = 0; t < 16; ++t) {
|
|
4775
|
-
W[t] = M[i][t];
|
|
4776
|
-
}
|
|
4777
|
-
|
|
4778
|
-
for (let t = 16; t < 80; ++t) {
|
|
4779
|
-
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
|
4780
|
-
}
|
|
4781
|
-
|
|
4782
|
-
let a = H[0];
|
|
4783
|
-
let b = H[1];
|
|
4784
|
-
let c = H[2];
|
|
4785
|
-
let d = H[3];
|
|
4786
|
-
let e = H[4];
|
|
4787
|
-
|
|
4788
|
-
for (let t = 0; t < 80; ++t) {
|
|
4789
|
-
const s = Math.floor(t / 20);
|
|
4790
|
-
const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
|
4791
|
-
e = d;
|
|
4792
|
-
d = c;
|
|
4793
|
-
c = ROTL(b, 30) >>> 0;
|
|
4794
|
-
b = a;
|
|
4795
|
-
a = T;
|
|
4796
|
-
}
|
|
4797
|
-
|
|
4798
|
-
H[0] = H[0] + a >>> 0;
|
|
4799
|
-
H[1] = H[1] + b >>> 0;
|
|
4800
|
-
H[2] = H[2] + c >>> 0;
|
|
4801
|
-
H[3] = H[3] + d >>> 0;
|
|
4802
|
-
H[4] = H[4] + e >>> 0;
|
|
4803
|
-
}
|
|
4804
|
-
|
|
4805
|
-
return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
|
|
4806
|
-
}
|
|
4807
|
-
|
|
4808
|
-
v35('v5', 0x50, sha1);
|
|
4809
|
-
|
|
4810
|
-
var useTimerStore = create$1(function () {
|
|
4811
|
-
return {};
|
|
4812
|
-
});
|
|
4813
|
-
setInterval(function () {
|
|
4814
|
-
var currentState = useTimerStore.getState();
|
|
4815
|
-
var nextState = {};
|
|
4816
|
-
var now = Date.now();
|
|
4817
|
-
for (var key in currentState) {
|
|
4818
|
-
var _currentState$key = currentState[key],
|
|
4819
|
-
lastUpdated = _currentState$key.lastUpdated,
|
|
4820
|
-
interval = _currentState$key.interval;
|
|
4821
|
-
var shouldUpdate = now - lastUpdated >= interval;
|
|
4822
|
-
if (shouldUpdate) nextState[key] = {
|
|
4823
|
-
lastUpdated: now,
|
|
4824
|
-
interval: interval
|
|
4825
|
-
};
|
|
4826
|
-
}
|
|
4827
|
-
if (!isEmpty(nextState)) useTimerStore.setState(nextState);
|
|
4828
|
-
}, 1000);
|
|
4829
|
-
var useTimer = function useTimer() {
|
|
4830
|
-
var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60;
|
|
4831
|
-
var key = useMemo(function () {
|
|
4832
|
-
return v4();
|
|
4833
|
-
}, []);
|
|
4834
|
-
useEffect(function () {
|
|
4835
|
-
useTimerStore.setState(_defineProperty({}, key, {
|
|
4836
|
-
lastUpdated: Date.now(),
|
|
4837
|
-
interval: 1000 * interval // convert seconds to ms
|
|
4838
|
-
}));
|
|
4839
|
-
|
|
4840
|
-
return function () {
|
|
4841
|
-
return useTimerStore.setState(omit([key], useTimerStore.getState()), true);
|
|
4842
|
-
};
|
|
4843
|
-
}, [interval, key]);
|
|
4844
|
-
return useTimerStore(prop(key));
|
|
4845
|
-
};
|
|
4846
|
-
|
|
4847
|
-
var useUpdateEffect = function useUpdateEffect(callback) {
|
|
4848
|
-
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
4849
|
-
var isInitialMount = useRef(true);
|
|
4850
|
-
useEffect(function () {
|
|
4851
|
-
if (isInitialMount.current) {
|
|
4852
|
-
isInitialMount.current = false;
|
|
4853
|
-
return;
|
|
4854
|
-
}
|
|
4855
|
-
callback();
|
|
4856
|
-
}, dependencies);
|
|
4857
|
-
};
|
|
4858
|
-
|
|
4859
|
-
export { HoneybadgerErrorBoundary, PrivateRoute, destroyBrowserSubscription, handleMetaClick, isMetaKeyPressed, registerBrowserNotifications, useDebounce, useDisplayErrorPage, useErrorDisplayStore, useFetchNeetoApps, useFuncDebounce, useHotKeys, useIsElementVisibleInDom, useKeyboardShortcutsPaneState, useLocalStorage, useMutationWithInvalidation, useNavigationCheckpoints, useOnClickOutside, usePersistedQuery, usePrevious, useQueryParams, useRegisterNavigationCheckpoint, useStateWithDependency, useTimer, useUpdateEffect, withImmutableActions, withT, withTitle };
|
|
4860
|
-
//# sourceMappingURL=react-utils.js.map
|