@tanstack/router-core 0.0.1-beta.16 → 0.0.1-beta.161

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/fileRoute.js +29 -0
  3. package/build/cjs/fileRoute.js.map +1 -0
  4. package/build/cjs/history.js +226 -0
  5. package/build/cjs/history.js.map +1 -0
  6. package/build/cjs/index.js +78 -0
  7. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  8. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  9. package/build/cjs/path.js.map +1 -0
  10. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
  11. package/build/cjs/qss.js.map +1 -0
  12. package/build/cjs/route.js +101 -0
  13. package/build/cjs/route.js.map +1 -0
  14. package/build/cjs/router.js +1134 -0
  15. package/build/cjs/router.js.map +1 -0
  16. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +34 -19
  17. package/build/cjs/searchParams.js.map +1 -0
  18. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +54 -64
  19. package/build/cjs/utils.js.map +1 -0
  20. package/build/esm/index.js +1439 -2091
  21. package/build/esm/index.js.map +1 -1
  22. package/build/stats-html.html +59 -49
  23. package/build/stats-react.json +203 -234
  24. package/build/types/index.d.ts +573 -431
  25. package/build/umd/index.development.js +1673 -2221
  26. package/build/umd/index.development.js.map +1 -1
  27. package/build/umd/index.production.js +13 -2
  28. package/build/umd/index.production.js.map +1 -1
  29. package/package.json +11 -7
  30. package/src/fileRoute.ts +162 -0
  31. package/src/history.ts +292 -0
  32. package/src/index.ts +3 -10
  33. package/src/link.ts +121 -118
  34. package/src/path.ts +37 -17
  35. package/src/qss.ts +1 -2
  36. package/src/route.ts +874 -218
  37. package/src/routeInfo.ts +47 -211
  38. package/src/router.ts +1511 -1024
  39. package/src/searchParams.ts +33 -9
  40. package/src/utils.ts +80 -49
  41. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  42. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  43. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  44. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  45. package/build/cjs/node_modules/history/index.js +0 -815
  46. package/build/cjs/node_modules/history/index.js.map +0 -1
  47. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  48. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  49. package/build/cjs/packages/router-core/src/index.js +0 -58
  50. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  51. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  52. package/build/cjs/packages/router-core/src/route.js +0 -147
  53. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  54. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  55. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  56. package/build/cjs/packages/router-core/src/routeMatch.js +0 -231
  57. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  58. package/build/cjs/packages/router-core/src/router.js +0 -833
  59. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  60. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  61. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  62. package/src/frameworks.ts +0 -11
  63. package/src/routeConfig.ts +0 -514
  64. package/src/routeMatch.ts +0 -319
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @tanstack/router-core/src/index.ts
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var route = require('./route.js');
16
+
17
+ class FileRoute {
18
+ constructor(path) {
19
+ this.path = path;
20
+ }
21
+ createRoute = options => {
22
+ const route$1 = new route.Route(options);
23
+ route$1.isRoot = false;
24
+ return route$1;
25
+ };
26
+ }
27
+
28
+ exports.FileRoute = FileRoute;
29
+ //# sourceMappingURL=fileRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n AnySearchSchema,\n ResolveFullSearchSchema,\n MergeParamsFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n InferFullSearchSchema,\n UpdatableRouteOptions,\n Route,\n AnyPathParams,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n} from './route'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : Replace<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['__types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? string\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n constructor(public path: TFilePath) {}\n\n createRoute = <\n TLoader = unknown,\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = ParsePathParams<TPath> extends never\n ? AnyPathParams\n : Record<ParsePathParams<TPath>, RouteConstraints['TPath']>,\n TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<\n TParentRoute['__types']['allParams'],\n TParams\n >,\n TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['__types']['routeContext'],\n TAllParentContext extends RouteConstraints['TId'] = TParentRoute['__types']['context'],\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TContext extends RouteConstraints['TAllContext'] = MergeParamsFromParent<\n TParentRoute['__types']['context'],\n TRouteContext\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TLoader,\n InferFullSearchSchema<TParentRoute>,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TParentContext,\n TAllParentContext,\n TRouteContext,\n TContext\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<\n TLoader,\n TSearchSchema,\n TFullSearchSchema,\n TAllParams,\n TRouteContext,\n TContext\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TLoader,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TParentContext,\n TAllParentContext,\n TRouteContext,\n TContext,\n TRouterContext,\n TChildren,\n TRouteTree\n > => {\n const route = new Route(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n"],"names":["FileRoute","constructor","path","createRoute","options","route","Route","isRoot"],"mappings":";;;;;;;;;;;;;;;;AAwEO,MAAMA,SAAS,CAYpB;EACAC,WAAWA,CAAQC,IAAe,EAAE;IAAA,IAAjBA,CAAAA,IAAe,GAAfA,IAAe,CAAA;AAAG,GAAA;EAErCC,WAAW,GAyBTC,OAyBG,IAmBA;AACH,IAAA,MAAMC,OAAK,GAAG,IAAIC,WAAK,CAACF,OAAc,CAAC,CAAA;IACrCC,OAAK,CAASE,MAAM,GAAG,KAAK,CAAA;AAC9B,IAAA,OAAOF,OAAK,CAAA;GACb,CAAA;AACH;;;;"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * @tanstack/router-core/src/index.ts
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ // While the public API was clearly inspired by the "history" npm package,
16
+ // This implementation attempts to be more lightweight by
17
+ // making assumptions about the way TanStack Router works
18
+
19
+ const pushStateEvent = 'pushstate';
20
+ const popStateEvent = 'popstate';
21
+ const beforeUnloadEvent = 'beforeunload';
22
+ const beforeUnloadListener = event => {
23
+ event.preventDefault();
24
+ // @ts-ignore
25
+ return event.returnValue = '';
26
+ };
27
+ const stopBlocking = () => {
28
+ removeEventListener(beforeUnloadEvent, beforeUnloadListener, {
29
+ capture: true
30
+ });
31
+ };
32
+ function createHistory(opts) {
33
+ let location = opts.getLocation();
34
+ let unsub = () => {};
35
+ let listeners = new Set();
36
+ let blockers = [];
37
+ let queue = [];
38
+ const tryFlush = () => {
39
+ if (blockers.length) {
40
+ blockers[0]?.(tryFlush, () => {
41
+ blockers = [];
42
+ stopBlocking();
43
+ });
44
+ return;
45
+ }
46
+ while (queue.length) {
47
+ queue.shift()?.();
48
+ }
49
+ if (!opts.listener) {
50
+ onUpdate();
51
+ }
52
+ };
53
+ const queueTask = task => {
54
+ queue.push(task);
55
+ tryFlush();
56
+ };
57
+ const onUpdate = () => {
58
+ location = opts.getLocation();
59
+ listeners.forEach(listener => listener());
60
+ };
61
+ return {
62
+ get location() {
63
+ return location;
64
+ },
65
+ listen: cb => {
66
+ if (listeners.size === 0) {
67
+ unsub = typeof opts.listener === 'function' ? opts.listener(onUpdate) : () => {};
68
+ }
69
+ listeners.add(cb);
70
+ return () => {
71
+ listeners.delete(cb);
72
+ if (listeners.size === 0) {
73
+ unsub();
74
+ }
75
+ };
76
+ },
77
+ push: (path, state) => {
78
+ queueTask(() => {
79
+ opts.pushState(path, state);
80
+ });
81
+ },
82
+ replace: (path, state) => {
83
+ queueTask(() => {
84
+ opts.replaceState(path, state);
85
+ });
86
+ },
87
+ go: index => {
88
+ queueTask(() => {
89
+ opts.go(index);
90
+ });
91
+ },
92
+ back: () => {
93
+ queueTask(() => {
94
+ opts.back();
95
+ });
96
+ },
97
+ forward: () => {
98
+ queueTask(() => {
99
+ opts.forward();
100
+ });
101
+ },
102
+ createHref: str => opts.createHref(str),
103
+ block: cb => {
104
+ blockers.push(cb);
105
+ if (blockers.length === 1) {
106
+ addEventListener(beforeUnloadEvent, beforeUnloadListener, {
107
+ capture: true
108
+ });
109
+ }
110
+ return () => {
111
+ blockers = blockers.filter(b => b !== cb);
112
+ if (!blockers.length) {
113
+ stopBlocking();
114
+ }
115
+ };
116
+ }
117
+ };
118
+ }
119
+ function createBrowserHistory(opts) {
120
+ const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`);
121
+ const createHref = opts?.createHref ?? (path => path);
122
+ const getLocation = () => parseLocation(getHref(), history.state);
123
+ return createHistory({
124
+ getLocation,
125
+ listener: onUpdate => {
126
+ window.addEventListener(pushStateEvent, onUpdate);
127
+ window.addEventListener(popStateEvent, onUpdate);
128
+ var pushState = window.history.pushState;
129
+ window.history.pushState = function () {
130
+ let res = pushState.apply(history, arguments);
131
+ onUpdate();
132
+ return res;
133
+ };
134
+ var replaceState = window.history.replaceState;
135
+ window.history.replaceState = function () {
136
+ let res = replaceState.apply(history, arguments);
137
+ onUpdate();
138
+ return res;
139
+ };
140
+ return () => {
141
+ window.history.pushState = pushState;
142
+ window.history.replaceState = replaceState;
143
+ window.removeEventListener(pushStateEvent, onUpdate);
144
+ window.removeEventListener(popStateEvent, onUpdate);
145
+ };
146
+ },
147
+ pushState: (path, state) => {
148
+ window.history.pushState({
149
+ ...state,
150
+ key: createRandomKey()
151
+ }, '', createHref(path));
152
+ },
153
+ replaceState: (path, state) => {
154
+ window.history.replaceState({
155
+ ...state,
156
+ key: createRandomKey()
157
+ }, '', createHref(path));
158
+ },
159
+ back: () => window.history.back(),
160
+ forward: () => window.history.forward(),
161
+ go: n => window.history.go(n),
162
+ createHref: path => createHref(path)
163
+ });
164
+ }
165
+ function createHashHistory() {
166
+ return createBrowserHistory({
167
+ getHref: () => window.location.hash.substring(1),
168
+ createHref: path => `#${path}`
169
+ });
170
+ }
171
+ function createMemoryHistory(opts = {
172
+ initialEntries: ['/']
173
+ }) {
174
+ const entries = opts.initialEntries;
175
+ let index = opts.initialIndex ?? entries.length - 1;
176
+ let currentState = {};
177
+ const getLocation = () => parseLocation(entries[index], currentState);
178
+ return createHistory({
179
+ getLocation,
180
+ listener: false,
181
+ pushState: (path, state) => {
182
+ currentState = {
183
+ ...state,
184
+ key: createRandomKey()
185
+ };
186
+ entries.push(path);
187
+ index++;
188
+ },
189
+ replaceState: (path, state) => {
190
+ currentState = {
191
+ ...state,
192
+ key: createRandomKey()
193
+ };
194
+ entries[index] = path;
195
+ },
196
+ back: () => {
197
+ index--;
198
+ },
199
+ forward: () => {
200
+ index = Math.min(index + 1, entries.length - 1);
201
+ },
202
+ go: n => window.history.go(n),
203
+ createHref: path => path
204
+ });
205
+ }
206
+ function parseLocation(href, state) {
207
+ let hashIndex = href.indexOf('#');
208
+ let searchIndex = href.indexOf('?');
209
+ return {
210
+ href,
211
+ pathname: href.substring(0, hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : href.length),
212
+ hash: hashIndex > -1 ? href.substring(hashIndex) : '',
213
+ search: searchIndex > -1 ? href.slice(searchIndex, hashIndex === -1 ? undefined : hashIndex) : '',
214
+ state
215
+ };
216
+ }
217
+
218
+ // Thanks co-pilot!
219
+ function createRandomKey() {
220
+ return (Math.random() + 1).toString(36).substring(7);
221
+ }
222
+
223
+ exports.createBrowserHistory = createBrowserHistory;
224
+ exports.createHashHistory = createHashHistory;
225
+ exports.createMemoryHistory = createMemoryHistory;
226
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sources":["../../src/history.ts"],"sourcesContent":["// While the public API was clearly inspired by the \"history\" npm package,\n// This implementation attempts to be more lightweight by\n// making assumptions about the way TanStack Router works\n\nexport interface RouterHistory {\n location: RouterLocation\n listen: (cb: () => void) => () => void\n push: (path: string, state?: any) => void\n replace: (path: string, state?: any) => void\n go: (index: number) => void\n back: () => void\n forward: () => void\n createHref: (href: string) => string\n block: (blockerFn: BlockerFn) => () => void\n}\n\nexport interface ParsedPath {\n href: string\n pathname: string\n search: string\n hash: string\n}\n\nexport interface RouterLocation extends ParsedPath {\n state: any\n}\n\ntype BlockerFn = (retry: () => void, cancel: () => void) => void\n\nconst pushStateEvent = 'pushstate'\nconst popStateEvent = 'popstate'\nconst beforeUnloadEvent = 'beforeunload'\n\nconst beforeUnloadListener = (event: Event) => {\n event.preventDefault()\n // @ts-ignore\n return (event.returnValue = '')\n}\n\nconst stopBlocking = () => {\n removeEventListener(beforeUnloadEvent, beforeUnloadListener, {\n capture: true,\n })\n}\n\nfunction createHistory(opts: {\n getLocation: () => RouterLocation\n listener: false | ((onUpdate: () => void) => () => void)\n pushState: (path: string, state: any) => void\n replaceState: (path: string, state: any) => void\n go: (n: number) => void\n back: () => void\n forward: () => void\n createHref: (path: string) => string\n}): RouterHistory {\n let location = opts.getLocation()\n let unsub = () => {}\n let listeners = new Set<() => void>()\n let blockers: BlockerFn[] = []\n let queue: (() => void)[] = []\n\n const tryFlush = () => {\n if (blockers.length) {\n blockers[0]?.(tryFlush, () => {\n blockers = []\n stopBlocking()\n })\n return\n }\n\n while (queue.length) {\n queue.shift()?.()\n }\n\n if (!opts.listener) {\n onUpdate()\n }\n }\n\n const queueTask = (task: () => void) => {\n queue.push(task)\n tryFlush()\n }\n\n const onUpdate = () => {\n location = opts.getLocation()\n listeners.forEach((listener) => listener())\n }\n\n return {\n get location() {\n return location\n },\n listen: (cb: () => void) => {\n if (listeners.size === 0) {\n unsub =\n typeof opts.listener === 'function'\n ? opts.listener(onUpdate)\n : () => {}\n }\n listeners.add(cb)\n\n return () => {\n listeners.delete(cb)\n if (listeners.size === 0) {\n unsub()\n }\n }\n },\n push: (path: string, state: any) => {\n queueTask(() => {\n opts.pushState(path, state)\n })\n },\n replace: (path: string, state: any) => {\n queueTask(() => {\n opts.replaceState(path, state)\n })\n },\n go: (index) => {\n queueTask(() => {\n opts.go(index)\n })\n },\n back: () => {\n queueTask(() => {\n opts.back()\n })\n },\n forward: () => {\n queueTask(() => {\n opts.forward()\n })\n },\n createHref: (str) => opts.createHref(str),\n block: (cb) => {\n blockers.push(cb)\n\n if (blockers.length === 1) {\n addEventListener(beforeUnloadEvent, beforeUnloadListener, {\n capture: true,\n })\n }\n\n return () => {\n blockers = blockers.filter((b) => b !== cb)\n\n if (!blockers.length) {\n stopBlocking()\n }\n }\n },\n }\n}\n\nexport function createBrowserHistory(opts?: {\n getHref?: () => string\n createHref?: (path: string) => string\n}): RouterHistory {\n const getHref =\n opts?.getHref ??\n (() =>\n `${window.location.pathname}${window.location.search}${window.location.hash}`)\n const createHref = opts?.createHref ?? ((path) => path)\n const getLocation = () => parseLocation(getHref(), history.state)\n\n return createHistory({\n getLocation,\n listener: (onUpdate) => {\n window.addEventListener(pushStateEvent, onUpdate)\n window.addEventListener(popStateEvent, onUpdate)\n\n var pushState = window.history.pushState\n window.history.pushState = function () {\n let res = pushState.apply(history, arguments as any)\n onUpdate()\n return res\n }\n var replaceState = window.history.replaceState\n window.history.replaceState = function () {\n let res = replaceState.apply(history, arguments as any)\n onUpdate()\n return res\n }\n\n return () => {\n window.history.pushState = pushState\n window.history.replaceState = replaceState\n window.removeEventListener(pushStateEvent, onUpdate)\n window.removeEventListener(popStateEvent, onUpdate)\n }\n },\n pushState: (path, state) => {\n window.history.pushState(\n { ...state, key: createRandomKey() },\n '',\n createHref(path),\n )\n },\n replaceState: (path, state) => {\n window.history.replaceState(\n { ...state, key: createRandomKey() },\n '',\n createHref(path),\n )\n },\n back: () => window.history.back(),\n forward: () => window.history.forward(),\n go: (n) => window.history.go(n),\n createHref: (path) => createHref(path),\n })\n}\n\nexport function createHashHistory(): RouterHistory {\n return createBrowserHistory({\n getHref: () => window.location.hash.substring(1),\n createHref: (path) => `#${path}`,\n })\n}\n\nexport function createMemoryHistory(\n opts: {\n initialEntries: string[]\n initialIndex?: number\n } = {\n initialEntries: ['/'],\n },\n): RouterHistory {\n const entries = opts.initialEntries\n let index = opts.initialIndex ?? entries.length - 1\n let currentState = {}\n\n const getLocation = () => parseLocation(entries[index]!, currentState)\n\n return createHistory({\n getLocation,\n listener: false,\n pushState: (path, state) => {\n currentState = {\n ...state,\n key: createRandomKey(),\n }\n entries.push(path)\n index++\n },\n replaceState: (path, state) => {\n currentState = {\n ...state,\n key: createRandomKey(),\n }\n entries[index] = path\n },\n back: () => {\n index--\n },\n forward: () => {\n index = Math.min(index + 1, entries.length - 1)\n },\n go: (n) => window.history.go(n),\n createHref: (path) => path,\n })\n}\n\nfunction parseLocation(href: string, state: any): RouterLocation {\n let hashIndex = href.indexOf('#')\n let searchIndex = href.indexOf('?')\n\n return {\n href,\n pathname: href.substring(\n 0,\n hashIndex > 0\n ? searchIndex > 0\n ? Math.min(hashIndex, searchIndex)\n : hashIndex\n : searchIndex > 0\n ? searchIndex\n : href.length,\n ),\n hash: hashIndex > -1 ? href.substring(hashIndex) : '',\n search:\n searchIndex > -1\n ? href.slice(searchIndex, hashIndex === -1 ? undefined : hashIndex)\n : '',\n state,\n }\n}\n\n// Thanks co-pilot!\nfunction createRandomKey() {\n return (Math.random() + 1).toString(36).substring(7)\n}\n"],"names":["pushStateEvent","popStateEvent","beforeUnloadEvent","beforeUnloadListener","event","preventDefault","returnValue","stopBlocking","removeEventListener","capture","createHistory","opts","location","getLocation","unsub","listeners","Set","blockers","queue","tryFlush","length","shift","listener","onUpdate","queueTask","task","push","forEach","listen","cb","size","add","delete","path","state","pushState","replace","replaceState","go","index","back","forward","createHref","str","block","addEventListener","filter","b","createBrowserHistory","getHref","window","pathname","search","hash","parseLocation","history","res","apply","arguments","key","createRandomKey","n","createHashHistory","substring","createMemoryHistory","initialEntries","entries","initialIndex","currentState","Math","min","href","hashIndex","indexOf","searchIndex","slice","undefined","random","toString"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;;AA2BA,MAAMA,cAAc,GAAG,WAAW,CAAA;AAClC,MAAMC,aAAa,GAAG,UAAU,CAAA;AAChC,MAAMC,iBAAiB,GAAG,cAAc,CAAA;AAExC,MAAMC,oBAAoB,GAAIC,KAAY,IAAK;EAC7CA,KAAK,CAACC,cAAc,EAAE,CAAA;AACtB;AACA,EAAA,OAAQD,KAAK,CAACE,WAAW,GAAG,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAMC,YAAY,GAAGA,MAAM;AACzBC,EAAAA,mBAAmB,CAACN,iBAAiB,EAAEC,oBAAoB,EAAE;AAC3DM,IAAAA,OAAO,EAAE,IAAA;AACX,GAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAASC,aAAaA,CAACC,IAStB,EAAiB;AAChB,EAAA,IAAIC,QAAQ,GAAGD,IAAI,CAACE,WAAW,EAAE,CAAA;AACjC,EAAA,IAAIC,KAAK,GAAGA,MAAM,EAAE,CAAA;AACpB,EAAA,IAAIC,SAAS,GAAG,IAAIC,GAAG,EAAc,CAAA;EACrC,IAAIC,QAAqB,GAAG,EAAE,CAAA;EAC9B,IAAIC,KAAqB,GAAG,EAAE,CAAA;EAE9B,MAAMC,QAAQ,GAAGA,MAAM;IACrB,IAAIF,QAAQ,CAACG,MAAM,EAAE;AACnBH,MAAAA,QAAQ,CAAC,CAAC,CAAC,GAAGE,QAAQ,EAAE,MAAM;AAC5BF,QAAAA,QAAQ,GAAG,EAAE,CAAA;AACbV,QAAAA,YAAY,EAAE,CAAA;AAChB,OAAC,CAAC,CAA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AAC,EAAEC,QAAQ,CAAC,EAAE,CAAC,CAACf,SAAS,CAAC,CAAC,CAAC,CAAA;AACtD;;;;;;"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @tanstack/router-core/src/index.ts
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var invariant = require('tiny-invariant');
16
+ var tinyWarning = require('tiny-warning');
17
+ var history = require('./history.js');
18
+ var path = require('./path.js');
19
+ var qss = require('./qss.js');
20
+ var route = require('./route.js');
21
+ var fileRoute = require('./fileRoute.js');
22
+ var router = require('./router.js');
23
+ var searchParams = require('./searchParams.js');
24
+ var utils = require('./utils.js');
25
+
26
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
+
28
+ var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
29
+ var tinyWarning__default = /*#__PURE__*/_interopDefaultLegacy(tinyWarning);
30
+
31
+
32
+
33
+ Object.defineProperty(exports, 'invariant', {
34
+ enumerable: true,
35
+ get: function () { return invariant__default["default"]; }
36
+ });
37
+ Object.defineProperty(exports, 'warning', {
38
+ enumerable: true,
39
+ get: function () { return tinyWarning__default["default"]; }
40
+ });
41
+ exports.createBrowserHistory = history.createBrowserHistory;
42
+ exports.createHashHistory = history.createHashHistory;
43
+ exports.createMemoryHistory = history.createMemoryHistory;
44
+ exports.cleanPath = path.cleanPath;
45
+ exports.interpolatePath = path.interpolatePath;
46
+ exports.joinPaths = path.joinPaths;
47
+ exports.matchByPath = path.matchByPath;
48
+ exports.matchPathname = path.matchPathname;
49
+ exports.parsePathname = path.parsePathname;
50
+ exports.resolvePath = path.resolvePath;
51
+ exports.trimPath = path.trimPath;
52
+ exports.trimPathLeft = path.trimPathLeft;
53
+ exports.trimPathRight = path.trimPathRight;
54
+ exports.decode = qss.decode;
55
+ exports.encode = qss.encode;
56
+ exports.RootRoute = route.RootRoute;
57
+ exports.Route = route.Route;
58
+ exports.RouterContext = route.RouterContext;
59
+ exports.rootRouteId = route.rootRouteId;
60
+ exports.FileRoute = fileRoute.FileRoute;
61
+ exports.PathParamError = router.PathParamError;
62
+ exports.Router = router.Router;
63
+ exports.SearchParamError = router.SearchParamError;
64
+ exports.componentTypes = router.componentTypes;
65
+ exports.isRedirect = router.isRedirect;
66
+ exports.lazyFn = router.lazyFn;
67
+ exports.redirect = router.redirect;
68
+ exports.defaultParseSearch = searchParams.defaultParseSearch;
69
+ exports.defaultStringifySearch = searchParams.defaultStringifySearch;
70
+ exports.parseSearchWith = searchParams.parseSearchWith;
71
+ exports.stringifySearchWith = searchParams.stringifySearchWith;
72
+ exports.functionalUpdate = utils.functionalUpdate;
73
+ exports.isPlainObject = utils.isPlainObject;
74
+ exports.last = utils.last;
75
+ exports.partialDeepEqual = utils.partialDeepEqual;
76
+ exports.pick = utils.pick;
77
+ exports.replaceEqualDeep = utils.replaceEqualDeep;
78
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * router-core
2
+ * @tanstack/router-core/src/index.ts
3
3
  *
