From e000a06e99964d4af209ae0068b0c5b6c6eeb6d6 Mon Sep 17 00:00:00 2001 From: "moxey.eth" Date: Mon, 12 Feb 2024 21:33:43 +1100 Subject: [PATCH] refactor: revert attach --- examples/_dev/src/index.tsx | 2 +- examples/_dev/src/todos.tsx | 1 - src/farc.tsx | 30 ++---------------------------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/examples/_dev/src/index.tsx b/examples/_dev/src/index.tsx index 9bd08875..8111bb35 100644 --- a/examples/_dev/src/index.tsx +++ b/examples/_dev/src/index.tsx @@ -141,7 +141,7 @@ app.frame('/falsy-intents', () => { } }) -app.attach(todoApp) +app.route('/todos', todoApp) const server = Bun.serve(app) console.log(`𝑭𝒂𝒓𝒄 ▶︎ http://localhost:${server.port}/dev`) diff --git a/examples/_dev/src/todos.tsx b/examples/_dev/src/todos.tsx index a0a3aa5d..403e454b 100644 --- a/examples/_dev/src/todos.tsx +++ b/examples/_dev/src/todos.tsx @@ -14,7 +14,6 @@ export const app = new Farc({ index: -1, todos: [], }, - route: '/todos', }) app.frame('/', ({ buttonValue, deriveState, inputText }) => { diff --git a/src/farc.tsx b/src/farc.tsx index 6cc4f694..d077fa05 100644 --- a/src/farc.tsx +++ b/src/farc.tsx @@ -11,12 +11,7 @@ import { ImageResponse } from 'hono-og' import { inspectRoutes } from 'hono/dev' import type { HonoOptions } from 'hono/hono-base' import { jsxRenderer } from 'hono/jsx-renderer' -import { - type Env, - type MergePath, - type MergeSchemaPath, - type Schema, -} from 'hono/types' +import { type Env, type Schema } from 'hono/types' import { App, DevStyles, Preview } from './dev/components.js' import { getFrameRoutes, htmlToFrame, htmlToState } from './dev/utils.js' @@ -39,7 +34,6 @@ export type FarcConstructorParameters< env extends Env = Env, > = HonoOptions & { initialState?: state | undefined - route?: string | undefined } export type FrameHandlerReturnType = { @@ -56,31 +50,13 @@ export class Farc< basePath extends string = '/', > extends Hono { #initialState: state = undefined as state - subPath: string | undefined constructor({ initialState, - route, ...options }: FarcConstructorParameters = {}) { super(options) if (initialState) this.#initialState = initialState - if (route) this.subPath = route - } - - attach< - subEnv extends Env, - subSchema extends Schema, - subBasePath extends string, - >( - app: Farc, - ): Farc< - any, - env, - MergeSchemaPath> & schema, - basePath - > { - return this.route(app.subPath!, app as any) as any } frame( @@ -152,9 +128,7 @@ export class Farc< property="fc:frame:post_url" content={`${ action - ? toBaseUrl(c.req.url) + - parsePath(this.subPath || '') + - parsePath(action || '') + ? toBaseUrl(c.req.url) + parsePath(action || '') : context.url }?${postSearch}`} />