@remix-run/router 0.2.0-pre.0 → 0.2.0-pre.1

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 (75) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE.md +22 -0
  3. package/dist/__tests__/TestSequences/EncodedReservedCharacters.d.ts +2 -0
  4. package/dist/__tests__/TestSequences/GoBack.d.ts +2 -0
  5. package/dist/__tests__/TestSequences/GoForward.d.ts +2 -0
  6. package/{__tests__/TestSequences/InitialLocationDefaultKey.ts → dist/__tests__/TestSequences/InitialLocationDefaultKey.d.ts} +1 -4
  7. package/dist/__tests__/TestSequences/InitialLocationHasKey.d.ts +2 -0
  8. package/dist/__tests__/TestSequences/Listen.d.ts +2 -0
  9. package/dist/__tests__/TestSequences/ListenPopOnly.d.ts +2 -0
  10. package/dist/__tests__/TestSequences/PushMissingPathname.d.ts +2 -0
  11. package/dist/__tests__/TestSequences/PushNewLocation.d.ts +2 -0
  12. package/dist/__tests__/TestSequences/PushRelativePathname.d.ts +2 -0
  13. package/dist/__tests__/TestSequences/PushRelativePathnameWarning.d.ts +2 -0
  14. package/dist/__tests__/TestSequences/PushSamePath.d.ts +2 -0
  15. package/dist/__tests__/TestSequences/PushState.d.ts +2 -0
  16. package/dist/__tests__/TestSequences/ReplaceNewLocation.d.ts +2 -0
  17. package/dist/__tests__/TestSequences/ReplaceSamePath.d.ts +2 -0
  18. package/dist/__tests__/TestSequences/ReplaceState.d.ts +2 -0
  19. package/dist/__tests__/browser-test.d.ts +4 -0
  20. package/dist/__tests__/create-path-test.d.ts +1 -0
  21. package/dist/__tests__/hash-base-test.d.ts +4 -0
  22. package/dist/__tests__/hash-test.d.ts +4 -0
  23. package/dist/__tests__/memory-test.d.ts +1 -0
  24. package/dist/__tests__/router-test.d.ts +2 -0
  25. package/dist/__tests__/setup.d.ts +1 -0
  26. package/dist/history.d.ts +226 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.js +2418 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/main.js +19 -0
  31. package/dist/router.d.ts +299 -0
  32. package/dist/router.development.js +2294 -0
  33. package/dist/router.development.js.map +1 -0
  34. package/dist/router.production.min.js +12 -0
  35. package/dist/router.production.min.js.map +1 -0
  36. package/dist/umd/router.development.js +2487 -0
  37. package/dist/umd/router.development.js.map +1 -0
  38. package/dist/umd/router.production.min.js +12 -0
  39. package/dist/umd/router.production.min.js.map +1 -0
  40. package/dist/utils.d.ts +244 -0
  41. package/package.json +21 -15
  42. package/.eslintrc +0 -12
  43. package/__tests__/.eslintrc +0 -8
  44. package/__tests__/TestSequences/EncodedReservedCharacters.ts +0 -27
  45. package/__tests__/TestSequences/GoBack.ts +0 -43
  46. package/__tests__/TestSequences/GoForward.ts +0 -70
  47. package/__tests__/TestSequences/InitialLocationHasKey.ts +0 -5
  48. package/__tests__/TestSequences/Listen.ts +0 -10
  49. package/__tests__/TestSequences/ListenPopOnly.ts +0 -14
  50. package/__tests__/TestSequences/PushMissingPathname.ts +0 -23
  51. package/__tests__/TestSequences/PushNewLocation.ts +0 -17
  52. package/__tests__/TestSequences/PushRelativePathname.ts +0 -23
  53. package/__tests__/TestSequences/PushRelativePathnameWarning.ts +0 -28
  54. package/__tests__/TestSequences/PushSamePath.ts +0 -33
  55. package/__tests__/TestSequences/PushState.ts +0 -16
  56. package/__tests__/TestSequences/ReplaceNewLocation.ts +0 -26
  57. package/__tests__/TestSequences/ReplaceSamePath.ts +0 -23
  58. package/__tests__/TestSequences/ReplaceState.ts +0 -16
  59. package/__tests__/browser-test.ts +0 -145
  60. package/__tests__/create-path-test.ts +0 -61
  61. package/__tests__/custom-environment.js +0 -19
  62. package/__tests__/hash-base-test.ts +0 -52
  63. package/__tests__/hash-test.ts +0 -149
  64. package/__tests__/memory-test.ts +0 -174
  65. package/__tests__/resolveTo-test.tsx +0 -26
  66. package/__tests__/router-test.ts +0 -6300
  67. package/__tests__/setup.ts +0 -15
  68. package/history.ts +0 -622
  69. package/index.ts +0 -96
  70. package/jest-transformer.js +0 -10
  71. package/jest.config.js +0 -10
  72. package/node-main.js +0 -7
  73. package/router.ts +0 -2033
  74. package/tsconfig.json +0 -19
  75. package/utils.ts +0 -822
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @remix-run/router
2
2
 
