-
Notifications
You must be signed in to change notification settings - Fork 8
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
Run RefStudio in the browser #358
Conversation
Codecov Report
@@ Coverage Diff @@
## main #358 +/- ##
==========================================
+ Coverage 84.42% 86.80% +2.38%
==========================================
Files 157 16 -141
Lines 9372 917 -8455
Branches 1022 0 -1022
==========================================
- Hits 7912 796 -7116
+ Misses 1449 121 -1328
+ Partials 11 0 -11 see 150 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -18,7 +18,9 @@ export function useFileProjectNewListener() { | |||
const createFile = useSetAtom(createFileAtom); | |||
|
|||
return async () => { | |||
const newProjectPath = await save({ defaultPath: await getNewProjectsBaseDir() }); | |||
const newProjectPath = import.meta.env.VITE_IS_WEB |
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 a workaround for not having a "Save" dialog on the web version.
@@ -1,7 +1,8 @@ | |||
import { emit, EventCallback, listen } from '@tauri-apps/api/event'; | |||
import type { EventCallback } from '@tauri-apps/api/event'; |
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 we'd enforce that only tauri-wrapper.ts
can import values (not types) from @tauri-apps/api
. Every other module should use the wrapper. In theory import/no-restricted-paths
could enforce this but I had trouble getting it to work.
type: 'dir'; | ||
} | ||
type FakeNode = FakeFile | FakeDir; | ||
type NormalizedPath = string & { _brand: 'normalized' }; |
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.
The idea here is that you should only put a "normalized" path (no double-slashes) in the Map
. This type enforces that you've gone through normalizePath
before touching the Map
.
|
||
import * as tauriEvent from '@tauri-apps/api/event'; | ||
|
||
const listeners = new Map<string, tauriEvent.EventCallback<unknown>>(); |
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.
@danvk added support to register multiple listeners for the same event. I'm not sure if we are using that currently, but def something we might use in the future.
There should be no visible changes to the desktop app from this PR.
To run the web version, use:
and open http://localhost:1421/ in your browser.
I took the approach of "stub everything out until it runs". I wound up having to implement more logic in the stubs than I expected:
settingsManager.ts
: I made a lightweight in-memory version oftauri-settings
; we'll eventually want to rip this out and move settings into the Python API.invoke
: I made this a no-op@tauri-apps/api/event
: I implemented a very simple event bus@tauri-apps/api/fs
: I implemented an in-memory filesystem to make this API work. Eventually we'll want to connect this to an API on the Python server once we have a clearer idea about exactly the API we need for project lifecycle.The default display looks pretty empty (this might be a bug in my in-memory FS) but you can X out the project and either create a new one or a sample one to try the editor:
try.sample.project.mov
Saving changes requires a menu bar in the app. I exposed a global
emitEvent
that you can call from the dev tools if you want to save a file:save.changes.mov
See #347