// Generated by scripts/generate-manifest.mjs. Do not edit by hand. import type { AddOnCompiled } from '../../../../../types.js' type TemplateRecord = Record type TemplateAddOn = TemplateRecord & { integrations?: Array routes?: Array } type TemplateRenderContext = { [key: string]: any packageManager: any projectName: any typescript: any tailwind: any blank: any js: any jsx: any fileRouter: any codeRouter: any routerOnly: any includeExamples: any addOnEnabled: Record addOnOption: Record addOns: Array integrations: Array routes: Array getPackageManagerAddScript: (...args: Array) => string getPackageManagerRunScript: (...args: Array) => string getPackageManagerExecuteScript: (...args: Array) => string relativePath: (...args: Array) => string integrationImportContent: (...args: Array) => string integrationImportCode: (...args: Array) => string | undefined renderTemplate: (content: string) => string ignoreFile: () => never } type TemplateRenderer = (context: TemplateRenderContext) => string | undefined function __escapeXML(value: unknown) { if (value === undefined || value === null) { return '' } return String(value).replace(/[&<>'"]/g, (character) => { switch (character) { case '&': return '&' case '<': return '<' case '>': return '>' case '"': return '"' case "'": return ''' default: return character } }) } export function getManifestTemplateKey(template: string) { let hash = 0x811c9dc5 for (let i = 0; i < template.length; i++) { hash ^= template.charCodeAt(i) hash = Math.imul(hash, 0x01000193) >>> 0 } return `${hash.toString(16).padStart(8, '0')}:${template.length}` } const templateRenderers: Record = { } export function hasManifestTemplate(template: string) { return getManifestTemplateKey(template) in templateRenderers } export function renderManifestTemplate( template: string, context: TemplateRenderContext, ) { const key = getManifestTemplateKey(template) const renderer = templateRenderers[key] if (!renderer) { throw new Error(`Template ${key} was not precompiled into the manifest`) } return renderer(context) ?? '' } export const addOn = { "name": "oRPC", "description": "Integrate oRPC into your application.", "phase": "add-on", "modes": [ "file-router" ], "link": "https://orpc.unnoq.com/", "dependsOn": [ "tanstack-query" ], "type": "add-on", "category": "api", "color": "#FF6B6B", "priority": 34, "routes": [ { "icon": "Network", "url": "/demo/orpc-todo", "name": "oRPC Todo", "path": "src/routes/demo.orpc-todo.tsx", "jsName": "ORPCTodos" } ], "id": "oRPC", "version": "0.0.0", "packageAdditions": { "dependencies": { "@orpc/client": "^1.13.6", "@orpc/json-schema": "^1.13.6", "@orpc/openapi": "^1.13.6", "@orpc/server": "^1.13.6", "@orpc/tanstack-query": "^1.13.6", "@orpc/zod": "^1.13.6", "zod": "^4.3.6" } }, "readmeIsEjs": false, "files": { "src/orpc/client.ts": "import { createRouterClient } from '@orpc/server'\nimport { createORPCClient } from '@orpc/client'\nimport { RPCLink } from '@orpc/client/fetch'\nimport { createTanstackQueryUtils } from '@orpc/tanstack-query'\nimport { getRequestHeaders } from '@tanstack/react-start/server'\nimport { createIsomorphicFn } from '@tanstack/react-start'\n\nimport type { RouterClient } from '@orpc/server'\n\nimport router from '#/orpc/router'\n\nconst getORPCClient = createIsomorphicFn()\n .server(() =>\n createRouterClient(router, {\n context: () => ({\n headers: getRequestHeaders(),\n }),\n }),\n )\n .client((): RouterClient => {\n const link = new RPCLink({\n url: `${window.location.origin}/api/rpc`,\n })\n return createORPCClient(link)\n })\n\nexport const client: RouterClient = getORPCClient()\n\nexport const orpc = createTanstackQueryUtils(client)\n", "src/orpc/router/index.ts": "import { addTodo, listTodos } from './todos'\n\nexport default {\n listTodos,\n addTodo,\n}\n", "src/orpc/router/todos.ts": "import { os } from '@orpc/server'\nimport * as z from 'zod'\n\nconst todos = [\n { id: 1, name: 'Get groceries' },\n { id: 2, name: 'Buy a new phone' },\n { id: 3, name: 'Finish the project' },\n]\n\nexport const listTodos = os.input(z.object({})).handler(() => {\n return todos\n})\n\nexport const addTodo = os\n .input(z.object({ name: z.string() }))\n .handler(({ input }) => {\n const newTodo = { id: todos.length + 1, name: input.name }\n todos.push(newTodo)\n return newTodo\n })\n", "src/orpc/schema.ts": "import { z } from 'zod'\n\nexport const TodoSchema = z.object({\n id: z.number().int().min(1),\n name: z.string(),\n})\n", "src/polyfill.ts": "import { File } from \"node:buffer\";\n\n/**\n * This file aims to polyfill missing APIs in Node.js 18 that oRPC depends on.\n *\n * Since Stackblitz runs on Node.js 18, these polyfills ensure oRPC works in that environment.\n * If you're running oRPC locally, please use Node.js 20 or later for full compatibility.\n */\n\n/**\n * Note: Stackblitz provides an emulated Node.js environment with inherent limitations.\n * If you encounter issues, please test on a local setup with Node.js 20 or later before reporting them.\n */\n\n/**\n * The `oz.file()` schema depends on the `File` API.\n * If you're not using `oz.file()`, you can safely remove this polyfill.\n */\nif (typeof globalThis.File === \"undefined\") {\n globalThis.File = File as any;\n}\n", "src/routes/api.$.ts": "import '#/polyfill'\n\nimport { OpenAPIHandler } from '@orpc/openapi/fetch'\nimport { ZodToJsonSchemaConverter } from '@orpc/zod/zod4'\nimport { SmartCoercionPlugin } from '@orpc/json-schema'\nimport { createFileRoute } from '@tanstack/react-router'\nimport { onError } from '@orpc/server'\nimport { OpenAPIReferencePlugin } from '@orpc/openapi/plugins'\n\nimport { TodoSchema } from '#/orpc/schema'\nimport router from '#/orpc/router'\n\nconst handler = new OpenAPIHandler(router, {\n interceptors: [\n onError((error) => {\n console.error(error)\n }),\n ],\n plugins: [\n new SmartCoercionPlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n }),\n new OpenAPIReferencePlugin({\n schemaConverters: [new ZodToJsonSchemaConverter()],\n specGenerateOptions: {\n info: {\n title: 'TanStack ORPC Playground',\n version: '1.0.0',\n },\n commonSchemas: {\n Todo: { schema: TodoSchema },\n UndefinedError: { error: 'UndefinedError' },\n },\n security: [{ bearerAuth: [] }],\n components: {\n securitySchemes: {\n bearerAuth: {\n type: 'http',\n scheme: 'bearer',\n },\n },\n },\n },\n docsConfig: {\n authentication: {\n securitySchemes: {\n bearerAuth: {\n token: 'default-token',\n },\n },\n },\n },\n }),\n ],\n})\n\nasync function handle({ request }: { request: Request }) {\n const { response } = await handler.handle(request, {\n prefix: '/api',\n context: {},\n })\n\n return response ?? new Response('Not Found', { status: 404 })\n}\n\nexport const Route = createFileRoute('/api/$')({\n server: {\n handlers: {\n HEAD: handle,\n GET: handle,\n POST: handle,\n PUT: handle,\n PATCH: handle,\n DELETE: handle,\n },\n },\n})\n", "src/routes/api.rpc.$.ts": "import '#/polyfill'\n\nimport { RPCHandler } from '@orpc/server/fetch'\nimport { createFileRoute } from '@tanstack/react-router'\nimport router from '#/orpc/router'\n\nconst handler = new RPCHandler(router)\n\nasync function handle({ request }: { request: Request }) {\n const { response } = await handler.handle(request, {\n prefix: '/api/rpc',\n context: {},\n })\n\n return response ?? new Response('Not Found', { status: 404 })\n}\n\nexport const Route = createFileRoute('/api/rpc/$')({\n server: {\n handlers: {\n HEAD: handle,\n GET: handle,\n POST: handle,\n PUT: handle,\n PATCH: handle,\n DELETE: handle,\n },\n },\n})\n", "src/routes/demo/orpc-todo.tsx": "import { useCallback, useState } from 'react'\nimport { createFileRoute } from '@tanstack/react-router'\nimport { useMutation, useQuery } from '@tanstack/react-query'\n\nimport { orpc } from '#/orpc/client'\n\nexport const Route = createFileRoute('/demo/orpc-todo')({\n component: ORPCTodos,\n loader: async ({ context }) => {\n await context.queryClient.prefetchQuery(\n orpc.listTodos.queryOptions({\n input: {},\n }),\n )\n },\n})\n\nfunction ORPCTodos() {\n const { data, refetch } = useQuery(\n orpc.listTodos.queryOptions({\n input: {},\n }),\n )\n\n const [todo, setTodo] = useState('')\n const { mutate: addTodo } = useMutation({\n mutationFn: orpc.addTodo.call,\n onSuccess: () => {\n refetch()\n setTodo('')\n },\n })\n\n const submitTodo = useCallback(() => {\n addTodo({ name: todo })\n }, [addTodo, todo])\n\n return (\n
\n
\n

oRPC

\n

Todos

\n
    \n {data?.map((t) => (\n
  • \n {t.name}\n
  • \n ))}\n
\n
\n setTodo(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n submitTodo()\n }\n }}\n placeholder=\"Enter a new todo...\"\n className=\"demo-input\"\n />\n \n Add todo\n \n
\n
\n
\n )\n}\n" }, "deletedFiles": [], "smallLogo": "" } satisfies AddOnCompiled