3
+ ## 0.2.0-pre.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix missing `dist` files
8
+
3
9
  ## 0.2.0-pre.0
4
10
 
5
11
  ### Minor Changes
package/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) React Training 2015-2019
4
+ Copyright (c) Remix Software 2020-2022
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function EncodeReservedCharacters(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function GoBack(history: History): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function GoForward(history: History): Promise<void>;
@@ -1,5 +1,2 @@
1
1
  import type { History } from "../../history";
2
-
3
- export default function InitialLocationDefaultKey(history: History) {
4
- expect(history.location.key).toBe("default");
5
- }
2
+ export default function InitialLocationDefaultKey(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function InitialLocationHasKey(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function Listen(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function ListenPopOnly(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushMissingPathname(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushNewLocation(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushRelativePathname(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushRelativePathnameWarning(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushSamePath(history: History): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function PushState(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function ReplaceNewLocation(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function ReplaceSamePath(history: History): void;
@@ -0,0 +1,2 @@
1
+ import type { History } from "../../history";
2
+ export default function ReplaceState(history: History): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment ./__tests__/custom-environment.js
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment ./__tests__/custom-environment.js
3
+ */
4
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment ./__tests__/custom-environment.js
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function invariant(value: boolean, message?: string): asserts value;
2
+ export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Actions represent the type of change to a location value.
3
+ */
4
+ export declare enum Action {
5
+ /**
6
+ * A POP indicates a change to an arbitrary index in the history stack, such
7
+ * as a back or forward navigation. It does not describe the direction of the
8
+ * navigation, only that the current index changed.
9
+ *
10
+ * Note: This is the default action for newly created history objects.
11
+ */
12
+ Pop = "POP",
13
+ /**
14
+ * A PUSH indicates a new entry being added to the history stack, such as when
15
+ * a link is clicked and a new page loads. When this happens, all subsequent
16
+ * entries in the stack are lost.
17
+ */
18
+ Push = "PUSH",
19
+ /**
20
+ * A REPLACE indicates the entry at the current index in the history stack
21
+ * being replaced by a new one.
22
+ */
23
+ Replace = "REPLACE"
24
+ }
25
+ /**
26
+ * The pathname, search, and hash values of a URL.
27
+ */
28
+ export interface Path {
29
+ /**
30
+ * A URL pathname, beginning with a /.
31
+ */
32
+ pathname: string;
33
+ /**
34
+ * A URL search string, beginning with a ?.
35
+ */
36
+ search: string;
37
+ /**
38
+ * A URL fragment identifier, beginning with a #.
39
+ */
40
+ hash: string;
41
+ }
42
+ /**
43
+ * An entry in a history stack. A location contains information about the
44
+ * URL path, as well as possibly some arbitrary state and a key.
45
+ */
46
+ export interface Location extends Path {
47
+ /**
48
+ * A value of arbitrary data associated with this location.
49
+ */
50
+ state: any;
51
+ /**
52
+ * A unique string associated with this location. May be used to safely store
53
+ * and retrieve data in some other storage API, like `localStorage`.
54
+ *
55
+ * Note: This value is always "default" on the initial location.
56
+ */
57
+ key: string;
58
+ }
59
+ /**
60
+ * A change to the current location.
61
+ */
62
+ export interface Update {
63
+ /**
64
+ * The action that triggered the change.
65
+ */
66
+ action: Action;
67
+ /**
68
+ * The new location.
69
+ */
70
+ location: Location;
71
+ }
72
+ /**
73
+ * A function that receives notifications about location changes.
74
+ */
75
+ export interface Listener {
76
+ (update: Update): void;
77
+ }
78
+ /**
79
+ * Describes a location that is the destination of some navigation, either via
80
+ * `history.push` or `history.replace`. May be either a URL or the pieces of a
81
+ * URL path.
82
+ */
83
+ export declare type To = string | Partial<Path>;
84
+ /**
85
+ * A history is an interface to the navigation stack. The history serves as the
86
+ * source of truth for the current location, as well as provides a set of
87
+ * methods that may be used to change it.
88
+ *
89
+ * It is similar to the DOM's `window.history` object, but with a smaller, more
90
+ * focused API.
91
+ */
92
+ export interface History {
93
+ /**
94
+ * The last action that modified the current location. This will always be
95
+ * Action.Pop when a history instance is first created. This value is mutable.
96
+ */
97
+ readonly action: Action;
98
+ /**
99
+ * The current location. This value is mutable.
100
+ */
101
+ readonly location: Location;
102
+ /**
103
+ * Returns a valid href for the given `to` value that may be used as
104
+ * the value of an <a href> attribute.
105
+ *
106
+ * @param to - The destination URL
107
+ */
108
+ createHref(to: To): string;
109
+ /**
110
+ * Pushes a new location onto the history stack, increasing its length by one.
111
+ * If there were any entries in the stack after the current one, they are
112
+ * lost.
113
+ *
114
+ * @param to - The new URL
115
+ * @param state - Data to associate with the new location
116
+ */
117
+ push(to: To, state?: any): void;
118
+ /**
119
+ * Replaces the current location in the history stack with a new one. The
120
+ * location that was replaced will no longer be available.
121
+ *
122
+ * @param to - The new URL
123
+ * @param state - Data to associate with the new location
124
+ */
125
+ replace(to: To, state?: any): void;
126
+ /**
127
+ * Navigates `n` entries backward/forward in the history stack relative to the
128
+ * current index. For example, a "back" navigation would use go(-1).
129
+ *
130
+ * @param delta - The delta in the stack index
131
+ */
132
+ go(delta: number): void;
133
+ /**
134
+ * Sets up a listener that will be called whenever the current location
135
+ * changes.
136
+ *
137
+ * @param listener - A function that will be called when the location changes
138
+ * @returns unlisten - A function that may be used to stop listening
139
+ */
140
+ listen(listener: Listener): () => void;
141
+ }
142
+ /**
143
+ * A user-supplied object that describes a location. Used when providing
144
+ * entries to `createMemoryHistory` via its `initialEntries` option.
145
+ */
146
+ export declare type InitialEntry = string | Partial<Location>;
147
+ export declare type MemoryHistoryOptions = {
148
+ initialEntries?: InitialEntry[];
149
+ initialIndex?: number;
150
+ v5Compat?: boolean;
151
+ };
152
+ /**
153
+ * A memory history stores locations in memory. This is useful in stateful
154
+ * environments where there is no web browser, such as node tests or React
155
+ * Native.
156
+ */
157
+ export interface MemoryHistory extends History {
158
+ /**
159
+ * The current index in the history stack.
160
+ */
161
+ readonly index: number;
162
+ }
163
+ /**
164
+ * Memory history stores the current location in memory. It is designed for use
165
+ * in stateful non-browser environments like tests and React Native.
166
+ */
167
+ export declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
168
+ /**
169
+ * A browser history stores the current location in regular URLs in a web
170
+ * browser environment. This is the standard for most web apps and provides the
171
+ * cleanest URLs the browser's address bar.
172
+ *
173
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
174
+ */
175
+ export interface BrowserHistory extends UrlHistory {
176
+ }
177
+ export declare type BrowserHistoryOptions = UrlHistoryOptions;
178
+ /**
179
+ * Browser history stores the location in regular URLs. This is the standard for
180
+ * most web apps, but it requires some configuration on the server to ensure you
181
+ * serve the same app at multiple URLs.
182
+ *
183
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
184
+ */
185
+ export declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
186
+ /**
187
+ * A hash history stores the current location in the fragment identifier portion
188
+ * of the URL in a web browser environment.
189
+ *
190
+ * This is ideal for apps that do not control the server for some reason
191
+ * (because the fragment identifier is never sent to the server), including some
192
+ * shared hosting environments that do not provide fine-grained controls over
193
+ * which pages are served at which URLs.
194
+ *
195
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
196
+ */
197
+ export interface HashHistory extends UrlHistory {
198
+ }
199
+ export declare type HashHistoryOptions = UrlHistoryOptions;
200
+ /**
201
+ * Hash history stores the location in window.location.hash. This makes it ideal
202
+ * for situations where you don't want to send the location to the server for
203
+ * some reason, either because you do cannot configure it or the URL space is
204
+ * reserved for something else.
205
+ *
206
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
207
+ */
208
+ export declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
209
+ /**
210
+ * Creates a Location object with a unique key from the given Path
211
+ */
212
+ export declare function createLocation(current: string | Location, to: To, state?: any, key?: string): Location;
213
+ /**
214
+ * Creates a string URL path from the given pathname, search, and hash components.
215
+ */
216
+ export declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
217
+ /**
218
+ * Parses a string URL path into its separate pathname, search, and hash components.
219
+ */
220
+ export declare function parsePath(path: string): Partial<Path>;
221
+ export interface UrlHistory extends History {
222
+ }
223
+ export declare type UrlHistoryOptions = {
224
+ window?: Window;
225
+ v5Compat?: boolean;
226
+ };
@@ -0,0 +1,11 @@
1
+ import type { BrowserHistoryOptions, HashHistoryOptions, MemoryHistoryOptions } from "./history";
2
+ import type { Router, RouterInit } from "./router";
3
+ declare function createMemoryRouter({ initialEntries, initialIndex, ...routerInit }: MemoryHistoryOptions & Omit<RouterInit, "history">): Router;
4
+ declare function createBrowserRouter({ window, ...routerInit }: BrowserHistoryOptions & Omit<RouterInit, "history">): Router;
5
+ declare function createHashRouter({ window, ...routerInit }: HashHistoryOptions & Omit<RouterInit, "history">): Router;
6
+ export * from "./router";
7
+ export type { ActionFunction, DataRouteObject, FormEncType, FormMethod, JsonFunction, LoaderFunction, ParamParseKey, Params, PathMatch, PathPattern, RedirectFunction, RouteMatch, RouteObject, ShouldRevalidateFunction, Submission, } from "./utils";
8
+ export { generatePath, getToPathname, invariant, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, resolvePath, resolveTo, stripBasename, warning, } from "./utils";
9
+ export type { BrowserHistory, HashHistory, History, InitialEntry, Location, MemoryHistory, Path, To, } from "./history";
10
+ export { Action, createBrowserHistory, createPath, createHashHistory, createMemoryHistory, parsePath, } from "./history";
11
+ export { createBrowserRouter, createHashRouter, createMemoryRouter };