I went a little crazy

This commit is contained in:
Corey Johnson 2025-07-11 13:05:50 -07:00
parent fc9288d0cc
commit d4c725465a
47 changed files with 113 additions and 133 deletions

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -1,4 +1,4 @@
import { subdomainPackageInfo } from "@/orchestrator"
import { subdomainPackageInfo } from "../orchestrator"
import type { LoaderProps } from "@workshop/nano-remix"
export const loader = async (_req: Request) => {

View File

@ -1,4 +1,4 @@
import { startSubdomainServers } from "@/orchestrator"
import { startSubdomainServers } from "./orchestrator"
import { nanoRemix } from "@workshop/nano-remix"
import { join } from "node:path"
@ -35,8 +35,8 @@ const startServer = (portMap: Record<string, number>) => {
const targetPort = subdomain && portMap[subdomain]
if (!targetPort) {
const routePath = join(import.meta.dir, "routes")
return nanoRemix(req, { routePath })
const routesDir = join(import.meta.dir, "routes")
return nanoRemix(req, { routesDir })
}
try {

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -1,8 +1,11 @@
{
"name": "@workshop/nano-remix",
"type": "module",
"module": "src/main.ts",
"types": "src/main.ts",
"exports": {
".": "./src/main.ts",
"./*": "./src/*.ts"
},
"prettier": {
"printWidth": 110,
"semi": false

View File

@ -1,5 +1,5 @@
import { type FC, useEffect, useState, type JSX } from "hono/jsx"
import type { Action } from "@/main"
import type { Action } from "./main"
type ActionData<T extends (...args: any) => Promise<any>> = Exclude<Awaited<ReturnType<T>>, Response>

View File

@ -1,5 +1,5 @@
export { Form, useAction, wrapComponentWithLoader, submitAction } from "@/clientHelpers"
export { nanoRemix } from "@/nanoRemix"
export { Form, useAction, wrapComponentWithLoader, submitAction } from "./clientHelpers"
export { nanoRemix } from "./nanoRemix"
export type Loader<Data extends object> = (
req: Request,

View File

@ -1,21 +1,42 @@
import { renderServer } from "@/renderServer"
import { renderServer } from "./renderServer"
import { buildRoute } from "./buildRoute"
import { join, extname } from "node:path"
import { stat } from "node:fs/promises"
type Options = {
routesDir?: string
distDir?: string
publicDir?: string
disableCache?: boolean
}
let defaultPublicDir: string | undefined
try {
const publicDir = join(process.cwd(), "public")
const statInfo = await stat(publicDir)
if (statInfo.isDirectory()) {
defaultPublicDir = publicDir
}
} catch (error) {}
export const nanoRemix = async (req: Request, options: Options = {}) => {
const defaultRoutesDir = join(process.cwd(), "src", "routes")
const nanoRemixDir = join(process.cwd(), ".nano-remix")
const defaultDistDir = join(nanoRemixDir, "dist")
const defaultRoutesDir = "./src/routes"
const publicDir = options.publicDir || defaultPublicDir
const url = new URL(req.url)
if (publicDir) {
const filePath = join(publicDir, url.pathname)
const file = Bun.file(filePath)
if (await file.exists()) {
return new Response(file)
}
}
const routesDir = options.routesDir || defaultRoutesDir
const distDir = options.distDir || defaultDistDir
const router = new Bun.FileSystemRouter({ style: "nextjs", dir: routesDir })
const url = new URL(req.url)
// I want to request the css and js files directly, so we detect the extension
const ext = extname(url.pathname)

View File

@ -1,4 +1,4 @@
import type { Action, Loader } from "@/main"
import type { Action, Loader } from "./main"
export const renderServer = async (req: Request, route: Bun.MatchedRoute) => {
const contentType = req.headers.get("Content-Type")

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 123 KiB

View File

@ -1,14 +1,10 @@
import { nanoRemix } from "@workshop/nano-remix"
import { join } from "path"
Bun.serve({
routes: {
"/": {
"/*": {
GET: (req) => {
return nanoRemix(req, {
routePath: join(import.meta.dir, "routes"),
publicDir: join(import.meta.dir, "..", "public"),
})
return nanoRemix(req)
},
},
},

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -1,7 +1,7 @@
import { mkdir } from "node:fs/promises"
import { dirname, join } from "node:path"
import type { Reminder } from "@/reminders"
import { timeBomb } from "@/utils"
import type { Reminder } from "./reminders"
import { timeBomb } from "./utils"
export interface Keys {
threads: Record<string, string> // threadId: previousResponseId

View File

@ -1,6 +1,6 @@
import { DateTime } from "luxon"
import KV from "@/kv"
import { ensure, zone } from "@/utils.ts"
import KV from "./kv"
import { ensure, zone } from "./utils.ts"
export type Reminder = {
id: string

View File

@ -24,11 +24,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -4,8 +4,8 @@ import {
highPersonality,
injectPersonality,
lowPersonality,
} from "@/instructions"
import { tools } from "@/tools"
} from "./instructions"
import { tools } from "./tools"
import { Agent, InputGuardrailTripwireTriggered, run, user, system } from "@openai/agents"
import type { AgentInputItem, InputGuardrail } from "@openai/agents-core"
import { currentLocalTime } from "@workshop/shared/utils"

View File

@ -1,4 +1,4 @@
import { buildInstructions, shouldReplyInstructions } from "@/instructions"
import { buildInstructions, shouldReplyInstructions } from "../instructions"
import {
Agent,
type AgentInputItem,

View File

@ -1,8 +1,8 @@
import { getPendingReminders, updateReminder } from "@workshop/shared/reminders"
import { DateTime } from "luxon"
import { Client } from "discord.js"
import { buildInstructions } from "@/instructions"
import { respondToSystemMessage } from "@/ai"
import { buildInstructions } from "../instructions"
import { respondToSystemMessage } from "../ai"
import { ensure } from "@workshop/shared/utils"
const channelId = process.env.CHANNEL_ID ?? "1382121375619223594"

View File

@ -1,5 +1,5 @@
import { respondToUserMessage } from "@/ai"
import { storeEvaluation } from "@/eval"
import { respondToUserMessage } from "../ai"
import { storeEvaluation } from "../eval"
import { ActivityType, type Client } from "discord.js"
export const listenForEvents = (client: Client) => {

View File

@ -1,7 +1,7 @@
import { Client, GatewayIntentBits, Partials } from "discord.js"
import { listenForEvents } from "@/discord/events"
import { runCronJobs } from "@/discord/cron"
import { alertAboutCrashLog, logCrash } from "@/discord/crash"
import { listenForEvents } from "./events"
import { runCronJobs } from "./cron"
import { alertAboutCrashLog, logCrash } from "./crash"
const client = new Client({
intents: [

View File

@ -1,4 +1,4 @@
import type { UserContext } from "@/ai"
import type { UserContext } from "./ai"
export const buildInstructions = (context: UserContext) => {
return `

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -1,4 +1,4 @@
import { checkboxRegex } from "@/todo"
import { checkboxRegex } from "./todo"
import { EditorView } from "@codemirror/view"
export const autoTodoOnNewline = EditorView.updateListener.of((update) => {

View File

@ -1,3 +1,3 @@
export { TodoEditor } from "@/todoEditor"
export { Todo, type TodoJSON } from "@/todo"
export { todoListToString, type TodoList } from "@/todoList"
export { TodoEditor } from "./todoEditor"
export { Todo, type TodoJSON } from "./todo"
export { todoListToString, type TodoList } from "./todoList"

View File

@ -6,8 +6,8 @@ const server = serve({
port: parseInt(process.env.PORT || "3000"),
routes: {
"/*": (req) => {
const routePath = join(import.meta.dir, "routes")
return nanoRemix(req, { routePath })
const routesDir = join(import.meta.dir, "routes")
return nanoRemix(req, { routesDir })
},
},

View File

@ -1,5 +1,5 @@
import { DateTime } from "luxon"
import { Todo } from "@/todo"
import { Todo } from "./todo"
import { test, expect } from "bun:test"
test("parsing valid todos", () => {

View File

@ -1,5 +1,5 @@
import { EditorView } from "@codemirror/view"
import { Todo } from "@/todo"
import { Todo } from "./todo"
import { triggerTodoCompletionEffect } from "./todoCompletion"
export const todoClickHandler = EditorView.domEventHandlers({

View File

@ -1,4 +1,4 @@
import { completionAnimationEffect } from "@/todoDecorations"
import { completionAnimationEffect } from "./todoDecorations"
import { EditorView } from "@codemirror/view"
export const triggerTodoCompletionEffect = async (view: EditorView, pos: number) => {

View File

@ -1,4 +1,4 @@
import { Todo } from "@/todo"
import { Todo } from "./todo"
import { RangeSetBuilder, StateEffect } from "@codemirror/state"
import { EditorView, Decoration, ViewPlugin, ViewUpdate, WidgetType } from "@codemirror/view"
import { type RefObject } from "hono/jsx"

View File

@ -3,12 +3,12 @@ import { defaultKeymap, history, historyKeymap } from "@codemirror/commands"
import { EditorState } from "@codemirror/state"
import { EditorView, lineNumbers, keymap } from "@codemirror/view"
import { foldGutter, foldKeymap } from "@codemirror/language"
import { refreshFilterEffect, todoDecorations } from "@/todoDecorations"
import { autoTodoOnNewline } from "@/autoTodoOnNewline"
import { buildKeyBindings, todoKeymap } from "@/todoKeymap"
import { todoClickHandler } from "@/todoClickHandler"
import { dateAutocompletion } from "@/dateAutocompletion"
import { todoTimer } from "@/todoTimer"
import { refreshFilterEffect, todoDecorations } from "./todoDecorations"
import { autoTodoOnNewline } from "./autoTodoOnNewline"
import { buildKeyBindings, todoKeymap } from "./todoKeymap"
import { todoClickHandler } from "./todoClickHandler"
import { dateAutocompletion } from "./dateAutocompletion"
import { todoTimer } from "./todoTimer"
import { DateTime } from "luxon"
import { searchKeymap } from "@codemirror/search"

View File

@ -2,7 +2,7 @@ import { indentMore, indentLess } from "@codemirror/commands"
import { EditorView, keymap, type KeyBinding } from "@codemirror/view"
import { Todo } from "./todo"
import { type RefObject } from "hono/jsx"
import { parseTodoList, todoListToString } from "@/todoList"
import { parseTodoList, todoListToString } from "./todoList"
import { todoTimer } from "./todoTimer"
import { triggerTodoCompletionEffect } from "./todoCompletion"
import { selectNextOccurrence } from "@codemirror/search"

View File

@ -1,4 +1,4 @@
import { parseTodoList, todoListToString, type TodoList } from "@/todoList"
import { parseTodoList, todoListToString, type TodoList } from "./todoList"
import { test, expect } from "bun:test"
test("todoListToString", () => {

View File

@ -1,4 +1,4 @@
import { Todo, type TodoJSON } from "@/todo"
import { Todo, type TodoJSON } from "./todo"
import { ensure } from "@workshop/shared/utils"
type TodoHeader = {

View File

@ -1,6 +1,6 @@
import { EditorView, ViewPlugin, ViewUpdate, WidgetType, Decoration } from "@codemirror/view"
import { RangeSetBuilder } from "@codemirror/state"
import { Todo } from "@/todo"
import { Todo } from "./todo"
class CountdownWidget extends WidgetType {
duration: number

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}

View File

@ -1,11 +1,11 @@
import { HStack, VStack } from "@/lib/stack"
import Placeholder from "@/lib/placeholder"
import { Icon, IconLink, IconName } from "@/lib/icon"
import { Button } from "@/lib/button"
import { Input } from "@/lib/input"
import { Select } from "@/lib/select"
import { Grid } from "@/lib/grid"
import { Divider } from "@/lib/divider"
import { HStack, VStack } from "../lib/stack"
import Placeholder from "../lib/placeholder"
import { Icon, IconLink, IconName } from "../lib/icon"
import { Button } from "../lib/button"
import { Input } from "../lib/input"
import { Select } from "../lib/select"
import { Grid } from "../lib/grid"
import { Divider } from "../lib/divider"
export const Cards = () => {
return (

View File

@ -1,4 +1,4 @@
import { TailwindSize } from "@/types"
import { TailwindSize } from "../types"
import "hono/jsx"
import { FC, PropsWithChildren } from "hono/jsx"

View File

@ -1,4 +1,4 @@
import { TailwindSize } from "@/types"
import { TailwindSize } from "../types"
import "hono/jsx"
import { FC } from "hono/jsx"
import * as icons from "lucide-static"

View File

@ -1,6 +1,6 @@
import "hono/jsx"
import { Avatar, AvatarProps } from "@/lib/avatar"
import { Image, ImageProps } from "@/lib/image"
import { Avatar, AvatarProps } from "./avatar"
import { Image, ImageProps } from "./image"
export const Placeholder = {
Avatar(props: PlaceholderAvatarProps) {

View File

@ -1,4 +1,4 @@
import { TailwindSize } from "@/types"
import { TailwindSize } from "../types"
import "hono/jsx"
import { FC, PropsWithChildren } from "hono/jsx"

View File

@ -1,6 +1,6 @@
import { LoaderProps } from "@workshop/nano-remix"
import "@/index.css"
import { Cards } from "@/examples/cards"
import type { LoaderProps } from "@workshop/nano-remix"
import "../../index.css"
import { Cards } from "../../examples/cards"
export const loader = async (req: Request) => {
const exampleName = req.url.split("/").pop() || ""

View File

@ -1,8 +1,8 @@
import { LoaderProps } from "@workshop/nano-remix"
import type { LoaderProps } from "@workshop/nano-remix"
import "../index.css"
import { readdir } from "node:fs/promises"
import { join, basename } from "node:path"
import { VStack } from "@/lib/stack"
import { VStack } from "../lib/stack"
export const loader = async (req: Request) => {
const examples = await readdir(join(import.meta.dir, "../examples"))

View File

@ -1,15 +1,15 @@
import { LoaderProps } from "@workshop/nano-remix"
import "@/index.css"
import { Test as AvatarTest } from "@/lib/avatar"
import { Test as DividerTest } from "@/lib/divider"
import { Test as ButtonTest } from "@/lib/button"
import { Test as GridTest } from "@/lib/grid"
import { Test as IconTest } from "@/lib/icon"
import { Test as ImageTest } from "@/lib/image"
import { Test as InputTest } from "@/lib/input"
import { Test as PlaceholderTest } from "@/lib/placeholder"
import { Test as SelectTest } from "@/lib/select"
import { Test as StackTest } from "@/lib/stack"
import type { LoaderProps } from "@workshop/nano-remix"
import "../../index.css"
import { Test as AvatarTest } from "../../lib/avatar"
import { Test as DividerTest } from "../../lib/divider"
import { Test as ButtonTest } from "../../lib/button"
import { Test as GridTest } from "../../lib/grid"
import { Test as IconTest } from "../../lib/icon"
import { Test as ImageTest } from "../../lib/image"
import { Test as InputTest } from "../../lib/input"
import { Test as PlaceholderTest } from "../../lib/placeholder"
import { Test as SelectTest } from "../../lib/select"
import { Test as StackTest } from "../../lib/stack"
export const loader = async (req: Request) => {
const testName = req.url.split("/").pop() || ""

View File

@ -6,8 +6,8 @@ const server = serve({
port: parseInt(process.env.PORT || "3000"),
routes: {
"/*": (req) => {
const routePath = join(import.meta.dir, "routes")
return nanoRemix(req, { routePath })
const routesDir = join(import.meta.dir, "routes")
return nanoRemix(req, { routesDir })
},
},

View File

@ -25,11 +25,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
"noPropertyAccessFromIndexSignature": false
}
}