Skip to content

Commit 216ccbd

Browse files
committed
feat: move devtool to separate package
1 parent 89f36c6 commit 216ccbd

19 files changed

Lines changed: 303 additions & 36 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@will-be-done/hyperdb": patch
3+
"@will-be-done/hyperdb-devtool": patch
4+
---
5+
6+
Move the React devtool into a standalone package and remove the goober dependency from HyperDB core.

bun.lock

Lines changed: 34 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"packages/*"
1414
],
1515
"scripts": {
16-
"build": "bun run --filter='@will-be-done/hyperdb' build && bun run --filter='@will-be-done/hyperdb-doc' build",
16+
"build": "bun run --filter='@will-be-done/hyperdb' build && bun run --filter='@will-be-done/hyperdb-devtool' build && bun run --filter='@will-be-done/hyperdb-doc' build",
1717
"changeset": "changeset",
1818
"format": "prettier --write .",
1919
"format:check": "prettier --check .",
20-
"lint": "bun run --filter='@will-be-done/hyperdb' lint",
21-
"lint:cycles": "bun run --filter='@will-be-done/hyperdb' lint:cycles",
22-
"release": "bun run --filter='@will-be-done/hyperdb' build && changeset publish",
23-
"test": "bun run --filter='@will-be-done/hyperdb' test",
24-
"ts": "bun run --filter='@will-be-done/hyperdb' ts",
20+
"lint": "bun run --filter='@will-be-done/hyperdb' lint && bun run --filter='@will-be-done/hyperdb-devtool' lint",
21+
"lint:cycles": "bun run --filter='@will-be-done/hyperdb' lint:cycles && bun run --filter='@will-be-done/hyperdb-devtool' lint:cycles",
22+
"release": "bun run --filter='@will-be-done/hyperdb' build && bun run --filter='@will-be-done/hyperdb-devtool' build && changeset publish",
23+
"test": "bun run --filter='@will-be-done/hyperdb' test && bun run --filter='@will-be-done/hyperdb-devtool' test",
24+
"ts": "bun run --filter='@will-be-done/hyperdb' ts && bun run --filter='@will-be-done/hyperdb-devtool' ts",
2525
"version-packages": "changeset version"
2626
},
2727
"devDependencies": {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/** @type {import("dependency-cruiser").IConfiguration} */
2+
module.exports = {
3+
forbidden: [
4+
{
5+
name: "no-circular",
6+
severity: "error",
7+
comment:
8+
"Detects runtime and type-only import cycles. Keep tsPreCompilationDeps enabled so TypeScript-only edges are included.",
9+
from: {},
10+
to: {
11+
circular: true,
12+
},
13+
},
14+
],
15+
options: {
16+
doNotFollow: {
17+
path: ["node_modules", "dist"],
18+
},
19+
includeOnly: ["^src"],
20+
moduleSystems: ["es6"],
21+
tsPreCompilationDeps: true,
22+
tsConfig: {
23+
fileName: "tsconfig.eslint.json",
24+
},
25+
enhancedResolveOptions: {
26+
conditionNames: ["import", "require", "node", "default", "types"],
27+
extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"],
28+
exportsFields: ["exports"],
29+
mainFields: ["module", "main", "types", "typings"],
30+
},
31+
skipAnalysisNotInRules: true,
32+
},
33+
};

packages/hyperdb-devtool/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# @will-be-done/hyperdb-devtool
2+
3+
React devtools for HyperDB.
4+
5+
```tsx
6+
import { HyperDBDevtools } from "@will-be-done/hyperdb-devtool/react";
7+
8+
<HyperDBDevtools db={db} />;
9+
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import js from "@eslint/js";
2+
import importPlugin from "eslint-plugin-import";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import unusedImports from "eslint-plugin-unused-imports";
5+
import globals from "globals";
6+
import { globalIgnores } from "eslint/config";
7+
import tseslint from "typescript-eslint";
8+
9+
export default tseslint.config([
10+
globalIgnores(["dist"]),
11+
{
12+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
13+
files: ["src/**/*.{ts,tsx}"],
14+
languageOptions: {
15+
ecmaVersion: 2020,
16+
globals: globals.browser,
17+
parserOptions: {
18+
project: "./tsconfig.eslint.json",
19+
tsconfigRootDir: import.meta.dirname,
20+
},
21+
},
22+
plugins: {
23+
import: importPlugin,
24+
"react-hooks": reactHooks,
25+
"unused-imports": unusedImports,
26+
},
27+
settings: {
28+
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
29+
"import/resolver": {
30+
node: {
31+
extensions: [".js", ".jsx", ".ts", ".tsx"],
32+
},
33+
},
34+
},
35+
rules: {
36+
"require-yield": "off",
37+
"@typescript-eslint/await-thenable": "error",
38+
"@typescript-eslint/no-floating-promises": "error",
39+
"@typescript-eslint/no-misused-promises": "error",
40+
"@typescript-eslint/no-unused-vars": "off",
41+
"@typescript-eslint/require-yield": "off",
42+
"import/no-cycle": ["error", { ignoreExternal: true }],
43+
"no-unused-vars": "off",
44+
"react-hooks/exhaustive-deps": "warn",
45+
"unused-imports/no-unused-imports": "error",
46+
"unused-imports/no-unused-vars": [
47+
"warn",
48+
{
49+
vars: "all",
50+
varsIgnorePattern: "^_",
51+
args: "after-used",
52+
argsIgnorePattern: "^_",
53+
},
54+
],
55+
},
56+
},
57+
]);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "@will-be-done/hyperdb-devtool",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"exports": {
6+
"./react": {
7+
"types": "./dist/react.d.ts",
8+
"import": "./dist/react.mjs",
9+
"require": "./dist/react.cjs"
10+
}
11+
},
12+
"files": [
13+
"dist",
14+
"README.md"
15+
],
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"scripts": {
20+
"analyze": "ANALYZE=true vite build && tsc",
21+
"build": "vite build && tsc",
22+
"lint": "eslint .",
23+
"lint:cycles": "depcruise src --config .dependency-cruiser.cjs",
24+
"prepack": "bun run build",
25+
"ts": "tsc",
26+
"test": "vitest run"
27+
},
28+
"dependencies": {
29+
"@will-be-done/hyperdb": "0.0.0",
30+
"goober": "^2.1.18"
31+
},
32+
"peerDependencies": {
33+
"react": ">=18.0.0",
34+
"react-dom": ">=18.0.0"
35+
},
36+
"devDependencies": {
37+
"@eslint/js": "^9.39.1",
38+
"@types/react": "19.2.17",
39+
"@types/react-dom": "19.2.3",
40+
"@vitest/browser-playwright": "4.1.5",
41+
"dependency-cruiser": "^17.4.3",
42+
"eslint": "^9.39.1",
43+
"eslint-plugin-import": "^2.32.0",
44+
"eslint-plugin-react-hooks": "7.1.1",
45+
"eslint-plugin-unused-imports": "^4.3.0",
46+
"globals": "^16.5.0",
47+
"playwright": "^1.61.0",
48+
"react": "19.2.7",
49+
"react-dom": "19.2.7",
50+
"rollup-plugin-visualizer": "^7.0.1",
51+
"typescript": "~5.9.3",
52+
"typescript-eslint": "^8.48.0",
53+
"vite": "^8.0.12",
54+
"vitest": "4.1.5"
55+
}
56+
}

packages/hyperdb/src/devtool/components.test.tsx renamed to packages/hyperdb-devtool/src/components.test.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { afterEach, describe, expect, it } from "vitest";
22
import { renderToString } from "react-dom/server";
3-
import { DB, execSync } from "../hyperdb/db";
4-
import { BptreeInmemDriver } from "../hyperdb/drivers/inmemory/bptree-inmem-driver";
5-
import { SubscribableDB } from "../hyperdb/runtime/subscribable-db";
3+
import { DB, execSync, SubscribableDB } from "@will-be-done/hyperdb";
4+
import { BptreeInmemDriver } from "@will-be-done/hyperdb/drivers/inmemory";
65
import {
76
HyperDBDevtools,
87
HyperDBDevtoolsPanel,
@@ -25,13 +24,13 @@ import {
2524
hyperDBTraceStore,
2625
markTraceFrameCached,
2726
startRootTrace,
28-
} from "../hyperdb/tracing/store";
29-
import type { SelectCommandEvent } from "../hyperdb/tracing/store";
27+
} from "@will-be-done/hyperdb/tracing";
28+
import type { SelectCommandEvent } from "@will-be-done/hyperdb/tracing";
3029
import type {
3130
MutationEvent,
3231
RootTrace,
3332
TraceFrame,
34-
} from "../hyperdb/tracing/store";
33+
} from "@will-be-done/hyperdb/tracing";
3534

3635
const createDB = (dbName?: string): SubscribableDB => {
3736
const db = new SubscribableDB(new DB(new BptreeInmemDriver(), { dbName }));

packages/hyperdb/src/devtool/components.tsx renamed to packages/hyperdb-devtool/src/components.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import React, {
66
useState,
77
} from "react";
88
import { css, setup, styled } from "goober";
9-
import { DBProvider, useSyncSelector } from "../react";
10-
import type { SubscribableDB } from "../hyperdb/runtime/subscribable-db";
9+
import { DBProvider, useSyncSelector } from "@will-be-done/hyperdb/react";
10+
import type { SubscribableDB } from "@will-be-done/hyperdb";
1111
import {
1212
getTraceDBInfo,
1313
hyperDBTraceStore,
@@ -22,7 +22,7 @@ import {
2222
type TraceDBInfo,
2323
type TraceFrame,
2424
type TraceStatus,
25-
} from "../hyperdb/tracing/store";
25+
} from "@will-be-done/hyperdb/tracing";
2626
import {
2727
traceStoreTraceSelection,
2828
traceStoreTraces,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./components";
2+
export * from "@will-be-done/hyperdb/tracing";

0 commit comments

Comments
 (0)