@tanstack/solid-start-client 1.114.29
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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/cjs/Meta.cjs +12 -0
- package/dist/cjs/Meta.cjs.map +1 -0
- package/dist/cjs/Meta.d.cts +1 -0
- package/dist/cjs/Scripts.cjs +12 -0
- package/dist/cjs/Scripts.cjs.map +1 -0
- package/dist/cjs/Scripts.d.cts +1 -0
- package/dist/cjs/StartClient.cjs +43 -0
- package/dist/cjs/StartClient.cjs.map +1 -0
- package/dist/cjs/StartClient.d.cts +4 -0
- package/dist/cjs/index.cjs +54 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +16 -0
- package/dist/cjs/renderRSC.cjs +25 -0
- package/dist/cjs/renderRSC.cjs.map +1 -0
- package/dist/cjs/renderRSC.d.cts +2 -0
- package/dist/cjs/routesManifest.d.cts +0 -0
- package/dist/cjs/tests/createServerFn.test-d.d.cts +0 -0
- package/dist/cjs/tests/setupTests.d.cts +0 -0
- package/dist/cjs/useServerFn.cjs +27 -0
- package/dist/cjs/useServerFn.cjs.map +1 -0
- package/dist/cjs/useServerFn.d.cts +1 -0
- package/dist/esm/Meta.d.ts +1 -0
- package/dist/esm/Meta.js +12 -0
- package/dist/esm/Meta.js.map +1 -0
- package/dist/esm/Scripts.d.ts +1 -0
- package/dist/esm/Scripts.js +12 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/StartClient.d.ts +4 -0
- package/dist/esm/StartClient.js +43 -0
- package/dist/esm/StartClient.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/renderRSC.d.ts +2 -0
- package/dist/esm/renderRSC.js +25 -0
- package/dist/esm/renderRSC.js.map +1 -0
- package/dist/esm/routesManifest.d.ts +0 -0
- package/dist/esm/tests/createServerFn.test-d.d.ts +0 -0
- package/dist/esm/tests/setupTests.d.ts +0 -0
- package/dist/esm/useServerFn.d.ts +1 -0
- package/dist/esm/useServerFn.js +27 -0
- package/dist/esm/useServerFn.js.map +1 -0
- package/package.json +69 -0
- package/src/Meta.tsx +10 -0
- package/src/Scripts.tsx +8 -0
- package/src/StartClient.tsx +41 -0
- package/src/index.tsx +75 -0
- package/src/renderRSC.tsx +92 -0
- package/src/routesManifest.ts +0 -0
- package/src/tests/createServerFn.test-d.tsx +15 -0
- package/src/tests/setupTests.tsx +1 -0
- package/src/useServerFn.ts +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
> 🤫 we're cooking up something special!
|
|
2
|
+
|
|
3
|
+
<img src="https://static.scarf.sh/a.png?x-pxid=d988eb79-b0fc-4a2b-8514-6a1ab932d188" />
|
|
4
|
+
|
|
5
|
+
# TanStack Start
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
🤖 Type-safe router w/ built-in caching & URL state management for React!
|
|
10
|
+
|
|
11
|
+
<a href="https://twitter.com/intent/tweet?button_hashtag=TanStack" target="\_parent">
|
|
12
|
+
<img alt="#TanStack" src="https://img.shields.io/twitter/url?color=%2308a0e9&label=%23TanStack&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DTanStack">
|
|
13
|
+
</a><a href="https://discord.com/invite/WrRKjPJ" target="\_parent">
|
|
14
|
+
<img alt="" src="https://img.shields.io/badge/Discord-TanStack-%235865F2" />
|
|
15
|
+
</a><a href="https://npmjs.com/package/@tanstack/solid-router" target="\_parent">
|
|
16
|
+
<img alt="" src="https://img.shields.io/npm/dm/@tanstack/router.svg" />
|
|
17
|
+
</a><a href="https://bundlephobia.com/result?p=@tanstack/solid-router" target="\_parent">
|
|
18
|
+
<img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/solid-router" />
|
|
19
|
+
</a><a href="#badge">
|
|
20
|
+
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
|
|
21
|
+
</a><a href="https://github.com/tanstack/router/discussions">
|
|
22
|
+
<img alt="Join the discussion on Github" src="https://img.shields.io/badge/Github%20Discussions%20%26%20Support-Chat%20now!-blue" />
|
|
23
|
+
</a><a href="https://bestofjs.org/projects/router"><img alt="Best of JS" src="https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=tanstack%2Frouter%26since=daily" /></a><a href="https://github.com/tanstack/router" target="\_parent">
|
|
24
|
+
<img alt="" src="https://img.shields.io/github/stars/tanstack/router.svg?style=social&label=Star" />
|
|
25
|
+
</a><a href="https://twitter.com/tan_stack" target="\_parent">
|
|
26
|
+
<img alt="" src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social&label=Follow @TanStack" />
|
|
27
|
+
</a><a href="https://twitter.com/tannerlinsley" target="\_parent">
|
|
28
|
+
<img alt="" src="https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow @TannerLinsley" />
|
|
29
|
+
</a>
|
|
30
|
+
|
|
31
|
+
Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Query](https://github.com/tannerlinsley/react-query), [React Table](https://github.com/tanstack/react-table), [React Charts](https://github.com/tannerlinsley/react-charts), [React Virtual](https://github.com/tannerlinsley/react-virtual)
|
|
32
|
+
|
|
33
|
+
## Visit [tanstack.com/router](https://tanstack.com/router) for docs, guides, API and more!
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
const solidRouter = require("@tanstack/solid-router");
|
|
5
|
+
const Meta = () => {
|
|
6
|
+
if (process.env.NODE_ENV === "development") {
|
|
7
|
+
console.warn("The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.");
|
|
8
|
+
}
|
|
9
|
+
return web.createComponent(solidRouter.HeadContent, {});
|
|
10
|
+
};
|
|
11
|
+
exports.Meta = Meta;
|
|
12
|
+
//# sourceMappingURL=Meta.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Meta.cjs","sources":["../../src/Meta.tsx"],"sourcesContent":["import { HeadContent } from '@tanstack/solid-router'\n\nexport const Meta = () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n 'The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.',\n )\n }\n return <HeadContent />\n}\n"],"names":["Meta","process","env","NODE_ENV","console","warn","_$createComponent","HeadContent"],"mappings":";;;;AAEO,MAAMA,OAAOA,MAAM;AACpBC,MAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,YAAQC,KACN,4FACF;AAAA,EAAA;AAEFC,SAAAA,IAAAA,gBAAQC,YAAW,aAAA,EAAA;AACrB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Meta: () => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
const solidRouter = require("@tanstack/solid-router");
|
|
5
|
+
const Scripts = () => {
|
|
6
|
+
if (process.env.NODE_ENV === "development") {
|
|
7
|
+
console.warn("The Scripts component was moved to `@tanstack/solid-router`");
|
|
8
|
+
}
|
|
9
|
+
return web.createComponent(solidRouter.Scripts, {});
|
|
10
|
+
};
|
|
11
|
+
exports.Scripts = Scripts;
|
|
12
|
+
//# sourceMappingURL=Scripts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scripts.cjs","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Scripts as RouterScripts } from '@tanstack/solid-router'\n\nexport const Scripts = () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn('The Scripts component was moved to `@tanstack/solid-router`')\n }\n return <RouterScripts />\n}\n"],"names":["Scripts","process","env","NODE_ENV","console","warn","_$createComponent","RouterScripts"],"mappings":";;;;AAEO,MAAMA,UAAUA,MAAM;AACvBC,MAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,YAAQC,KAAK,6DAA6D;AAAA,EAAA;AAE5EC,SAAAA,IAAAA,gBAAQC,YAAa,SAAA,EAAA;AACvB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Scripts: () => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
const solidRouter = require("@tanstack/solid-router");
|
|
5
|
+
const startClientCore = require("@tanstack/start-client-core");
|
|
6
|
+
let hydrationPromise;
|
|
7
|
+
const Dummy = (props) => web.memo(() => props.children);
|
|
8
|
+
function StartClient(props) {
|
|
9
|
+
if (!hydrationPromise) {
|
|
10
|
+
if (!props.router.state.matches.length) {
|
|
11
|
+
hydrationPromise = startClientCore.hydrate(props.router);
|
|
12
|
+
} else {
|
|
13
|
+
hydrationPromise = Promise.resolve();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return web.createComponent(solidRouter.Await, {
|
|
17
|
+
promise: hydrationPromise,
|
|
18
|
+
children: () => web.createComponent(Dummy, {
|
|
19
|
+
get children() {
|
|
20
|
+
return web.createComponent(Dummy, {
|
|
21
|
+
get children() {
|
|
22
|
+
return web.createComponent(solidRouter.RouterProvider, {
|
|
23
|
+
get router() {
|
|
24
|
+
return props.router;
|
|
25
|
+
},
|
|
26
|
+
InnerWrap: (props2) => web.createComponent(Dummy, {
|
|
27
|
+
get children() {
|
|
28
|
+
return [web.createComponent(Dummy, {
|
|
29
|
+
get children() {
|
|
30
|
+
return [web.createComponent(solidRouter.HeadContent, {}), web.memo(() => props2.children)];
|
|
31
|
+
}
|
|
32
|
+
}), web.createComponent(Dummy, {})];
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.StartClient = StartClient;
|
|
43
|
+
//# sourceMappingURL=StartClient.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartClient.cjs","sources":["../../src/StartClient.tsx"],"sourcesContent":["import { Await, HeadContent, RouterProvider } from '@tanstack/solid-router'\nimport { hydrate } from '@tanstack/start-client-core'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { JSXElement } from 'solid-js'\n\nlet hydrationPromise: Promise<void | Array<Array<void>>> | undefined\n\nconst Dummy = (props: { children?: JSXElement }) => <>{props.children}</>\n\nexport function StartClient(props: { router: AnyRouter }) {\n if (!hydrationPromise) {\n if (!props.router.state.matches.length) {\n hydrationPromise = hydrate(props.router)\n } else {\n hydrationPromise = Promise.resolve()\n }\n }\n return (\n <Await\n promise={hydrationPromise}\n children={() => (\n <Dummy>\n <Dummy>\n <RouterProvider\n router={props.router}\n InnerWrap={(props) => (\n <Dummy>\n <Dummy>\n <HeadContent />\n {props.children}\n </Dummy>\n <Dummy />\n </Dummy>\n )}\n />\n </Dummy>\n </Dummy>\n )}\n />\n )\n}\n"],"names":["hydrationPromise","Dummy","props","_$memo","children","StartClient","router","state","matches","length","hydrate","Promise","resolve","_$createComponent","Await","promise","RouterProvider","InnerWrap","HeadContent"],"mappings":";;;;;AAKA,IAAIA;AAEJ,MAAMC,QAAQA,CAACC,UAAgCC,IAAA,KAAA,MAAQD,MAAME,QAAQ;AAE9D,SAASC,YAAYH,OAA8B;AACxD,MAAI,CAACF,kBAAkB;AACrB,QAAI,CAACE,MAAMI,OAAOC,MAAMC,QAAQC,QAAQ;AACnBC,yBAAAA,gBAAAA,QAAQR,MAAMI,MAAM;AAAA,IAAA,OAClC;AACLN,yBAAmBW,QAAQC,QAAQ;AAAA,IAAA;AAAA,EACrC;AAEF,SAAAC,IAAAA,gBACGC,YAAAA,OAAK;AAAA,IACJC,SAASf;AAAAA,IACTI,UAAUA,MAAAS,IAAAA,gBACPZ,OAAK;AAAA,MAAA,IAAAG,WAAA;AAAA,eAAAS,IAAAA,gBACHZ,OAAK;AAAA,UAAA,IAAAG,WAAA;AAAA,mBAAAS,IAAAA,gBACHG,YAAAA,gBAAc;AAAA,cAAA,IACbV,SAAM;AAAA,uBAAEJ,MAAMI;AAAAA,cAAM;AAAA,cACpBW,WAAYf,CAAAA,WAAKW,IAAAA,gBACdZ,OAAK;AAAA,gBAAA,IAAAG,WAAA;AAAAS,yBAAAA,CAAAA,oBACHZ,OAAK;AAAA,oBAAA,IAAAG,WAAA;AAAAS,6BAAAA,CAAAA,IAAAA,gBACHK,YAAAA,aAAW,CAAA,CAAA,GAAAf,IAAAA,KACXD,MAAAA,OAAME,QAAQ,CAAA;AAAA,oBAAA;AAAA,kBAAAS,CAAAA,GAAAA,IAAAA,gBAEhBZ,OAAK,CAAA,CAAA,CAAA;AAAA,gBAAA;AAAA,cAAA,CAAA;AAAA,YAAA,CAET;AAAA,UAAA;AAAA,QAAA,CAAA;AAAA,MAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAIR;AAGP;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const startClientCore = require("@tanstack/start-client-core");
|
|
4
|
+
const Meta = require("./Meta.cjs");
|
|
5
|
+
const Scripts = require("./Scripts.cjs");
|
|
6
|
+
const StartClient = require("./StartClient.cjs");
|
|
7
|
+
const renderRSC = require("./renderRSC.cjs");
|
|
8
|
+
const useServerFn = require("./useServerFn.cjs");
|
|
9
|
+
Object.defineProperty(exports, "clientOnly", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: () => startClientCore.clientOnly
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "createIsomorphicFn", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => startClientCore.createIsomorphicFn
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createMiddleware", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => startClientCore.createMiddleware
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "createServerFn", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: () => startClientCore.createServerFn
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "globalMiddleware", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: () => startClientCore.globalMiddleware
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "json", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: () => startClientCore.json
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "mergeHeaders", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: () => startClientCore.mergeHeaders
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "registerGlobalMiddleware", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: () => startClientCore.registerGlobalMiddleware
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "serverOnly", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: () => startClientCore.serverOnly
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "startSerializer", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: () => startClientCore.startSerializer
|
|
48
|
+
});
|
|
49
|
+
exports.Meta = Meta.Meta;
|
|
50
|
+
exports.Scripts = Scripts.Scripts;
|
|
51
|
+
exports.StartClient = StartClient.StartClient;
|
|
52
|
+
exports.renderRsc = renderRSC.renderRsc;
|
|
53
|
+
exports.useServerFn = useServerFn.useServerFn;
|
|
54
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { mergeHeaders } from '@tanstack/start-client-core';
|
|
2
|
+
export { startSerializer } from '@tanstack/start-client-core';
|
|
3
|
+
export { type DehydratedRouter, type ClientExtractedBaseEntry, type StartSsrGlobal, type ClientExtractedEntry, type SsrMatch, type ClientExtractedPromise, type ClientExtractedStream, type ResolvePromiseState, } from '@tanstack/start-client-core';
|
|
4
|
+
export { createIsomorphicFn, type IsomorphicFn, type ServerOnlyFn, type ClientOnlyFn, type IsomorphicFnBase, } from '@tanstack/start-client-core';
|
|
5
|
+
export { createServerFn } from '@tanstack/start-client-core';
|
|
6
|
+
export { type ServerFn as FetchFn, type ServerFnCtx as FetchFnCtx, type CompiledFetcherFnOptions, type CompiledFetcherFn, type Fetcher, type RscStream, type FetcherData, type FetcherBaseOptions, type ServerFn, type ServerFnCtx, type ServerFnResponseType, } from '@tanstack/start-client-core';
|
|
7
|
+
export { type JsonResponse } from '@tanstack/start-client-core';
|
|
8
|
+
export { createMiddleware, type IntersectAllValidatorInputs, type IntersectAllValidatorOutputs, type MiddlewareServerFn, type AnyMiddleware, type MiddlewareOptions, type MiddlewareWithTypes, type MiddlewareValidator, type MiddlewareServer, type MiddlewareAfterClient, type MiddlewareAfterMiddleware, type MiddlewareAfterServer, type Middleware, type MiddlewareClientFnOptions, type MiddlewareClientFnResult, type MiddlewareClientNextFn, type ClientResultWithContext, type AssignAllClientContextBeforeNext, type AssignAllMiddleware, type AssignAllServerContext, type MiddlewareAfterValidator, type MiddlewareClientFn, type MiddlewareServerFnResult, type MiddlewareClient, type MiddlewareServerFnOptions, type MiddlewareServerNextFn, type ServerResultWithContext, } from '@tanstack/start-client-core';
|
|
9
|
+
export { registerGlobalMiddleware, globalMiddleware, } from '@tanstack/start-client-core';
|
|
10
|
+
export { serverOnly, clientOnly } from '@tanstack/start-client-core';
|
|
11
|
+
export { json } from '@tanstack/start-client-core';
|
|
12
|
+
export { Meta } from './Meta.cjs';
|
|
13
|
+
export { Scripts } from './Scripts.cjs';
|
|
14
|
+
export { StartClient } from './StartClient.cjs';
|
|
15
|
+
export { renderRsc } from './renderRSC.cjs';
|
|
16
|
+
export { useServerFn } from './useServerFn.cjs';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const invariant = require("tiny-invariant");
|
|
4
|
+
function renderRsc(input) {
|
|
5
|
+
if (typeof input === "object" && !input.state) {
|
|
6
|
+
input.state = {
|
|
7
|
+
status: "pending",
|
|
8
|
+
promise: Promise.resolve().then(() => {
|
|
9
|
+
invariant(false, "renderRSC() is coming soon!");
|
|
10
|
+
}).then((element) => {
|
|
11
|
+
input.state.value = element;
|
|
12
|
+
input.state.status = "success";
|
|
13
|
+
}).catch((err) => {
|
|
14
|
+
input.state.status = "error";
|
|
15
|
+
input.state.error = err;
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (input.state.status === "pending") {
|
|
20
|
+
throw input.state.promise;
|
|
21
|
+
}
|
|
22
|
+
return input.state.value;
|
|
23
|
+
}
|
|
24
|
+
exports.renderRsc = renderRsc;
|
|
25
|
+
//# sourceMappingURL=renderRSC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderRSC.cjs","sources":["../../src/renderRSC.tsx"],"sourcesContent":["// TODO: RSCs\n// // @ts-expect-error\n// import * as reactDom from '@vinxi/react-server-dom/client'\n// import { isValidElement } from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport type * as Solid from 'solid-js'\n\nexport function renderRsc(input: any): Solid.JSX.Element {\n // TODO: isValidElement\n // if (isValidElement(input)) {\n // return input\n // }\n\n if (typeof input === 'object' && !input.state) {\n input.state = {\n status: 'pending',\n promise: Promise.resolve()\n .then(() => {\n let element\n\n // We're in node\n // TODO: RSCs\n // if (reactDom.createFromNodeStream) {\n // const stream = await import('node:stream')\n\n // let body: any = input\n\n // // Unwrap the response\n // if (input instanceof Response) {\n // body = input.body\n // }\n\n // // Convert ReadableStream to NodeJS stream.Readable\n // if (body instanceof ReadableStream) {\n // body = stream.Readable.fromWeb(body as any)\n // }\n\n // if (stream.Readable.isReadable(body)) {\n // // body = copyStreamToRaw(body)\n // } else if (input.text) {\n // // create a readable stream by awaiting the text method\n // body = new stream.Readable({\n // async read() {\n // input.text().then((value: any) => {\n // this.push(value)\n // this.push(null)\n // })\n // },\n // })\n // } else {\n // console.error('input', input)\n // throw new Error('Unexpected rsc input type 👆')\n // }\n\n // element = await reactDom.createFromNodeStream(body)\n // } else {\n // // We're in the browser\n // if (input.body instanceof ReadableStream) {\n // input = input.body\n // }\n\n // if (input instanceof ReadableStream) {\n // element = await reactDom.createFromReadableStream(input)\n // }\n\n // if (input instanceof Response) {\n // // copy to the response body to cache the raw data\n // element = await reactDom.createFromFetch(input)\n // }\n // }\n\n // return element\n\n invariant(false, 'renderRSC() is coming soon!')\n })\n .then((element) => {\n input.state.value = element\n input.state.status = 'success'\n })\n .catch((err) => {\n input.state.status = 'error'\n input.state.error = err\n }),\n }\n }\n\n if (input.state.status === 'pending') {\n throw input.state.promise\n }\n\n return input.state.value\n}\n"],"names":["renderRsc","input","state","status","promise","Promise","resolve","then","invariant","element","value","catch","err","error"],"mappings":";;;AAOO,SAASA,UAAUC,OAA+B;AAMvD,MAAI,OAAOA,UAAU,YAAY,CAACA,MAAMC,OAAO;AAC7CD,UAAMC,QAAQ;AAAA,MACZC,QAAQ;AAAA,MACRC,SAASC,QAAQC,QAAQ,EACtBC,KAAK,MAAM;AAwDVC,kBAAU,OAAO,6BAA6B;AAAA,MAAA,CAC/C,EACAD,KAAME,CAAY,YAAA;AACjBR,cAAMC,MAAMQ,QAAQD;AACpBR,cAAMC,MAAMC,SAAS;AAAA,MAAA,CACtB,EACAQ,MAAOC,CAAQ,QAAA;AACdX,cAAMC,MAAMC,SAAS;AACrBF,cAAMC,MAAMW,QAAQD;AAAAA,MACrB,CAAA;AAAA,IACL;AAAA,EAAA;AAGEX,MAAAA,MAAMC,MAAMC,WAAW,WAAW;AACpC,UAAMF,MAAMC,MAAME;AAAAA,EAAAA;AAGpB,SAAOH,MAAMC,MAAMQ;AACrB;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const routerCore = require("@tanstack/router-core");
|
|
4
|
+
const solidRouter = require("@tanstack/solid-router");
|
|
5
|
+
function useServerFn(serverFn) {
|
|
6
|
+
const router = solidRouter.useRouter();
|
|
7
|
+
return async (...args) => {
|
|
8
|
+
try {
|
|
9
|
+
const res = await serverFn(...args);
|
|
10
|
+
if (routerCore.isRedirect(res)) {
|
|
11
|
+
throw res;
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
} catch (err) {
|
|
15
|
+
if (routerCore.isRedirect(err)) {
|
|
16
|
+
const resolvedRedirect = router.resolveRedirect({
|
|
17
|
+
...err,
|
|
18
|
+
_fromLocation: router.state.location
|
|
19
|
+
});
|
|
20
|
+
return router.navigate(resolvedRedirect);
|
|
21
|
+
}
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.useServerFn = useServerFn;
|
|
27
|
+
//# sourceMappingURL=useServerFn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useServerFn.cjs","sources":["../../src/useServerFn.ts"],"sourcesContent":["import { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/solid-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return (async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n const resolvedRedirect = router.resolveRedirect({\n ...err,\n _fromLocation: router.state.location,\n })\n\n return router.navigate(resolvedRedirect)\n }\n\n throw err\n }\n }) as any\n}\n"],"names":["useRouter","isRedirect"],"mappings":";;;;AAGO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAASA,YAAAA,UAAU;AAEzB,SAAQ,UAAU,SAAqB;AACjC,QAAA;AACF,YAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,UAAAC,WAAAA,WAAW,GAAG,GAAG;AACb,cAAA;AAAA,MAAA;AAGD,aAAA;AAAA,aACA,KAAK;AACR,UAAAA,WAAAA,WAAW,GAAG,GAAG;AACb,cAAA,mBAAmB,OAAO,gBAAgB;AAAA,UAC9C,GAAG;AAAA,UACH,eAAe,OAAO,MAAM;AAAA,QAAA,CAC7B;AAEM,eAAA,OAAO,SAAS,gBAAgB;AAAA,MAAA;AAGnC,YAAA;AAAA,IAAA;AAAA,EAEV;AACF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(serverFn: T): (...args: Parameters<T>) => ReturnType<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Meta: () => import("solid-js").JSX.Element;
|
package/dist/esm/Meta.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { HeadContent } from "@tanstack/solid-router";
|
|
3
|
+
const Meta = () => {
|
|
4
|
+
if (process.env.NODE_ENV === "development") {
|
|
5
|
+
console.warn("The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.");
|
|
6
|
+
}
|
|
7
|
+
return createComponent(HeadContent, {});
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
Meta
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=Meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Meta.js","sources":["../../src/Meta.tsx"],"sourcesContent":["import { HeadContent } from '@tanstack/solid-router'\n\nexport const Meta = () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n 'The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.',\n )\n }\n return <HeadContent />\n}\n"],"names":["Meta","process","env","NODE_ENV","console","warn","_$createComponent","HeadContent"],"mappings":";;AAEO,MAAMA,OAAOA,MAAM;AACpBC,MAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,YAAQC,KACN,4FACF;AAAA,EAAA;AAEFC,SAAAA,gBAAQC,aAAW,EAAA;AACrB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Scripts: () => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { Scripts as Scripts$1 } from "@tanstack/solid-router";
|
|
3
|
+
const Scripts = () => {
|
|
4
|
+
if (process.env.NODE_ENV === "development") {
|
|
5
|
+
console.warn("The Scripts component was moved to `@tanstack/solid-router`");
|
|
6
|
+
}
|
|
7
|
+
return createComponent(Scripts$1, {});
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
Scripts
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=Scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Scripts as RouterScripts } from '@tanstack/solid-router'\n\nexport const Scripts = () => {\n if (process.env.NODE_ENV === 'development') {\n console.warn('The Scripts component was moved to `@tanstack/solid-router`')\n }\n return <RouterScripts />\n}\n"],"names":["Scripts","process","env","NODE_ENV","console","warn","_$createComponent","RouterScripts"],"mappings":";;AAEO,MAAMA,UAAUA,MAAM;AACvBC,MAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,YAAQC,KAAK,6DAA6D;AAAA,EAAA;AAE5EC,SAAAA,gBAAQC,WAAa,EAAA;AACvB;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createComponent, memo } from "solid-js/web";
|
|
2
|
+
import { Await, RouterProvider, HeadContent } from "@tanstack/solid-router";
|
|
3
|
+
import { hydrate } from "@tanstack/start-client-core";
|
|
4
|
+
let hydrationPromise;
|
|
5
|
+
const Dummy = (props) => memo(() => props.children);
|
|
6
|
+
function StartClient(props) {
|
|
7
|
+
if (!hydrationPromise) {
|
|
8
|
+
if (!props.router.state.matches.length) {
|
|
9
|
+
hydrationPromise = hydrate(props.router);
|
|
10
|
+
} else {
|
|
11
|
+
hydrationPromise = Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return createComponent(Await, {
|
|
15
|
+
promise: hydrationPromise,
|
|
16
|
+
children: () => createComponent(Dummy, {
|
|
17
|
+
get children() {
|
|
18
|
+
return createComponent(Dummy, {
|
|
19
|
+
get children() {
|
|
20
|
+
return createComponent(RouterProvider, {
|
|
21
|
+
get router() {
|
|
22
|
+
return props.router;
|
|
23
|
+
},
|
|
24
|
+
InnerWrap: (props2) => createComponent(Dummy, {
|
|
25
|
+
get children() {
|
|
26
|
+
return [createComponent(Dummy, {
|
|
27
|
+
get children() {
|
|
28
|
+
return [createComponent(HeadContent, {}), memo(() => props2.children)];
|
|
29
|
+
}
|
|
30
|
+
}), createComponent(Dummy, {})];
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
StartClient
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=StartClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartClient.js","sources":["../../src/StartClient.tsx"],"sourcesContent":["import { Await, HeadContent, RouterProvider } from '@tanstack/solid-router'\nimport { hydrate } from '@tanstack/start-client-core'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { JSXElement } from 'solid-js'\n\nlet hydrationPromise: Promise<void | Array<Array<void>>> | undefined\n\nconst Dummy = (props: { children?: JSXElement }) => <>{props.children}</>\n\nexport function StartClient(props: { router: AnyRouter }) {\n if (!hydrationPromise) {\n if (!props.router.state.matches.length) {\n hydrationPromise = hydrate(props.router)\n } else {\n hydrationPromise = Promise.resolve()\n }\n }\n return (\n <Await\n promise={hydrationPromise}\n children={() => (\n <Dummy>\n <Dummy>\n <RouterProvider\n router={props.router}\n InnerWrap={(props) => (\n <Dummy>\n <Dummy>\n <HeadContent />\n {props.children}\n </Dummy>\n <Dummy />\n </Dummy>\n )}\n />\n </Dummy>\n </Dummy>\n )}\n />\n )\n}\n"],"names":["hydrationPromise","Dummy","props","_$memo","children","StartClient","router","state","matches","length","hydrate","Promise","resolve","_$createComponent","Await","promise","RouterProvider","InnerWrap","HeadContent"],"mappings":";;;AAKA,IAAIA;AAEJ,MAAMC,QAAQA,CAACC,UAAgCC,KAAA,MAAQD,MAAME,QAAQ;AAE9D,SAASC,YAAYH,OAA8B;AACxD,MAAI,CAACF,kBAAkB;AACrB,QAAI,CAACE,MAAMI,OAAOC,MAAMC,QAAQC,QAAQ;AACnBC,yBAAAA,QAAQR,MAAMI,MAAM;AAAA,IAAA,OAClC;AACLN,yBAAmBW,QAAQC,QAAQ;AAAA,IAAA;AAAA,EACrC;AAEF,SAAAC,gBACGC,OAAK;AAAA,IACJC,SAASf;AAAAA,IACTI,UAAUA,MAAAS,gBACPZ,OAAK;AAAA,MAAA,IAAAG,WAAA;AAAA,eAAAS,gBACHZ,OAAK;AAAA,UAAA,IAAAG,WAAA;AAAA,mBAAAS,gBACHG,gBAAc;AAAA,cAAA,IACbV,SAAM;AAAA,uBAAEJ,MAAMI;AAAAA,cAAM;AAAA,cACpBW,WAAYf,CAAAA,WAAKW,gBACdZ,OAAK;AAAA,gBAAA,IAAAG,WAAA;AAAAS,yBAAAA,CAAAA,gBACHZ,OAAK;AAAA,oBAAA,IAAAG,WAAA;AAAAS,6BAAAA,CAAAA,gBACHK,aAAW,CAAA,CAAA,GAAAf,KACXD,MAAAA,OAAME,QAAQ,CAAA;AAAA,oBAAA;AAAA,kBAAAS,CAAAA,GAAAA,gBAEhBZ,OAAK,CAAA,CAAA,CAAA;AAAA,gBAAA;AAAA,cAAA,CAAA;AAAA,YAAA,CAET;AAAA,UAAA;AAAA,QAAA,CAAA;AAAA,MAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAIR;AAGP;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { mergeHeaders } from '@tanstack/start-client-core';
|
|
2
|
+
export { startSerializer } from '@tanstack/start-client-core';
|
|
3
|
+
export { type DehydratedRouter, type ClientExtractedBaseEntry, type StartSsrGlobal, type ClientExtractedEntry, type SsrMatch, type ClientExtractedPromise, type ClientExtractedStream, type ResolvePromiseState, } from '@tanstack/start-client-core';
|
|
4
|
+
export { createIsomorphicFn, type IsomorphicFn, type ServerOnlyFn, type ClientOnlyFn, type IsomorphicFnBase, } from '@tanstack/start-client-core';
|
|
5
|
+
export { createServerFn } from '@tanstack/start-client-core';
|
|
6
|
+
export { type ServerFn as FetchFn, type ServerFnCtx as FetchFnCtx, type CompiledFetcherFnOptions, type CompiledFetcherFn, type Fetcher, type RscStream, type FetcherData, type FetcherBaseOptions, type ServerFn, type ServerFnCtx, type ServerFnResponseType, } from '@tanstack/start-client-core';
|
|
7
|
+
export { type JsonResponse } from '@tanstack/start-client-core';
|
|
8
|
+
export { createMiddleware, type IntersectAllValidatorInputs, type IntersectAllValidatorOutputs, type MiddlewareServerFn, type AnyMiddleware, type MiddlewareOptions, type MiddlewareWithTypes, type MiddlewareValidator, type MiddlewareServer, type MiddlewareAfterClient, type MiddlewareAfterMiddleware, type MiddlewareAfterServer, type Middleware, type MiddlewareClientFnOptions, type MiddlewareClientFnResult, type MiddlewareClientNextFn, type ClientResultWithContext, type AssignAllClientContextBeforeNext, type AssignAllMiddleware, type AssignAllServerContext, type MiddlewareAfterValidator, type MiddlewareClientFn, type MiddlewareServerFnResult, type MiddlewareClient, type MiddlewareServerFnOptions, type MiddlewareServerNextFn, type ServerResultWithContext, } from '@tanstack/start-client-core';
|
|
9
|
+
export { registerGlobalMiddleware, globalMiddleware, } from '@tanstack/start-client-core';
|
|
10
|
+
export { serverOnly, clientOnly } from '@tanstack/start-client-core';
|
|
11
|
+
export { json } from '@tanstack/start-client-core';
|
|
12
|
+
export { Meta } from './Meta.js';
|
|
13
|
+
export { Scripts } from './Scripts.js';
|
|
14
|
+
export { StartClient } from './StartClient.js';
|
|
15
|
+
export { renderRsc } from './renderRSC.js';
|
|
16
|
+
export { useServerFn } from './useServerFn.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { clientOnly, createIsomorphicFn, createMiddleware, createServerFn, globalMiddleware, json, mergeHeaders, registerGlobalMiddleware, serverOnly, startSerializer } from "@tanstack/start-client-core";
|
|
2
|
+
import { Meta } from "./Meta.js";
|
|
3
|
+
import { Scripts } from "./Scripts.js";
|
|
4
|
+
import { StartClient } from "./StartClient.js";
|
|
5
|
+
import { renderRsc } from "./renderRSC.js";
|
|
6
|
+
import { useServerFn } from "./useServerFn.js";
|
|
7
|
+
export {
|
|
8
|
+
Meta,
|
|
9
|
+
Scripts,
|
|
10
|
+
StartClient,
|
|
11
|
+
clientOnly,
|
|
12
|
+
createIsomorphicFn,
|
|
13
|
+
createMiddleware,
|
|
14
|
+
createServerFn,
|
|
15
|
+
globalMiddleware,
|
|
16
|
+
json,
|
|
17
|
+
mergeHeaders,
|
|
18
|
+
registerGlobalMiddleware,
|
|
19
|
+
renderRsc,
|
|
20
|
+
serverOnly,
|
|
21
|
+
startSerializer,
|
|
22
|
+
useServerFn
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import invariant from "tiny-invariant";
|
|
2
|
+
function renderRsc(input) {
|
|
3
|
+
if (typeof input === "object" && !input.state) {
|
|
4
|
+
input.state = {
|
|
5
|
+
status: "pending",
|
|
6
|
+
promise: Promise.resolve().then(() => {
|
|
7
|
+
invariant(false, "renderRSC() is coming soon!");
|
|
8
|
+
}).then((element) => {
|
|
9
|
+
input.state.value = element;
|
|
10
|
+
input.state.status = "success";
|
|
11
|
+
}).catch((err) => {
|
|
12
|
+
input.state.status = "error";
|
|
13
|
+
input.state.error = err;
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (input.state.status === "pending") {
|
|
18
|
+
throw input.state.promise;
|
|
19
|
+
}
|
|
20
|
+
return input.state.value;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
renderRsc
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=renderRSC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderRSC.js","sources":["../../src/renderRSC.tsx"],"sourcesContent":["// TODO: RSCs\n// // @ts-expect-error\n// import * as reactDom from '@vinxi/react-server-dom/client'\n// import { isValidElement } from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport type * as Solid from 'solid-js'\n\nexport function renderRsc(input: any): Solid.JSX.Element {\n // TODO: isValidElement\n // if (isValidElement(input)) {\n // return input\n // }\n\n if (typeof input === 'object' && !input.state) {\n input.state = {\n status: 'pending',\n promise: Promise.resolve()\n .then(() => {\n let element\n\n // We're in node\n // TODO: RSCs\n // if (reactDom.createFromNodeStream) {\n // const stream = await import('node:stream')\n\n // let body: any = input\n\n // // Unwrap the response\n // if (input instanceof Response) {\n // body = input.body\n // }\n\n // // Convert ReadableStream to NodeJS stream.Readable\n // if (body instanceof ReadableStream) {\n // body = stream.Readable.fromWeb(body as any)\n // }\n\n // if (stream.Readable.isReadable(body)) {\n // // body = copyStreamToRaw(body)\n // } else if (input.text) {\n // // create a readable stream by awaiting the text method\n // body = new stream.Readable({\n // async read() {\n // input.text().then((value: any) => {\n // this.push(value)\n // this.push(null)\n // })\n // },\n // })\n // } else {\n // console.error('input', input)\n // throw new Error('Unexpected rsc input type 👆')\n // }\n\n // element = await reactDom.createFromNodeStream(body)\n // } else {\n // // We're in the browser\n // if (input.body instanceof ReadableStream) {\n // input = input.body\n // }\n\n // if (input instanceof ReadableStream) {\n // element = await reactDom.createFromReadableStream(input)\n // }\n\n // if (input instanceof Response) {\n // // copy to the response body to cache the raw data\n // element = await reactDom.createFromFetch(input)\n // }\n // }\n\n // return element\n\n invariant(false, 'renderRSC() is coming soon!')\n })\n .then((element) => {\n input.state.value = element\n input.state.status = 'success'\n })\n .catch((err) => {\n input.state.status = 'error'\n input.state.error = err\n }),\n }\n }\n\n if (input.state.status === 'pending') {\n throw input.state.promise\n }\n\n return input.state.value\n}\n"],"names":["renderRsc","input","state","status","promise","Promise","resolve","then","invariant","element","value","catch","err","error"],"mappings":";AAOO,SAASA,UAAUC,OAA+B;AAMvD,MAAI,OAAOA,UAAU,YAAY,CAACA,MAAMC,OAAO;AAC7CD,UAAMC,QAAQ;AAAA,MACZC,QAAQ;AAAA,MACRC,SAASC,QAAQC,QAAQ,EACtBC,KAAK,MAAM;AAwDVC,kBAAU,OAAO,6BAA6B;AAAA,MAAA,CAC/C,EACAD,KAAME,CAAY,YAAA;AACjBR,cAAMC,MAAMQ,QAAQD;AACpBR,cAAMC,MAAMC,SAAS;AAAA,MAAA,CACtB,EACAQ,MAAOC,CAAQ,QAAA;AACdX,cAAMC,MAAMC,SAAS;AACrBF,cAAMC,MAAMW,QAAQD;AAAAA,MACrB,CAAA;AAAA,IACL;AAAA,EAAA;AAGEX,MAAAA,MAAMC,MAAMC,WAAW,WAAW;AACpC,UAAMF,MAAMC,MAAME;AAAAA,EAAAA;AAGpB,SAAOH,MAAMC,MAAMQ;AACrB;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(serverFn: T): (...args: Parameters<T>) => ReturnType<T>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isRedirect } from "@tanstack/router-core";
|
|
2
|
+
import { useRouter } from "@tanstack/solid-router";
|
|
3
|
+
function useServerFn(serverFn) {
|
|
4
|
+
const router = useRouter();
|
|
5
|
+
return async (...args) => {
|
|
6
|
+
try {
|
|
7
|
+
const res = await serverFn(...args);
|
|
8
|
+
if (isRedirect(res)) {
|
|
9
|
+
throw res;
|
|
10
|
+
}
|
|
11
|
+
return res;
|
|
12
|
+
} catch (err) {
|
|
13
|
+
if (isRedirect(err)) {
|
|
14
|
+
const resolvedRedirect = router.resolveRedirect({
|
|
15
|
+
...err,
|
|
16
|
+
_fromLocation: router.state.location
|
|
17
|
+
});
|
|
18
|
+
return router.navigate(resolvedRedirect);
|
|
19
|
+
}
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
useServerFn
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useServerFn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useServerFn.js","sources":["../../src/useServerFn.ts"],"sourcesContent":["import { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/solid-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return (async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n const resolvedRedirect = router.resolveRedirect({\n ...err,\n _fromLocation: router.state.location,\n })\n\n return router.navigate(resolvedRedirect)\n }\n\n throw err\n }\n }) as any\n}\n"],"names":[],"mappings":";;AAGO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAAS,UAAU;AAEzB,SAAQ,UAAU,SAAqB;AACjC,QAAA;AACF,YAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,UAAA,WAAW,GAAG,GAAG;AACb,cAAA;AAAA,MAAA;AAGD,aAAA;AAAA,aACA,KAAK;AACR,UAAA,WAAW,GAAG,GAAG;AACb,cAAA,mBAAmB,OAAO,gBAAgB;AAAA,UAC9C,GAAG;AAAA,UACH,eAAe,OAAO,MAAM;AAAA,QAAA,CAC7B;AAEM,eAAA,OAAO,SAAS,gBAAgB;AAAA,MAAA;AAGnC,YAAA;AAAA,IAAA;AAAA,EAEV;AACF;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/solid-start-client",
|
|
3
|
+
"version": "1.114.29",
|
|
4
|
+
"description": "Modern and scalable routing for Solid applications",
|
|
5
|
+
"author": "Tanner Linsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/TanStack/router.git",
|
|
10
|
+
"directory": "packages/solid-start-client"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://tanstack.com/start",
|
|
13
|
+
"funding": {
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"solid",
|
|
19
|
+
"location",
|
|
20
|
+
"router",
|
|
21
|
+
"routing",
|
|
22
|
+
"async",
|
|
23
|
+
"async router",
|
|
24
|
+
"typescript"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "dist/esm/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/esm/index.d.ts",
|
|
32
|
+
"default": "./dist/esm/index.js"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/cjs/index.d.cts",
|
|
36
|
+
"default": "./dist/cjs/index.cjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"src"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=12"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"cookie-es": "^1.2.2",
|
|
51
|
+
"jsesc": "^3.1.0",
|
|
52
|
+
"tiny-invariant": "^1.3.3",
|
|
53
|
+
"tiny-warning": "^1.0.3",
|
|
54
|
+
"vinxi": "^0.5.3",
|
|
55
|
+
"@tanstack/router-core": "^1.114.29",
|
|
56
|
+
"@tanstack/solid-router": "^1.114.29",
|
|
57
|
+
"@tanstack/start-client-core": "^1.114.29"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@solidjs/testing-library": "^0.8.10",
|
|
61
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
62
|
+
"@types/jsesc": "^3.0.3",
|
|
63
|
+
"vite-plugin-solid": "^2.11.2"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"solid-js": ">=1.0.0"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {}
|
|
69
|
+
}
|
package/src/Meta.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HeadContent } from '@tanstack/solid-router'
|
|
2
|
+
|
|
3
|
+
export const Meta = () => {
|
|
4
|
+
if (process.env.NODE_ENV === 'development') {
|
|
5
|
+
console.warn(
|
|
6
|
+
'The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.',
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
return <HeadContent />
|
|
10
|
+
}
|
package/src/Scripts.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Await, HeadContent, RouterProvider } from '@tanstack/solid-router'
|
|
2
|
+
import { hydrate } from '@tanstack/start-client-core'
|
|
3
|
+
import type { AnyRouter } from '@tanstack/router-core'
|
|
4
|
+
import type { JSXElement } from 'solid-js'
|
|
5
|
+
|
|
6
|
+
let hydrationPromise: Promise<void | Array<Array<void>>> | undefined
|
|
7
|
+
|
|
8
|
+
const Dummy = (props: { children?: JSXElement }) => <>{props.children}</>
|
|
9
|
+
|
|
10
|
+
export function StartClient(props: { router: AnyRouter }) {
|
|
11
|
+
if (!hydrationPromise) {
|
|
12
|
+
if (!props.router.state.matches.length) {
|
|
13
|
+
hydrationPromise = hydrate(props.router)
|
|
14
|
+
} else {
|
|
15
|
+
hydrationPromise = Promise.resolve()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<Await
|
|
20
|
+
promise={hydrationPromise}
|
|
21
|
+
children={() => (
|
|
22
|
+
<Dummy>
|
|
23
|
+
<Dummy>
|
|
24
|
+
<RouterProvider
|
|
25
|
+
router={props.router}
|
|
26
|
+
InnerWrap={(props) => (
|
|
27
|
+
<Dummy>
|
|
28
|
+
<Dummy>
|
|
29
|
+
<HeadContent />
|
|
30
|
+
{props.children}
|
|
31
|
+
</Dummy>
|
|
32
|
+
<Dummy />
|
|
33
|
+
</Dummy>
|
|
34
|
+
)}
|
|
35
|
+
/>
|
|
36
|
+
</Dummy>
|
|
37
|
+
</Dummy>
|
|
38
|
+
)}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="vinxi/types/client" />
|
|
2
|
+
export { mergeHeaders } from '@tanstack/start-client-core'
|
|
3
|
+
export { startSerializer } from '@tanstack/start-client-core'
|
|
4
|
+
export {
|
|
5
|
+
type DehydratedRouter,
|
|
6
|
+
type ClientExtractedBaseEntry,
|
|
7
|
+
type StartSsrGlobal,
|
|
8
|
+
type ClientExtractedEntry,
|
|
9
|
+
type SsrMatch,
|
|
10
|
+
type ClientExtractedPromise,
|
|
11
|
+
type ClientExtractedStream,
|
|
12
|
+
type ResolvePromiseState,
|
|
13
|
+
} from '@tanstack/start-client-core'
|
|
14
|
+
export {
|
|
15
|
+
createIsomorphicFn,
|
|
16
|
+
type IsomorphicFn,
|
|
17
|
+
type ServerOnlyFn,
|
|
18
|
+
type ClientOnlyFn,
|
|
19
|
+
type IsomorphicFnBase,
|
|
20
|
+
} from '@tanstack/start-client-core'
|
|
21
|
+
export { createServerFn } from '@tanstack/start-client-core'
|
|
22
|
+
export {
|
|
23
|
+
type ServerFn as FetchFn,
|
|
24
|
+
type ServerFnCtx as FetchFnCtx,
|
|
25
|
+
type CompiledFetcherFnOptions,
|
|
26
|
+
type CompiledFetcherFn,
|
|
27
|
+
type Fetcher,
|
|
28
|
+
type RscStream,
|
|
29
|
+
type FetcherData,
|
|
30
|
+
type FetcherBaseOptions,
|
|
31
|
+
type ServerFn,
|
|
32
|
+
type ServerFnCtx,
|
|
33
|
+
type ServerFnResponseType,
|
|
34
|
+
} from '@tanstack/start-client-core'
|
|
35
|
+
export { type JsonResponse } from '@tanstack/start-client-core'
|
|
36
|
+
export {
|
|
37
|
+
createMiddleware,
|
|
38
|
+
type IntersectAllValidatorInputs,
|
|
39
|
+
type IntersectAllValidatorOutputs,
|
|
40
|
+
type MiddlewareServerFn,
|
|
41
|
+
type AnyMiddleware,
|
|
42
|
+
type MiddlewareOptions,
|
|
43
|
+
type MiddlewareWithTypes,
|
|
44
|
+
type MiddlewareValidator,
|
|
45
|
+
type MiddlewareServer,
|
|
46
|
+
type MiddlewareAfterClient,
|
|
47
|
+
type MiddlewareAfterMiddleware,
|
|
48
|
+
type MiddlewareAfterServer,
|
|
49
|
+
type Middleware,
|
|
50
|
+
type MiddlewareClientFnOptions,
|
|
51
|
+
type MiddlewareClientFnResult,
|
|
52
|
+
type MiddlewareClientNextFn,
|
|
53
|
+
type ClientResultWithContext,
|
|
54
|
+
type AssignAllClientContextBeforeNext,
|
|
55
|
+
type AssignAllMiddleware,
|
|
56
|
+
type AssignAllServerContext,
|
|
57
|
+
type MiddlewareAfterValidator,
|
|
58
|
+
type MiddlewareClientFn,
|
|
59
|
+
type MiddlewareServerFnResult,
|
|
60
|
+
type MiddlewareClient,
|
|
61
|
+
type MiddlewareServerFnOptions,
|
|
62
|
+
type MiddlewareServerNextFn,
|
|
63
|
+
type ServerResultWithContext,
|
|
64
|
+
} from '@tanstack/start-client-core'
|
|
65
|
+
export {
|
|
66
|
+
registerGlobalMiddleware,
|
|
67
|
+
globalMiddleware,
|
|
68
|
+
} from '@tanstack/start-client-core'
|
|
69
|
+
export { serverOnly, clientOnly } from '@tanstack/start-client-core'
|
|
70
|
+
export { json } from '@tanstack/start-client-core'
|
|
71
|
+
export { Meta } from './Meta'
|
|
72
|
+
export { Scripts } from './Scripts'
|
|
73
|
+
export { StartClient } from './StartClient'
|
|
74
|
+
export { renderRsc } from './renderRSC'
|
|
75
|
+
export { useServerFn } from './useServerFn'
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// TODO: RSCs
|
|
2
|
+
// // @ts-expect-error
|
|
3
|
+
// import * as reactDom from '@vinxi/react-server-dom/client'
|
|
4
|
+
// import { isValidElement } from 'solid-js'
|
|
5
|
+
import invariant from 'tiny-invariant'
|
|
6
|
+
import type * as Solid from 'solid-js'
|
|
7
|
+
|
|
8
|
+
export function renderRsc(input: any): Solid.JSX.Element {
|
|
9
|
+
// TODO: isValidElement
|
|
10
|
+
// if (isValidElement(input)) {
|
|
11
|
+
// return input
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
if (typeof input === 'object' && !input.state) {
|
|
15
|
+
input.state = {
|
|
16
|
+
status: 'pending',
|
|
17
|
+
promise: Promise.resolve()
|
|
18
|
+
.then(() => {
|
|
19
|
+
let element
|
|
20
|
+
|
|
21
|
+
// We're in node
|
|
22
|
+
// TODO: RSCs
|
|
23
|
+
// if (reactDom.createFromNodeStream) {
|
|
24
|
+
// const stream = await import('node:stream')
|
|
25
|
+
|
|
26
|
+
// let body: any = input
|
|
27
|
+
|
|
28
|
+
// // Unwrap the response
|
|
29
|
+
// if (input instanceof Response) {
|
|
30
|
+
// body = input.body
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// // Convert ReadableStream to NodeJS stream.Readable
|
|
34
|
+
// if (body instanceof ReadableStream) {
|
|
35
|
+
// body = stream.Readable.fromWeb(body as any)
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
// if (stream.Readable.isReadable(body)) {
|
|
39
|
+
// // body = copyStreamToRaw(body)
|
|
40
|
+
// } else if (input.text) {
|
|
41
|
+
// // create a readable stream by awaiting the text method
|
|
42
|
+
// body = new stream.Readable({
|
|
43
|
+
// async read() {
|
|
44
|
+
// input.text().then((value: any) => {
|
|
45
|
+
// this.push(value)
|
|
46
|
+
// this.push(null)
|
|
47
|
+
// })
|
|
48
|
+
// },
|
|
49
|
+
// })
|
|
50
|
+
// } else {
|
|
51
|
+
// console.error('input', input)
|
|
52
|
+
// throw new Error('Unexpected rsc input type 👆')
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
// element = await reactDom.createFromNodeStream(body)
|
|
56
|
+
// } else {
|
|
57
|
+
// // We're in the browser
|
|
58
|
+
// if (input.body instanceof ReadableStream) {
|
|
59
|
+
// input = input.body
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
// if (input instanceof ReadableStream) {
|
|
63
|
+
// element = await reactDom.createFromReadableStream(input)
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
// if (input instanceof Response) {
|
|
67
|
+
// // copy to the response body to cache the raw data
|
|
68
|
+
// element = await reactDom.createFromFetch(input)
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
// return element
|
|
73
|
+
|
|
74
|
+
invariant(false, 'renderRSC() is coming soon!')
|
|
75
|
+
})
|
|
76
|
+
.then((element) => {
|
|
77
|
+
input.state.value = element
|
|
78
|
+
input.state.status = 'success'
|
|
79
|
+
})
|
|
80
|
+
.catch((err) => {
|
|
81
|
+
input.state.status = 'error'
|
|
82
|
+
input.state.error = err
|
|
83
|
+
}),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (input.state.status === 'pending') {
|
|
88
|
+
throw input.state.promise
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return input.state.value
|
|
92
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// import { expectTypeOf, test } from 'vitest'
|
|
2
|
+
// import { createServerFn } from '@tanstack/start-client-core'
|
|
3
|
+
|
|
4
|
+
// test('createServerFn returns RSC', () => {
|
|
5
|
+
// const fn = createServerFn().handler(() => ({
|
|
6
|
+
// rscs: [
|
|
7
|
+
// <div key="0">I'm an RSC</div>,
|
|
8
|
+
// <div key="1">I'm an RSC</div>,
|
|
9
|
+
// ] as const,
|
|
10
|
+
// }))
|
|
11
|
+
|
|
12
|
+
// expectTypeOf(fn()).toEqualTypeOf<
|
|
13
|
+
// Promise<{ rscs: readonly [ReadableStream, ReadableStream] }>
|
|
14
|
+
// >()
|
|
15
|
+
// })
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isRedirect } from '@tanstack/router-core'
|
|
2
|
+
import { useRouter } from '@tanstack/solid-router'
|
|
3
|
+
|
|
4
|
+
export function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(
|
|
5
|
+
serverFn: T,
|
|
6
|
+
): (...args: Parameters<T>) => ReturnType<T> {
|
|
7
|
+
const router = useRouter()
|
|
8
|
+
|
|
9
|
+
return (async (...args: Array<any>) => {
|
|
10
|
+
try {
|
|
11
|
+
const res = await serverFn(...args)
|
|
12
|
+
|
|
13
|
+
if (isRedirect(res)) {
|
|
14
|
+
throw res
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return res
|
|
18
|
+
} catch (err) {
|
|
19
|
+
if (isRedirect(err)) {
|
|
20
|
+
const resolvedRedirect = router.resolveRedirect({
|
|
21
|
+
...err,
|
|
22
|
+
_fromLocation: router.state.location,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return router.navigate(resolvedRedirect)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
throw err
|
|
29
|
+
}
|
|
30
|
+
}) as any
|
|
31
|
+
}
|