@tanstack/router-core 0.0.1-beta.195 → 0.0.1-beta.197

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.195",
4
+ "version": "0.0.1-beta.197",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -43,6 +43,7 @@
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
45
  "@tanstack/store": "^0.0.1",
46
+ "@tanstack/history": "0.0.1-beta.194",
46
47
  "@gisatcz/cross-package-react-context": "^0.2.0"
47
48
  },
48
49
  "scripts": {
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
+ export * from '@tanstack/history'
1
2
  export { default as invariant } from 'tiny-invariant'
2
3
  export { default as warning } from 'tiny-warning'
3
- export * from './history'
4
4
  export * from './link'
5
5
  export * from './path'
6
6
  export * from './qss'
package/src/router.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import { Store } from '@tanstack/store'
2
2
  import invariant from 'tiny-invariant'
3
+ import {
4
+ createBrowserHistory,
5
+ createMemoryHistory,
6
+ HistoryLocation,
7
+ HistoryState,
8
+ RouterHistory,
9
+ } from '@tanstack/history'
3
10
 
4
11
  //
5
12
 
@@ -53,13 +60,6 @@ import {
53
60
  partialDeepEqual,
54
61
  NonNullableUpdater,
55
62
  } from './utils'
56
- import {
57
- createBrowserHistory,
58
- createMemoryHistory,
59
- HistoryLocation,
60
- HistoryState,
61
- RouterHistory,
62
- } from './history'
63
63
 
64
64
  //
65
65
 
@@ -69,6 +69,13 @@ declare global {
69
69
  }
70
70
  }
71
71
 
72
+ declare module '@tanstack/history' {
73
+ interface HistoryState {
74
+ __tempLocation?: HistoryLocation
75
+ __tempKey?: string
76
+ }
77
+ }
78
+
72
79
  export interface Register {
73
80
  // router: Router
74
81
  }
