@octanejs/tanstack-router 0.1.11 → 0.1.15
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 +8 -8
- package/src/Asset.tsrx +4 -5
- package/src/Body.ts +1 -2
- package/src/CatchBoundary.tsrx +1 -3
- package/src/Head.ts +1 -2
- package/src/Html.ts +1 -2
- package/src/Link.tsrx +9 -3
- package/src/RouterProvider.tsrx +2 -1
- package/src/ScriptOnce.tsrx +1 -2
- package/src/context.ts +1 -2
- package/src/generator-plugin.js +8 -0
- package/src/linkTypes.ts +1 -2
- package/src/useBlocker.tsrx +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"isbot": "^5.1.22"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"octane": "0.1.
|
|
61
|
+
"octane": "0.1.16"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@tanstack/react-router": "1.170.
|
|
65
|
-
"@tsrx/react": "^0.2.
|
|
64
|
+
"@tanstack/react-router": "1.170.18",
|
|
65
|
+
"@tsrx/react": "^0.2.50",
|
|
66
66
|
"esbuild": "^0.28.1",
|
|
67
|
-
"react": "^19.2.
|
|
68
|
-
"react-dom": "^19.2.
|
|
69
|
-
"vitest": "^4.1.
|
|
70
|
-
"octane": "0.1.
|
|
67
|
+
"react": "^19.2.7",
|
|
68
|
+
"react-dom": "^19.2.7",
|
|
69
|
+
"vitest": "^4.1.10",
|
|
70
|
+
"octane": "0.1.16"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run"
|
package/src/Asset.tsrx
CHANGED
|
@@ -4,7 +4,8 @@ import type { RouterManagedTag } from '@tanstack/router-core';
|
|
|
4
4
|
import { useRouter } from './context.ts';
|
|
5
5
|
import { useHydrated } from './ClientOnly.tsrx';
|
|
6
6
|
|
|
7
|
-
export type AssetProps =
|
|
7
|
+
export type AssetProps =
|
|
8
|
+
RouterManagedTag & {
|
|
8
9
|
assetKey: string;
|
|
9
10
|
target: 'head' | 'body';
|
|
10
11
|
};
|
|
@@ -70,11 +71,9 @@ function mountAsset(props: AssetProps) {
|
|
|
70
71
|
|
|
71
72
|
export function Asset(props: AssetProps) @{
|
|
72
73
|
const router = useRouter();
|
|
73
|
-
const server = isServer ?? router.isServer;
|
|
74
74
|
const hydrated = useHydrated();
|
|
75
|
-
const renderElement = server || props.target === 'body' && !hydrated;
|
|
76
75
|
|
|
77
|
-
if (!
|
|
76
|
+
if (!(isServer ?? router.isServer)) {
|
|
78
77
|
useLayoutEffect(() => mountAsset(props), [
|
|
79
78
|
props.assetKey,
|
|
80
79
|
props.attrs,
|
|
@@ -84,7 +83,7 @@ export function Asset(props: AssetProps) @{
|
|
|
84
83
|
]);
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
@if (
|
|
86
|
+
@if ((isServer ?? router.isServer) || props.target === 'body' && !hydrated) {
|
|
88
87
|
@switch (props.tag) {
|
|
89
88
|
@case 'title': {
|
|
90
89
|
<title {...props.attrs} data-tsr-managed-key={props.assetKey}>
|
package/src/Body.ts
CHANGED
|
@@ -18,9 +18,8 @@ const HydrationRangeOwner: ComponentBody<Pick<BodyProps, 'children'>> = (props)
|
|
|
18
18
|
|
|
19
19
|
export const Body: ComponentBody<BodyProps> = (props) => {
|
|
20
20
|
const router = useRouter();
|
|
21
|
-
const server = isServer ?? router.isServer;
|
|
22
21
|
const { children, ...attrs } = props;
|
|
23
|
-
if (
|
|
22
|
+
if (isServer ?? router.isServer) {
|
|
24
23
|
return createElement(
|
|
25
24
|
'body',
|
|
26
25
|
attrs,
|
package/src/CatchBoundary.tsrx
CHANGED
|
@@ -97,9 +97,7 @@ export function ErrorComponent(props: {
|
|
|
97
97
|
style="font-size:.7em;border:1px solid red;border-radius:.25rem;padding:.3rem;color:red;overflow:auto"
|
|
98
98
|
>
|
|
99
99
|
@if (props.error?.message) {
|
|
100
|
-
<code>
|
|
101
|
-
{props.error.message as string}
|
|
102
|
-
</code>
|
|
100
|
+
<code>{props.error.message as string}</code>
|
|
103
101
|
}
|
|
104
102
|
</pre>
|
|
105
103
|
</div>
|
package/src/Head.ts
CHANGED
|
@@ -10,9 +10,8 @@ export interface HeadProps {
|
|
|
10
10
|
|
|
11
11
|
export const Head: ComponentBody<HeadProps> = (props) => {
|
|
12
12
|
const router = useRouter();
|
|
13
|
-
const server = isServer ?? router.isServer;
|
|
14
13
|
const { children, ...attrs } = props;
|
|
15
|
-
if (
|
|
14
|
+
if (isServer ?? router.isServer) {
|
|
16
15
|
return createElement('head', attrs, children);
|
|
17
16
|
}
|
|
18
17
|
if (typeof document !== 'undefined') {
|
package/src/Html.ts
CHANGED
|
@@ -10,9 +10,8 @@ export interface HtmlProps {
|
|
|
10
10
|
|
|
11
11
|
export const Html: ComponentBody<HtmlProps> = (props) => {
|
|
12
12
|
const router = useRouter();
|
|
13
|
-
const server = isServer ?? router.isServer;
|
|
14
13
|
const { children, ...attrs } = props;
|
|
15
|
-
if (
|
|
14
|
+
if (isServer ?? router.isServer) {
|
|
16
15
|
return createElement('html', attrs, children);
|
|
17
16
|
}
|
|
18
17
|
return children;
|
package/src/Link.tsrx
CHANGED
|
@@ -16,9 +16,15 @@ import type { LinkComponentProps, OctaneAnchorProps, UseLinkPropsOptions } from
|
|
|
16
16
|
// Keep the generic implementation signature visible to `.tsrx` consumers so
|
|
17
17
|
// route-aware `to`/`params`/`search` inference and native anchor event types are
|
|
18
18
|
// available before declaration emit.
|
|
19
|
-
export function Link<
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export function Link<
|
|
20
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
21
|
+
TFrom extends string = string,
|
|
22
|
+
TTo extends string | undefined = undefined,
|
|
23
|
+
TMaskFrom extends string = TFrom,
|
|
24
|
+
TMaskTo extends string = '',
|
|
25
|
+
>(props: LinkComponentProps<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) @{
|
|
26
|
+
const { _asChild: AsChild, children, ...rest } = props as
|
|
27
|
+
typeof props & {
|
|
22
28
|
_asChild?: any;
|
|
23
29
|
};
|
|
24
30
|
const linkProps = useLinkProps(
|
package/src/RouterProvider.tsrx
CHANGED
|
@@ -14,7 +14,8 @@ import { SafeFragment } from './SafeFragment.tsrx';
|
|
|
14
14
|
// Upstream's `RouterProps` is `Omit<RouterOptions<…>, 'context'> & { router }` —
|
|
15
15
|
// extra props reconfigure the instance via `router.update()`. The octane binding
|
|
16
16
|
// keeps the router-typed member strict and the option passthrough permissive.
|
|
17
|
-
export type RouterProps =
|
|
17
|
+
export type RouterProps =
|
|
18
|
+
{
|
|
18
19
|
router: AnyRouter;
|
|
19
20
|
context?: Record<string, any>;
|
|
20
21
|
} & Record<string, any>;
|
package/src/ScriptOnce.tsrx
CHANGED
|
@@ -4,13 +4,12 @@ import { useRouter } from './context.ts';
|
|
|
4
4
|
|
|
5
5
|
export function ScriptOnce(props: { children: string }) @{
|
|
6
6
|
const router = useRouter();
|
|
7
|
-
const server = isServer ?? router.isServer;
|
|
8
7
|
const [hydrating, setHydrating] = useState(true);
|
|
9
8
|
useEffect(() => {
|
|
10
9
|
setHydrating(false);
|
|
11
10
|
}, []);
|
|
12
11
|
|
|
13
|
-
@if (
|
|
12
|
+
@if ((isServer ?? router.isServer) || hydrating) {
|
|
14
13
|
<script
|
|
15
14
|
nonce={router.options.ssr?.nonce}
|
|
16
15
|
dangerouslySetInnerHTML={{
|
package/src/context.ts
CHANGED
|
@@ -20,8 +20,7 @@ export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
|
20
20
|
}): TRouter;
|
|
21
21
|
export function useRouter(...args: unknown[]): AnyRouter {
|
|
22
22
|
const opts = (args.length && typeof args[0] !== 'symbol' ? args[0] : undefined) as
|
|
23
|
-
|
|
24
|
-
| undefined;
|
|
23
|
+
{ router?: AnyRouter; warn?: boolean } | undefined;
|
|
25
24
|
const ctx = useContext(routerContext);
|
|
26
25
|
const router = opts?.router ?? ctx;
|
|
27
26
|
if (!router && opts?.warn !== false) {
|
package/src/generator-plugin.js
CHANGED
|
@@ -18,6 +18,14 @@ import { compileToVolarMappings } from 'octane/compiler/volar';
|
|
|
18
18
|
* @returns {string}
|
|
19
19
|
*/
|
|
20
20
|
export function maskOctaneRouteSource(source, filename = 'route.tsrx') {
|
|
21
|
+
// Only .tsrx carries the native template dialect. Plain .ts/.tsx route
|
|
22
|
+
// files (robots.txt.ts-style server routes, shared route helpers) must
|
|
23
|
+
// pass through untouched — the TSRX parser is not a general TS parser and
|
|
24
|
+
// rejects valid TS it was never meant to see.
|
|
25
|
+
if (!filename.endsWith('.tsrx')) {
|
|
26
|
+
return source;
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
const { sourceAst } = compileToVolarMappings(source, filename);
|
|
22
30
|
const output = source.split('');
|
|
23
31
|
|
package/src/linkTypes.ts
CHANGED
|
@@ -58,8 +58,7 @@ export type LinkProps<
|
|
|
58
58
|
|
|
59
59
|
export interface LinkPropsChildren {
|
|
60
60
|
children?:
|
|
61
|
-
|
|
|
62
|
-
| ((state: { isActive: boolean; isTransitioning: boolean }) => unknown);
|
|
61
|
+
OctaneRenderable | ((state: { isActive: boolean; isTransitioning: boolean }) => unknown);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
export type CreateLinkProps = LinkProps<any, any, string, string, string, string>;
|
package/src/useBlocker.tsrx
CHANGED
|
@@ -180,7 +180,8 @@ export function useBlocker(
|
|
|
180
180
|
|
|
181
181
|
// Upstream's PromptProps: the blocker options plus optional children (a render
|
|
182
182
|
// prop receiving the resolver, or plain renderables).
|
|
183
|
-
export type PromptProps =
|
|
183
|
+
export type PromptProps =
|
|
184
|
+
(UseBlockerOpts | LegacyBlockerOpts) & {
|
|
184
185
|
children?: OctaneNode | ((params: BlockerResolver) => OctaneNode);
|
|
185
186
|
};
|
|
186
187
|
|