UNPKG

@relax.dev/router

Version:
74 lines (71 loc) 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.preventBlinkingBySettingScrollRestoration = preventBlinkingBySettingScrollRestoration; exports.getDisplayName = getDisplayName; exports.isDesktopSafari = isDesktopSafari; exports.getTypedRouterElements = getTypedRouterElements; var _Page = require("./entities/Page"); var _Router = require("./entities/Router"); var _useRouter = require("./hooks/useRouter"); var _useLocation = require("./hooks/useLocation"); var _useParams = require("./hooks/useParams"); var _useFirstPageCheck = require("./hooks/useFirstPageCheck"); var _useThrottlingLocation = require("./hooks/useThrottlingLocation"); /** * @ignore * @packageDocumentation */ /** * @ignore */ function preventBlinkingBySettingScrollRestoration() { if ('scrollRestoration' in window.history && window.history.scrollRestoration === 'auto') { window.history.scrollRestoration = 'manual'; } } /** * @ignore * @param WrappedComponent */ function getDisplayName(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } function isDesktopSafari() { var ua = window.navigator.userAgent; return ua.indexOf('AppleWebKit/') > 0 && ua.indexOf('Safari/') > 0 && !ua.includes('Chrome/') && !ua.includes('Mobile/') && !ua.includes('Android') && !ua.includes('iPhone'); } function getTypedRouterElements() { var createRouter = function createRouter(routes) { var routerConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; return new _Router.Router(routes, routerConfig); }; var createPage = function createPage(panelId, viewId, rootId) { return new _Page.Page(panelId, viewId, rootId); }; var useRouter = function useRouter(withUpdate) { return (0, _useRouter.useRouter)(withUpdate); }; var useLocation = function useLocation(withUpdate, panelId) { return (0, _useLocation.useLocation)(withUpdate, panelId); }; var useParams = function useParams(panelId) { return (0, _useParams.useParams)(panelId); }; var useFirstPageCheck = function useFirstPageCheck(withUpdate, panelId) { return (0, _useFirstPageCheck.useFirstPageCheck)(withUpdate, panelId); }; var useThrottlingLocation = function useThrottlingLocation() { return (0, _useThrottlingLocation.useThrottlingLocation)(); }; return { createRouter: createRouter, createPage: createPage, useRouter: useRouter, useLocation: useLocation, useParams: useParams, useFirstPageCheck: useFirstPageCheck, useThrottlingLocation: useThrottlingLocation }; }