@@ -1,301 +0,0 @@
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 subscribers = 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.subscriber) {
50
- onUpdate();
51
- }
52
- };
53
- const queueTask = task => {
54
- queue.push(task);
55
- tryFlush();
56
- };
57
- const onUpdate = () => {
58
- location = opts.getLocation();
59
- subscribers.forEach(subscriber => subscriber());
60
- };
61
- return {
62
- get location() {
63
- return location;
64
- },
65
- subscribe: cb => {
66
- if (subscribers.size === 0) {
67
- unsub = typeof opts.subscriber === 'function' ? opts.subscriber(onUpdate) : () => {};
68
- }
69
- subscribers.add(cb);
70
- return () => {
71
- subscribers.delete(cb);
72
- if (subscribers.size === 0) {
73
- unsub();
74
- }
75
- };
76
- },
77
- push: (path, state) => {
78
- assignKey(state);
79
- queueTask(() => {
80
- opts.pushState(path, state, onUpdate);
81
- });
82
- },
83
- replace: (path, state) => {
84
- assignKey(state);
85
- queueTask(() => {
86
- opts.replaceState(path, state, onUpdate);
87
- });
88
- },
89
- go: index => {
90
- queueTask(() => {
91
- opts.go(index);
92
- });
93
- },
94
- back: () => {
95
- queueTask(() => {
96
- opts.back();
97
- });
98
- },
99
- forward: () => {
100
- queueTask(() => {
101
- opts.forward();
102
- });
103
- },
104
- createHref: str => opts.createHref(str),
105
- block: cb => {
106
- blockers.push(cb);
107
- if (blockers.length === 1) {
108
- addEventListener(beforeUnloadEvent, beforeUnloadListener, {
109
- capture: true
110
- });
111
- }
112
- return () => {
113
- blockers = blockers.filter(b => b !== cb);
114
- if (!blockers.length) {
115
- stopBlocking();
116
- }
117
- };
118
- },
119
- flush: () => opts.flush?.()
120
- };
121
- }
122
- function assignKey(state) {
123
- state.key = createRandomKey();
124
- // if (state.__actualLocation) {
125
- // state.__actualLocation.state = {
126
- // ...state.__actualLocation.state,
127
- // key,
128
- // }
129
- // }
130
- }
131
-
132
- /**
133
- * Creates a history object that can be used to interact with the browser's
134
- * navigation. This is a lightweight API wrapping the browser's native methods.
135
- * It is designed to work with TanStack Router, but could be used as a standalone API as well.
136
- * IMPORTANT: This API implements history throttling via a microtask to prevent
137
- * excessive calls to the history API. In some browsers, calling history.pushState or
138
- * history.replaceState in quick succession can cause the browser to ignore subsequent
139
- * calls. This API smooths out those differences and ensures that your application
140
- * state will *eventually* match the browser state. In most cases, this is not a problem,
141
- * but if you need to ensure that the browser state is up to date, you can use the
142
- * `history.flush` method to immediately flush all pending state changes to the browser URL.
143
- * @param opts
144
- * @param opts.getHref A function that returns the current href (path + search + hash)
145
- * @param opts.createHref A function that takes a path and returns a href (path + search + hash)
146
- * @returns A history instance
147
- */
148
- function createBrowserHistory(opts) {
149
- const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`);
150
- const createHref = opts?.createHref ?? (path => path);
151
- let currentLocation = parseLocation(getHref(), window.history.state);
152
- const getLocation = () => currentLocation;
153
- let next;
154
-
155
- // Because we are proactively updating the location
156
- // in memory before actually updating the browser history,
157
- // we need to track when we are doing this so we don't
158
- // notify subscribers twice on the last update.
159
- let tracking = true;
160
-
161
- // We need to track the current scheduled update to prevent
162
- // multiple updates from being scheduled at the same time.
163
- let scheduled;
164
-
165
- // This function is a wrapper to prevent any of the callback's
166
- // side effects from causing a subscriber notification
167
- const untrack = fn => {
168
- tracking = false;
169
- fn();
170
- tracking = true;
171
- };
172
-
173
- // This function flushes the next update to the browser history
174
- const flush = () => {
175
- // Do not notify subscribers about this push/replace call
176
- untrack(() => {
177
- if (!next) return;
178
- window.history[next.isPush ? 'pushState' : 'replaceState'](next.state, '', next.href);
179
- // Reset the nextIsPush flag and clear the scheduled update
180
- next = undefined;
181
- scheduled = undefined;
182
- });
183
- };
184
-
185
- // This function queues up a call to update the browser history
186
- const queueHistoryAction = (type, path, state, onUpdate) => {
187
- const href = createHref(path);
188
-
189
- // Update the location in memory
190
- currentLocation = parseLocation(href, state);
191
-
192
- // Keep track of the next location we need to flush to the URL
193
- next = {
194
- href,
195
- state,
196
- isPush: next?.isPush || type === 'push'
197
- };
198
- // Notify subscribers
199
- onUpdate();
200
- if (!scheduled) {
201
- // Schedule an update to the browser history
202
- scheduled = Promise.resolve().then(() => flush());
203
- }
204
- };
205
- return createHistory({
206
- getLocation,
207
- subscriber: onUpdate => {
208
- window.addEventListener(pushStateEvent, () => {
209
- currentLocation = parseLocation(getHref(), window.history.state);
210
- onUpdate();
211
- });
212
- window.addEventListener(popStateEvent, () => {
213
- currentLocation = parseLocation(getHref(), window.history.state);
214
- onUpdate();
215
- });
216
- var pushState = window.history.pushState;
217
- window.history.pushState = function () {
218
- let res = pushState.apply(history, arguments);
219
- if (tracking) onUpdate();
220
- return res;
221
- };
222
- var replaceState = window.history.replaceState;
223
- window.history.replaceState = function () {
224
- let res = replaceState.apply(history, arguments);
225
- if (tracking) onUpdate();
226
- return res;
227
- };
228
- return () => {
229
- window.history.pushState = pushState;
230
- window.history.replaceState = replaceState;
231
- window.removeEventListener(pushStateEvent, onUpdate);
232
- window.removeEventListener(popStateEvent, onUpdate);
233
- };
234
- },
235
- pushState: (path, state, onUpdate) => queueHistoryAction('push', path, state, onUpdate),
236
- replaceState: (path, state, onUpdate) => queueHistoryAction('replace', path, state, onUpdate),
237
- back: () => window.history.back(),
238
- forward: () => window.history.forward(),
239
- go: n => window.history.go(n),
240
- createHref: path => createHref(path),
241
- flush
242
- });
243
- }
244
- function createHashHistory() {
245
- return createBrowserHistory({
246
- getHref: () => window.location.hash.substring(1),
247
- createHref: path => `#${path}`
248
- });
249
- }
250
- function createMemoryHistory(opts = {
251
- initialEntries: ['/']
252
- }) {
253
- const entries = opts.initialEntries;
254
- let index = opts.initialIndex ?? entries.length - 1;
255
- let currentState = {
256
- key: createRandomKey()
257
- };
258
- const getLocation = () => parseLocation(entries[index], currentState);
259
- return createHistory({
260
- getLocation,
261
- subscriber: false,
262
- pushState: (path, state) => {
263
- currentState = state;
264
- entries.push(path);
265
- index++;
266
- },
267
- replaceState: (path, state) => {
268
- currentState = state;
269
- entries[index] = path;
270
- },
271
- back: () => {
272
- index--;
273
- },
274
- forward: () => {
275
- index = Math.min(index + 1, entries.length - 1);
276
- },
277
- go: n => window.history.go(n),
278
- createHref: path => path
279
- });
280
- }
281
- function parseLocation(href, state) {
282
- let hashIndex = href.indexOf('#');
283
- let searchIndex = href.indexOf('?');
284
- return {
285
- href,
286
- pathname: href.substring(0, hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : href.length),
287
- hash: hashIndex > -1 ? href.substring(hashIndex) : '',
288
- search: searchIndex > -1 ? href.slice(searchIndex, hashIndex === -1 ? undefined : hashIndex) : '',
289
- state: state || {}
290
- };
291
- }
292
-
293
- // Thanks co-pilot!
294
- function createRandomKey() {
295
- return (Math.random() + 1).toString(36).substring(7);
296
- }
297
-
298
- exports.createBrowserHistory = createBrowserHistory;
299
- exports.createHashHistory = createHashHistory;
300
- exports.createMemoryHistory = createMemoryHistory;
301
- //# sourceMappingURL=history.js.map
@@ -1 +0,0 @@
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: HistoryLocation\n subscribe: (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 flush: () => void\n}\n\nexport interface HistoryLocation extends ParsedPath {\n state: HistoryState\n}\n\nexport interface ParsedPath {\n href: string\n pathname: string\n search: string\n hash: string\n}\n\nexport interface HistoryState {\n key: string\n __tempLocation?: HistoryLocation\n __tempKey?: string\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: () => HistoryLocation\n subscriber: false | ((onUpdate: () => void) => () => void)\n pushState: (path: string, state: any, onUpdate: () => void) => void\n replaceState: (path: string, state: any, onUpdate: () => void) => void\n go: (n: number) => void\n back: () => void\n forward: () => void\n createHref: (path: string) => string\n flush?: () => void\n}): RouterHistory {\n let location = opts.getLocation()\n let unsub = () => {}\n let subscribers = 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.subscriber) {\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 subscribers.forEach((subscriber) => subscriber())\n }\n\n return {\n get location() {\n return location\n },\n subscribe: (cb: () => void) => {\n if (subscribers.size === 0) {\n unsub =\n typeof opts.subscriber === 'function'\n ? opts.subscriber(onUpdate)\n : () => {}\n }\n subscribers.add(cb)\n\n return () => {\n subscribers.delete(cb)\n if (subscribers.size === 0) {\n unsub()\n }\n }\n },\n push: (path: string, state: any) => {\n assignKey(state)\n queueTask(() => {\n opts.pushState(path, state, onUpdate)\n })\n },\n replace: (path: string, state: any) => {\n assignKey(state)\n queueTask(() => {\n opts.replaceState(path, state, onUpdate)\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 flush: () => opts.flush?.(),\n }\n}\n\nfunction assignKey(state: HistoryState) {\n state.key = createRandomKey()\n // if (state.__actualLocation) {\n // state.__actualLocation.state = {\n // ...state.__actualLocation.state,\n // key,\n // }\n // }\n}\n\n/**\n * Creates a history object that can be used to interact with the browser's\n * navigation. This is a lightweight API wrapping the browser's native methods.\n * It is designed to work with TanStack Router, but could be used as a standalone API as well.\n * IMPORTANT: This API implements history throttling via a microtask to prevent\n * excessive calls to the history API. In some browsers, calling history.pushState or\n * history.replaceState in quick succession can cause the browser to ignore subsequent\n * calls. This API smooths out those differences and ensures that your application\n * state will *eventually* match the browser state. In most cases, this is not a problem,\n * but if you need to ensure that the browser state is up to date, you can use the\n * `history.flush` method to immediately flush all pending state changes to the browser URL.\n * @param opts\n * @param opts.getHref A function that returns the current href (path + search + hash)\n * @param opts.createHref A function that takes a path and returns a href (path + search + hash)\n * @returns A history instance\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\n const createHref = opts?.createHref ?? ((path) => path)\n\n let currentLocation = parseLocation(getHref(), window.history.state)\n\n const getLocation = () => currentLocation\n\n let next:\n | undefined\n | {\n // This is the latest location that we were attempting to push/replace\n href: string\n // This is the latest state that we were attempting to push/replace\n state: any\n // This is the latest type that we were attempting to push/replace\n isPush: boolean\n }\n\n // Because we are proactively updating the location\n // in memory before actually updating the browser history,\n // we need to track when we are doing this so we don't\n // notify subscribers twice on the last update.\n let tracking = true\n\n // We need to track the current scheduled update to prevent\n // multiple updates from being scheduled at the same time.\n let scheduled: Promise<void> | undefined\n\n // This function is a wrapper to prevent any of the callback's\n // side effects from causing a subscriber notification\n const untrack = (fn: () => void) => {\n tracking = false\n fn()\n tracking = true\n }\n\n // This function flushes the next update to the browser history\n const flush = () => {\n // Do not notify subscribers about this push/replace call\n untrack(() => {\n if (!next) return\n window.history[next.isPush ? 'pushState' : 'replaceState'](\n next.state,\n '',\n next.href,\n )\n // Reset the nextIsPush flag and clear the scheduled update\n next = undefined\n scheduled = undefined\n })\n }\n\n // This function queues up a call to update the browser history\n const queueHistoryAction = (\n type: 'push' | 'replace',\n path: string,\n state: any,\n onUpdate: () => void,\n ) => {\n const href = createHref(path)\n\n // Update the location in memory\n currentLocation = parseLocation(href, state)\n\n // Keep track of the next location we need to flush to the URL\n next = {\n href,\n state,\n isPush: next?.isPush || type === 'push',\n }\n // Notify subscribers\n onUpdate()\n\n if (!scheduled) {\n // Schedule an update to the browser history\n scheduled = Promise.resolve().then(() => flush())\n }\n }\n\n return createHistory({\n getLocation,\n subscriber: (onUpdate) => {\n window.addEventListener(pushStateEvent, () => {\n currentLocation = parseLocation(getHref(), window.history.state)\n onUpdate()\n })\n window.addEventListener(popStateEvent, () => {\n currentLocation = parseLocation(getHref(), window.history.state)\n onUpdate()\n })\n\n var pushState = window.history.pushState\n window.history.pushState = function () {\n let res = pushState.apply(history, arguments as any)\n if (tracking) 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 if (tracking) 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, onUpdate) =>\n queueHistoryAction('push', path, state, onUpdate),\n replaceState: (path, state, onUpdate) =>\n queueHistoryAction('replace', path, state, onUpdate),\n back: () => window.history.back(),\n forward: () => window.history.forward(),\n go: (n) => window.history.go(n),\n createHref: (path) => createHref(path),\n flush,\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 key: createRandomKey(),\n } as HistoryState\n\n const getLocation = () => parseLocation(entries[index]!, currentState)\n\n return createHistory({\n getLocation,\n subscriber: false,\n pushState: (path, state) => {\n currentState = state\n entries.push(path)\n index++\n },\n replaceState: (path, state) => {\n currentState = state\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: HistoryState): HistoryLocation {\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: 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","subscribers","Set","blockers","queue","tryFlush","length","shift","subscriber","onUpdate","queueTask","task","push","forEach","subscribe","cb","size","add","delete","path","state","assignKey","pushState","replace","replaceState","go","index","back","forward","createHref","str","block","addEventListener","filter","b","flush","key","createRandomKey","createBrowserHistory","getHref","window","pathname","search","hash","currentLocation","parseLocation","history","next","tracking","scheduled","untrack","fn","isPush","href","undefined","queueHistoryAction","type","Promise","resolve","then","res","apply","arguments","n","createHashHistory","substring","createMemoryHistory","initialEntries","entries","initialIndex","currentState","Math","min","hashIndex","indexOf","searchIndex","slice","random","toString"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;;AAkCA,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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terHistory {
2
- location: HistoryLocation;
3
- subscribe: (cb: () => void) => () => void;
4
- push: (path: string, state?: any) => void;
5
- replace: (path: string, state?: any) => void;
6
- go: (index: number) => void;
7
- back: () => void;
8
- forward: () => void;
9
- createHref: (href: string) => string;
10
- block: (blockerFn: BlockerFn) => () => void;
11
- flush: () => void;
12
- }
13
- export interface HistoryLocation extends ParsedPath {
14
- state: HistoryState;
15
- }
16
- export interface ParsedPath {
17
- href: string;
18
- pathname: string;
19
- search: string;
20
- hash: string;
21
- }
22
- export interface HistoryState {
23
- key: string;
24
- __tempLocation?: HistoryLocation;
25
- __tempKey?: string;
26
- }
27
- type BlockerFn = (retry: () => void, cancel: () => void) => void;
28
- /**
29
- * Creates a history object that can be used to interact with the browser's
30
- * navigation. This is a lightweight API wrapping the browser's native methods.
31
- * It is designed to work with TanStack Router, but could be used as a standalone API as well.
32
- * IMPORTANT: This API implements history throttling via a microtask to prevent
33
- * excessive calls to the history API. In some browsers, calling history.pushState or
34
- * history.replaceState in quick succession can cause the browser to ignore subsequent
35
- * calls. This API smooths out those differences and ensures that your application
36
- * state will *eventually* match the browser state. In most cases, this is not a problem,
37
- * but if you need to ensure that the browser state is up to date, you can use the
38
- * `history.flush` method to immediately flush all pending state changes to the browser URL.
39
- * @param opts
40
- * @param opts.getHref A function that returns the current href (path + search + hash)
41
- * @param opts.createHref A function that takes a path and returns a href (path + search + hash)
42
- * @returns A history instance
43
- */
44
- export declare function createBrowserHistory(opts?: {
45
- getHref?: () => string;
46
- createHref?: (path: string) => string;
47
- }): RouterHistory;
48
- export declare function createHashHistory(): RouterHistory;
49
- export declare function createMemoryHistory(opts?: {
50
- initialEntries: string[];
51
- initialIndex?: number;
52
- }): RouterHistory;
53
- export {};