Skip to content

Commit

Permalink
add "Rebuilding..." loader, upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Mar 22, 2024
1 parent c446c91 commit 1912b97
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ tmp
dist
# tests/example-init
.npmrc
*.__tmp_entrypoint.tsx
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions dev-server-api/routes/api/dev_package_examples/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default withEdgeSpec({
dev_package_example_id: z.coerce.number(),
file_path: z.string(),
tscircuit_soup: z.any(),
is_loading: z.boolean(),
error: z.string().nullable().optional().default(null),
last_updated_at: z.string().datetime(),
}),
Expand All @@ -32,6 +33,7 @@ export default withEdgeSpec({
})
.then((r) => ({
...r,
is_loading: r.is_loading === 1,
tscircuit_soup: JSON.parse(r.tscircuit_soup),
})),
})
Expand Down
2 changes: 1 addition & 1 deletion dev-server-api/src/db/get-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type DbClient = Kysely<KyselyDatabaseSchema>
let globalDb: Kysely<KyselyDatabaseSchema> | undefined

export const getDbFilePath = () =>
process.env.TSCI_DEV_SERVER_DB ?? "./.tscircuit/dev-server.db"
process.env.TSCI_DEV_SERVER_DB ?? "./.tscircuit/dev-server.sqlite"

export const getDb = async (): Promise<Kysely<KyselyDatabaseSchema>> => {
if (globalDb) return globalDb
Expand Down
Binary file modified dev-server-frontend/bun.lockb
Binary file not shown.
9 changes: 5 additions & 4 deletions dev-server-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"start": "npm run dev",
"build": "tsc && vite build --base /preview && rm -f dist/bundle* && make-vfs --dir dist --outfile ./dist/bundle.ts",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10",
"preview": "vite preview"
"preview": "vite preview",
"update-deps": "bun add @tscircuit/pcb-viewer@latest @tscircuit/builder@latest @tscircuit/schematic-viewer@latest"
},
"dependencies": {
"@radix-ui/react-alert-dialog": "^1.0.5",
Expand All @@ -28,9 +29,9 @@
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@tscircuit/builder": "^1.5.5",
"@tscircuit/pcb-viewer": "^1.2.12",
"@tscircuit/schematic-viewer": "^1.1.7",
"@tscircuit/builder": "latest",
"@tscircuit/pcb-viewer": "latest",
"@tscircuit/schematic-viewer": "latest",
"axios": "^1.6.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
Expand Down
7 changes: 7 additions & 0 deletions dev-server-frontend/src/ExampleContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const ExampleContentView = () => {

const itemHeight =
viewMode === "split" && splitMode === "vertical" ? halfHeight : editorHeight
console.log(pkg)

return (
<div
Expand Down Expand Up @@ -66,6 +67,12 @@ export const ExampleContentView = () => {
</div>
</div>
)}
{pkg && pkg.is_loading && (
<div className="absolute top-0 right-0 bg-white p-4 py-2 m-4 rounded-md flex items-center z-10 shadow-lg border border-gray-200">
<div className="border-2 border-blue-400 border-t-transparent rounded-full w-4 h-4 animate-spin mr-2"></div>
Rebuilding...
</div>
)}
{pkg && (viewMode === "schematic" || viewMode === "split") && (
<Schematic
key={pkg?.last_updated_at}
Expand Down
4 changes: 2 additions & 2 deletions lib/cmd-fns/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const devCmd = async (ctx: AppContext, args: any) => {
// Add .tscircuit to .gitignore if it's not already there
// TODO

// Delete old .tscircuit/dev-server.db
unlink(Path.join(cwd, ".tscircuit/dev-server.db")).catch(() => {})
// Delete old .tscircuit/dev-server.sqlite
unlink(Path.join(cwd, ".tscircuit/dev-server.sqlite")).catch(() => {})

console.log(
kleur.green(
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"bootstrap": "bun i && cd dev-server-api && bun i && cd ../dev-server-frontend && bun i",
"bootstrap:ci": "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
"start": "bun cli.ts",
"start:dev-server:dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.db concurrently 'cd dev-server-api && bun start' 'cd dev-server-frontend && bun start'",
"start:dev-server:dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.sqlite concurrently 'cd dev-server-api && bun start' 'cd dev-server-frontend && bun start'",
"start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
"build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
"build:dev-server:api": "cd dev-server-api && bun run build",
"build:cli": "bun build-cli.ts",
"build": "bun build:dev-server && npm run build:cli",
"dev-with-test-project": "bun cli.ts dev --cwd ./tests/assets/example-project",
"test:init": "bun cli.ts init --dir ./tmp/test --name test"
"test:init": "bun cli.ts init --dir ./tmp/test --name test",
"update-deps": "bun add @tscircuit/builder@latest @tscircuit/react-fiber@latest && cd dev-server-frontend && bun run update-deps"
},
"bin": {
"tscircuit": "./dist/cli.js",
Expand All @@ -34,8 +35,8 @@
"dependencies": {
"@edge-runtime/primitives": "^4.1.0",
"@hono/node-server": "^1.8.2",
"@tscircuit/builder": "^1.5.10",
"@tscircuit/react-fiber": "^1.0.10",
"@tscircuit/builder": "latest",
"@tscircuit/react-fiber": "latest",
"axios": "^1.6.7",
"better-sqlite3": "^9.4.3",
"chokidar": "^3.6.0",
Expand Down

0 comments on commit 1912b97

Please sign in to comment.