-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat (toolbar): Adding new top level package for web developer toolbar #446
Conversation
Just to note on the packaging stuff, does it make sense to have the example packaging in the toolbar folder? As opposed to keep the toolbar a lighter package and include it as a dependency in an/all-of-the example(s)? Or if we need a proper app to dev/test the toolbar, maybe that goes in a subfolder that isn't included in the package list? |
❌ Deploy Preview for electric-sql-basic-items-example failed.
|
This is how it works. The web app in the folder is for dev only and isn't built into the package. The package itself is quite minimal and can be added to any of the examples. I can try to tease apart the dev app code from the toolbar code for clarity. Maybe I can get code reloading etc to work properly with a clean example app and the toolbar as a dependency then I could dump the dev web app altogether. I tried this before and couldn't get it to work. maybe using |
I've moved the dev app into a sub folder for tidiness but the structure is the same. There is a dev app that is used during development in I have added the toolbar to the web-wa-sqlite example. It shows if you do |
fdbaf26
to
7999d39
Compare
@thruflo I've got the SQLite console working with codemirror. And sort of got the running of DAL queries working too but was blocked by the way There are a couple of outstanding build issues:
We could merge this now with these two issues or wait til fix them properly next week. |
Awesome :) I'll have a play with it. Sounds like it's worth resolving the build issues before merging -- no mad rush. |
(Maybe also sync on the |
import './Example.css' | ||
|
||
// toolbar imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally it would be good to keep the imports in this example as clean / minimal as possible. I'd suggest add a toolbar.tsx src file and have that encapsulate these details and just expose the component.
Also presumably the css import should not be required here (should be imported and thus bundled by the toolbar lib).
Also you're mixing double quote and single quite and the import spacing is inconsistent. Syntax wise you want:
import { globalRegistry } from 'electric-sql/satellite'
import { AddToolbar, TypescriptApi } from '@electric-sql/debug-toolbar'
This should be normalised by prettier, so have you run the listing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the globalRegistry needs to be done from the client code not the library I played with this a lot - its to do with when to global singleton gets created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @thruflo was hinting at having a single file expose all of this such that you need only a single import:
import { globalRegistry, AddToolbar, TypescriptApi } from '@electric-sql/debug-toolbar'
For the rest nothing changes.
@@ -0,0 +1,160 @@ | |||
#electric-toolbar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it makes sense to only have one toolbar at a time and for it to always be at the bottom. But does this need to be the concern of the core toolbar component, i.e.: could the toolbar have normal positioning and then there's a wrapper that deals with the fixed / absolute etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is useful to get the css reset working nicely - this id specificity overrides class ones
Note from
Seems |
There's a missing
|
I get an error trying to edit the SQL command. Specifically, I can move the cursor around but then when I try to e.g.: type backspace to delete a character I get:
|
I have a few comments on the layout and naming:
On the last point, generally we want this to work with mobile too, so we have to take care of how functional the UI is at smaller sizes. And it might be nice to make resizable -- although I know the extension panel will handle this so maybe ignore. But right now as an overlay, it hides the page content underneath it, rather than allowing that to scroll. |
@thruflo can you have another look at this now? It's still using the separate root element added into the dom. I couldn't get it to build as an exported react component, due to complexities of loading react. (The codemirror react library I'm using has a I have published it to the npm registry yet - this might have to wait til next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
I left quite some comments but nothing major.
Also, prettier reports some formatting issues when running npm run check-styleguide
both in the toolbar and in linearlite.
examples/linearlite/src/App.tsx
Outdated
@@ -11,6 +11,11 @@ import LeftMenu from './components/LeftMenu' | |||
import { ElectricProvider, initElectric, dbName, DEBUG } from './electric' | |||
import { Electric } from './generated/client' | |||
|
|||
// toolbar imports | |||
import { globalRegistry } from "electric-sql/satellite"; | |||
import AddToolbar, { TypescriptApi } from '@electric-sql/debug-toolbar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we find a more descriptive name for TypescriptApi
?
Is it just the toolbar API itself? Could be Toolbar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone with ToolbarTypescript
as there may be other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get why we are naming the toolbar class after the programming language its implemented in.
What do you mean when you say there could be another? If it is in another language it won't be in this package so it will be imported from somewhere else. I don't see the need to differentiate its name by the programming language.
import './Example.css' | ||
|
||
// toolbar imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe @thruflo was hinting at having a single file expose all of this such that you need only a single import:
import { globalRegistry, AddToolbar, TypescriptApi } from '@electric-sql/debug-toolbar'
For the rest nothing changes.
"types": "dist/index.d.ts", | ||
"author": "ElectricSQL", | ||
"license": "Apache-2.0", | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I would even argue that we don't want to package a demo-app with the toolbar. Demo apps should be found in examples
.
@kevin-dp I've pretty much done all the changes as you suggested except:
I have also added the OpenSourceOne font via a CDN I tried using the pnpm workspace for local dev but you still have go through the build step for every change, it usable but annoying. I have added instructions on setting this up locally in the readme, but I will keep my local dev-app for convenience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some new comments.
Also, it seems that there are some comments you did not address (e.g. the comments in toolbar/src/index.tsx
).
Also i just noticed that there are no unit tests.
Perhaps we should add unit tests for the toolbar to check that when you create a toolbar it can access the satellites, and correctly query and reset the DB. We can use the better-sqlite3
driver in these unit tests. That will give some assurance that the global registry mechanism works.
There is a conflict on the lock file so you will need to update it and push it.
Don't forget to generate a changeset for your PR.
"@types/node": ">=16.11.0", | ||
"@types/react": "^18.0.18", | ||
"@types/react-dom": "^18.0.11", | ||
"electric-sql": "latest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a real dev dependency?
It's probably a remnant of the local dev app you use.
But since we don't checkout the dev app we probably don't need this dev dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it need them all - at least it doesn't build without them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in src/api/toolbar-typescript.ts
the global registry is being imported:
import { GlobalRegistry } from 'electric-sql/satellite'
So electric-sql
needs to be a dependency rather than a dev dependency.
Perhaps it should even be a peer dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticing now that it is listed as a peer-dependency. Why does it need to be a dev dependency also then? Is it being used in some test somewhere? I don't think there are any tests.
toolbar/src/api/types.ts
Outdated
@@ -0,0 +1 @@ | |||
export type { Row, Statement, ConnectivityState } from 'electric-sql/dist/util' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not import/re-export things from electric-sql/dist
, dist
is the distribution folder.
This should be electric-sql/util
. I would not bother re-exporting it here, you can import it directly from electric in whichever file you need it. Please double check that there are no other places where you import from electric-sql/dist
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done these import directly now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but you're still doing import { Row, Statement, ConnectivityState } from 'electric-sql/dist/util'
.
You should not import from dist
but just electric-sql/util
. Same for other imports where you import from dist
.
toolbar/src/index.tsx
Outdated
} | ||
} | ||
|
||
export function typescriptApi( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't like typescript
being in the name of this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this to clientApi
toolbar/package.json
Outdated
@@ -28,7 +28,8 @@ | |||
"esbuild": "^0.16.17", | |||
"esbuild-plugin-inline-image": "^0.0.9", | |||
"prettier": "3.0.3", | |||
"typescript": "^4.4.3" | |||
"typescript": "^4.4.3", | |||
"zod": "^3.21.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need zod
as a dev dependency?
I don't see it being used anywhere in the toolbar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no you're right
859c00d
to
c54a42a
Compare
No description provided.