@octanejs/remix-router 0.1.0 → 0.1.2
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/README.md +20 -6
- package/package.json +12 -7
- package/src/index.ts +16 -14
- package/src/lib/Await.tsrx +1 -1
- package/src/lib/DefaultErrorComponent.tsrx +3 -3
- package/src/lib/RenderErrorBoundary.tsrx +1 -1
- package/src/lib/actions.ts +1 -1
- package/src/lib/components/MemoryRouter.tsrx +1 -1
- package/src/lib/components/Navigate.ts +1 -1
- package/src/lib/components/Router.tsrx +1 -1
- package/src/lib/components/RouterProvider.tsrx +1 -1
- package/src/lib/components/Routes.tsrx +1 -1
- package/src/lib/components/routes-collector.ts +1 -8
- package/src/lib/components/utils.ts +4 -65
- package/src/lib/components/with-props.ts +1 -1
- package/src/lib/context.ts +2 -4
- package/src/lib/dom/Form.tsrx +1 -1
- package/src/lib/dom/Link.tsrx +1 -1
- package/src/lib/dom/NavLink.tsrx +1 -1
- package/src/lib/dom/dom.ts +1 -1
- package/src/lib/dom/hooks.ts +1 -1
- package/src/lib/dom/lib.ts +8 -7
- package/src/lib/dom/routers.tsrx +1 -1
- package/src/lib/dom/server.tsrx +6 -28
- package/src/lib/errors.ts +1 -1
- package/src/lib/hooks.ts +6 -16
- package/src/lib/href.ts +9 -4
- package/src/lib/router/history.ts +2 -2
- package/src/lib/router/instrumentation.ts +391 -187
- package/src/lib/router/links.ts +1 -1
- package/src/lib/router/router.ts +128 -78
- package/src/lib/router/server-runtime-types.ts +8 -11
- package/src/lib/router/url.ts +1 -1
- package/src/lib/router/utils.ts +107 -31
- package/src/lib/server-runtime/cookies.ts +7 -7
- package/src/lib/server-runtime/crypto.ts +2 -2
- package/src/lib/server-runtime/mode.ts +1 -1
- package/src/lib/server-runtime/sessions/cookieStorage.ts +1 -1
- package/src/lib/server-runtime/sessions/memoryStorage.ts +1 -1
- package/src/lib/server-runtime/sessions.ts +8 -5
- package/src/lib/server-runtime/warnings.ts +1 -1
- package/src/lib/types/future.ts +1 -7
- package/src/lib/types/params.ts +1 -1
- package/src/lib/types/register.ts +1 -1
- package/src/lib/types/route-module.ts +1 -1
- package/src/lib/types/utils.ts +1 -1
package/src/lib/href.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from react-router@
|
|
1
|
+
// Vendored from react-router@8.2.0 packages/react-router/lib/href.ts — unmodified.
|
|
2
2
|
// Re-vendor with `node scripts/vendor-remix-router.mjs`; never hand-edit.
|
|
3
3
|
import type { Pages } from './types/register';
|
|
4
4
|
import type { Equal } from './types/utils';
|
|
@@ -14,6 +14,10 @@ type ToArgs<Params extends Record<string, string | undefined>> =
|
|
|
14
14
|
// otherwise, require `params` arg
|
|
15
15
|
[Params];
|
|
16
16
|
|
|
17
|
+
function stringify(p: any) {
|
|
18
|
+
return p == null ? '' : typeof p === 'string' ? p : String(p);
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
22
|
Returns a resolved URL path for the specified route.
|
|
19
23
|
|
|
@@ -35,16 +39,17 @@ export function href<Path extends keyof Args>(path: Path, ...args: Args[Path]):
|
|
|
35
39
|
if (isRequired && value === undefined) {
|
|
36
40
|
throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
|
|
37
41
|
}
|
|
38
|
-
return value
|
|
42
|
+
return value == null ? '' : '/' + encodeURIComponent(stringify(value));
|
|
39
43
|
},
|
|
40
44
|
);
|
|
41
45
|
|
|
42
46
|
if (path.endsWith('*')) {
|
|
43
47
|
// treat trailing splat the same way as compilePath, and force it to be as if it were `/*`.
|
|
44
|
-
// `react-router typegen` will not generate the params for a malformed splat,
|
|
48
|
+
// `react-router typegen` will not generate the params for a malformed splat,
|
|
49
|
+
// causing a type error, but we can still do the correct thing here.
|
|
45
50
|
const value = params?.['*'];
|
|
46
51
|
if (value !== undefined) {
|
|
47
|
-
result += '/' + value;
|
|
52
|
+
result += '/' + stringify(value).split('/').map(encodeURIComponent).join('/');
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from react-router@
|
|
1
|
+
// Vendored from react-router@8.2.0 packages/react-router/lib/router/history.ts — unmodified.
|
|
2
2
|
// Re-vendor with `node scripts/vendor-remix-router.mjs`; never hand-edit.
|
|
3
3
|
import { PROTOCOL_RELATIVE_URL_REGEX } from './url';
|
|
4
4
|
|
|
@@ -53,7 +53,7 @@ export interface Path {
|
|
|
53
53
|
hash: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// TODO: (
|
|
56
|
+
// TODO: (v9) Change the Location generic default from `any` to `unknown` and
|
|
57
57
|
// remove Remix `useLocation` wrapper.
|
|
58
58
|
|
|
59
59
|
/**
|