-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
722 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import glob from 'fast-glob' | ||
|
||
await rewriteHonoJsx() | ||
|
||
async function rewriteHonoJsx() { | ||
const files = await glob('./src/_lib/**/*.js') | ||
for (const file of files) { | ||
const content = await Bun.file(file).text() | ||
await Bun.write( | ||
file, | ||
content | ||
.replaceAll('hono/jsx/jsx-runtime', 'farc/jsx/jsx-runtime') | ||
.replaceAll('hono/jsx/jsx-dev-runtime', 'farc/jsx/jsx-dev-runtime'), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "example", | ||
"name": "example-dev", | ||
"private": true, | ||
"scripts": { | ||
"dev": "bun run --hot src/index.tsx" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Button, Farc, TextInput } from 'farc' | ||
|
||
import { app as todoApp } from './todos' | ||
|
||
const app = new Farc({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "hono/jsx" | ||
} | ||
} | ||
"jsxImportSource": "hono/jsx", | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["**/*.ts", "**/*.tsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
|
||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
To install dependencies: | ||
```sh | ||
bun install | ||
``` | ||
|
||
To run: | ||
```sh | ||
bun run dev | ||
``` | ||
|
||
open http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Button, Farc, TextInput } from 'farc' | ||
import { handle } from 'hono/vercel' | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
} | ||
|
||
const app = new Farc({ basePath: '/api' }) | ||
|
||
app.frame('/', (context) => { | ||
const { buttonValue, inputText, status } = context | ||
const fruit = inputText || buttonValue | ||
return { | ||
image: ( | ||
<div | ||
style={{ | ||
alignItems: 'center', | ||
background: | ||
status === 'response' | ||
? 'linear-gradient(to right, #432889, #17101F)' | ||
: 'black', | ||
backgroundSize: '100% 100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
flexWrap: 'nowrap', | ||
height: '100%', | ||
justifyContent: 'center', | ||
textAlign: 'center', | ||
width: '100%', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
color: 'white', | ||
fontSize: 60, | ||
fontStyle: 'normal', | ||
letterSpacing: '-0.025em', | ||
lineHeight: 1.4, | ||
marginTop: 30, | ||
padding: '0 120px', | ||
whiteSpace: 'pre-wrap', | ||
}} | ||
> | ||
{status === 'response' | ||
? `Nice choice.${fruit ? ` ${fruit.toUpperCase()}!!` : ''}` | ||
: 'Welcome!'} | ||
</div> | ||
</div> | ||
), | ||
intents: [ | ||
<TextInput placeholder="Enter custom fruit..." />, | ||
<Button value="apples">Apples</Button>, | ||
<Button value="oranges">Oranges</Button>, | ||
<Button value="bananas">Bananas</Button>, | ||
status === 'response' && <Button.Reset>Reset</Button.Reset>, | ||
], | ||
} | ||
}) | ||
|
||
export const GET = handle(app.hono) | ||
export const POST = handle(app.hono) | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
const server = Bun.serve(app) | ||
console.log(`𝑭𝒂𝒓𝒄 ▶︎ http://localhost:${server.port}/dev`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "example-vercel-edge", | ||
"type": "module", | ||
"scripts": { | ||
"build": "farc vercel-build", | ||
"start": "bun run --hot api/index.tsx", | ||
"deploy": "vercel" | ||
}, | ||
"dependencies": { | ||
"farc": "workspace:*", | ||
"hono": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"tsx": "^4.7.1", | ||
"typescript": "^5.3.3", | ||
"vercel": "^32.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "NodeNext", | ||
"skipLibCheck": true, | ||
|
||
"moduleResolution": "NodeNext", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "farc/jsx", | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["**/*.ts", "**/*.tsx", "**/*.mtsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { extname, normalize, resolve } from 'node:path' | ||
import glob from 'fast-glob' | ||
import { ensureDirSync, writeJsonSync } from 'fs-extra/esm' | ||
|
||
export async function build() { | ||
const files = await glob('./api/**/*.{js,jsx,ts,tsx}') | ||
for (const file of files) { | ||
const fileDir = normalize(file).replace(extname(file), '') | ||
const dir = resolve( | ||
process.cwd(), | ||
`./.vercel/output/functions/${fileDir}.func`, | ||
) | ||
ensureDirSync(dir) | ||
writeJsonSync(`${dir}/package.json`, { type: 'module' }) | ||
} | ||
|
||
ensureDirSync('./.vercel/output') | ||
ensureDirSync('./.vercel/output/static') | ||
writeJsonSync('./.vercel/output/config.json', { | ||
version: 3, | ||
routes: [ | ||
{ | ||
handle: 'filesystem', | ||
}, | ||
{ | ||
src: '^/api(?:/(.*))$', | ||
dest: '/api', | ||
check: true, | ||
}, | ||
{ | ||
src: '^/api(/.*)?$', | ||
status: 404, | ||
}, | ||
{ | ||
handle: 'error', | ||
}, | ||
{ | ||
status: 404, | ||
src: '^(?!/api).*$', | ||
dest: '/404.html', | ||
}, | ||
{ | ||
handle: 'miss', | ||
}, | ||
{ | ||
src: '^/api/(.+)(?:\\.(?:tsx))$', | ||
dest: '/api/$1', | ||
check: true, | ||
}, | ||
], | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env node | ||
import { cac } from 'cac' | ||
|
||
import { build as build_vercel } from './commands/vercel-build.js' | ||
import { version } from './version.js' | ||
|
||
export const cli = cac('farc') | ||
|
||
cli.command('vercel-build').action(build_vercel) | ||
|
||
cli.help() | ||
cli.version(version) | ||
|
||
cli.parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const version = '0.0.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.