@tanstack/start-fn-stubs
Advanced tools
@@ -0,13 +1,12 @@ | ||
| //#region src/createIsomorphicFn.ts | ||
| function createIsomorphicFn() { | ||
| const fn = () => void 0; | ||
| return Object.assign(fn, { | ||
| server: () => ({ client: () => () => { | ||
| } }), | ||
| client: () => ({ server: () => () => { | ||
| } }) | ||
| }); | ||
| const fn = () => void 0; | ||
| return Object.assign(fn, { | ||
| server: () => ({ client: () => () => {} }), | ||
| client: () => ({ server: () => () => {} }) | ||
| }); | ||
| } | ||
| export { | ||
| createIsomorphicFn | ||
| }; | ||
| //# sourceMappingURL=createIsomorphicFn.js.map | ||
| //#endregion | ||
| export { createIsomorphicFn }; | ||
| //# sourceMappingURL=createIsomorphicFn.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"createIsomorphicFn.js","sources":["../../src/createIsomorphicFn.ts"],"sourcesContent":["// a function that can have different implementations on the client and server.\n// implementations not provided will default to a no-op function.\n\nexport type IsomorphicFn<\n TArgs extends Array<any> = [],\n TServer = undefined,\n TClient = undefined,\n> = (...args: TArgs) => TServer | TClient\n\nexport interface ServerOnlyFn<\n TArgs extends Array<any>,\n TServer,\n> extends IsomorphicFn<TArgs, TServer> {\n client: <TClient>(\n clientImpl: (...args: TArgs) => TClient,\n ) => IsomorphicFn<TArgs, TServer, TClient>\n}\n\nexport interface ClientOnlyFn<\n TArgs extends Array<any>,\n TClient,\n> extends IsomorphicFn<TArgs, undefined, TClient> {\n server: <TServer>(\n serverImpl: (...args: TArgs) => TServer,\n ) => IsomorphicFn<TArgs, TServer, TClient>\n}\n\nexport interface IsomorphicFnBase {\n server: <TArgs extends Array<any>, TServer>(\n serverImpl: (...args: TArgs) => TServer,\n ) => ServerOnlyFn<TArgs, TServer>\n client: <TArgs extends Array<any>, TClient>(\n clientImpl: (...args: TArgs) => TClient,\n ) => ClientOnlyFn<TArgs, TClient>\n}\n\n// this is a dummy function, it will be replaced by the transformer\n// if we use `createIsomorphicFn` in this library itself, vite tries to execute it before the transformer runs\n// therefore we must return a dummy function that allows calling `server` and `client` method chains.\nexport function createIsomorphicFn(): IsomorphicFnBase {\n const fn = () => undefined\n return Object.assign(fn, {\n server: () => ({ client: () => () => {} }),\n client: () => ({ server: () => () => {} }),\n }) as any\n}\n"],"names":[],"mappings":"AAuCO,SAAS,qBAAuC;AACrD,QAAM,KAAK,MAAM;AACjB,SAAO,OAAO,OAAO,IAAI;AAAA,IACvB,QAAQ,OAAO,EAAE,QAAQ,MAAM,MAAM;AAAA,IAAC;IACtC,QAAQ,OAAO,EAAE,QAAQ,MAAM,MAAM;AAAA,IAAC,EAAA;AAAA,EAAE,CACzC;AACH;"} | ||
| {"version":3,"file":"createIsomorphicFn.js","names":[],"sources":["../../src/createIsomorphicFn.ts"],"sourcesContent":["// a function that can have different implementations on the client and server.\n// implementations not provided will default to a no-op function.\n\nexport type IsomorphicFn<\n TArgs extends Array<any> = [],\n TServer = undefined,\n TClient = undefined,\n> = (...args: TArgs) => TServer | TClient\n\nexport interface ServerOnlyFn<\n TArgs extends Array<any>,\n TServer,\n> extends IsomorphicFn<TArgs, TServer> {\n client: <TClient>(\n clientImpl: (...args: TArgs) => TClient,\n ) => IsomorphicFn<TArgs, TServer, TClient>\n}\n\nexport interface ClientOnlyFn<\n TArgs extends Array<any>,\n TClient,\n> extends IsomorphicFn<TArgs, undefined, TClient> {\n server: <TServer>(\n serverImpl: (...args: TArgs) => TServer,\n ) => IsomorphicFn<TArgs, TServer, TClient>\n}\n\nexport interface IsomorphicFnBase {\n server: <TArgs extends Array<any>, TServer>(\n serverImpl: (...args: TArgs) => TServer,\n ) => ServerOnlyFn<TArgs, TServer>\n client: <TArgs extends Array<any>, TClient>(\n clientImpl: (...args: TArgs) => TClient,\n ) => ClientOnlyFn<TArgs, TClient>\n}\n\n// this is a dummy function, it will be replaced by the transformer\n// if we use `createIsomorphicFn` in this library itself, vite tries to execute it before the transformer runs\n// therefore we must return a dummy function that allows calling `server` and `client` method chains.\nexport function createIsomorphicFn(): IsomorphicFnBase {\n const fn = () => undefined\n return Object.assign(fn, {\n server: () => ({ client: () => () => {} }),\n client: () => ({ server: () => () => {} }),\n }) as any\n}\n"],"mappings":";AAuCA,SAAgB,qBAAuC;CACrD,MAAM,WAAW,KAAA;AACjB,QAAO,OAAO,OAAO,IAAI;EACvB,eAAe,EAAE,oBAAoB,IAAI;EACzC,eAAe,EAAE,oBAAoB,IAAI;EAC1C,CAAC"} |
@@ -1,7 +0,7 @@ | ||
| const createServerOnlyFn = (fn) => fn; | ||
| const createClientOnlyFn = (fn) => fn; | ||
| export { | ||
| createClientOnlyFn, | ||
| createServerOnlyFn | ||
| }; | ||
| //# sourceMappingURL=envOnly.js.map | ||
| //#region src/envOnly.ts | ||
| var createServerOnlyFn = (fn) => fn; | ||
| var createClientOnlyFn = (fn) => fn; | ||
| //#endregion | ||
| export { createClientOnlyFn, createServerOnlyFn }; | ||
| //# sourceMappingURL=envOnly.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"envOnly.js","sources":["../../src/envOnly.ts"],"sourcesContent":["type EnvOnlyFn = <TFn extends (...args: Array<any>) => any>(fn: TFn) => TFn\n\n// A function that will only be available in the server build\n// If called on the client, it will throw an error\nexport const createServerOnlyFn: EnvOnlyFn = (fn) => fn\n\n// A function that will only be available in the client build\n// If called on the server, it will throw an error\nexport const createClientOnlyFn: EnvOnlyFn = (fn) => fn\n"],"names":[],"mappings":"AAIO,MAAM,qBAAgC,CAAC,OAAO;AAI9C,MAAM,qBAAgC,CAAC,OAAO;"} | ||
| {"version":3,"file":"envOnly.js","names":[],"sources":["../../src/envOnly.ts"],"sourcesContent":["type EnvOnlyFn = <TFn extends (...args: Array<any>) => any>(fn: TFn) => TFn\n\n// A function that will only be available in the server build\n// If called on the client, it will throw an error\nexport const createServerOnlyFn: EnvOnlyFn = (fn) => fn\n\n// A function that will only be available in the client build\n// If called on the server, it will throw an error\nexport const createClientOnlyFn: EnvOnlyFn = (fn) => fn\n"],"mappings":";AAIA,IAAa,sBAAiC,OAAO;AAIrD,IAAa,sBAAiC,OAAO"} |
| import { createIsomorphicFn } from "./createIsomorphicFn.js"; | ||
| import { createClientOnlyFn, createServerOnlyFn } from "./envOnly.js"; | ||
| export { | ||
| createClientOnlyFn, | ||
| createIsomorphicFn, | ||
| createServerOnlyFn | ||
| }; | ||
| //# sourceMappingURL=index.js.map | ||
| export { createClientOnlyFn, createIsomorphicFn, createServerOnlyFn }; |
+1
-1
| { | ||
| "name": "@tanstack/start-fn-stubs", | ||
| "version": "1.161.5", | ||
| "version": "1.161.6", | ||
| "description": "Stub functions for TanStack Start isomorphic and environment-specific functions", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"} |
9579
-1.4%13
-7.14%92
-9.8%