4
4
  * Copyright (c) TanStack
5
5
  *
@@ -31,8 +31,8 @@ function trimPath(path) {
31
31
  return trimPathRight(trimPathLeft(path));
32
32
  }
33
33
  function resolvePath(basepath, base, to) {
34
- base = base.replace(new RegExp("^" + basepath), '/');
35
- to = to.replace(new RegExp("^" + basepath), '/');
34
+ base = base.replace(new RegExp(`^${basepath}`), '/');
35
+ to = to.replace(new RegExp(`^${basepath}`), '/');
36
36
  let baseSegments = parsePathname(base);
37
37
  const toSegments = parsePathname(to);
38
38
  toSegments.forEach((toSegment, index) => {
@@ -45,13 +45,10 @@ function resolvePath(basepath, base, to) {
45
45
  baseSegments.push(toSegment);
46
46
  } else ;
47
47
  } else if (toSegment.value === '..') {
48
- var _last;
49
-
50
48
  // Extra trailing slash? pop it off
51
- if (baseSegments.length > 1 && ((_last = utils.last(baseSegments)) == null ? void 0 : _last.value) === '/') {
49
+ if (baseSegments.length > 1 && utils.last(baseSegments)?.value === '/') {
52
50
  baseSegments.pop();
53
51
  }
54
-
55
52
  baseSegments.pop();
56
53
  } else if (toSegment.value === '.') {
57
54
  return;
@@ -66,10 +63,8 @@ function parsePathname(pathname) {
66
63
  if (!pathname) {
67
64
  return [];
68
65
  }
69
-
70
66
  pathname = cleanPath(pathname);
71
67
  const segments = [];
72
-
73
68
  if (pathname.slice(0, 1) === '/') {
74
69
  pathname = pathname.substring(1);
75
70
  segments.push({
@@ -77,34 +72,30 @@ function parsePathname(pathname) {
77
72
  value: '/'
78
73
  });
79
74
  }
80
-
81
75
  if (!pathname) {
82
76
  return segments;
83
- } // Remove empty segments and '.' segments
84
-
77
+ }
85
78
 
79
+ // Remove empty segments and '.' segments
86
80
  const split = pathname.split('/').filter(Boolean);
87
81
  segments.push(...split.map(part => {
88
- if (part.startsWith('*')) {
82
+ if (part === '$' || part === '*') {
89
83
  return {
90
84
  type: 'wildcard',
91
85
  value: part
92
86
  };
93
87
  }
94
-
95
- if (part.charAt(0) === ':') {
88
+ if (part.charAt(0) === '$') {
96
89
  return {
97
90
  type: 'param',
98
91
  value: part
99
92
  };
100
93
  }
101
-
102
94
  return {
103
95
  type: 'pathname',
104
96
  value: part
105
97
  };
106
98
  }));
107
-
108
99
  if (pathname.slice(-1) === '/') {
109
100
  pathname = pathname.substring(1);
110
101
  segments.push({
@@ -112,66 +103,70 @@ function parsePathname(pathname) {
112
103
  value: '/'
113
104
  });
114
105
  }
115
-
116
106
  return segments;
117
107
  }
118
- function interpolatePath(path, params, leaveWildcard) {
108
+ function interpolatePath(path, params, leaveWildcards = false) {
119
109
  const interpolatedPathSegments = parsePathname(path);
120
110
  return joinPaths(interpolatedPathSegments.map(segment => {
121
- if (segment.value === '*' && !leaveWildcard) {
122
- return '';
111
+ if (segment.type === 'wildcard') {
112
+ const value = params[segment.value];
113
+ if (leaveWildcards) return `${segment.value}${value ?? ''}`;
114
+ return value;
123
115
  }
124
-
125
116
  if (segment.type === 'param') {
126
- var _segment$value$substr;
127
-
128
- return (_segment$value$substr = params[segment.value.substring(1)]) != null ? _segment$value$substr : '';
117
+ return params[segment.value.substring(1)] ?? '';
129
118
  }
130
-
131
119
  return segment.value;
132
120
  }));
133
121
  }
134
- function matchPathname(currentPathname, matchLocation) {
135
- const pathParams = matchByPath(currentPathname, matchLocation); // const searchMatched = matchBySearch(currentLocation.search, matchLocation)
122
+ function matchPathname(basepath, currentPathname, matchLocation) {
123
+ const pathParams = matchByPath(basepath, currentPathname, matchLocation);
124
+ // const searchMatched = matchBySearch(location.search, matchLocation)
136
125
 
137
126
  if (matchLocation.to && !pathParams) {
138
127
  return;
139
- } // if (matchLocation.search && !searchMatched) {
140
- // return
141
- // }
142
-
143
-
144
- return pathParams != null ? pathParams : {};
128
+ }
129
+ return pathParams ?? {};
145
130
  }
146
- function matchByPath(from, matchLocation) {
147
- var _matchLocation$to;
148
-
131
+ function matchByPath(basepath, from, matchLocation) {
132
+ // Remove the base path from the pathname
133
+ from = basepath != '/' ? from.substring(basepath.length) : from;
134
+ // Default to to $ (wildcard)
135
+ const to = `${matchLocation.to ?? '$'}`;
136
+ // Parse the from and to
149
137
  const baseSegments = parsePathname(from);
150
- const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
138
+ const routeSegments = parsePathname(to);
139
+ if (!from.startsWith('/')) {
140
+ baseSegments.unshift({
141
+ type: 'pathname',
142
+ value: '/'
143
+ });
144
+ }
145
+ if (!to.startsWith('/')) {
146
+ routeSegments.unshift({
147
+ type: 'pathname',
148
+ value: '/'
149
+ });
150
+ }
151
151
  const params = {};
152
-
153
152
  let isMatch = (() => {
154
153
  for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
155
154
  const baseSegment = baseSegments[i];
156
155
  const routeSegment = routeSegments[i];
157
- const isLastRouteSegment = i === routeSegments.length - 1;
158
- const isLastBaseSegment = i === baseSegments.length - 1;
159
-
156
+ const isLastBaseSegment = i >= baseSegments.length - 1;
157
+ const isLastRouteSegment = i >= routeSegments.length - 1;
160
158
  if (routeSegment) {
161
159
  if (routeSegment.type === 'wildcard') {
162
- if (baseSegment != null && baseSegment.value) {
160
+ if (baseSegment?.value) {
163
161
  params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
164
162
  return true;
165
163
  }
166
-
167
164
  return false;
168
165
  }
169
-
170
166
  if (routeSegment.type === 'pathname') {
171
- if (routeSegment.value === '/' && !(baseSegment != null && baseSegment.value)) {
167
+ if (routeSegment.value === '/' && !baseSegment?.value) {
172
168
  return true;
173
169
  }
174
-
175
170
  if (baseSegment) {
176
171
  if (matchLocation.caseSensitive) {
177
172
  if (routeSegment.value !== baseSegment.value) {
@@ -182,30 +177,24 @@ function matchByPath(from, matchLocation) {
182
177
  }
183
178
  }
184
179
  }
185
-
186
180
  if (!baseSegment) {
187
181
  return false;
188
182
  }
189
-
190
183
  if (routeSegment.type === 'param') {
191
- if ((baseSegment == null ? void 0 : baseSegment.value) === '/') {
184
+ if (baseSegment?.value === '/') {
192
185
  return false;
193
186
  }
194
-
195
- if (!baseSegment.value.startsWith(':')) {
187
+ if (baseSegment.value.charAt(0) !== '$') {
196
188
  params[routeSegment.value.substring(1)] = baseSegment.value;
197
189
  }
198
190
  }
199
191
  }
200
-
201
- if (isLastRouteSegment && !isLastBaseSegment) {
192
+ if (!isLastBaseSegment && isLastRouteSegment) {
202
193
  return !!matchLocation.fuzzy;
203
194
  }
204
195
  }
205
-
206
196
  return true;
207
197
  })();
208
-
209
198
  return isMatch ? params : undefined;
210
199
  }
211
200
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sources":["../../src/path.ts"],"sourcesContent":["import { AnyPathParams } from './route'\nimport { MatchLocation } from './router'\nimport { last } from './utils'\n\nexport interface Segment {\n type: 'pathname' | 'param' | 'wildcard'\n value: string\n}\n\nexport function joinPaths(paths: (string | undefined)[]) {\n return cleanPath(paths.filter(Boolean).join('/'))\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 resolvePath(basepath: string, base: string, to: string) {\n base = base.replace(new RegExp(`^${basepath}`), '/')\n to = to.replace(new RegExp(`^${basepath}`), '/')\n\n let baseSegments = parsePathname(base)\n const toSegments = parsePathname(to)\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 // Extra trailing slash? pop it off\n if (baseSegments.length > 1 && last(baseSegments)?.value === '/') {\n baseSegments.pop()\n }\n baseSegments.pop()\n } else if (toSegment.value === '.') {\n return\n } else {\n baseSegments.push(toSegment)\n }\n })\n\n const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)])\n\n return cleanPath(joined)\n}\n\nexport function parsePathname(pathname?: string): Segment[] {\n if (!pathname) {\n return []\n }\n\n pathname = cleanPath(pathname)\n\n const segments: 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: 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\nexport function interpolatePath(\n path: string | undefined,\n params: any,\n leaveWildcards: boolean = false,\n) {\n const interpolatedPathSegments = parsePathname(path)\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = params[segment.value]\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n return params![segment.value.substring(1)] ?? ''\n }\n\n return segment.value\n }),\n )\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 matchByPath(\n basepath: string,\n from: string,\n matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>,\n): Record<string, string> | undefined {\n // Remove the base path from the pathname\n from = basepath != '/' ? from.substring(basepath.length) : from\n // Default to to $ (wildcard)\n const to = `${matchLocation.to ?? '$'}`\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 let 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 if (baseSegment?.value) {\n params['*'] = joinPaths(baseSegments.slice(i).map((d) => d.value))\n return true\n }\n return false\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)] = baseSegment.value\n }\n }\n }\n\n if (!isLastBaseSegment && isLastRouteSegment) {\n return !!matchLocation.fuzzy\n }\n }\n\n return true\n })()\n\n return isMatch ? (params as Record<string, string>) : undefined\n}\n"],"names":["joinPaths","paths","cleanPath","filter","Boolean","join","path","replace","trimPathLeft","trimPathRight","trimPath","resolvePath","basepath","base","to","RegExp","baseSegments","parsePathname","toSegments","forEach","toSegment","index","value","length","push","last","pop","joined","map","d","pathname","segments","slice","substring","type","split","part","charAt","interpolatePath","params","leaveWildcards","interpolatedPathSegments","segment","matchPathname","currentPathname","matchLocation","pathParams","matchByPath","from","routeSegments","startsWith","unshift","isMatch","i","Math","max","baseSegment","routeSegment","isLastBaseSegment","isLastRouteSegment","caseSensitive","toLowerCase","fuzzy","undefined"],"mappings":";;;;;;;;;;;;;;;;AASO,SAASA,SAASA,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