Comments (4)
How do we sync the file tree with the file system inside webcontainer?
I already wrote a function to traverse the tree and reads all files, we can add a boolean to disable reading the files and just returning the files without contents and use it for this. The slow part is just reading the files (esp. with node deps)
Imho we can leverage the fact that we don't have access to the webcontainer directly but only through the custom store. We add a function to the custom store to create a file that write to the webcontainer filesystem and to the list of files (a POJO). This ensure that we always have access to the whole file system (minus node_modules but we don't care about those imho) and they don't go out of sync.
//we add a files field here
const { subscribe, update } = writable({
current_file: files.src.directory.routes.directory['+page.svelte'].file.contents,
current_path: './src/routes/+page.svelte',
iframe_url: './loading',
files,
});
//and a function like this in the webcontainer store
create_file(path: string, content?: string){
webcontainer_instance.fs.writeFile(path, content);
// we don't even need to save the content here, just the fact that there's a file. Also we can use the same structure the webcontainer file tree uses so that we can save it as POJO later on
files[path];
}
For file icons we can use simple-icons because they have the most dev icons I think. How can we swap out the icons per name, just matching against a list of names and extensions or do we need something sophisticated / glob?
I was thinking of of having a map of regex -> icon so that we can match against specific files (for example . svelte or vite.config.json) for specific icons. And than have a default for file and folder.
from sveltelab.
For file icons we can use simple-icons because they have the most dev icons I think. How can we swap out the icons per name, just matching against a list of names and extensions or do we need something sophisticated / glob?
from sveltelab.
How do we sync the file tree with the file system inside webcontainer?
I already wrote a function to traverse the tree and reads all files, we can add a boolean to disable reading the files and just returning the files without contents and use it for this. The slow part is just reading the files (esp. with node deps)
from sveltelab.
Just joking...we need also the content so that we can later on store it.
I think performance wise is better to have a separated store for it tho otherwise the store we use for the tree would be "dirty" and every keystroke.
from sveltelab.
Related Issues (20)
- β¨ Support Svelte Inspector HOT 3
- π dropdown menu looking _stupid_ in Safari macOS
- β¨ Include default .gitignore in exported project HOT 4
- β¨ Show `.svelte-kit` or add command to show it HOT 1
- π Address Login with email problems
- β¨ alias g4c to git to allow for github repo dependencies HOT 1
- π Vite error when opening project preview in a new tab HOT 3
- β¨ Add carbon-components-svelte template HOT 1
- π Moving folders sometimes causes ghost files
- β¨ reduce call in profile for personal repls HOT 4
- β¨ explore HOT 2
- π After forking a project, the save button doesn't appear HOT 1
- π "Additional step required" when opening fullscreen view HOT 5
- β¨ "workspace:*" in package.json HOT 4
- π Incorrect keyboard shortcuts HOT 1
- β¨ disable js in iframe HOT 1
- β¨ Easier way to find the import from github command HOT 2
- When trying to save the project I get Can't Save the projectπ HOT 13
- Trying to add shadcn-sveelte to a Projectπ HOT 1
- Error management with monorepo and sveltekit 2π HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltelab.