Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wevm/framework
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Feb 28, 2024
2 parents 7262c2f + 3443f8a commit 6e21874
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .changeset/nice-apples-bake.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
"frog": patch
"frog": minor
"create-frog": minor
---

Initial release.
1 change: 1 addition & 0 deletions site/pages/concepts/images-intents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Check out Vercel's [Open Graph Image Generation page](https://vercel.com/docs/fu
In **Frog**, an **Image** can be rendered via the `image` return property:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
2 changes: 2 additions & 0 deletions site/pages/concepts/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ then the **Frog** (and Hono) API should seem familiar to you.
At a high-level, the most basic **Frog** application looks like this:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -184,6 +185,7 @@ Farcaster Frames have two main UI components: an **Image**, and a set of **Inten
We can represent this in the **Frog** API via the `image` and `intents` properties of the frame route:
```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
import { Button, Frog } from 'frog'

Expand Down
3 changes: 2 additions & 1 deletion site/pages/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ bun i frog


```tsx twoslash [src/index.tsx]
/** @jsxImportSource frog/jsx */
// @noErrors
/** @jsxImportSource hono/jsx */
// ---cut---
import { Button, Frog } from 'frog'

Expand Down
1 change: 1 addition & 0 deletions site/pages/platforms/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ curl -fsSL https://bun.sh/install | bash
Next, scaffold your frame:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
3 changes: 3 additions & 0 deletions site/pages/platforms/cloudflare-workers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npm install wrangler --save-dev
Next, scaffold your frame:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -83,6 +84,7 @@ It is recommended to use your own Hub API URL in production.
After that, we export our app via the `default` export.

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -166,6 +168,7 @@ they will be redirected to the `/foo` path.
[Read more on Browser Redirects](/concepts/browser-redirects)

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
3 changes: 3 additions & 0 deletions site/pages/platforms/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npm install next@latest react@latest react-dom@latest vercel@latest
Next, scaffold your frame:

```tsx twoslash [app/api/[[...routes]]/route.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog, TextInput } from 'frog'
Expand Down Expand Up @@ -84,6 +85,7 @@ It is recommended to use your own Hub API URL in production.
After that, we will add handlers to handle requests in the `api/` route:

```tsx twoslash [app/api/[[...routes]]/route.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog, TextInput } from 'frog'
Expand Down Expand Up @@ -177,6 +179,7 @@ they will be redirected to the `/foo` path (ie. `/app/foo/page.tsx` in your Next
[Read more on Browser Redirects](/concepts/browser-redirects)

```tsx twoslash [app/api/[[...routes]]/route.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog, TextInput } from 'frog'
Expand Down
1 change: 1 addition & 0 deletions site/pages/platforms/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bunx create-frog -t node
Next, scaffold your frame:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
3 changes: 3 additions & 0 deletions site/pages/platforms/vercel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ npm install vercel --save-dev
Next, scaffold your frame:

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -87,6 +88,7 @@ It is recommended to use your own Hub API URL in production.
After that, we will append Vercel handlers to the file.

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -177,6 +179,7 @@ they will be redirected to the `/` path.
[Read more on Browser Redirects](/concepts/browser-redirects)

```tsx twoslash [src/index.tsx]
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
4 changes: 4 additions & 0 deletions site/pages/reference/frog-frame-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Derives new state from the state of the previous frame.
Internally uses [Immers's `produce` function](https://immerjs.github.io/immer/produce/) to create a draft of the state, and then applies the changes to the state.

```tsx twoslash
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -172,6 +173,7 @@ The value of the input that was previously interacted with.
For example, if the user typed `"Banana"`, then `inputText` will be `"Banana"`.

```tsx twoslash
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog, TextInput } from 'frog'
Expand Down Expand Up @@ -201,6 +203,7 @@ app.frame('/', (c) => {
The data of the previous intents.

```tsx twoslash
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down Expand Up @@ -247,6 +250,7 @@ app.frame('/result', (c) => { // [!code focus]
The state of the previous frame.

```tsx twoslash
// @noErrors
/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
Expand Down
1 change: 1 addition & 0 deletions site/pages/reference/frog-frame-response.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ Title of the frame (added as `og:title`).

```tsx twoslash
/** @jsxImportSource frog/jsx */
import { Button, Frog } from 'frog'
// ---cut---
export const app = new Frog()

Expand Down
41 changes: 25 additions & 16 deletions src/frog-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,30 @@ export class FrogBase<
for (const [key, value] of Object.entries(headers ?? {}))
c.header(key, value)

const isDevEnabled = this.dev?.enabled ?? true
const content = isDevEnabled && (
<a style={{ textDecoration: 'none' }} href={`${context.url}/dev`}>
open 𝒇𝒓𝒂𝒎𝒆 devtools
</a>
const isDevEnabled =
// check if devtools are enabled on constructor.
(this.dev?.enabled ?? true) &&
// check if route has `/dev` path.
this.hono.routes.some((r) => {
if (!r.path.startsWith(this.basePath + parsePath(path))) return false
if (!r.path.includes('/dev')) return false
return true
})

const body = isDevEnabled && (
<body
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
minHeight: '100vh',
overflow: 'hidden',
}}
>
<a style={{ textDecoration: 'none' }} href={`${context.url}/dev`}>
open 𝒇𝒓𝒂𝒎𝒆 devtools
</a>
</body>
)

return c.render(
Expand Down Expand Up @@ -364,17 +383,7 @@ export class FrogBase<
content={serializeJson(baseContext)}
/>
</head>
<body
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
minHeight: '100vh',
overflow: 'hidden',
}}
>
{content}
</body>
{body}
</html>,
)
})
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frog",
"version": "1.0.0-alpha.0",
"version": "0.1.0",
"type": "module",
"module": "_lib/index.js",
"types": "_lib/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion templates/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "next",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
Expand Down

0 comments on commit 6e21874

Please sign in to comment.