@octanejs/tanstack-start 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/package.json +13 -8
- package/src/GenericHydrate.tsrx +396 -0
- package/src/GenericHydrate.tsrx.d.ts +5 -0
- package/src/Hydrate.tsrx +106 -0
- package/src/Hydrate.tsrx.d.ts +63 -0
- package/src/client-only-server-strip.js +76 -0
- package/src/hydration/generic.d.ts +18 -0
- package/src/hydration/generic.js +26 -0
- package/src/hydration/idle.d.ts +9 -0
- package/src/hydration/idle.js +10 -0
- package/src/hydration/load.tsrx +38 -0
- package/src/hydration/load.tsrx.d.ts +8 -0
- package/src/hydration/never.tsrx +71 -0
- package/src/hydration/never.tsrx.d.ts +6 -0
- package/src/hydration/visible.tsrx +123 -0
- package/src/hydration/visible.tsrx.d.ts +12 -0
- package/src/hydration.d.ts +20 -0
- package/src/hydration.js +8 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +2 -0
- package/src/internal/router-generator/filesystem/physical/getRouteNodes.js +4 -6
- package/src/internal/router-generator/generator.js +3 -0
- package/src/internal/router-plugin/core/code-splitter/compilers.js +3 -6
- package/src/internal/router-plugin/core/config.d.ts +1 -3
- package/src/internal/router-plugin/esbuild.d.ts +4 -10
- package/src/internal/router-plugin/vite.d.ts +4 -10
- package/src/internal/start-plugin-core/import-protection/analysis.js +13 -12
- package/src/internal/start-plugin-core/schema.d.ts +4 -14
- package/src/internal/start-plugin-core/start-compiler/compiler.d.ts +1 -6
- package/src/internal/start-plugin-core/types.d.ts +1 -2
- package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.js +16 -16
- package/src/internal/start-plugin-core/vite/schema.d.ts +3 -12
- package/src/plugin-vite.js +5 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HydrationCondition,
|
|
3
|
+
HydrationInteractionEvents,
|
|
4
|
+
HydrationPrefetchStrategy,
|
|
5
|
+
} from '@tanstack/start-client-core/hydration';
|
|
6
|
+
import type { OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
7
|
+
|
|
8
|
+
export declare function media(
|
|
9
|
+
query: string,
|
|
10
|
+
): OctaneHydrationStrategy<'media', true> & HydrationPrefetchStrategy<'media'>;
|
|
11
|
+
|
|
12
|
+
export declare function condition(
|
|
13
|
+
condition: HydrationCondition,
|
|
14
|
+
): OctaneHydrationStrategy<'condition', false>;
|
|
15
|
+
|
|
16
|
+
export declare function interaction(options?: {
|
|
17
|
+
events?: HydrationInteractionEvents;
|
|
18
|
+
}): OctaneHydrationStrategy<'interaction', true> & HydrationPrefetchStrategy<'interaction'>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// media / condition / interaction hydration strategies — port of
|
|
2
|
+
// @tanstack/react-start-client's hydration/generic.ts. The gating logic lives
|
|
3
|
+
// in @tanstack/start-client-core; these factories just attach octane's
|
|
4
|
+
// GenericHydrate renderer.
|
|
5
|
+
import {
|
|
6
|
+
condition as coreCondition,
|
|
7
|
+
interaction as coreInteraction,
|
|
8
|
+
media as coreMedia,
|
|
9
|
+
withHydrationRenderer,
|
|
10
|
+
} from '@tanstack/start-client-core/hydration';
|
|
11
|
+
import { GenericHydrate } from '../GenericHydrate.tsrx';
|
|
12
|
+
|
|
13
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
14
|
+
export function media(query) {
|
|
15
|
+
return /* @__PURE__ */ withHydrationRenderer(coreMedia(query), GenericHydrate);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
19
|
+
export function condition(condition) {
|
|
20
|
+
return /* @__PURE__ */ withHydrationRenderer(coreCondition(condition), GenericHydrate);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
24
|
+
export function interaction(options) {
|
|
25
|
+
return /* @__PURE__ */ withHydrationRenderer(coreInteraction(options), GenericHydrate);
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HydrationPrefetchStrategy,
|
|
3
|
+
IdleHydrationOptions,
|
|
4
|
+
} from '@tanstack/start-client-core/hydration';
|
|
5
|
+
import type { OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
6
|
+
|
|
7
|
+
export declare function idle(
|
|
8
|
+
options?: IdleHydrationOptions,
|
|
9
|
+
): OctaneHydrationStrategy<'idle', true> & HydrationPrefetchStrategy<'idle'>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// idle hydration strategy — port of @tanstack/react-start-client's
|
|
2
|
+
// hydration/idle.ts. Delegates the requestIdleCallback gating to
|
|
3
|
+
// @tanstack/start-client-core and attaches octane's GenericHydrate renderer.
|
|
4
|
+
import { idle as coreIdle, withHydrationRenderer } from '@tanstack/start-client-core/hydration';
|
|
5
|
+
import { GenericHydrate } from '../GenericHydrate.tsrx';
|
|
6
|
+
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
|
+
export function idle(options = {}) {
|
|
9
|
+
return /* @__PURE__ */ withHydrationRenderer(coreIdle(options), GenericHydrate);
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// load hydration strategy — port of @tanstack/react-start-client's
|
|
2
|
+
// hydration/load.tsx. `load` hydrates immediately, so its renderer skips the
|
|
3
|
+
// marker/gate machinery entirely: a bare Suspense wrapper plus an onHydrated
|
|
4
|
+
// notification effect.
|
|
5
|
+
import { Suspense, useEffect, useRef } from 'octane';
|
|
6
|
+
import type { OctaneNode } from 'octane';
|
|
7
|
+
import { load as coreLoad, withHydrationRenderer } from '@tanstack/start-client-core/hydration';
|
|
8
|
+
import type { HydrateProps } from '../Hydrate.tsrx';
|
|
9
|
+
|
|
10
|
+
function HydratedBoundary(props: { onHydrated?: () => void; children?: OctaneNode }) {
|
|
11
|
+
const { onHydrated } = props;
|
|
12
|
+
const didHydrateRef = useRef(false);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (didHydrateRef.current) return;
|
|
16
|
+
didHydrateRef.current = true;
|
|
17
|
+
onHydrated?.();
|
|
18
|
+
}, [onHydrated]);
|
|
19
|
+
|
|
20
|
+
return props.children;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// OCTANE ADAPTATION: octane's `Hydrate` renders `_h` as a child component
|
|
24
|
+
// (upstream bare-calls it inline); LoadHydrate is that component.
|
|
25
|
+
export function LoadHydrate(props: HydrateProps) @{
|
|
26
|
+
<div>
|
|
27
|
+
<Suspense fallback={props.fallback ?? null}>
|
|
28
|
+
<HydratedBoundary onHydrated={props.onHydrated}>{props.children}</HydratedBoundary>
|
|
29
|
+
</Suspense>
|
|
30
|
+
</div>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const loadStrategy = /* @__PURE__ */ withHydrationRenderer(coreLoad(), LoadHydrate);
|
|
34
|
+
|
|
35
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
36
|
+
export function load() {
|
|
37
|
+
return loadStrategy;
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OctaneNode } from 'octane';
|
|
2
|
+
import type { HydrationPrefetchStrategy } from '@tanstack/start-client-core/hydration';
|
|
3
|
+
import type { HydrateProps, OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
4
|
+
|
|
5
|
+
export declare function LoadHydrate(props: HydrateProps): OctaneNode;
|
|
6
|
+
|
|
7
|
+
export declare function load(): OctaneHydrationStrategy<'load', true> &
|
|
8
|
+
HydrationPrefetchStrategy<'load'>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// never hydration strategy — port of @tanstack/react-start-client's
|
|
2
|
+
// hydration/never.tsx. Server HTML is preserved verbatim and the subtree is
|
|
3
|
+
// never hydrated: the gate promise never resolves, so the Suspense boundary
|
|
4
|
+
// keeps showing the saved server HTML (re-injected via dangerouslySetInnerHTML)
|
|
5
|
+
// forever. `reactUse` feature-detection is dropped — octane's `use` always
|
|
6
|
+
// exists.
|
|
7
|
+
import { Suspense, use, useCallback, useId, useRef } from 'octane';
|
|
8
|
+
import type { OctaneNode } from 'octane';
|
|
9
|
+
import { useHydrated } from '@octanejs/tanstack-router';
|
|
10
|
+
import { isServer } from '@tanstack/router-core/isServer';
|
|
11
|
+
import { never as coreNever, withHydrationRenderer } from '@tanstack/start-client-core/hydration';
|
|
12
|
+
import {
|
|
13
|
+
hydrateIdAttribute,
|
|
14
|
+
hydrateWhenAttribute,
|
|
15
|
+
} from '@tanstack/start-client-core/hydration/constants';
|
|
16
|
+
import { getFallbackHtml, saveFallbackHtml } from '@tanstack/start-client-core/hydration/runtime';
|
|
17
|
+
import type { HydrateProps, InternalHydrateProps } from '../Hydrate.tsrx';
|
|
18
|
+
|
|
19
|
+
const neverType = 'never';
|
|
20
|
+
const neverPromise = new Promise<void>(() => {});
|
|
21
|
+
|
|
22
|
+
function NeverGate(props: { children?: OctaneNode }) {
|
|
23
|
+
if (isServer ?? typeof window === 'undefined') {
|
|
24
|
+
return props.children;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
use(neverPromise);
|
|
28
|
+
|
|
29
|
+
return props.children;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// OCTANE ADAPTATION: octane's `Hydrate` renders `_h` as a child component
|
|
33
|
+
// (upstream bare-calls it inline); NeverHydrate is that component.
|
|
34
|
+
export function NeverHydrate(props: HydrateProps) @{
|
|
35
|
+
const internalProps = props as InternalHydrateProps;
|
|
36
|
+
const hydrated = useHydrated();
|
|
37
|
+
const octaneId = useId();
|
|
38
|
+
const id = internalProps.h ? `${internalProps.h}${octaneId}` : octaneId;
|
|
39
|
+
const shouldPreserveServerHTMLRef = useRef<boolean | undefined>(undefined);
|
|
40
|
+
shouldPreserveServerHTMLRef.current ??= (isServer ?? typeof window === 'undefined') || !hydrated;
|
|
41
|
+
const markerRef = useCallback((element: HTMLDivElement | null) => {
|
|
42
|
+
if (!element) return;
|
|
43
|
+
if (!shouldPreserveServerHTMLRef.current) {
|
|
44
|
+
element.replaceChildren();
|
|
45
|
+
} else {
|
|
46
|
+
saveFallbackHtml(id, element);
|
|
47
|
+
}
|
|
48
|
+
}, [id]);
|
|
49
|
+
const savedHtml = getFallbackHtml(id);
|
|
50
|
+
|
|
51
|
+
<div
|
|
52
|
+
ref={markerRef}
|
|
53
|
+
{...{
|
|
54
|
+
[hydrateIdAttribute]: id,
|
|
55
|
+
[hydrateWhenAttribute]: neverType,
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<Suspense
|
|
59
|
+
fallback={savedHtml
|
|
60
|
+
? <div style={{ display: 'contents' }} dangerouslySetInnerHTML={{ __html: savedHtml }} />
|
|
61
|
+
: props.fallback ?? null}
|
|
62
|
+
>
|
|
63
|
+
<NeverGate>{props.children}</NeverGate>
|
|
64
|
+
</Suspense>
|
|
65
|
+
</div>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
69
|
+
export function never() {
|
|
70
|
+
return /* @__PURE__ */ withHydrationRenderer(coreNever(), NeverHydrate);
|
|
71
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OctaneNode } from 'octane';
|
|
2
|
+
import type { HydrateProps, OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
3
|
+
|
|
4
|
+
export declare function NeverHydrate(props: HydrateProps): OctaneNode;
|
|
5
|
+
|
|
6
|
+
export declare function never(): OctaneHydrationStrategy<'never', false>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// visible hydration strategy — port of @tanstack/react-start-client's
|
|
2
|
+
// hydration/visible.tsx. Fully self-contained fast path (no shared gate
|
|
3
|
+
// registry): a per-instance promise gate resolved by an IntersectionObserver.
|
|
4
|
+
// `reactUse` feature-detection is dropped — octane's `use` always exists.
|
|
5
|
+
//
|
|
6
|
+
// OCTANE ADAPTATION: upstream's VisibleHydrate is bare-called as a method
|
|
7
|
+
// (`props.when._h(props)`) with the strategy as `this`, running its hooks on
|
|
8
|
+
// the caller's fiber. Octane's compiled components take the
|
|
9
|
+
// `(props, __s, __extra)` ABI and cannot be bare-called, so octane's `Hydrate`
|
|
10
|
+
// renders `_h` as a child component and VisibleHydrate derives its strategy
|
|
11
|
+
// from `props.when` instead of `this` (resolving a function-valued `when` per
|
|
12
|
+
// render, exactly as upstream's Hydrate does).
|
|
13
|
+
import { Suspense, use, useEffect, useRef, useState } from 'octane';
|
|
14
|
+
import type { OctaneNode } from 'octane';
|
|
15
|
+
import { isServer } from '@tanstack/router-core/isServer';
|
|
16
|
+
import type {
|
|
17
|
+
HydrationPrefetchStrategy,
|
|
18
|
+
VisibleHydrationOptions,
|
|
19
|
+
} from '@tanstack/start-client-core/hydration';
|
|
20
|
+
import type { HydrateProps, InternalHydrateProps, OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
21
|
+
|
|
22
|
+
type VisibleGate = {
|
|
23
|
+
p: Promise<void>;
|
|
24
|
+
r: boolean;
|
|
25
|
+
s: () => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function HydrationBoundary(props: { g: VisibleGate; o?: () => void; children?: OctaneNode }) {
|
|
29
|
+
const { g, o } = props;
|
|
30
|
+
|
|
31
|
+
if (!g.r) {
|
|
32
|
+
use(g.p);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
o?.();
|
|
37
|
+
}, [o]);
|
|
38
|
+
|
|
39
|
+
return props.children;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function VisibleHydrate(props: HydrateProps) @{
|
|
43
|
+
const when = props.when;
|
|
44
|
+
const strategy = (typeof when === 'function' ? when() : when) as OctaneHydrationStrategy<
|
|
45
|
+
'visible',
|
|
46
|
+
true
|
|
47
|
+
>;
|
|
48
|
+
const prefetchStrategy = props.prefetch;
|
|
49
|
+
const preload = (props as InternalHydrateProps).p;
|
|
50
|
+
const markerRef = useRef<HTMLDivElement | null>(null);
|
|
51
|
+
const [gate] = useState<VisibleGate>(() => {
|
|
52
|
+
let resolvePromise: () => void;
|
|
53
|
+
const nextGate: VisibleGate = {
|
|
54
|
+
p: new Promise<void>((resolve) => {
|
|
55
|
+
resolvePromise = resolve;
|
|
56
|
+
}),
|
|
57
|
+
r: false,
|
|
58
|
+
s: () => {
|
|
59
|
+
nextGate.r = true;
|
|
60
|
+
resolvePromise();
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
if (isServer ?? typeof window === 'undefined') {
|
|
64
|
+
nextGate.s();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return nextGate;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!preload || typeof prefetchStrategy === 'function') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return prefetchStrategy?._s?.({
|
|
76
|
+
element: markerRef.current,
|
|
77
|
+
prefetch: preload,
|
|
78
|
+
});
|
|
79
|
+
}, [prefetchStrategy, preload]);
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (gate.r) return;
|
|
83
|
+
|
|
84
|
+
return strategy._s?.({
|
|
85
|
+
element: markerRef.current,
|
|
86
|
+
gate: gate as never,
|
|
87
|
+
});
|
|
88
|
+
}, [gate, strategy]);
|
|
89
|
+
|
|
90
|
+
<div ref={markerRef}>
|
|
91
|
+
<Suspense fallback={props.fallback}>
|
|
92
|
+
<HydrationBoundary g={gate} o={props.onHydrated}>{props.children}</HydrationBoundary>
|
|
93
|
+
</Suspense>
|
|
94
|
+
</div>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
98
|
+
export function visible(
|
|
99
|
+
options?: VisibleHydrationOptions,
|
|
100
|
+
): OctaneHydrationStrategy<'visible', true> & HydrationPrefetchStrategy<'visible'> {
|
|
101
|
+
const rootMargin = options?.rootMargin ?? '600px';
|
|
102
|
+
const threshold = options?.threshold ?? 0;
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
_s: ({ element, gate, prefetch }) => {
|
|
106
|
+
const callback = prefetch || (gate as never as VisibleGate).s;
|
|
107
|
+
|
|
108
|
+
if (!element) {
|
|
109
|
+
callback();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const observer = new IntersectionObserver((entries) => {
|
|
114
|
+
if (!entries[0]!.isIntersecting) return;
|
|
115
|
+
observer.disconnect();
|
|
116
|
+
callback();
|
|
117
|
+
}, { rootMargin, threshold });
|
|
118
|
+
observer.observe(element);
|
|
119
|
+
return () => observer.disconnect();
|
|
120
|
+
},
|
|
121
|
+
_h: VisibleHydrate,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OctaneNode } from 'octane';
|
|
2
|
+
import type {
|
|
3
|
+
HydrationPrefetchStrategy,
|
|
4
|
+
VisibleHydrationOptions,
|
|
5
|
+
} from '@tanstack/start-client-core/hydration';
|
|
6
|
+
import type { HydrateProps, OctaneHydrationStrategy } from '../Hydrate.tsrx';
|
|
7
|
+
|
|
8
|
+
export declare function VisibleHydrate(props: HydrateProps): OctaneNode;
|
|
9
|
+
|
|
10
|
+
export declare function visible(
|
|
11
|
+
options?: VisibleHydrationOptions,
|
|
12
|
+
): OctaneHydrationStrategy<'visible', true> & HydrationPrefetchStrategy<'visible'>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { condition, interaction, media } from './hydration/generic.js';
|
|
2
|
+
export { idle } from './hydration/idle.js';
|
|
3
|
+
export { load } from './hydration/load.tsrx';
|
|
4
|
+
export { never } from './hydration/never.tsrx';
|
|
5
|
+
export { visible } from './hydration/visible.tsrx';
|
|
6
|
+
export type {
|
|
7
|
+
HydrationCondition,
|
|
8
|
+
HydrationInteractionEvent,
|
|
9
|
+
HydrationInteractionEvents,
|
|
10
|
+
IdleHydrationOptions,
|
|
11
|
+
HydrationPrefetchContext,
|
|
12
|
+
HydrationPrefetchFunction,
|
|
13
|
+
HydrationPrefetchWhen,
|
|
14
|
+
HydrationPrefetchStrategy,
|
|
15
|
+
HydrationPrefetchWaitReason,
|
|
16
|
+
HydrationStrategyTypes,
|
|
17
|
+
HydrationWhen,
|
|
18
|
+
VisibleHydrationOptions,
|
|
19
|
+
} from '@tanstack/start-client-core/hydration';
|
|
20
|
+
export type { HydrationStrategy, OctaneHydrationStrategy } from './Hydrate.tsrx';
|
package/src/hydration.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// `@octanejs/tanstack-start/hydration` — port of @tanstack/react-start's
|
|
2
|
+
// hydration.ts subpath: the hydration strategy factories consumed by
|
|
3
|
+
// `<Hydrate when={...}>`.
|
|
4
|
+
export { condition, interaction, media } from './hydration/generic.js';
|
|
5
|
+
export { idle } from './hydration/idle.js';
|
|
6
|
+
export { load } from './hydration/load.tsrx';
|
|
7
|
+
export { never } from './hydration/never.tsrx';
|
|
8
|
+
export { visible } from './hydration/visible.tsrx';
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
export { useServerFn } from './use-server-fn.js';
|
|
2
2
|
export * from '@tanstack/start-client-core';
|
|
3
|
+
export { Hydrate } from './Hydrate.tsrx';
|
|
4
|
+
export type {
|
|
5
|
+
HydrateOptions,
|
|
6
|
+
HydrateProps,
|
|
7
|
+
HydrationInteractionEvent,
|
|
8
|
+
HydrationInteractionEvents,
|
|
9
|
+
HydrationPrefetchStrategy,
|
|
10
|
+
HydrationStrategy,
|
|
11
|
+
HydrationWhen,
|
|
12
|
+
OctaneHydrationStrategy,
|
|
13
|
+
} from './Hydrate.tsrx';
|
|
3
14
|
export {
|
|
4
15
|
createClientOnlyFn,
|
|
5
16
|
createCsrfMiddleware,
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useServerFn } from './use-server-fn.js';
|
|
2
|
+
import { Hydrate } from './Hydrate.tsrx';
|
|
2
3
|
import {
|
|
3
4
|
createClientOnlyFn,
|
|
4
5
|
createCsrfMiddleware,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
|
|
12
13
|
export * from '@tanstack/start-client-core';
|
|
13
14
|
export {
|
|
15
|
+
Hydrate,
|
|
14
16
|
createClientOnlyFn,
|
|
15
17
|
createCsrfMiddleware,
|
|
16
18
|
createIsomorphicFn,
|
|
@@ -180,12 +180,10 @@ async function getRouteNodes(config, root, tokenRegexes) {
|
|
|
180
180
|
}
|
|
181
181
|
const lastOriginalSegment = originalRoutePath.split('/').filter(Boolean).pop() || '';
|
|
182
182
|
const indexTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegment);
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
)
|
|
188
|
-
) {
|
|
183
|
+
if (!(
|
|
184
|
+
lastOriginalSegment !== indexTokenCandidate &&
|
|
185
|
+
indexTokenSegmentRegex.test(indexTokenCandidate)
|
|
186
|
+
)) {
|
|
189
187
|
const updatedRouteSegments = routePath.split('/').filter(Boolean);
|
|
190
188
|
const updatedLastRouteSegment =
|
|
191
189
|
updatedRouteSegments[updatedRouteSegments.length - 1] || '';
|
|
@@ -240,6 +240,9 @@ var Generator = class Generator {
|
|
|
240
240
|
} else {
|
|
241
241
|
const unrecoverableErrors = errArray.filter((e) => !isRerun(e));
|
|
242
242
|
this.runPromise = void 0;
|
|
243
|
+
if (process.env.OCTANE_DEBUG_GENERATOR) {
|
|
244
|
+
for (const e of unrecoverableErrors) console.error('[generator-debug]', e);
|
|
245
|
+
}
|
|
243
246
|
throw new Error(unrecoverableErrors.map((e) => e.message).join());
|
|
244
247
|
}
|
|
245
248
|
}
|
|
@@ -836,12 +836,9 @@ function detectCodeSplitGroupingsFromRoute(opts) {
|
|
|
836
836
|
programPath.traverse({
|
|
837
837
|
CallExpression(path) {
|
|
838
838
|
if (!t.isIdentifier(path.node.callee)) return;
|
|
839
|
-
if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
path.node.callee.name === 'createFileRoute'
|
|
843
|
-
)
|
|
844
|
-
)
|
|
839
|
+
if (!(
|
|
840
|
+
path.node.callee.name === 'createRoute' || path.node.callee.name === 'createFileRoute'
|
|
841
|
+
))
|
|
845
842
|
return;
|
|
846
843
|
function babelHandleSplittingGroups(routeOptions) {
|
|
847
844
|
if (t.isObjectExpression(routeOptions))
|
|
@@ -251,9 +251,7 @@ export declare const getConfig: (
|
|
|
251
251
|
tmpDir: string;
|
|
252
252
|
importRoutesUsingAbsolutePaths: boolean;
|
|
253
253
|
virtualRouteConfig?:
|
|
254
|
-
|
|
|
255
|
-
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
256
|
-
| undefined;
|
|
254
|
+
string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
257
255
|
routeFilePrefix?: string | undefined;
|
|
258
256
|
routeFileIgnorePattern?: string | undefined;
|
|
259
257
|
pathParamsAllowedCharacters?: (':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
@@ -68,14 +68,11 @@ declare const TanStackRouterEsbuild: (
|
|
|
68
68
|
tmpDir: string;
|
|
69
69
|
importRoutesUsingAbsolutePaths: boolean;
|
|
70
70
|
virtualRouteConfig?:
|
|
71
|
-
|
|
|
72
|
-
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
73
|
-
| undefined;
|
|
71
|
+
string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
74
72
|
routeFilePrefix?: string | undefined;
|
|
75
73
|
routeFileIgnorePattern?: string | undefined;
|
|
76
74
|
pathParamsAllowedCharacters?:
|
|
77
|
-
|
|
78
|
-
| undefined;
|
|
75
|
+
(':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
79
76
|
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
80
77
|
autoCodeSplitting?: boolean | undefined;
|
|
81
78
|
customScaffolding?:
|
|
@@ -143,14 +140,11 @@ declare const tanstackRouter: (
|
|
|
143
140
|
tmpDir: string;
|
|
144
141
|
importRoutesUsingAbsolutePaths: boolean;
|
|
145
142
|
virtualRouteConfig?:
|
|
146
|
-
|
|
|
147
|
-
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
148
|
-
| undefined;
|
|
143
|
+
string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
149
144
|
routeFilePrefix?: string | undefined;
|
|
150
145
|
routeFileIgnorePattern?: string | undefined;
|
|
151
146
|
pathParamsAllowedCharacters?:
|
|
152
|
-
|
|
153
|
-
| undefined;
|
|
147
|
+
(':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
154
148
|
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
155
149
|
autoCodeSplitting?: boolean | undefined;
|
|
156
150
|
customScaffolding?:
|
|
@@ -68,14 +68,11 @@ declare const tanstackRouter: (
|
|
|
68
68
|
tmpDir: string;
|
|
69
69
|
importRoutesUsingAbsolutePaths: boolean;
|
|
70
70
|
virtualRouteConfig?:
|
|
71
|
-
|
|
|
72
|
-
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
73
|
-
| undefined;
|
|
71
|
+
string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
74
72
|
routeFilePrefix?: string | undefined;
|
|
75
73
|
routeFileIgnorePattern?: string | undefined;
|
|
76
74
|
pathParamsAllowedCharacters?:
|
|
77
|
-
|
|
78
|
-
| undefined;
|
|
75
|
+
(':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
79
76
|
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
80
77
|
autoCodeSplitting?: boolean | undefined;
|
|
81
78
|
customScaffolding?:
|
|
@@ -146,14 +143,11 @@ declare const TanStackRouterVite: (
|
|
|
146
143
|
tmpDir: string;
|
|
147
144
|
importRoutesUsingAbsolutePaths: boolean;
|
|
148
145
|
virtualRouteConfig?:
|
|
149
|
-
|
|
|
150
|
-
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
151
|
-
| undefined;
|
|
146
|
+
string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
152
147
|
routeFilePrefix?: string | undefined;
|
|
153
148
|
routeFileIgnorePattern?: string | undefined;
|
|
154
149
|
pathParamsAllowedCharacters?:
|
|
155
|
-
|
|
156
|
-
| undefined;
|
|
150
|
+
(':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
157
151
|
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
158
152
|
autoCodeSplitting?: boolean | undefined;
|
|
159
153
|
customScaffolding?:
|
|
@@ -72,21 +72,22 @@ function collectIdentifiersFromPattern$1(pattern, add) {
|
|
|
72
72
|
function isValidExportName(name) {
|
|
73
73
|
if (name === 'default' || name.length === 0) return false;
|
|
74
74
|
const first = name.charCodeAt(0);
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if (!(
|
|
76
|
+
(first >= 65 && first <= 90) ||
|
|
77
|
+
(first >= 97 && first <= 122) ||
|
|
78
|
+
first === 95 ||
|
|
79
|
+
first === 36
|
|
80
|
+
))
|
|
78
81
|
return false;
|
|
79
82
|
for (let i = 1; i < name.length; i++) {
|
|
80
83
|
const ch = name.charCodeAt(i);
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
)
|
|
84
|
+
if (!(
|
|
85
|
+
(ch >= 65 && ch <= 90) ||
|
|
86
|
+
(ch >= 97 && ch <= 122) ||
|
|
87
|
+
(ch >= 48 && ch <= 57) ||
|
|
88
|
+
ch === 95 ||
|
|
89
|
+
ch === 36
|
|
90
|
+
))
|
|
90
91
|
return false;
|
|
91
92
|
}
|
|
92
93
|
return true;
|
|
@@ -208,8 +208,7 @@ export declare function parseStartConfig(
|
|
|
208
208
|
base: string;
|
|
209
209
|
disableCsrfMiddlewareWarning: boolean;
|
|
210
210
|
generateFunctionId?:
|
|
211
|
-
|
|
212
|
-
| undefined;
|
|
211
|
+
((opts: { filename: string; functionName: string }) => string | undefined) | undefined;
|
|
213
212
|
};
|
|
214
213
|
pages: {
|
|
215
214
|
path: string;
|
|
@@ -218,14 +217,7 @@ export declare function parseStartConfig(
|
|
|
218
217
|
exclude?: boolean | undefined;
|
|
219
218
|
priority?: number | undefined;
|
|
220
219
|
changefreq?:
|
|
221
|
-
| '
|
|
222
|
-
| 'always'
|
|
223
|
-
| 'hourly'
|
|
224
|
-
| 'daily'
|
|
225
|
-
| 'weekly'
|
|
226
|
-
| 'monthly'
|
|
227
|
-
| 'yearly'
|
|
228
|
-
| undefined;
|
|
220
|
+
'never' | 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | undefined;
|
|
229
221
|
lastmod?: string | Date | undefined;
|
|
230
222
|
alternateRefs?:
|
|
231
223
|
| {
|
|
@@ -297,8 +289,7 @@ export declare function parseStartConfig(
|
|
|
297
289
|
retryCount?: number | undefined;
|
|
298
290
|
retryDelay?: number | undefined;
|
|
299
291
|
onSuccess?:
|
|
300
|
-
|
|
301
|
-
| undefined;
|
|
292
|
+
((result: { page: z.infer<typeof pageBaseSchema>; html: string }) => unknown) | undefined;
|
|
302
293
|
headers?: Record<string, string> | undefined;
|
|
303
294
|
})
|
|
304
295
|
| undefined;
|
|
@@ -333,8 +324,7 @@ export declare function parseStartConfig(
|
|
|
333
324
|
| undefined;
|
|
334
325
|
mockAccess?: 'error' | 'warn' | 'off' | undefined;
|
|
335
326
|
onViolation?:
|
|
336
|
-
|
|
337
|
-
| undefined;
|
|
327
|
+
((violation: unknown) => boolean | void | Promise<boolean | void>) | undefined;
|
|
338
328
|
include?: (string | RegExp)[] | undefined;
|
|
339
329
|
exclude?: (string | RegExp)[] | undefined;
|
|
340
330
|
client?:
|
|
@@ -12,12 +12,7 @@ type Binding = ModuleInfoBinding & {
|
|
|
12
12
|
};
|
|
13
13
|
type Kind = 'None' | `Root` | `Builder` | LookupKind;
|
|
14
14
|
export type BuiltInLookupKind =
|
|
15
|
-
| '
|
|
16
|
-
| 'Middleware'
|
|
17
|
-
| 'IsomorphicFn'
|
|
18
|
-
| 'ServerOnlyFn'
|
|
19
|
-
| 'ClientOnlyFn'
|
|
20
|
-
| 'ClientOnlyJSX';
|
|
15
|
+
'ServerFn' | 'Middleware' | 'IsomorphicFn' | 'ServerOnlyFn' | 'ClientOnlyFn' | 'ClientOnlyJSX';
|
|
21
16
|
export type ExternalLookupKind = `External:${string}`;
|
|
22
17
|
export type LookupKind = BuiltInLookupKind | ExternalLookupKind;
|
|
23
18
|
export declare function getExternalLookupKind(
|
|
@@ -22,8 +22,7 @@ export type SerializationAdapterByRuntime = Partial<
|
|
|
22
22
|
Record<SerializationRuntime, SerializationAdapterModuleRef>
|
|
23
23
|
>;
|
|
24
24
|
export type SerializationAdapterConfig =
|
|
25
|
-
|
|
|
26
|
-
| SerializationAdapterByRuntime;
|
|
25
|
+
SerializationAdapterModuleRef | SerializationAdapterByRuntime;
|
|
27
26
|
export type StartCompilerEnvironment = 'client' | 'server';
|
|
28
27
|
export interface StartCompilerImportTransformImport {
|
|
29
28
|
libName: string;
|