@tanstack/router-core 0.0.1-beta.9 → 1.97.21
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/cjs/Matches.cjs +13 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +28 -0
- package/dist/cjs/RouterProvider.d.cts +18 -0
- package/dist/cjs/defer.cjs +25 -0
- package/dist/cjs/defer.cjs.map +1 -0
- package/dist/cjs/defer.d.cts +20 -0
- package/dist/cjs/index.cjs +50 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +25 -0
- package/dist/cjs/link.cjs +5 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +51 -0
- package/dist/cjs/location.d.cts +12 -0
- package/dist/cjs/manifest.d.cts +24 -0
- package/dist/cjs/path.cjs +289 -0
- package/dist/cjs/path.cjs.map +1 -0
- package/dist/cjs/path.d.cts +34 -0
- package/dist/cjs/qss.cjs +51 -0
- package/dist/cjs/qss.cjs.map +1 -0
- package/dist/cjs/qss.d.cts +27 -0
- package/dist/cjs/root.cjs +5 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/root.d.cts +2 -0
- package/dist/cjs/route.d.cts +148 -0
- package/dist/cjs/router.cjs +19 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +31 -0
- package/dist/cjs/searchMiddleware.cjs +42 -0
- package/dist/cjs/searchMiddleware.cjs.map +1 -0
- package/dist/cjs/searchMiddleware.d.cts +5 -0
- package/dist/cjs/searchParams.cjs +61 -0
- package/dist/cjs/searchParams.cjs.map +1 -0
- package/dist/cjs/searchParams.d.cts +7 -0
- package/dist/cjs/serializer.d.cts +15 -0
- package/dist/cjs/structuralSharing.d.cts +4 -0
- package/dist/cjs/utils.cjs +155 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +81 -0
- package/dist/cjs/validators.d.cts +51 -0
- package/dist/esm/Matches.d.ts +28 -0
- package/dist/esm/Matches.js +13 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +18 -0
- package/dist/esm/defer.d.ts +20 -0
- package/dist/esm/defer.js +25 -0
- package/dist/esm/defer.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/link.d.ts +51 -0
- package/dist/esm/link.js +5 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/location.d.ts +12 -0
- package/dist/esm/manifest.d.ts +24 -0
- package/dist/esm/path.d.ts +34 -0
- package/dist/esm/path.js +289 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/qss.d.ts +27 -0
- package/dist/esm/qss.js +51 -0
- package/dist/esm/qss.js.map +1 -0
- package/dist/esm/root.d.ts +2 -0
- package/dist/esm/root.js +5 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/route.d.ts +148 -0
- package/dist/esm/router.d.ts +31 -0
- package/dist/esm/router.js +19 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/searchMiddleware.d.ts +5 -0
- package/dist/esm/searchMiddleware.js +42 -0
- package/dist/esm/searchMiddleware.js.map +1 -0
- package/dist/esm/searchParams.d.ts +7 -0
- package/dist/esm/searchParams.js +61 -0
- package/dist/esm/searchParams.js.map +1 -0
- package/dist/esm/serializer.d.ts +15 -0
- package/dist/esm/structuralSharing.d.ts +4 -0
- package/dist/esm/utils.d.ts +81 -0
- package/dist/esm/utils.js +155 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/validators.d.ts +51 -0
- package/package.json +35 -32
- package/src/Matches.ts +94 -0
- package/src/RouterProvider.ts +20 -0
- package/src/defer.ts +52 -0
- package/src/index.ts +206 -19
- package/src/link.ts +122 -300
- package/src/location.ts +13 -0
- package/src/manifest.ts +32 -0
- package/src/path.ts +238 -47
- package/src/qss.ts +56 -19
- package/src/root.ts +2 -0
- package/src/route.ts +296 -223
- package/src/router.ts +34 -1281
- package/src/searchMiddleware.ts +54 -0
- package/src/searchParams.ts +43 -20
- package/src/serializer.ts +24 -0
- package/src/structuralSharing.ts +7 -0
- package/src/utils.ts +314 -75
- package/src/validators.ts +121 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/index.js +0 -58
- package/build/cjs/packages/router-core/src/index.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js +0 -222
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js +0 -71
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -150
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -822
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js +0 -70
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js +0 -125
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/build/esm/index.js +0 -2481
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -4034
- package/build/stats-react.json +0 -493
- package/build/types/index.d.ts +0 -618
- package/build/umd/index.development.js +0 -2514
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -12
- package/build/umd/index.production.js.map +0 -1
- package/src/frameworks.ts +0 -12
- package/src/routeConfig.ts +0 -495
- package/src/routeInfo.ts +0 -228
- package/src/routeMatch.ts +0 -374
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.cjs","sources":["../../src/path.ts"],"sourcesContent":["import { last } from './utils'\nimport type { MatchLocation } from './RouterProvider'\nimport type { AnyPathParams } from './route'\n\nexport interface Segment {\n type: 'pathname' | 'param' | 'wildcard'\n value: string\n}\n\nexport function joinPaths(paths: Array<string | undefined>) {\n return cleanPath(\n paths\n .filter((val) => {\n return val !== undefined\n })\n .join('/'),\n )\n}\n\nexport function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function trimPathRight(path: string) {\n return path === '/' ? path : path.replace(/\\/{1,}$/, '')\n}\n\nexport function trimPath(path: string) {\n return trimPathRight(trimPathLeft(path))\n}\n\nexport function removeTrailingSlash(value: string, basepath: string): string {\n if (value.endsWith('/') && value !== '/' && value !== `${basepath}/`) {\n return value.slice(0, -1)\n }\n return value\n}\n\n// intended to only compare path name\n// see the usage in the isActive under useLinkProps\n// /sample/path1 = /sample/path1/\n// /sample/path1/some <> /sample/path1\nexport function exactPathTest(\n pathName1: string,\n pathName2: string,\n basepath: string,\n): boolean {\n return (\n removeTrailingSlash(pathName1, basepath) ===\n removeTrailingSlash(pathName2, basepath)\n )\n}\n\n// When resolving relative paths, we treat all paths as if they are trailing slash\n// documents. All trailing slashes are removed after the path is resolved.\n// Here are a few examples:\n//\n// /a/b/c + ./d = /a/b/c/d\n// /a/b/c + ../d = /a/b/d\n// /a/b/c + ./d/ = /a/b/c/d\n// /a/b/c + ../d/ = /a/b/d\n// /a/b/c + ./ = /a/b/c\n//\n// Absolute paths that start with `/` short circuit the resolution process to the root\n// path.\n//\n// Here are some examples:\n//\n// /a/b/c + /d = /d\n// /a/b/c + /d/ = /d\n// /a/b/c + / = /\n//\n// Non-.-prefixed paths are still treated as relative paths, resolved like `./`\n//\n// Here are some examples:\n//\n// /a/b/c + d = /a/b/c/d\n// /a/b/c + d/ = /a/b/c/d\n// /a/b/c + d/e = /a/b/c/d/e\ninterface ResolvePathOptions {\n basepath: string\n base: string\n to: string\n trailingSlash?: 'always' | 'never' | 'preserve'\n caseSensitive?: boolean\n}\n\nexport function resolvePath({\n basepath,\n base,\n to,\n trailingSlash = 'never',\n caseSensitive,\n}: ResolvePathOptions) {\n base = removeBasepath(basepath, base, caseSensitive)\n to = removeBasepath(basepath, to, caseSensitive)\n\n let baseSegments = parsePathname(base)\n const toSegments = parsePathname(to)\n\n if (baseSegments.length > 1 && last(baseSegments)?.value === '/') {\n baseSegments.pop()\n }\n\n toSegments.forEach((toSegment, index) => {\n if (toSegment.value === '/') {\n if (!index) {\n // Leading slash\n baseSegments = [toSegment]\n } else if (index === toSegments.length - 1) {\n // Trailing Slash\n baseSegments.push(toSegment)\n } else {\n // ignore inter-slashes\n }\n } else if (toSegment.value === '..') {\n baseSegments.pop()\n } else if (toSegment.value === '.') {\n // ignore\n } else {\n baseSegments.push(toSegment)\n }\n })\n\n if (baseSegments.length > 1) {\n if (last(baseSegments)?.value === '/') {\n if (trailingSlash === 'never') {\n baseSegments.pop()\n }\n } else if (trailingSlash === 'always') {\n baseSegments.push({ type: 'pathname', value: '/' })\n }\n }\n\n const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)])\n return cleanPath(joined)\n}\n\nexport function parsePathname(pathname?: string): Array<Segment> {\n if (!pathname) {\n return []\n }\n\n pathname = cleanPath(pathname)\n\n const segments: Array<Segment> = []\n\n if (pathname.slice(0, 1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!pathname) {\n return segments\n }\n\n // Remove empty segments and '.' segments\n const split = pathname.split('/').filter(Boolean)\n\n segments.push(\n ...split.map((part): Segment => {\n if (part === '$' || part === '*') {\n return {\n type: 'wildcard',\n value: part,\n }\n }\n\n if (part.charAt(0) === '$') {\n return {\n type: 'param',\n value: part,\n }\n }\n\n return {\n type: 'pathname',\n value: decodeURI(part),\n }\n }),\n )\n\n if (pathname.slice(-1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n return segments\n}\n\ninterface InterpolatePathOptions {\n path?: string\n params: Record<string, unknown>\n leaveWildcards?: boolean\n leaveParams?: boolean\n // Map of encoded chars to decoded chars (e.g. '%40' -> '@') that should remain decoded in path params\n decodeCharMap?: Map<string, string>\n}\n\nexport function interpolatePath({\n path,\n params,\n leaveWildcards,\n leaveParams,\n decodeCharMap,\n}: InterpolatePathOptions) {\n const interpolatedPathSegments = parsePathname(path)\n const encodedParams: any = {}\n\n for (const [key, value] of Object.entries(params)) {\n const isValueString = typeof value === 'string'\n\n if (['*', '_splat'].includes(key)) {\n // the splat/catch-all routes shouldn't have the '/' encoded out\n encodedParams[key] = isValueString ? encodeURI(value) : value\n } else {\n encodedParams[key] = isValueString\n ? encodePathParam(value, decodeCharMap)\n : value\n }\n }\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = encodedParams._splat\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n if (leaveParams) {\n const value = encodedParams[segment.value]\n return `${segment.value}${value ?? ''}`\n }\n return encodedParams![segment.value.substring(1)] ?? 'undefined'\n }\n\n return segment.value\n }),\n )\n}\n\nfunction encodePathParam(value: string, decodeCharMap?: Map<string, string>) {\n let encoded = encodeURIComponent(value)\n if (decodeCharMap) {\n for (const [encodedChar, char] of decodeCharMap) {\n encoded = encoded.replaceAll(encodedChar, char)\n }\n }\n return encoded\n}\n\nexport function matchPathname(\n basepath: string,\n currentPathname: string,\n matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>,\n): AnyPathParams | undefined {\n const pathParams = matchByPath(basepath, currentPathname, matchLocation)\n // const searchMatched = matchBySearch(location.search, matchLocation)\n\n if (matchLocation.to && !pathParams) {\n return\n }\n\n return pathParams ?? {}\n}\n\nexport function removeBasepath(\n basepath: string,\n pathname: string,\n caseSensitive: boolean = false,\n) {\n // normalize basepath and pathname for case-insensitive comparison if needed\n const normalizedBasepath = caseSensitive ? basepath : basepath.toLowerCase()\n const normalizedPathname = caseSensitive ? pathname : pathname.toLowerCase()\n\n switch (true) {\n // default behaviour is to serve app from the root - pathname\n // left untouched\n case normalizedBasepath === '/':\n return pathname\n\n // shortcut for removing the basepath if it matches the pathname\n case normalizedPathname === normalizedBasepath:\n return ''\n\n // in case pathname is shorter than basepath - there is\n // nothing to remove\n case pathname.length < basepath.length:\n return pathname\n\n // avoid matching partial segments - strict equality handled\n // earlier, otherwise, basepath separated from pathname with\n // separator, therefore lack of separator means partial\n // segment match (`/app` should not match `/application`)\n case normalizedPathname[normalizedBasepath.length] !== '/':\n return pathname\n\n // remove the basepath from the pathname if it starts with it\n case normalizedPathname.startsWith(normalizedBasepath):\n return pathname.slice(basepath.length)\n\n // otherwise, return the pathname as is\n default:\n return pathname\n }\n}\n\nexport function matchByPath(\n basepath: string,\n from: string,\n matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>,\n): Record<string, string> | undefined {\n // check basepath first\n if (basepath !== '/' && !from.startsWith(basepath)) {\n return undefined\n }\n // Remove the base path from the pathname\n from = removeBasepath(basepath, from, matchLocation.caseSensitive)\n // Default to to $ (wildcard)\n const to = removeBasepath(\n basepath,\n `${matchLocation.to ?? '$'}`,\n matchLocation.caseSensitive,\n )\n\n // Parse the from and to\n const baseSegments = parsePathname(from)\n const routeSegments = parsePathname(to)\n\n if (!from.startsWith('/')) {\n baseSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!to.startsWith('/')) {\n routeSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n const params: Record<string, string> = {}\n\n const isMatch = (() => {\n for (\n let i = 0;\n i < Math.max(baseSegments.length, routeSegments.length);\n i++\n ) {\n const baseSegment = baseSegments[i]\n const routeSegment = routeSegments[i]\n\n const isLastBaseSegment = i >= baseSegments.length - 1\n const isLastRouteSegment = i >= routeSegments.length - 1\n\n if (routeSegment) {\n if (routeSegment.type === 'wildcard') {\n const _splat = decodeURI(\n joinPaths(baseSegments.slice(i).map((d) => d.value)),\n )\n // TODO: Deprecate *\n params['*'] = _splat\n params['_splat'] = _splat\n return true\n }\n\n if (routeSegment.type === 'pathname') {\n if (routeSegment.value === '/' && !baseSegment?.value) {\n return true\n }\n\n if (baseSegment) {\n if (matchLocation.caseSensitive) {\n if (routeSegment.value !== baseSegment.value) {\n return false\n }\n } else if (\n routeSegment.value.toLowerCase() !==\n baseSegment.value.toLowerCase()\n ) {\n return false\n }\n }\n }\n\n if (!baseSegment) {\n return false\n }\n\n if (routeSegment.type === 'param') {\n if (baseSegment.value === '/') {\n return false\n }\n if (baseSegment.value.charAt(0) !== '$') {\n params[routeSegment.value.substring(1)] = decodeURIComponent(\n baseSegment.value,\n )\n }\n }\n }\n\n if (!isLastBaseSegment && isLastRouteSegment) {\n params['**'] = joinPaths(baseSegments.slice(i + 1).map((d) => d.value))\n return !!matchLocation.fuzzy && routeSegment?.value !== '/'\n }\n }\n\n return true\n })()\n\n return isMatch ? params : undefined\n}\n"],"names":["last"],"mappings":";;;AASO,SAAS,UAAU,OAAkC;AACnD,SAAA;AAAA,IACL,MACG,OAAO,CAAC,QAAQ;AACf,aAAO,QAAQ;AAAA,IAAA,CAChB,EACA,KAAK,GAAG;AAAA,EACb;AACF;AAEO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,G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AC;AACtE,eAAO,CAAC,CAAC,cAAc,UAAS,6CAAc,WAAU;AAAA,MAAA;AAAA,IAC1D;AAGK,WAAA;AAAA,EAAA,GACN;AAEH,SAAO,UAAU,SAAS;AAC5B;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MatchLocation } from './RouterProvider.cjs';
|
|
2
|
+
import { AnyPathParams } from './route.cjs';
|
|
3
|
+
export interface Segment {
|
|
4
|
+
type: 'pathname' | 'param' | 'wildcard';
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function joinPaths(paths: Array<string | undefined>): string;
|
|
8
|
+
export declare function cleanPath(path: string): string;
|
|
9
|
+
export declare function trimPathLeft(path: string): string;
|
|
10
|
+
export declare function trimPathRight(path: string): string;
|
|
11
|
+
export declare function trimPath(path: string): string;
|
|
12
|
+
export declare function removeTrailingSlash(value: string, basepath: string): string;
|
|
13
|
+
export declare function exactPathTest(pathName1: string, pathName2: string, basepath: string): boolean;
|
|
14
|
+
interface ResolvePathOptions {
|
|
15
|
+
basepath: string;
|
|
16
|
+
base: string;
|
|
17
|
+
to: string;
|
|
18
|
+
trailingSlash?: 'always' | 'never' | 'preserve';
|
|
19
|
+
caseSensitive?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function resolvePath({ basepath, base, to, trailingSlash, caseSensitive, }: ResolvePathOptions): string;
|
|
22
|
+
export declare function parsePathname(pathname?: string): Array<Segment>;
|
|
23
|
+
interface InterpolatePathOptions {
|
|
24
|
+
path?: string;
|
|
25
|
+
params: Record<string, unknown>;
|
|
26
|
+
leaveWildcards?: boolean;
|
|
27
|
+
leaveParams?: boolean;
|
|
28
|
+
decodeCharMap?: Map<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export declare function interpolatePath({ path, params, leaveWildcards, leaveParams, decodeCharMap, }: InterpolatePathOptions): string;
|
|
31
|
+
export declare function matchPathname(basepath: string, currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
|
|
32
|
+
export declare function removeBasepath(basepath: string, pathname: string, caseSensitive?: boolean): string;
|
|
33
|
+
export declare function matchByPath(basepath: string, from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
|
|
34
|
+
export {};
|
package/dist/cjs/qss.cjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function encode(obj, pfx) {
|
|
4
|
+
let k, i, tmp, str = "";
|
|
5
|
+
for (k in obj) {
|
|
6
|
+
if ((tmp = obj[k]) !== void 0) {
|
|
7
|
+
if (Array.isArray(tmp)) {
|
|
8
|
+
for (i = 0; i < tmp.length; i++) {
|
|
9
|
+
str && (str += "&");
|
|
10
|
+
str += encodeURIComponent(k) + "=" + encodeURIComponent(tmp[i]);
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
str && (str += "&");
|
|
14
|
+
str += encodeURIComponent(k) + "=" + encodeURIComponent(tmp);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return (pfx || "") + str;
|
|
19
|
+
}
|
|
20
|
+
function toValue(mix) {
|
|
21
|
+
if (!mix) return "";
|
|
22
|
+
const str = decodeURIComponent(mix);
|
|
23
|
+
if (str === "false") return false;
|
|
24
|
+
if (str === "true") return true;
|
|
25
|
+
return +str * 0 === 0 && +str + "" === str ? +str : str;
|
|
26
|
+
}
|
|
27
|
+
function decode(str, pfx) {
|
|
28
|
+
let tmp, k;
|
|
29
|
+
const out = {}, arr = (pfx ? str.substr(pfx.length) : str).split("&");
|
|
30
|
+
while (tmp = arr.shift()) {
|
|
31
|
+
const equalIndex = tmp.indexOf("=");
|
|
32
|
+
if (equalIndex !== -1) {
|
|
33
|
+
k = tmp.slice(0, equalIndex);
|
|
34
|
+
k = decodeURIComponent(k);
|
|
35
|
+
const value = tmp.slice(equalIndex + 1);
|
|
36
|
+
if (out[k] !== void 0) {
|
|
37
|
+
out[k] = [].concat(out[k], toValue(value));
|
|
38
|
+
} else {
|
|
39
|
+
out[k] = toValue(value);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
k = tmp;
|
|
43
|
+
k = decodeURIComponent(k);
|
|
44
|
+
out[k] = "";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
exports.decode = decode;
|
|
50
|
+
exports.encode = encode;
|
|
51
|
+
//# sourceMappingURL=qss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qss.cjs","sources":["../../src/qss.ts"],"sourcesContent":["/**\n * Program uses a modified version of the `qss` package:\n * Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License\n * https://github.com/lukeed/qss/blob/master/license.md\n */\n\n/**\n * Encodes an object into a query string.\n * @param obj - The object to encode into a query string.\n * @param [pfx] - An optional prefix to add before the query string.\n * @returns The encoded query string.\n * @example\n * ```\n * // Example input: encode({ token: 'foo', key: 'value' })\n * // Expected output: \"token=foo&key=value\"\n * ```\n */\nexport function encode(obj: any, pfx?: string) {\n let k,\n i,\n tmp,\n str = ''\n\n for (k in obj) {\n if ((tmp = obj[k]) !== void 0) {\n if (Array.isArray(tmp)) {\n for (i = 0; i < tmp.length; i++) {\n str && (str += '&')\n str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i])\n }\n } else {\n str && (str += '&')\n str += encodeURIComponent(k) + '=' + encodeURIComponent(tmp)\n }\n }\n }\n\n return (pfx || '') + str\n}\n\n/**\n * Converts a string value to its appropriate type (string, number, boolean).\n * @param mix - The string value to convert.\n * @returns The converted value.\n * @example\n * // Example input: toValue(\"123\")\n * // Expected output: 123\n */\nfunction toValue(mix: any) {\n if (!mix) return ''\n const str = decodeURIComponent(mix)\n if (str === 'false') return false\n if (str === 'true') return true\n return +str * 0 === 0 && +str + '' === str ? +str : str\n}\n\n/**\n * Decodes a query string into an object.\n * @param str - The query string to decode.\n * @param [pfx] - An optional prefix to filter out from the query string.\n * @returns The decoded key-value pairs in an object format.\n * @example\n * // Example input: decode(\"token=foo&key=value\")\n * // Expected output: { \"token\": \"foo\", \"key\": \"value\" }\n */\nexport function decode(str: any, pfx?: string) {\n let tmp, k\n const out: any = {},\n arr = (pfx ? str.substr(pfx.length) : str).split('&')\n\n while ((tmp = arr.shift())) {\n const equalIndex = tmp.indexOf('=')\n if (equalIndex !== -1) {\n k = tmp.slice(0, equalIndex)\n k = decodeURIComponent(k)\n const value = tmp.slice(equalIndex + 1)\n if (out[k] !== void 0) {\n // @ts-expect-error\n out[k] = [].concat(out[k], toValue(value))\n } else {\n out[k] = toValue(value)\n }\n } else {\n k = tmp\n k = decodeURIComponent(k)\n out[k] = ''\n }\n }\n\n return out\n}\n"],"names":[],"mappings":";;AAiBgB,SAAA,OAAO,KAAU,KAAc;AACzC,MAAA,GACF,GACA,KACA,MAAM;AAER,OAAK,KAAK,KAAK;AACb,SAAK,MAAM,IAAI,CAAC,OAAO,QAAQ;AACzB,UAAA,MAAM,QAAQ,GAAG,GAAG;AACtB,aAAK,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AAC/B,kBAAQ,OAAO;AACf,iBAAO,mBAAmB,CAAC,IAAI,MAAM,mBAAmB,IAAI,CAAC,CAAC;AAAA,QAAA;AAAA,MAChE,OACK;AACL,gBAAQ,OAAO;AACf,eAAO,mBAAmB,CAAC,IAAI,MAAM,mBAAmB,GAAG;AAAA,MAAA;AAAA,IAC7D;AAAA,EACF;AAGF,UAAQ,OAAO,MAAM;AACvB;AAUA,SAAS,QAAQ,KAAU;AACrB,MAAA,CAAC,IAAY,QAAA;AACX,QAAA,MAAM,mBAAmB,GAAG;AAC9B,MAAA,QAAQ,QAAgB,QAAA;AACxB,MAAA,QAAQ,OAAe,QAAA;AACpB,SAAA,CAAC,MAAM,MAAM,KAAK,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM;AACtD;AAWgB,SAAA,OAAO,KAAU,KAAc;AAC7C,MAAI,KAAK;AACT,QAAM,MAAW,CACf,GAAA,OAAO,MAAM,IAAI,OAAO,IAAI,MAAM,IAAI,KAAK,MAAM,GAAG;AAE9C,SAAA,MAAM,IAAI,SAAU;AACpB,UAAA,aAAa,IAAI,QAAQ,GAAG;AAClC,QAAI,eAAe,IAAI;AACjB,UAAA,IAAI,MAAM,GAAG,UAAU;AAC3B,UAAI,mBAAmB,CAAC;AACxB,YAAM,QAAQ,IAAI,MAAM,aAAa,CAAC;AAClC,UAAA,IAAI,CAAC,MAAM,QAAQ;AAEjB,YAAA,CAAC,IAAI,CAAA,EAAG,OAAO,IAAI,CAAC,GAAG,QAAQ,KAAK,CAAC;AAAA,MAAA,OACpC;AACD,YAAA,CAAC,IAAI,QAAQ,KAAK;AAAA,MAAA;AAAA,IACxB,OACK;AACD,UAAA;AACJ,UAAI,mBAAmB,CAAC;AACxB,UAAI,CAAC,IAAI;AAAA,IAAA;AAAA,EACX;AAGK,SAAA;AACT;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Program uses a modified version of the `qss` package:
|
|
3
|
+
* Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License
|
|
4
|
+
* https://github.com/lukeed/qss/blob/master/license.md
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Encodes an object into a query string.
|
|
8
|
+
* @param obj - The object to encode into a query string.
|
|
9
|
+
* @param [pfx] - An optional prefix to add before the query string.
|
|
10
|
+
* @returns The encoded query string.
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* // Example input: encode({ token: 'foo', key: 'value' })
|
|
14
|
+
* // Expected output: "token=foo&key=value"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function encode(obj: any, pfx?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a query string into an object.
|
|
20
|
+
* @param str - The query string to decode.
|
|
21
|
+
* @param [pfx] - An optional prefix to filter out from the query string.
|
|
22
|
+
* @returns The decoded key-value pairs in an object format.
|
|
23
|
+
* @example
|
|
24
|
+
* // Example input: decode("token=foo&key=value")
|
|
25
|
+
* // Expected output: { "token": "foo", "key": "value" }
|
|
26
|
+
*/
|
|
27
|
+
export declare function decode(str: any, pfx?: string): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.cjs","sources":["../../src/root.ts"],"sourcesContent":["export const rootRouteId = '__root__'\nexport type RootRouteId = typeof rootRouteId\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc;;"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ParsePathParams } from './link.cjs';
|
|
2
|
+
import { RootRouteId } from './root.cjs';
|
|
3
|
+
import { Assign } from './utils.cjs';
|
|
4
|
+
import { AnySchema, AnyStandardSchemaValidator, AnyValidatorAdapter, AnyValidatorObj, StandardSchemaValidator, ValidatorAdapter, ValidatorFn, ValidatorObj } from './validators.cjs';
|
|
5
|
+
export type AnyPathParams = {};
|
|
6
|
+
export type SearchSchemaInput = {
|
|
7
|
+
__TSearchSchemaInput__: 'TSearchSchemaInput';
|
|
8
|
+
};
|
|
9
|
+
export type AnyContext = {};
|
|
10
|
+
export interface RouteContext {
|
|
11
|
+
}
|
|
12
|
+
export type PreloadableObj = {
|
|
13
|
+
preload?: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export type RoutePathOptions<TCustomId, TPath> = {
|
|
16
|
+
path: TPath;
|
|
17
|
+
} | {
|
|
18
|
+
id: TCustomId;
|
|
19
|
+
};
|
|
20
|
+
export interface StaticDataRouteOption {
|
|
21
|
+
}
|
|
22
|
+
export type RoutePathOptionsIntersection<TCustomId, TPath> = {
|
|
23
|
+
path: TPath;
|
|
24
|
+
id: TCustomId;
|
|
25
|
+
};
|
|
26
|
+
export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult;
|
|
27
|
+
export type SearchMiddlewareContext<TSearchSchema> = {
|
|
28
|
+
search: TSearchSchema;
|
|
29
|
+
next: (newSearch: TSearchSchema) => TSearchSchema;
|
|
30
|
+
};
|
|
31
|
+
export type SearchMiddleware<TSearchSchema> = (ctx: SearchMiddlewareContext<TSearchSchema>) => TSearchSchema;
|
|
32
|
+
export type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends {
|
|
33
|
+
id: infer TParentId extends string;
|
|
34
|
+
} ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
|
|
35
|
+
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
36
|
+
types: {
|
|
37
|
+
fullSearchSchema: infer TFullSearchSchema;
|
|
38
|
+
};
|
|
39
|
+
} ? TFullSearchSchema : {};
|
|
40
|
+
export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
41
|
+
types: {
|
|
42
|
+
fullSearchSchemaInput: infer TFullSearchSchemaInput;
|
|
43
|
+
};
|
|
44
|
+
} ? TFullSearchSchemaInput : {};
|
|
45
|
+
export type InferAllParams<TRoute> = TRoute extends {
|
|
46
|
+
types: {
|
|
47
|
+
allParams: infer TAllParams;
|
|
48
|
+
};
|
|
49
|
+
} ? TAllParams : {};
|
|
50
|
+
export type InferAllContext<TRoute> = unknown extends TRoute ? TRoute : TRoute extends {
|
|
51
|
+
types: {
|
|
52
|
+
allContext: infer TAllContext;
|
|
53
|
+
};
|
|
54
|
+
} ? TAllContext : {};
|
|
55
|
+
export type ResolveSearchSchemaFnInput<TSearchValidator> = TSearchValidator extends (input: infer TSearchSchemaInput) => any ? TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, keyof SearchSchemaInput> : ResolveSearchSchemaFn<TSearchValidator> : AnySchema;
|
|
56
|
+
export type ResolveSearchSchemaInput<TSearchValidator> = TSearchValidator extends AnyStandardSchemaValidator ? NonNullable<TSearchValidator['~standard']['types']>['input'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['input'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFnInput<TSearchValidator['parse']> : ResolveSearchSchemaFnInput<TSearchValidator>;
|
|
57
|
+
export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (...args: any) => infer TSearchSchema ? TSearchSchema : AnySchema;
|
|
58
|
+
export type ResolveSearchSchema<TSearchValidator> = unknown extends TSearchValidator ? TSearchValidator : TSearchValidator extends AnyStandardSchemaValidator ? NonNullable<TSearchValidator['~standard']['types']>['output'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['output'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFn<TSearchValidator['parse']> : ResolveSearchSchemaFn<TSearchValidator>;
|
|
59
|
+
export type ParseSplatParams<TPath extends string> = TPath & `${string}$` extends never ? TPath & `${string}$/${string}` extends never ? never : '_splat' : '_splat';
|
|
60
|
+
export interface SplatParams {
|
|
61
|
+
_splat?: string;
|
|
62
|
+
}
|
|
63
|
+
export type ResolveParams<TPath extends string> = ParseSplatParams<TPath> extends never ? Record<ParsePathParams<TPath>, string> : Record<ParsePathParams<TPath>, string> & SplatParams;
|
|
64
|
+
export type ParseParamsFn<in out TPath extends string, in out TParams> = (rawParams: ResolveParams<TPath>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : Record<ParsePathParams<TPath>, any>;
|
|
65
|
+
export type StringifyParamsFn<in out TPath extends string, in out TParams> = (params: TParams) => ResolveParams<TPath>;
|
|
66
|
+
export type ParamsOptions<in out TPath extends string, in out TParams> = {
|
|
67
|
+
params?: {
|
|
68
|
+
parse?: ParseParamsFn<TPath, TParams>;
|
|
69
|
+
stringify?: StringifyParamsFn<TPath, TParams>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
@deprecated Use params.parse instead
|
|
73
|
+
*/
|
|
74
|
+
parseParams?: ParseParamsFn<TPath, TParams>;
|
|
75
|
+
/**
|
|
76
|
+
@deprecated Use params.stringify instead
|
|
77
|
+
*/
|
|
78
|
+
stringifyParams?: StringifyParamsFn<TPath, TParams>;
|
|
79
|
+
};
|
|
80
|
+
interface RequiredStaticDataRouteOption {
|
|
81
|
+
staticData: StaticDataRouteOption;
|
|
82
|
+
}
|
|
83
|
+
interface OptionalStaticDataRouteOption {
|
|
84
|
+
staticData?: StaticDataRouteOption;
|
|
85
|
+
}
|
|
86
|
+
export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption ? OptionalStaticDataRouteOption : RequiredStaticDataRouteOption;
|
|
87
|
+
export type MetaDescriptor = {
|
|
88
|
+
charSet: 'utf-8';
|
|
89
|
+
} | {
|
|
90
|
+
title: string;
|
|
91
|
+
} | {
|
|
92
|
+
name: string;
|
|
93
|
+
content: string;
|
|
94
|
+
} | {
|
|
95
|
+
property: string;
|
|
96
|
+
content: string;
|
|
97
|
+
} | {
|
|
98
|
+
httpEquiv: string;
|
|
99
|
+
content: string;
|
|
100
|
+
} | {
|
|
101
|
+
'script:ld+json': LdJsonObject;
|
|
102
|
+
} | {
|
|
103
|
+
tagName: 'meta' | 'link';
|
|
104
|
+
[name: string]: string;
|
|
105
|
+
} | Record<string, unknown>;
|
|
106
|
+
type LdJsonObject = {
|
|
107
|
+
[Key in string]: LdJsonValue;
|
|
108
|
+
} & {
|
|
109
|
+
[Key in string]?: LdJsonValue | undefined;
|
|
110
|
+
};
|
|
111
|
+
type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>;
|
|
112
|
+
type LdJsonPrimitive = string | number | boolean | null;
|
|
113
|
+
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
114
|
+
export type RouteLinkEntry = {};
|
|
115
|
+
export type SearchValidator<TInput, TOutput> = ValidatorObj<TInput, TOutput> | ValidatorFn<TInput, TOutput> | ValidatorAdapter<TInput, TOutput> | StandardSchemaValidator<TInput, TOutput> | undefined;
|
|
116
|
+
export type AnySearchValidator = SearchValidator<any, any>;
|
|
117
|
+
export type DefaultSearchValidator = SearchValidator<Record<string, unknown>, AnySchema>;
|
|
118
|
+
export type LooseReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn : never;
|
|
119
|
+
export type LooseAsyncReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn extends Promise<infer TReturn> ? TReturn : TReturn : never;
|
|
120
|
+
export type ContextReturnType<TContextFn> = unknown extends TContextFn ? TContextFn : LooseReturnType<TContextFn> extends never ? AnyContext : LooseReturnType<TContextFn>;
|
|
121
|
+
export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn ? TContextFn : LooseAsyncReturnType<TContextFn> extends never ? AnyContext : LooseAsyncReturnType<TContextFn>;
|
|
122
|
+
export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<ContextReturnType<TRouteContextFn>, ContextAsyncReturnType<TBeforeLoadFn>>;
|
|
123
|
+
export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn ? TLoaderFn : LooseAsyncReturnType<TLoaderFn> extends never ? {} : LooseAsyncReturnType<TLoaderFn>;
|
|
124
|
+
export type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
|
|
125
|
+
export type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
|
|
126
|
+
export type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
|
|
127
|
+
export type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Use `ErrorComponentProps` instead.
|
|
130
|
+
*/
|
|
131
|
+
export type ErrorRouteProps = {
|
|
132
|
+
error: unknown;
|
|
133
|
+
info?: {
|
|
134
|
+
componentStack: string;
|
|
135
|
+
};
|
|
136
|
+
reset: () => void;
|
|
137
|
+
};
|
|
138
|
+
export type ErrorComponentProps = {
|
|
139
|
+
error: Error;
|
|
140
|
+
info?: {
|
|
141
|
+
componentStack: string;
|
|
142
|
+
};
|
|
143
|
+
reset: () => void;
|
|
144
|
+
};
|
|
145
|
+
export type NotFoundRouteProps = {
|
|
146
|
+
data: unknown;
|
|
147
|
+
};
|
|
148
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function defaultSerializeError(err) {
|
|
4
|
+
if (err instanceof Error) {
|
|
5
|
+
const obj = {
|
|
6
|
+
name: err.name,
|
|
7
|
+
message: err.message
|
|
8
|
+
};
|
|
9
|
+
if (process.env.NODE_ENV === "development") {
|
|
10
|
+
obj.stack = err.stack;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
data: err
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.defaultSerializeError = defaultSerializeError;
|
|
19
|
+
//# sourceMappingURL=router.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.cjs","sources":["../../src/router.ts"],"sourcesContent":["import type { DeferredPromiseState } from './defer'\nimport type { ControlledPromise } from './utils'\n\nexport interface ViewTransitionOptions {\n types: Array<string>\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\nexport interface ExtractedBaseEntry {\n dataType: '__beforeLoadContext' | 'loaderData'\n type: string\n path: Array<string>\n id: number\n matchIndex: number\n}\n\nexport interface ExtractedStream extends ExtractedBaseEntry {\n type: 'stream'\n streamState: StreamState\n}\n\nexport interface ExtractedPromise extends ExtractedBaseEntry {\n type: 'promise'\n promiseState: DeferredPromiseState<any>\n}\n\nexport type ExtractedEntry = ExtractedStream | ExtractedPromise\n\nexport type StreamState = {\n promises: Array<ControlledPromise<string | null>>\n}\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n"],"names":[],"mappings":";;AAOO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IACf;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAAA;AAGrB,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,MAAM;AAAA,EACR;AACF;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DeferredPromiseState } from './defer.cjs';
|
|
2
|
+
import { ControlledPromise } from './utils.cjs';
|
|
3
|
+
export interface ViewTransitionOptions {
|
|
4
|
+
types: Array<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function defaultSerializeError(err: unknown): {
|
|
7
|
+
name: string;
|
|
8
|
+
message: string;
|
|
9
|
+
} | {
|
|
10
|
+
data: unknown;
|
|
11
|
+
};
|
|
12
|
+
export interface ExtractedBaseEntry {
|
|
13
|
+
dataType: '__beforeLoadContext' | 'loaderData';
|
|
14
|
+
type: string;
|
|
15
|
+
path: Array<string>;
|
|
16
|
+
id: number;
|
|
17
|
+
matchIndex: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ExtractedStream extends ExtractedBaseEntry {
|
|
20
|
+
type: 'stream';
|
|
21
|
+
streamState: StreamState;
|
|
22
|
+
}
|
|
23
|
+
export interface ExtractedPromise extends ExtractedBaseEntry {
|
|
24
|
+
type: 'promise';
|
|
25
|
+
promiseState: DeferredPromiseState<any>;
|
|
26
|
+
}
|
|
27
|
+
export type ExtractedEntry = ExtractedStream | ExtractedPromise;
|
|
28
|
+
export type StreamState = {
|
|
29
|
+
promises: Array<ControlledPromise<string | null>>;
|
|
30
|
+
};
|
|
31
|
+
export type TrailingSlashOption = 'always' | 'never' | 'preserve';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils = require("./utils.cjs");
|
|
4
|
+
function retainSearchParams(keys) {
|
|
5
|
+
return ({ search, next }) => {
|
|
6
|
+
const result = next(search);
|
|
7
|
+
if (keys === true) {
|
|
8
|
+
return { ...search, ...result };
|
|
9
|
+
}
|
|
10
|
+
keys.forEach((key) => {
|
|
11
|
+
if (!(key in result)) {
|
|
12
|
+
result[key] = search[key];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function stripSearchParams(input) {
|
|
19
|
+
return ({ search, next }) => {
|
|
20
|
+
if (input === true) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const result = next(search);
|
|
24
|
+
if (Array.isArray(input)) {
|
|
25
|
+
input.forEach((key) => {
|
|
26
|
+
delete result[key];
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
Object.entries(input).forEach(
|
|
30
|
+
([key, value]) => {
|
|
31
|
+
if (utils.deepEqual(result[key], value)) {
|
|
32
|
+
delete result[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.retainSearchParams = retainSearchParams;
|
|
41
|
+
exports.stripSearchParams = stripSearchParams;
|
|
42
|
+
//# sourceMappingURL=searchMiddleware.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchMiddleware.cjs","sources":["../../src/searchMiddleware.ts"],"sourcesContent":["import { deepEqual } from './utils'\nimport type { NoInfer, PickOptional } from './utils'\nimport type { SearchMiddleware } from './route'\nimport type { IsRequiredParams } from './link'\n\nexport function retainSearchParams<TSearchSchema extends object>(\n keys: Array<keyof TSearchSchema> | true,\n): SearchMiddleware<TSearchSchema> {\n return ({ search, next }) => {\n const result = next(search)\n if (keys === true) {\n return { ...search, ...result }\n }\n // add missing keys from search to result\n keys.forEach((key) => {\n if (!(key in result)) {\n result[key] = search[key]\n }\n })\n return result\n }\n}\n\nexport function stripSearchParams<\n TSearchSchema,\n TOptionalProps = PickOptional<NoInfer<TSearchSchema>>,\n const TValues =\n | Partial<NoInfer<TOptionalProps>>\n | Array<keyof TOptionalProps>,\n const TInput = IsRequiredParams<TSearchSchema> extends never\n ? TValues | true\n : TValues,\n>(input: NoInfer<TInput>): SearchMiddleware<TSearchSchema> {\n return ({ search, next }) => {\n if (input === true) {\n return {}\n }\n const result = next(search) as Record<string, unknown>\n if (Array.isArray(input)) {\n input.forEach((key) => {\n delete result[key]\n })\n } else {\n Object.entries(input as Record<string, unknown>).forEach(\n ([key, value]) => {\n if (deepEqual(result[key], value)) {\n delete result[key]\n }\n },\n )\n }\n return result as any\n }\n}\n"],"names":["deepEqual"],"mappings":";;;AAKO,SAAS,mBACd,MACiC;AACjC,SAAO,CAAC,EAAE,QAAQ,WAAW;AACrB,UAAA,SAAS,KAAK,MAAM;AAC1B,QAAI,SAAS,MAAM;AACjB,aAAO,EAAE,GAAG,QAAQ,GAAG,OAAO;AAAA,IAAA;AAG3B,SAAA,QAAQ,CAAC,QAAQ;AAChB,UAAA,EAAE,OAAO,SAAS;AACb,eAAA,GAAG,IAAI,OAAO,GAAG;AAAA,MAAA;AAAA,IAC1B,CACD;AACM,WAAA;AAAA,EACT;AACF;AAEO,SAAS,kBASd,OAAyD;AACzD,SAAO,CAAC,EAAE,QAAQ,WAAW;AAC3B,QAAI,UAAU,MAAM;AAClB,aAAO,CAAC;AAAA,IAAA;AAEJ,UAAA,SAAS,KAAK,MAAM;AACtB,QAAA,MAAM,QAAQ,KAAK,GAAG;AAClB,YAAA,QAAQ,CAAC,QAAQ;AACrB,eAAO,OAAO,GAAG;AAAA,MAAA,CAClB;AAAA,IAAA,OACI;AACE,aAAA,QAAQ,KAAgC,EAAE;AAAA,QAC/C,CAAC,CAAC,KAAK,KAAK,MAAM;AAChB,cAAIA,MAAU,UAAA,OAAO,GAAG,GAAG,KAAK,GAAG;AACjC,mBAAO,OAAO,GAAG;AAAA,UAAA;AAAA,QACnB;AAAA,MAEJ;AAAA,IAAA;AAEK,WAAA;AAAA,EACT;AACF;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NoInfer, PickOptional } from './utils.cjs';
|
|
2
|
+
import { SearchMiddleware } from './route.cjs';
|
|
3
|
+
import { IsRequiredParams } from './link.cjs';
|
|
4
|
+
export declare function retainSearchParams<TSearchSchema extends object>(keys: Array<keyof TSearchSchema> | true): SearchMiddleware<TSearchSchema>;
|
|
5
|
+
export declare function stripSearchParams<TSearchSchema, TOptionalProps = PickOptional<NoInfer<TSearchSchema>>, const TValues = Partial<NoInfer<TOptionalProps>> | Array<keyof TOptionalProps>, const TInput = IsRequiredParams<TSearchSchema> extends never ? TValues | true : TValues>(input: NoInfer<TInput>): SearchMiddleware<TSearchSchema>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const qss = require("./qss.cjs");
|
|
4
|
+
const defaultParseSearch = parseSearchWith(JSON.parse);
|
|
5
|
+
const defaultStringifySearch = stringifySearchWith(
|
|
6
|
+
JSON.stringify,
|
|
7
|
+
JSON.parse
|
|
8
|
+
);
|
|
9
|
+
function parseSearchWith(parser) {
|
|
10
|
+
return (searchStr) => {
|
|
11
|
+
if (searchStr.substring(0, 1) === "?") {
|
|
12
|
+
searchStr = searchStr.substring(1);
|
|
13
|
+
}
|
|
14
|
+
const query = qss.decode(searchStr);
|
|
15
|
+
for (const key in query) {
|
|
16
|
+
const value = query[key];
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
try {
|
|
19
|
+
query[key] = parser(value);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return query;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function stringifySearchWith(stringify, parser) {
|
|
28
|
+
function stringifyValue(val) {
|
|
29
|
+
if (typeof val === "object" && val !== null) {
|
|
30
|
+
try {
|
|
31
|
+
return stringify(val);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
}
|
|
34
|
+
} else if (typeof val === "string" && typeof parser === "function") {
|
|
35
|
+
try {
|
|
36
|
+
parser(val);
|
|
37
|
+
return stringify(val);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return val;
|
|
42
|
+
}
|
|
43
|
+
return (search) => {
|
|
44
|
+
search = { ...search };
|
|
45
|
+
Object.keys(search).forEach((key) => {
|
|
46
|
+
const val = search[key];
|
|
47
|
+
if (typeof val === "undefined" || val === void 0) {
|
|
48
|
+
delete search[key];
|
|
49
|
+
} else {
|
|
50
|
+
search[key] = stringifyValue(val);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const searchStr = qss.encode(search).toString();
|
|
54
|
+
return searchStr ? `?${searchStr}` : "";
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.defaultParseSearch = defaultParseSearch;
|
|
58
|
+
exports.defaultStringifySearch = defaultStringifySearch;
|
|
59
|
+
exports.parseSearchWith = parseSearchWith;
|
|
60
|
+
exports.stringifySearchWith = stringifySearchWith;
|
|
61
|
+
//# sourceMappingURL=searchParams.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchParams.cjs","sources":["../../src/searchParams.ts"],"sourcesContent":["import { decode, encode } from './qss'\nimport type { AnySchema } from './validators'\n\nexport const defaultParseSearch = parseSearchWith(JSON.parse)\nexport const defaultStringifySearch = stringifySearchWith(\n JSON.stringify,\n JSON.parse,\n)\n\nexport function parseSearchWith(parser: (str: string) => any) {\n return (searchStr: string): AnySchema => {\n if (searchStr.substring(0, 1) === '?') {\n searchStr = searchStr.substring(1)\n }\n\n const query: Record<string, unknown> = decode(searchStr)\n\n // Try to parse any query params that might be json\n for (const key in query) {\n const value = query[key]\n if (typeof value === 'string') {\n try {\n query[key] = parser(value)\n } catch (err) {\n //\n }\n }\n }\n\n return query\n }\n}\n\nexport function stringifySearchWith(\n stringify: (search: any) => string,\n parser?: (str: string) => any,\n) {\n function stringifyValue(val: any) {\n if (typeof val === 'object' && val !== null) {\n try {\n return stringify(val)\n } catch (err) {\n // silent\n }\n } else if (typeof val === 'string' && typeof parser === 'function') {\n try {\n // Check if it's a valid parseable string.\n // If it is, then stringify it again.\n parser(val)\n return stringify(val)\n } catch (err) {\n // silent\n }\n }\n return val\n }\n\n return (search: Record<string, any>) => {\n search = { ...search }\n\n Object.keys(search).forEach((key) => {\n const val = search[key]\n if (typeof val === 'undefined' || val === undefined) {\n delete search[key]\n } else {\n search[key] = stringifyValue(val)\n }\n })\n\n const searchStr = encode(search as Record<string, string>).toString()\n\n return searchStr ? `?${searchStr}` : ''\n }\n}\n\nexport type SearchSerializer = (searchObj: Record<string, any>) => string\nexport type SearchParser = (searchStr: string) => Record<string, any>\n"],"names":["decode","encode"],"mappings":";;;AAGa,MAAA,qBAAqB,gBAAgB,KAAK,KAAK;AACrD,MAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,KAAK;AACP;AAEO,SAAS,gBAAgB,QAA8B;AAC5D,SAAO,CAAC,cAAiC;AACvC,QAAI,UAAU,UAAU,GAAG,CAAC,MAAM,KAAK;AACzB,kBAAA,UAAU,UAAU,CAAC;AAAA,IAAA;AAG7B,UAAA,QAAiCA,WAAO,SAAS;AAGvD,eAAW,OAAO,OAAO;AACjB,YAAA,QAAQ,MAAM,GAAG;AACnB,UAAA,OAAO,UAAU,UAAU;AACzB,YAAA;AACI,gBAAA,GAAG,IAAI,OAAO,KAAK;AAAA,iBAClB,KAAK;AAAA,QAAA;AAAA,MAEd;AAAA,IACF;AAGK,WAAA;AAAA,EACT;AACF;AAEgB,SAAA,oBACd,WACA,QACA;AACA,WAAS,eAAe,KAAU;AAChC,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AACvC,UAAA;AACF,eAAO,UAAU,GAAG;AAAA,eACb,KAAK;AAAA,MAAA;AAAA,eAGL,OAAO,QAAQ,YAAY,OAAO,WAAW,YAAY;AAC9D,UAAA;AAGF,eAAO,GAAG;AACV,eAAO,UAAU,GAAG;AAAA,eACb,KAAK;AAAA,MAAA;AAAA,IAEd;AAEK,WAAA;AAAA,EAAA;AAGT,SAAO,CAAC,WAAgC;AAC7B,aAAA,EAAE,GAAG,OAAO;AAErB,WAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,QAAQ;AAC7B,YAAA,MAAM,OAAO,GAAG;AACtB,UAAI,OAAO,QAAQ,eAAe,QAAQ,QAAW;AACnD,eAAO,OAAO,GAAG;AAAA,MAAA,OACZ;AACE,eAAA,GAAG,IAAI,eAAe,GAAG;AAAA,MAAA;AAAA,IAClC,CACD;AAED,UAAM,YAAYC,IAAAA,OAAO,MAAgC,EAAE,SAAS;AAE7D,WAAA,YAAY,IAAI,SAAS,KAAK;AAAA,EACvC;AACF;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnySchema } from './validators.cjs';
|
|
2
|
+
export declare const defaultParseSearch: (searchStr: string) => AnySchema;
|
|
3
|
+
export declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
4
|
+
export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySchema;
|
|
5
|
+
export declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;
|
|
6
|
+
export type SearchSerializer = (searchObj: Record<string, any>) => string;
|
|
7
|
+
export type SearchParser = (searchStr: string) => Record<string, any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface StartSerializer {
|
|
2
|
+
stringify: (obj: unknown) => string;
|
|
3
|
+
parse: (str: string) => unknown;
|
|
4
|
+
encode: <T>(value: T) => T;
|
|
5
|
+
decode: <T>(value: T) => T;
|
|
6
|
+
}
|
|
7
|
+
export type SerializerStringifyBy<T, TSerializable> = T extends TSerializable ? T : T extends (...args: Array<any>) => any ? 'Function is not serializable' : {
|
|
8
|
+
[K in keyof T]: SerializerStringifyBy<T[K], TSerializable>;
|
|
9
|
+
};
|
|
10
|
+
export type SerializerParseBy<T, TSerializable> = T extends TSerializable ? T : T extends React.JSX.Element ? ReadableStream : {
|
|
11
|
+
[K in keyof T]: SerializerParseBy<T[K], TSerializable>;
|
|
12
|
+
};
|
|
13
|
+
export type Serializable = Date | undefined | Error | FormData;
|
|
14
|
+
export type SerializerStringify<T> = SerializerStringifyBy<T, Serializable>;
|
|
15
|
+
export type SerializerParse<T> = SerializerParseBy<T, Serializable>;
|