cat-bookmarker/assets/node_modules/react-router/umd/react-router.development.js...

1 line
68 KiB
Plaintext
Raw Permalink Normal View History

2024-03-10 18:52:04 +00:00
{"version":3,"file":"react-router.development.js","sources":["../../../../packages/react-router/lib/context.ts","../../../../packages/react-router/lib/router.ts","../../../../packages/react-router/lib/hooks.tsx","../../../../packages/react-router/lib/components.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { History, Location } from \"history\";\nimport { Action as NavigationType } from \"history\";\n\nimport type { RouteMatch } from \"./router\";\n\n/**\n * A Navigator is a \"location changer\"; it's how you get to different locations.\n *\n * Every history instance conforms to the Navigator interface, but the\n * distinction is useful primarily when it comes to the low-level <Router> API\n * where both the location and a navigator must be provided separately in order\n * to avoid \"tearing\" that may occur in a suspense-enabled app if the action\n * and/or location were to be read directly from the history instance.\n */\nexport type Navigator = Pick<History, \"go\" | \"push\" | \"replace\" | \"createHref\">;\n\ninterface NavigationContextObject {\n basename: string;\n navigator: Navigator;\n static: boolean;\n}\n\nexport const NavigationContext = React.createContext<NavigationContextObject>(\n null!\n);\n\nif (__DEV__) {\n NavigationContext.displayName = \"Navigation\";\n}\n\ninterface LocationContextObject {\n location: Location;\n navigationType: NavigationType;\n}\n\nexport const LocationContext = React.createContext<LocationContextObject>(\n null!\n);\n\nif (__DEV__) {\n LocationContext.displayName = \"Location\";\n}\n\ninterface RouteContextObject {\n outlet: React.ReactElement | null;\n matches: RouteMatch[];\n}\n\nexport const RouteContext = React.createContext<RouteContextObject>({\n outlet: null,\n matches: [],\n});\n\nif (__DEV__) {\n RouteContext.displayName = \"Route\";\n}\n","import type { Location, Path, To } from \"history\";\nimport { parsePath } from \"history\";\n\nexport function invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nexport function warning(cond: any, message: string): void {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging React Router!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nconst alreadyWarned: Record<string, boolean> = {};\nexport function warningOnce(key: string, cond: boolean, message: string) {\n if (!cond && !alreadyWarned[key]) {\n alreadyWarned[key] = true;\n warning(false, message);\n }\n}\n\ntype ParamParseFailed = { failed: true };\n\ntype ParamParseSegment<Segment extends string> =\n // Check here if there exists a forward slash in the string.\n Segment extends `${infer LeftSegment}/${infer RightSegment}`\n ? // If there is a forward slash, then attempt to parse each side of the\n // forward slash.\n ParamParseSegment<LeftSegment> extends infer LeftResult\n ? ParamParseSegment<RightSegment> extends infer RightResult\n ? LeftResult extends string\n ? // If the left side is successfully parsed as a param, then check if\n // the right side can be successfully parsed as well. If both sides\n // can be parsed, then the result is a union of the two sides\n // (read: \"foo\" | \"bar\").\n RightResult extends string\n ? LeftResult | RightResult\n : LeftResult\n : // If the left side is not successfully parsed as a param, then check\n // if only the right side can be successfully parse as a param. If it\n // can, then the result is just right, else it's a failure.\n RightResult extends string\n ? RightResult\n : ParamParseFaile