@tanstack/start-server-core 1.121.16 → 1.121.17

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.
Files changed (79) hide show
  1. package/package.json +4 -4
  2. package/dist/cjs/createRequestHandler.cjs +0 -50
  3. package/dist/cjs/createRequestHandler.cjs.map +0 -1
  4. package/dist/cjs/createRequestHandler.d.cts +0 -8
  5. package/dist/cjs/createStartHandler.cjs +0 -313
  6. package/dist/cjs/createStartHandler.cjs.map +0 -1
  7. package/dist/cjs/createStartHandler.d.cts +0 -7
  8. package/dist/cjs/h3.cjs +0 -355
  9. package/dist/cjs/h3.cjs.map +0 -1
  10. package/dist/cjs/h3.d.cts +0 -109
  11. package/dist/cjs/handlerCallback.cjs +0 -7
  12. package/dist/cjs/handlerCallback.cjs.map +0 -1
  13. package/dist/cjs/handlerCallback.d.cts +0 -9
  14. package/dist/cjs/index.cjs +0 -244
  15. package/dist/cjs/index.cjs.map +0 -1
  16. package/dist/cjs/index.d.cts +0 -12
  17. package/dist/cjs/loadVirtualModule.cjs +0 -39
  18. package/dist/cjs/loadVirtualModule.cjs.map +0 -1
  19. package/dist/cjs/loadVirtualModule.d.cts +0 -6
  20. package/dist/cjs/router-manifest.cjs +0 -49
  21. package/dist/cjs/router-manifest.cjs.map +0 -1
  22. package/dist/cjs/router-manifest.d.cts +0 -16
  23. package/dist/cjs/server-functions-handler.cjs +0 -148
  24. package/dist/cjs/server-functions-handler.cjs.map +0 -1
  25. package/dist/cjs/server-functions-handler.d.cts +0 -3
  26. package/dist/cjs/serverRoute.cjs +0 -102
  27. package/dist/cjs/serverRoute.cjs.map +0 -1
  28. package/dist/cjs/serverRoute.d.cts +0 -120
  29. package/dist/cjs/ssr-server.cjs +0 -247
  30. package/dist/cjs/ssr-server.cjs.map +0 -1
  31. package/dist/cjs/ssr-server.d.cts +0 -29
  32. package/dist/cjs/transformStreamWithRouter.cjs +0 -183
  33. package/dist/cjs/transformStreamWithRouter.cjs.map +0 -1
  34. package/dist/cjs/transformStreamWithRouter.d.cts +0 -6
  35. package/dist/cjs/tsrScript.cjs +0 -4
  36. package/dist/cjs/tsrScript.cjs.map +0 -1
  37. package/dist/cjs/tsrScript.d.cts +0 -1
  38. package/dist/cjs/virtual-modules.cjs +0 -9
  39. package/dist/cjs/virtual-modules.cjs.map +0 -1
  40. package/dist/cjs/virtual-modules.d.cts +0 -10
  41. package/dist/esm/createRequestHandler.d.ts +0 -8
  42. package/dist/esm/createRequestHandler.js +0 -50
  43. package/dist/esm/createRequestHandler.js.map +0 -1
  44. package/dist/esm/createStartHandler.d.ts +0 -7
  45. package/dist/esm/createStartHandler.js +0 -313
  46. package/dist/esm/createStartHandler.js.map +0 -1
  47. package/dist/esm/h3.d.ts +0 -109
  48. package/dist/esm/h3.js +0 -248
  49. package/dist/esm/h3.js.map +0 -1
  50. package/dist/esm/handlerCallback.d.ts +0 -9
  51. package/dist/esm/handlerCallback.js +0 -7
  52. package/dist/esm/handlerCallback.js.map +0 -1
  53. package/dist/esm/index.d.ts +0 -12
  54. package/dist/esm/index.js +0 -136
  55. package/dist/esm/index.js.map +0 -1
  56. package/dist/esm/loadVirtualModule.d.ts +0 -6
  57. package/dist/esm/loadVirtualModule.js +0 -17
  58. package/dist/esm/loadVirtualModule.js.map +0 -1
  59. package/dist/esm/router-manifest.d.ts +0 -16
  60. package/dist/esm/router-manifest.js +0 -49
  61. package/dist/esm/router-manifest.js.map +0 -1
  62. package/dist/esm/server-functions-handler.d.ts +0 -3
  63. package/dist/esm/server-functions-handler.js +0 -148
  64. package/dist/esm/server-functions-handler.js.map +0 -1
  65. package/dist/esm/serverRoute.d.ts +0 -120
  66. package/dist/esm/serverRoute.js +0 -102
  67. package/dist/esm/serverRoute.js.map +0 -1
  68. package/dist/esm/ssr-server.d.ts +0 -29
  69. package/dist/esm/ssr-server.js +0 -247
  70. package/dist/esm/ssr-server.js.map +0 -1
  71. package/dist/esm/transformStreamWithRouter.d.ts +0 -6
  72. package/dist/esm/transformStreamWithRouter.js +0 -183
  73. package/dist/esm/transformStreamWithRouter.js.map +0 -1
  74. package/dist/esm/tsrScript.d.ts +0 -1
  75. package/dist/esm/tsrScript.js +0 -5
  76. package/dist/esm/tsrScript.js.map +0 -1
  77. package/dist/esm/virtual-modules.d.ts +0 -10
  78. package/dist/esm/virtual-modules.js +0 -9
  79. package/dist/esm/virtual-modules.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverRoute.cjs","sources":["../../src/serverRoute.ts"],"sourcesContent":["import { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'\nimport type {\n Assign,\n Constrain,\n Expand,\n ResolveParams,\n RouteConstraints,\n TrimPathRight,\n} from '@tanstack/router-core'\nimport type {\n AnyRequestMiddleware,\n AssignAllServerContext,\n} from '@tanstack/start-client-core'\n\nexport function createServerFileRoute<\n TFilePath extends keyof ServerFileRoutesByPath,\n TParentRoute extends\n AnyServerRouteWithTypes = ServerFileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = ServerFileRoutesByPath[TFilePath]['id'],\n TPath extends\n RouteConstraints['TPath'] = ServerFileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = ServerFileRoutesByPath[TFilePath]['fullPath'],\n TChildren = ServerFileRoutesByPath[TFilePath]['children'],\n>(_: TFilePath): ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren> {\n return createServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>(\n undefined,\n )\n}\n\nexport interface ServerFileRoutesByPath {}\n\nexport interface ServerRouteOptions<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n> {\n id: TId\n path: TPath\n pathname: TFullPath\n originalIndex: number\n getParentRoute?: () => TParentRoute\n middleware?: Constrain<TMiddlewares, ReadonlyArray<AnyRequestMiddleware>>\n methods?: Record<\n string,\n ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, any, any>\n >\n caseSensitive?: boolean\n}\n\nexport type ServerRouteManifest = {\n middleware: boolean\n methods: Record<string, { middleware: boolean }>\n}\n\nexport function createServerRoute<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TChildren,\n>(\n __?: never,\n __opts?: Partial<\n ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, undefined>\n >,\n): ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren> {\n const options = __opts || {}\n\n const route: ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren> = {\n path: '' as TPath,\n id: '' as TId,\n fullPath: '' as TFullPath,\n to: '' as TrimPathRight<TFullPath>,\n options: options as ServerRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n any\n >,\n parentRoute: undefined as unknown as TParentRoute,\n _types: {} as ServerRouteTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n undefined,\n undefined\n >,\n // children: undefined as TChildren,\n middleware: (middlewares) =>\n createServerRoute(undefined, {\n ...options,\n middleware: middlewares,\n }) as never,\n methods: (methodsOrGetMethods) => {\n const methods = (() => {\n if (typeof methodsOrGetMethods === 'function') {\n return methodsOrGetMethods(createMethodBuilder())\n }\n\n return methodsOrGetMethods\n })()\n\n return createServerRoute(undefined, {\n ...__opts,\n methods: methods as never,\n }) as never\n },\n update: (opts) =>\n createServerRoute(undefined, {\n ...options,\n ...opts,\n }),\n init: (opts: { originalIndex: number }): void => {\n options.originalIndex = opts.originalIndex\n\n const isRoot = !options.path && !options.id\n\n route.parentRoute = options.getParentRoute?.() as TParentRoute\n\n if (isRoot) {\n route.path = rootRouteId as TPath\n } else if (!(route.parentRoute as any)) {\n throw new Error(\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a ServerRoute instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n route.parentRoute.id === rootRouteId ? '' : route.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([route.parentRoute.fullPath, path])\n\n route.path = path as TPath\n route.id = id as TId\n route.fullPath = fullPath as TFullPath\n route.to = fullPath as TrimPathRight<TFullPath>\n },\n\n _addFileChildren: (children) => {\n if (Array.isArray(children)) {\n route.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n route.children = Object.values(children) as TChildren\n }\n\n return route\n },\n\n _addFileTypes: <TFileTypes>() => route,\n }\n\n return route\n}\n\n// TODO this needs to be restricted to only allow middleware, no methods\n// TODO we also need to restrict pathless server routes to only allow middleware\nexport const createServerRootRoute = createServerRoute\n\nexport type ServerRouteAddFileChildrenFn<\n in out TParentRoute extends AnyServerRouteWithTypes,\n in out TId extends RouteConstraints['TId'],\n in out TPath extends RouteConstraints['TPath'],\n in out TFullPath extends RouteConstraints['TFullPath'],\n in out TMiddlewares,\n in out TMethods,\n in out TChildren,\n> = (\n children: TChildren,\n) => ServerRouteWithTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods,\n TChildren\n>\n\nconst createMethodBuilder = <\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n>(\n __opts?: ServerRouteMethodBuilderOptions<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n unknown,\n unknown\n >,\n): ServerRouteMethodBuilder<TParentRoute, TFullPath, TMiddlewares> => {\n return {\n _options: (__opts || {}) as never,\n _types: {} as never,\n middleware: (middlewares) =>\n createMethodBuilder({\n ...__opts,\n middlewares,\n }) as never,\n handler: (handler) =>\n createMethodBuilder({\n ...__opts,\n handler: handler as never,\n }) as never,\n }\n}\n\nexport interface ServerRouteMethodBuilderOptions<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse,\n> {\n handler?: ServerRouteMethodHandlerFn<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n >\n middlewares?: Constrain<\n TMethodMiddlewares,\n ReadonlyArray<AnyRequestMiddleware>\n >\n}\n\nexport type CreateServerFileRoute<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TChildren,\n> = () => ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>\n\nexport type AnyServerRouteWithTypes = ServerRouteWithTypes<\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\nexport interface ServerRouteWithTypes<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n TMethods,\n TChildren,\n> {\n _types: ServerRouteTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods\n >\n path: TPath\n id: TId\n fullPath: TFullPath\n to: TrimPathRight<TFullPath>\n parentRoute: TParentRoute\n children?: TChildren\n options: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, TMiddlewares>\n update: (\n opts: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, undefined>,\n ) => ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>\n init: (opts: { originalIndex: number }) => void\n _addFileChildren: ServerRouteAddFileChildrenFn<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods,\n TChildren\n >\n _addFileTypes: () => ServerRouteWithTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods,\n TChildren\n >\n}\n\nexport interface ServerRouteTypes<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n TMethods,\n> {\n id: TId\n path: TPath\n fullPath: TFullPath\n middlewares: TMiddlewares\n methods: TMethods\n parentRoute: TParentRoute\n allContext: ResolveAllServerContext<TParentRoute, TMiddlewares>\n}\n\nexport type ResolveAllServerContext<\n TParentRoute extends AnyServerRouteWithTypes,\n TMiddlewares,\n> = unknown extends TParentRoute\n ? AssignAllServerContext<TMiddlewares>\n : Assign<\n TParentRoute['_types']['allContext'],\n AssignAllServerContext<TMiddlewares>\n >\n\nexport type AnyServerRoute = AnyServerRouteWithTypes\n\nexport interface ServerRoute<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TChildren,\n> extends ServerRouteWithTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n undefined,\n undefined,\n TChildren\n >,\n ServerRouteMiddleware<TParentRoute, TId, TPath, TFullPath, TChildren>,\n ServerRouteMethods<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n undefined,\n TChildren\n > {}\n\nexport interface ServerRouteMiddleware<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TChildren,\n> {\n middleware: <const TNewMiddleware>(\n middleware: Constrain<TNewMiddleware, ReadonlyArray<AnyRequestMiddleware>>,\n ) => ServerRouteAfterMiddleware<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TNewMiddleware,\n TChildren\n >\n}\n\nexport interface ServerRouteAfterMiddleware<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n TChildren,\n> extends ServerRouteWithTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n undefined,\n TChildren\n >,\n ServerRouteMethods<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TChildren\n > {}\n\nexport interface ServerRouteMethods<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n TChildren,\n> {\n methods: <const TMethods>(\n methodsOrGetMethods: Constrain<\n TMethods,\n ServerRouteMethodsOptions<TParentRoute, TFullPath, TMiddlewares>\n >,\n ) => ServerRouteAfterMethods<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods,\n TChildren\n >\n}\n\nexport type ServerRouteMethodsOptions<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n> =\n | ServerRouteMethodsRecord<TParentRoute, TFullPath, TMiddlewares>\n | ((\n api: ServerRouteMethodBuilder<TParentRoute, TFullPath, TMiddlewares>,\n ) => ServerRouteMethodsRecord<TParentRoute, TFullPath, TMiddlewares>)\n\nexport interface ServerRouteMethodsRecord<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n> {\n GET?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n POST?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n PUT?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n PATCH?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n DELETE?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n OPTIONS?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n HEAD?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>\n}\n\nexport type ServerRouteMethodRecordValue<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n> =\n | ServerRouteMethodHandlerFn<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n undefined,\n any\n >\n | AnyRouteMethodsBuilder\n\nexport type ServerRouteVerb = (typeof ServerRouteVerbs)[number]\n\nexport const ServerRouteVerbs = [\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n] as const\n\nexport type ServerRouteMethodHandlerFn<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse,\n> = (\n ctx: ServerRouteMethodHandlerCtx<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares\n >,\n) => TResponse | Promise<TResponse>\n\nexport interface ServerRouteMethodHandlerCtx<\n in out TParentRoute extends AnyServerRouteWithTypes,\n in out TFullPath extends string,\n in out TMiddlewares,\n in out TMethodMiddlewares,\n> {\n context: Expand<\n AssignAllMethodContext<TParentRoute, TMiddlewares, TMethodMiddlewares>\n >\n request: Request\n params: Expand<ResolveParams<TFullPath>>\n pathname: TFullPath\n}\n\nexport type MergeMethodMiddlewares<TMiddlewares, TMethodMiddlewares> =\n TMiddlewares extends ReadonlyArray<any>\n ? TMethodMiddlewares extends ReadonlyArray<any>\n ? readonly [...TMiddlewares, ...TMethodMiddlewares]\n : TMiddlewares\n : TMethodMiddlewares\n\nexport type AssignAllMethodContext<\n TParentRoute extends AnyServerRouteWithTypes,\n TMiddlewares,\n TMethodMiddlewares,\n> = ResolveAllServerContext<\n TParentRoute,\n MergeMethodMiddlewares<TMiddlewares, TMethodMiddlewares>\n>\n\nexport type AnyRouteMethodsBuilder = ServerRouteMethodBuilderWithTypes<\n any,\n any,\n any,\n any,\n any\n>\n\nexport interface ServerRouteMethodBuilder<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n> extends ServerRouteMethodBuilderWithTypes<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n undefined,\n undefined\n >,\n ServerRouteMethodBuilderMiddleware<TParentRoute, TFullPath, TMiddlewares>,\n ServerRouteMethodBuilderHandler<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n undefined\n > {}\n\nexport interface ServerRouteMethodBuilderWithTypes<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse,\n> {\n _options: ServerRouteMethodBuilderOptions<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n >\n _types: ServerRouteMethodBuilderTypes<\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n >\n}\n\nexport interface ServerRouteMethodBuilderTypes<\n in out TFullPath extends string,\n in out TMiddlewares,\n in out TMethodMiddlewares,\n in out TResponse,\n> {\n middlewares: TMiddlewares\n methodMiddleware: TMethodMiddlewares\n fullPath: TFullPath\n response: TResponse\n}\n\nexport interface ServerRouteMethodBuilderMiddleware<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n> {\n middleware: <const TNewMethodMiddlewares>(\n middleware: Constrain<\n TNewMethodMiddlewares,\n ReadonlyArray<AnyRequestMiddleware>\n >,\n ) => ServerRouteMethodBuilderAfterMiddleware<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TNewMethodMiddlewares\n >\n}\n\nexport interface ServerRouteMethodBuilderAfterMiddleware<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n> extends ServerRouteMethodBuilderWithTypes<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n undefined\n >,\n ServerRouteMethodBuilderHandler<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares\n > {}\n\nexport interface ServerRouteMethodBuilderHandler<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n> {\n handler: <TResponse>(\n handler: ServerRouteMethodHandlerFn<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n >,\n ) => ServerRouteMethodBuilderAfterHandler<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n >\n}\n\nexport interface ServerRouteMethodBuilderAfterHandler<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse,\n> extends ServerRouteMethodBuilderWithTypes<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n TResponse\n > {\n opts: ServerRouteMethod<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares\n >\n}\n\nexport interface ServerRouteMethod<\n TParentRoute extends AnyServerRouteWithTypes,\n TFullPath extends string,\n TMiddlewares,\n TMethodMiddlewares,\n> {\n middleware?: Constrain<TMiddlewares, Array<AnyRequestMiddleware>>\n handler?: ServerRouteMethodHandlerFn<\n TParentRoute,\n TFullPath,\n TMiddlewares,\n TMethodMiddlewares,\n undefined\n >\n}\n\nexport interface ServerRouteAfterMethods<\n TParentRoute extends AnyServerRouteWithTypes,\n TId extends RouteConstraints['TId'],\n TPath extends RouteConstraints['TPath'],\n TFullPath extends RouteConstraints['TFullPath'],\n TMiddlewares,\n TMethods,\n TChildren,\n> extends ServerRouteWithTypes<\n TParentRoute,\n TId,\n TPath,\n TFullPath,\n TMiddlewares,\n TMethods,\n TChildren\n > {\n options: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, TMiddlewares>\n}\n"],"names":["rootRouteId","trimPathLeft","joinPaths"],"mappings":";;;AAcO,SAAS,sBAUd,GAA2E;AACpE,SAAA,kBAEP;AACF;AA6BgB,SAAA,kBAOd,IACA,QAG6D;AACvD,QAAA,UAAU,UAAU,CAAC;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,aAAa;AACtB,aAAKE,WAAU,UAAA,CAAC,KAAK,EAAE,CAAC;AAAA,MAAA;AAGpB,YAAA,WACJ,OAAOF,WAAA,cAAc,MAAME,WAAAA,UAAU,CAAC,MAAM,YAAY,UAAU,IAAI,CAAC;AAEzE,YAAM,OAAO;AACb,YAAM,KAAK;AACX,YAAM,WAAW;AACjB,YAAM,KAAK;AAAA,IACb;AAAA,IAEA,kBAAkB,CAAC,aAAa;AAC1B,UAAA,MAAM,QAAQ,QAAQ,GAAG;AAC3B,cAAM,WAAW;AAAA,MAAA;AAGnB,UAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AAC/C,cAAA,WAAW,OAAO,OAAO,QAAQ;AAAA,MAAA;AAGlC,aAAA;AAAA,IACT;AAAA,IAEA,eAAe,MAAkB;AAAA,EACnC;AAEO,SAAA;AACT;AAIO,MAAM,wBAAwB;AAsBrC,MAAM,sBAAsB,CAK1B,WAOoE;AAC7D,SAAA;AAAA,IACL,UAAW,UAAU,CAAC;AAAA,IACtB,QAAQ,CAAC;AAAA,IACT,YAAY,CAAC,gBACX,oBAAoB;AAAA,MAClB,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,IACH,SAAS,CAAC,YACR,oBAAoB;AAAA,MAClB,GAAG;AAAA,MACH;AAAA,IACD,CAAA;AAAA,EACL;AACF;;;;"}
@@ -1,120 +0,0 @@
1
- import { Assign, Constrain, Expand, ResolveParams, RouteConstraints, TrimPathRight } from '@tanstack/router-core';
2
- import { AnyRequestMiddleware, AssignAllServerContext } from '@tanstack/start-client-core';
3
- export declare function createServerFileRoute<TFilePath extends keyof ServerFileRoutesByPath, TParentRoute extends AnyServerRouteWithTypes = ServerFileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = ServerFileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = ServerFileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = ServerFileRoutesByPath[TFilePath]['fullPath'], TChildren = ServerFileRoutesByPath[TFilePath]['children']>(_: TFilePath): ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>;
4
- export interface ServerFileRoutesByPath {
5
- }
6
- export interface ServerRouteOptions<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares> {
7
- id: TId;
8
- path: TPath;
9
- pathname: TFullPath;
10
- originalIndex: number;
11
- getParentRoute?: () => TParentRoute;
12
- middleware?: Constrain<TMiddlewares, ReadonlyArray<AnyRequestMiddleware>>;
13
- methods?: Record<string, ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, any, any>>;
14
- caseSensitive?: boolean;
15
- }
16
- export type ServerRouteManifest = {
17
- middleware: boolean;
18
- methods: Record<string, {
19
- middleware: boolean;
20
- }>;
21
- };
22
- export declare function createServerRoute<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TChildren>(__?: never, __opts?: Partial<ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, undefined>>): ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>;
23
- export declare const createServerRootRoute: typeof createServerRoute;
24
- export type ServerRouteAddFileChildrenFn<in out TParentRoute extends AnyServerRouteWithTypes, in out TId extends RouteConstraints['TId'], in out TPath extends RouteConstraints['TPath'], in out TFullPath extends RouteConstraints['TFullPath'], in out TMiddlewares, in out TMethods, in out TChildren> = (children: TChildren) => ServerRouteWithTypes<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods, TChildren>;
25
- export interface ServerRouteMethodBuilderOptions<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares, TResponse> {
26
- handler?: ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, TResponse>;
27
- middlewares?: Constrain<TMethodMiddlewares, ReadonlyArray<AnyRequestMiddleware>>;
28
- }
29
- export type CreateServerFileRoute<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TChildren> = () => ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>;
30
- export type AnyServerRouteWithTypes = ServerRouteWithTypes<any, any, any, any, any, any, any>;
31
- export interface ServerRouteWithTypes<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares, TMethods, TChildren> {
32
- _types: ServerRouteTypes<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods>;
33
- path: TPath;
34
- id: TId;
35
- fullPath: TFullPath;
36
- to: TrimPathRight<TFullPath>;
37
- parentRoute: TParentRoute;
38
- children?: TChildren;
39
- options: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, TMiddlewares>;
40
- update: (opts: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, undefined>) => ServerRoute<TParentRoute, TId, TPath, TFullPath, TChildren>;
41
- init: (opts: {
42
- originalIndex: number;
43
- }) => void;
44
- _addFileChildren: ServerRouteAddFileChildrenFn<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods, TChildren>;
45
- _addFileTypes: () => ServerRouteWithTypes<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods, TChildren>;
46
- }
47
- export interface ServerRouteTypes<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares, TMethods> {
48
- id: TId;
49
- path: TPath;
50
- fullPath: TFullPath;
51
- middlewares: TMiddlewares;
52
- methods: TMethods;
53
- parentRoute: TParentRoute;
54
- allContext: ResolveAllServerContext<TParentRoute, TMiddlewares>;
55
- }
56
- export type ResolveAllServerContext<TParentRoute extends AnyServerRouteWithTypes, TMiddlewares> = unknown extends TParentRoute ? AssignAllServerContext<TMiddlewares> : Assign<TParentRoute['_types']['allContext'], AssignAllServerContext<TMiddlewares>>;
57
- export type AnyServerRoute = AnyServerRouteWithTypes;
58
- export interface ServerRoute<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TChildren> extends ServerRouteWithTypes<TParentRoute, TId, TPath, TFullPath, undefined, undefined, TChildren>, ServerRouteMiddleware<TParentRoute, TId, TPath, TFullPath, TChildren>, ServerRouteMethods<TParentRoute, TId, TPath, TFullPath, undefined, TChildren> {
59
- }
60
- export interface ServerRouteMiddleware<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TChildren> {
61
- middleware: <const TNewMiddleware>(middleware: Constrain<TNewMiddleware, ReadonlyArray<AnyRequestMiddleware>>) => ServerRouteAfterMiddleware<TParentRoute, TId, TPath, TFullPath, TNewMiddleware, TChildren>;
62
- }
63
- export interface ServerRouteAfterMiddleware<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares, TChildren> extends ServerRouteWithTypes<TParentRoute, TId, TPath, TFullPath, TMiddlewares, undefined, TChildren>, ServerRouteMethods<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TChildren> {
64
- }
65
- export interface ServerRouteMethods<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares, TChildren> {
66
- methods: <const TMethods>(methodsOrGetMethods: Constrain<TMethods, ServerRouteMethodsOptions<TParentRoute, TFullPath, TMiddlewares>>) => ServerRouteAfterMethods<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods, TChildren>;
67
- }
68
- export type ServerRouteMethodsOptions<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares> = ServerRouteMethodsRecord<TParentRoute, TFullPath, TMiddlewares> | ((api: ServerRouteMethodBuilder<TParentRoute, TFullPath, TMiddlewares>) => ServerRouteMethodsRecord<TParentRoute, TFullPath, TMiddlewares>);
69
- export interface ServerRouteMethodsRecord<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares> {
70
- GET?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
71
- POST?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
72
- PUT?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
73
- PATCH?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
74
- DELETE?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
75
- OPTIONS?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
76
- HEAD?: ServerRouteMethodRecordValue<TParentRoute, TFullPath, TMiddlewares>;
77
- }
78
- export type ServerRouteMethodRecordValue<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares> = ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, undefined, any> | AnyRouteMethodsBuilder;
79
- export type ServerRouteVerb = (typeof ServerRouteVerbs)[number];
80
- export declare const ServerRouteVerbs: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
81
- export type ServerRouteMethodHandlerFn<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares, TResponse> = (ctx: ServerRouteMethodHandlerCtx<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares>) => TResponse | Promise<TResponse>;
82
- export interface ServerRouteMethodHandlerCtx<in out TParentRoute extends AnyServerRouteWithTypes, in out TFullPath extends string, in out TMiddlewares, in out TMethodMiddlewares> {
83
- context: Expand<AssignAllMethodContext<TParentRoute, TMiddlewares, TMethodMiddlewares>>;
84
- request: Request;
85
- params: Expand<ResolveParams<TFullPath>>;
86
- pathname: TFullPath;
87
- }
88
- export type MergeMethodMiddlewares<TMiddlewares, TMethodMiddlewares> = TMiddlewares extends ReadonlyArray<any> ? TMethodMiddlewares extends ReadonlyArray<any> ? readonly [...TMiddlewares, ...TMethodMiddlewares] : TMiddlewares : TMethodMiddlewares;
89
- export type AssignAllMethodContext<TParentRoute extends AnyServerRouteWithTypes, TMiddlewares, TMethodMiddlewares> = ResolveAllServerContext<TParentRoute, MergeMethodMiddlewares<TMiddlewares, TMethodMiddlewares>>;
90
- export type AnyRouteMethodsBuilder = ServerRouteMethodBuilderWithTypes<any, any, any, any, any>;
91
- export interface ServerRouteMethodBuilder<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares> extends ServerRouteMethodBuilderWithTypes<TParentRoute, TFullPath, TMiddlewares, undefined, undefined>, ServerRouteMethodBuilderMiddleware<TParentRoute, TFullPath, TMiddlewares>, ServerRouteMethodBuilderHandler<TParentRoute, TFullPath, TMiddlewares, undefined> {
92
- }
93
- export interface ServerRouteMethodBuilderWithTypes<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares, TResponse> {
94
- _options: ServerRouteMethodBuilderOptions<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, TResponse>;
95
- _types: ServerRouteMethodBuilderTypes<TFullPath, TMiddlewares, TMethodMiddlewares, TResponse>;
96
- }
97
- export interface ServerRouteMethodBuilderTypes<in out TFullPath extends string, in out TMiddlewares, in out TMethodMiddlewares, in out TResponse> {
98
- middlewares: TMiddlewares;
99
- methodMiddleware: TMethodMiddlewares;
100
- fullPath: TFullPath;
101
- response: TResponse;
102
- }
103
- export interface ServerRouteMethodBuilderMiddleware<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares> {
104
- middleware: <const TNewMethodMiddlewares>(middleware: Constrain<TNewMethodMiddlewares, ReadonlyArray<AnyRequestMiddleware>>) => ServerRouteMethodBuilderAfterMiddleware<TParentRoute, TFullPath, TMiddlewares, TNewMethodMiddlewares>;
105
- }
106
- export interface ServerRouteMethodBuilderAfterMiddleware<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares> extends ServerRouteMethodBuilderWithTypes<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, undefined>, ServerRouteMethodBuilderHandler<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares> {
107
- }
108
- export interface ServerRouteMethodBuilderHandler<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares> {
109
- handler: <TResponse>(handler: ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, TResponse>) => ServerRouteMethodBuilderAfterHandler<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, TResponse>;
110
- }
111
- export interface ServerRouteMethodBuilderAfterHandler<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares, TResponse> extends ServerRouteMethodBuilderWithTypes<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, TResponse> {
112
- opts: ServerRouteMethod<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares>;
113
- }
114
- export interface ServerRouteMethod<TParentRoute extends AnyServerRouteWithTypes, TFullPath extends string, TMiddlewares, TMethodMiddlewares> {
115
- middleware?: Constrain<TMiddlewares, Array<AnyRequestMiddleware>>;
116
- handler?: ServerRouteMethodHandlerFn<TParentRoute, TFullPath, TMiddlewares, TMethodMiddlewares, undefined>;
117
- }
118
- export interface ServerRouteAfterMethods<TParentRoute extends AnyServerRouteWithTypes, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TMiddlewares, TMethods, TChildren> extends ServerRouteWithTypes<TParentRoute, TId, TPath, TFullPath, TMiddlewares, TMethods, TChildren> {
119
- options: ServerRouteOptions<TParentRoute, TId, TPath, TFullPath, TMiddlewares>;
120
- }
@@ -1,247 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const warning = require("tiny-warning");
4
- const routerCore = require("@tanstack/router-core");
5
- const jsesc = require("jsesc");
6
- const startClientCore = require("@tanstack/start-client-core");
7
- const tsrScript = require("./tsrScript.cjs");
8
- function attachRouterServerSsrUtils(router, manifest) {
9
- router.ssr = {
10
- manifest,
11
- serializer: startClientCore.startSerializer
12
- };
13
- router.serverSsr = {
14
- injectedHtml: [],
15
- streamedKeys: /* @__PURE__ */ new Set(),
16
- injectHtml: (getHtml) => {
17
- const promise = Promise.resolve().then(getHtml);
18
- router.serverSsr.injectedHtml.push(promise);
19
- router.emit({
20
- type: "onInjectedHtml",
21
- promise
22
- });
23
- return promise.then(() => {
24
- });
25
- },
26
- injectScript: (getScript, opts) => {
27
- return router.serverSsr.injectHtml(async () => {
28
- const script = await getScript();
29
- return `<script class='tsr-once'>${script}${process.env.NODE_ENV === "development" && ((opts == null ? void 0 : opts.logScript) ?? true) ? `; console.info(\`Injected From Server:
30
- ${jsesc(script, { quotes: "backtick" })}\`)` : ""}; if (typeof __TSR_SSR__ !== 'undefined') __TSR_SSR__.cleanScripts()<\/script>`;
31
- });
32
- },
33
- streamValue: (key, value) => {
34
- warning(
35
- !router.serverSsr.streamedKeys.has(key),
36
- "Key has already been streamed: " + key
37
- );
38
- router.serverSsr.streamedKeys.add(key);
39
- router.serverSsr.injectScript(
40
- () => `__TSR_SSR__.streamedValues['${key}'] = { value: ${jsesc(
41
- router.ssr.serializer.stringify(value),
42
- {
43
- isScriptContext: true,
44
- wrap: true,
45
- json: true
46
- }
47
- )}}`
48
- );
49
- },
50
- onMatchSettled
51
- };
52
- router.serverSsr.injectScript(() => tsrScript, {
53
- logScript: false
54
- });
55
- }
56
- function dehydrateRouter(router) {
57
- var _a, _b, _c;
58
- const dehydratedRouter = {
59
- manifest: router.ssr.manifest,
60
- dehydratedData: (_b = (_a = router.options).dehydrate) == null ? void 0 : _b.call(_a),
61
- lastMatchId: ((_c = router.state.matches[router.state.matches.length - 1]) == null ? void 0 : _c.id) || ""
62
- };
63
- router.serverSsr.injectScript(
64
- () => `__TSR_SSR__.dehydrated = ${jsesc(
65
- router.ssr.serializer.stringify(dehydratedRouter),
66
- {
67
- isScriptContext: true,
68
- wrap: true,
69
- json: true
70
- }
71
- )}`
72
- );
73
- }
74
- function extractAsyncLoaderData(loaderData, ctx) {
75
- const extracted = [];
76
- const replaced = replaceBy(loaderData, (value, path) => {
77
- if (value instanceof ReadableStream) {
78
- const [copy1, copy2] = value.tee();
79
- const entry = {
80
- type: "stream",
81
- path,
82
- id: extracted.length,
83
- matchIndex: ctx.match.index,
84
- stream: copy2
85
- };
86
- extracted.push(entry);
87
- return copy1;
88
- } else if (value instanceof Promise) {
89
- const deferredPromise = routerCore.defer(value);
90
- const entry = {
91
- type: "promise",
92
- path,
93
- id: extracted.length,
94
- matchIndex: ctx.match.index,
95
- promise: deferredPromise
96
- };
97
- extracted.push(entry);
98
- }
99
- return value;
100
- });
101
- return { replaced, extracted };
102
- }
103
- function onMatchSettled(opts) {
104
- const { router, match } = opts;
105
- let extracted = void 0;
106
- let serializedLoaderData = void 0;
107
- if (match.loaderData !== void 0) {
108
- const result = extractAsyncLoaderData(match.loaderData, {
109
- match
110
- });
111
- match.loaderData = result.replaced;
112
- extracted = result.extracted;
113
- serializedLoaderData = extracted.reduce(
114
- (acc, entry) => {
115
- return deepImmutableSetByPath(acc, ["temp", ...entry.path], void 0);
116
- },
117
- { temp: result.replaced }
118
- ).temp;
119
- }
120
- const initCode = `__TSR_SSR__.initMatch(${jsesc(
121
- {
122
- id: match.id,
123
- __beforeLoadContext: router.ssr.serializer.stringify(
124
- match.__beforeLoadContext
125
- ),
126
- loaderData: router.ssr.serializer.stringify(serializedLoaderData),
127
- error: router.ssr.serializer.stringify(match.error),
128
- extracted: extracted == null ? void 0 : extracted.map((entry) => routerCore.pick(entry, ["type", "path"])),
129
- updatedAt: match.updatedAt,
130
- status: match.status
131
- },
132
- {
133
- isScriptContext: true,
134
- wrap: true,
135
- json: true
136
- }
137
- )})`;
138
- router.serverSsr.injectScript(() => initCode);
139
- if (extracted) {
140
- extracted.forEach((entry) => {
141
- if (entry.type === "promise") return injectPromise(entry);
142
- return injectStream(entry);
143
- });
144
- }
145
- function injectPromise(entry) {
146
- router.serverSsr.injectScript(async () => {
147
- await entry.promise;
148
- return `__TSR_SSR__.resolvePromise(${jsesc(
149
- {
150
- matchId: match.id,
151
- id: entry.id,
152
- promiseState: entry.promise[routerCore.TSR_DEFERRED_PROMISE]
153
- },
154
- {
155
- isScriptContext: true,
156
- wrap: true,
157
- json: true
158
- }
159
- )})`;
160
- });
161
- }
162
- function injectStream(entry) {
163
- router.serverSsr.injectHtml(async () => {
164
- try {
165
- const reader = entry.stream.getReader();
166
- let chunk = null;
167
- while (!(chunk = await reader.read()).done) {
168
- if (chunk.value) {
169
- const code = `__TSR_SSR__.injectChunk(${jsesc(
170
- {
171
- matchId: match.id,
172
- id: entry.id,
173
- chunk: chunk.value
174
- },
175
- {
176
- isScriptContext: true,
177
- wrap: true,
178
- json: true
179
- }
180
- )})`;
181
- router.serverSsr.injectScript(() => code);
182
- }
183
- }
184
- router.serverSsr.injectScript(
185
- () => `__TSR_SSR__.closeStream(${jsesc(
186
- {
187
- matchId: match.id,
188
- id: entry.id
189
- },
190
- {
191
- isScriptContext: true,
192
- wrap: true,
193
- json: true
194
- }
195
- )})`
196
- );
197
- } catch (err) {
198
- console.error("stream read error", err);
199
- }
200
- return "";
201
- });
202
- }
203
- }
204
- function deepImmutableSetByPath(obj, path, value) {
205
- if (path.length === 0) {
206
- return value;
207
- }
208
- const [key, ...rest] = path;
209
- if (Array.isArray(obj)) {
210
- return obj.map((item, i) => {
211
- if (i === Number(key)) {
212
- return deepImmutableSetByPath(item, rest, value);
213
- }
214
- return item;
215
- });
216
- }
217
- if (routerCore.isPlainObject(obj)) {
218
- return {
219
- ...obj,
220
- [key]: deepImmutableSetByPath(obj[key], rest, value)
221
- };
222
- }
223
- return obj;
224
- }
225
- function replaceBy(obj, cb, path = []) {
226
- if (routerCore.isPlainArray(obj)) {
227
- return obj.map((value, i) => replaceBy(value, cb, [...path, `${i}`]));
228
- }
229
- if (routerCore.isPlainObject(obj)) {
230
- const newObj2 = {};
231
- for (const key in obj) {
232
- newObj2[key] = replaceBy(obj[key], cb, [...path, key]);
233
- }
234
- return newObj2;
235
- }
236
- const newObj = cb(obj, path);
237
- if (newObj !== obj) {
238
- return newObj;
239
- }
240
- return obj;
241
- }
242
- exports.attachRouterServerSsrUtils = attachRouterServerSsrUtils;
243
- exports.dehydrateRouter = dehydrateRouter;
244
- exports.extractAsyncLoaderData = extractAsyncLoaderData;
245
- exports.onMatchSettled = onMatchSettled;
246
- exports.replaceBy = replaceBy;
247
- //# sourceMappingURL=ssr-server.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssr-server.cjs","sources":["../../src/ssr-server.ts"],"sourcesContent":["import { default as warning } from 'tiny-warning'\nimport {\n TSR_DEFERRED_PROMISE,\n defer,\n isPlainArray,\n isPlainObject,\n pick,\n} from '@tanstack/router-core'\nimport jsesc from 'jsesc'\nimport { startSerializer } from '@tanstack/start-client-core'\nimport minifiedTsrBootStrapScript from './tsrScript?script-string'\nimport type {\n ClientExtractedBaseEntry,\n DehydratedRouter,\n ResolvePromiseState,\n SsrMatch,\n} from '@tanstack/start-client-core'\nimport type {\n AnyRouteMatch,\n AnyRouter,\n DeferredPromise,\n Manifest,\n} from '@tanstack/router-core'\n\nexport type ServerExtractedEntry =\n | ServerExtractedStream\n | ServerExtractedPromise\n\nexport interface ServerExtractedBaseEntry extends ClientExtractedBaseEntry {\n id: number\n matchIndex: number\n}\n\nexport interface ServerExtractedStream extends ServerExtractedBaseEntry {\n type: 'stream'\n stream: ReadableStream\n}\n\nexport interface ServerExtractedPromise extends ServerExtractedBaseEntry {\n type: 'promise'\n promise: DeferredPromise<any>\n}\n\nexport function attachRouterServerSsrUtils(\n router: AnyRouter,\n manifest: Manifest | undefined,\n) {\n router.ssr = {\n manifest,\n serializer: startSerializer,\n }\n\n router.serverSsr = {\n injectedHtml: [],\n streamedKeys: new Set(),\n injectHtml: (getHtml) => {\n const promise = Promise.resolve().then(getHtml)\n router.serverSsr!.injectedHtml.push(promise)\n router.emit({\n type: 'onInjectedHtml',\n promise,\n })\n\n return promise.then(() => {})\n },\n injectScript: (getScript, opts) => {\n return router.serverSsr!.injectHtml(async () => {\n const script = await getScript()\n return `<script class='tsr-once'>${script}${\n process.env.NODE_ENV === 'development' && (opts?.logScript ?? true)\n ? `; console.info(\\`Injected From Server:\n${jsesc(script, { quotes: 'backtick' })}\\`)`\n : ''\n }; if (typeof __TSR_SSR__ !== 'undefined') __TSR_SSR__.cleanScripts()</script>`\n })\n },\n streamValue: (key, value) => {\n warning(\n !router.serverSsr!.streamedKeys.has(key),\n 'Key has already been streamed: ' + key,\n )\n\n router.serverSsr!.streamedKeys.add(key)\n router.serverSsr!.injectScript(\n () =>\n `__TSR_SSR__.streamedValues['${key}'] = { value: ${jsesc(\n router.ssr!.serializer.stringify(value),\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )}}`,\n )\n },\n onMatchSettled,\n }\n\n router.serverSsr.injectScript(() => minifiedTsrBootStrapScript, {\n logScript: false,\n })\n}\n\nexport function dehydrateRouter(router: AnyRouter) {\n const dehydratedRouter: DehydratedRouter = {\n manifest: router.ssr!.manifest,\n dehydratedData: router.options.dehydrate?.(),\n lastMatchId:\n router.state.matches[router.state.matches.length - 1]?.id || '',\n }\n\n router.serverSsr!.injectScript(\n () =>\n `__TSR_SSR__.dehydrated = ${jsesc(\n router.ssr!.serializer.stringify(dehydratedRouter),\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )}`,\n )\n}\n\nexport function extractAsyncLoaderData(\n loaderData: any,\n ctx: {\n match: AnyRouteMatch\n router: AnyRouter\n },\n) {\n const extracted: Array<ServerExtractedEntry> = []\n\n const replaced = replaceBy(loaderData, (value, path) => {\n // If it's a stream, we need to tee it so we can read it multiple times\n if (value instanceof ReadableStream) {\n const [copy1, copy2] = value.tee()\n const entry: ServerExtractedStream = {\n type: 'stream',\n path,\n id: extracted.length,\n matchIndex: ctx.match.index,\n stream: copy2,\n }\n\n extracted.push(entry)\n return copy1\n } else if (value instanceof Promise) {\n const deferredPromise = defer(value)\n const entry: ServerExtractedPromise = {\n type: 'promise',\n path,\n id: extracted.length,\n matchIndex: ctx.match.index,\n promise: deferredPromise,\n }\n extracted.push(entry)\n }\n\n return value\n })\n\n return { replaced, extracted }\n}\n\nexport function onMatchSettled(opts: {\n router: AnyRouter\n match: AnyRouteMatch\n}) {\n const { router, match } = opts\n\n let extracted: Array<ServerExtractedEntry> | undefined = undefined\n let serializedLoaderData: any = undefined\n if (match.loaderData !== undefined) {\n const result = extractAsyncLoaderData(match.loaderData, {\n router,\n match,\n })\n match.loaderData = result.replaced\n extracted = result.extracted\n serializedLoaderData = extracted.reduce(\n (acc: any, entry: ServerExtractedEntry) => {\n return deepImmutableSetByPath(acc, ['temp', ...entry.path], undefined)\n },\n { temp: result.replaced },\n ).temp\n }\n\n const initCode = `__TSR_SSR__.initMatch(${jsesc(\n {\n id: match.id,\n __beforeLoadContext: router.ssr!.serializer.stringify(\n match.__beforeLoadContext,\n ),\n loaderData: router.ssr!.serializer.stringify(serializedLoaderData),\n error: router.ssr!.serializer.stringify(match.error),\n extracted: extracted?.map((entry) => pick(entry, ['type', 'path'])),\n updatedAt: match.updatedAt,\n status: match.status,\n } satisfies SsrMatch,\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )})`\n\n router.serverSsr!.injectScript(() => initCode)\n\n if (extracted) {\n extracted.forEach((entry) => {\n if (entry.type === 'promise') return injectPromise(entry)\n return injectStream(entry)\n })\n }\n\n function injectPromise(entry: ServerExtractedPromise) {\n router.serverSsr!.injectScript(async () => {\n await entry.promise\n\n return `__TSR_SSR__.resolvePromise(${jsesc(\n {\n matchId: match.id,\n id: entry.id,\n promiseState: entry.promise[TSR_DEFERRED_PROMISE],\n } satisfies ResolvePromiseState,\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )})`\n })\n }\n\n function injectStream(entry: ServerExtractedStream) {\n // Inject a promise that resolves when the stream is done\n // We do this to keep the stream open until we're done\n router.serverSsr!.injectHtml(async () => {\n //\n try {\n const reader = entry.stream.getReader()\n let chunk: ReadableStreamReadResult<any> | null = null\n while (!(chunk = await reader.read()).done) {\n if (chunk.value) {\n const code = `__TSR_SSR__.injectChunk(${jsesc(\n {\n matchId: match.id,\n id: entry.id,\n chunk: chunk.value,\n },\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )})`\n\n router.serverSsr!.injectScript(() => code)\n }\n }\n\n router.serverSsr!.injectScript(\n () =>\n `__TSR_SSR__.closeStream(${jsesc(\n {\n matchId: match.id,\n id: entry.id,\n },\n {\n isScriptContext: true,\n wrap: true,\n json: true,\n },\n )})`,\n )\n } catch (err) {\n console.error('stream read error', err)\n }\n\n return ''\n })\n }\n}\n\nfunction deepImmutableSetByPath<T>(obj: T, path: Array<string>, value: any): T {\n // immutable set by path retaining array and object references\n if (path.length === 0) {\n return value\n }\n\n const [key, ...rest] = path\n\n if (Array.isArray(obj)) {\n return obj.map((item, i) => {\n if (i === Number(key)) {\n return deepImmutableSetByPath(item, rest, value)\n }\n return item\n }) as T\n }\n\n if (isPlainObject(obj)) {\n return {\n ...obj,\n [key!]: deepImmutableSetByPath((obj as any)[key!], rest, value),\n }\n }\n\n return obj\n}\n\nexport function replaceBy<T>(\n obj: T,\n cb: (value: any, path: Array<string>) => any,\n path: Array<string> = [],\n): T {\n if (isPlainArray(obj)) {\n return obj.map((value, i) => replaceBy(value, cb, [...path, `${i}`])) as any\n }\n\n if (isPlainObject(obj)) {\n // Do not allow objects with illegal\n const newObj: any = {}\n\n for (const key in obj) {\n newObj[key] = replaceBy(obj[key], cb, [...path, key])\n }\n\n return newObj\n }\n\n // // Detect classes, functions, and other non-serializable objects\n // // and return undefined. Exclude some known types that are serializable\n // if (\n // typeof obj === 'function' ||\n // (typeof obj === 'object' &&\n // ![Object, Promise, ReadableStream].includes((obj as any)?.constructor))\n // ) {\n // console.info(obj)\n // warning(false, `Non-serializable value ☝️ found at ${path.join('.')}`)\n // return undefined as any\n // }\n\n const newObj = cb(obj, path)\n\n if (newObj !== obj) {\n return newObj\n }\n\n return obj\n}\n"],"names":["startSerializer","minifiedTsrBootStrapScript","defer","pick","TSR_DEFERRED_PROMISE","isPlainObject","isPlainArray","newObj"],"mappings":";;;;;;;AA2CgB,SAAA,2BACd,QACA,UACA;AACA,SAAO,MAAM;AAAA,IACX;AAAA,IACA,YAAYA,gBAAAA;AAAAA,EACd;AAEA,SAAO,YAAY;AAAA,IACjB,cAAc,CAAC;AAAA,IACf,kCAAkB,IAAI;AAAA,IACtB,YAAY,CAAC,YAAY;AACvB,YAAM,UAAU,QAAQ,QAAQ,EAAE,KAAK,OAAO;AACvC,aAAA,UAAW,aAAa,KAAK,OAAO;AAC3C,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN;AAAA,MAAA,CACD;AAEM,aAAA,QAAQ,KAAK,MAAM;AAAA,MAAA,CAAE;AAAA,IAC9B;AAAA,IACA,cAAc,CAAC,WAAW,SAAS;AAC1B,aAAA,OAAO,UAAW,WAAW,YAAY;AACxC,cAAA,SAAS,MAAM,UAAU;AACxB,eAAA,4BAA4B,MAAM,GACvC,QAAQ,IAAI,aAAa,mBAAkB,6BAAM,cAAa,QAC1D;AAAA,EACZ,MAAM,QAAQ,EAAE,QAAQ,WAAY,CAAA,CAAC,QACzB,EACN;AAAA,MAAA,CACD;AAAA,IACH;AAAA,IACA,aAAa,CAAC,KAAK,UAAU;AAC3B;AAAA,QACE,CAAC,OAAO,UAAW,aAAa,IAAI,GAAG;AAAA,QACvC,oCAAoC;AAAA,M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A0B,KAAQ,MAAqB,OAAe;AAEzE,MAAA,KAAK,WAAW,GAAG;AACd,WAAA;AAAA,EAAA;AAGT,QAAM,CAAC,KAAK,GAAG,IAAI,IAAI;AAEnB,MAAA,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,IAAI,CAAC,MAAM,MAAM;AACtB,UAAA,MAAM,OAAO,GAAG,GAAG;AACd,eAAA,uBAAuB,MAAM,MAAM,KAAK;AAAA,MAAA;AAE1C,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AAGC,MAAAC,WAAAA,cAAc,GAAG,GAAG;AACf,WAAA;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAI,GAAG,uBAAwB,IAAY,GAAI,GAAG,MAAM,KAAK;AAAA,IAChE;AAAA,EAAA;AAGK,SAAA;AACT;AAEO,SAAS,UACd,KACA,IACA,OAAsB,CAAA,GACnB;AACC,MAAAC,WAAAA,aAAa,GAAG,GAAG;AACrB,WAAO,IAAI,IAAI,CAAC,OAAO,MAAM,UAAU,OAAO,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC;AAAA,EAAA;AAGlE,MAAAD,WAAAA,cAAc,GAAG,GAAG;AAEtB,UAAME,UAAc,CAAC;AAErB,eAAW,OAAO,KAAK;AACrBA,cAAO,GAAG,IAAI,UAAU,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC;AAAA,IAAA;AAG/CA,WAAAA;AAAAA,EAAA;AAeH,QAAA,SAAS,GAAG,KAAK,IAAI;AAE3B,MAAI,WAAW,KAAK;AACX,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;;;;;;"}
@@ -1,29 +0,0 @@
1
- import { ClientExtractedBaseEntry } from '@tanstack/start-client-core';
2
- import { AnyRouteMatch, AnyRouter, DeferredPromise, Manifest } from '@tanstack/router-core';
3
- export type ServerExtractedEntry = ServerExtractedStream | ServerExtractedPromise;
4
- export interface ServerExtractedBaseEntry extends ClientExtractedBaseEntry {
5
- id: number;
6
- matchIndex: number;
7
- }
8
- export interface ServerExtractedStream extends ServerExtractedBaseEntry {
9
- type: 'stream';
10
- stream: ReadableStream;
11
- }
12
- export interface ServerExtractedPromise extends ServerExtractedBaseEntry {
13
- type: 'promise';
14
- promise: DeferredPromise<any>;
15
- }
16
- export declare function attachRouterServerSsrUtils(router: AnyRouter, manifest: Manifest | undefined): void;
17
- export declare function dehydrateRouter(router: AnyRouter): void;
18
- export declare function extractAsyncLoaderData(loaderData: any, ctx: {
19
- match: AnyRouteMatch;
20
- router: AnyRouter;
21
- }): {
22
- replaced: any;
23
- extracted: ServerExtractedEntry[];
24
- };
25
- export declare function onMatchSettled(opts: {
26
- router: AnyRouter;
27
- match: AnyRouteMatch;
28
- }): void;
29
- export declare function replaceBy<T>(obj: T, cb: (value: any, path: Array<string>) => any, path?: Array<string>): T;