@@ -97,28 +97,29 @@ export function isFSFile(fsObject: FSObject): fsObject is FSFile {
9797
9898export interface LocalFSState {
9999 root : FSObject ;
100+ separator : string ;
100101 getDirectory : ( path : string ) => FSDirectory | null ;
101102 createDirectory : (
102103 name : string ,
103- parentDirectory : FSDirectory
104+ parentDirectory : FSDirectory ,
104105 ) => FSDirectory | null ;
105106 createFile : (
106107 name : string ,
107108 parentDirectory : FSDirectory ,
108- contents ?: string
109+ contents ?: string ,
109110 ) => FSFile | null ;
110111 favorites : Array < string > ;
111112 validateFSObjectName : ( name : string ) => string | null ;
112113 fsObjectNameIsAvailable : ( name : string , directory : FSDirectory ) => boolean ;
113114 create : (
114115 type : FSObjectType ,
115116 name : string ,
116- parentDirectory : FSDirectory
117+ parentDirectory : FSDirectory ,
117118 ) => FSObject | null ;
118119 rename : (
119120 parentDirectory : FSDirectory ,
120121 fsObject : FSObject ,
121- newName : string
122+ newName : string ,
122123 ) => void ;
123124 delete : ( parentDirectory : FSDirectory , fsObject : FSObject ) => void ;
124125 getParentDirectory : ( path : string ) => FSDirectory | null ;
@@ -149,7 +150,7 @@ export const useLocalFS = create<LocalFSState>()(
149150
150151 const createDirectory : LocalFSState [ "createDirectory" ] = (
151152 name ,
152- parentDirectory
153+ parentDirectory ,
153154 ) => {
154155 if ( parentDirectory . contents [ name ] ) return null ;
155156
@@ -173,7 +174,7 @@ export const useLocalFS = create<LocalFSState>()(
173174 const createFile : LocalFSState [ "createFile" ] = (
174175 name ,
175176 parentDirectory ,
176- contents
177+ contents ,
177178 ) => {
178179 if ( parentDirectory . contents [ name ] ) {
179180 return null ;
@@ -198,7 +199,7 @@ export const useLocalFS = create<LocalFSState>()(
198199 } ;
199200
200201 const validateFSObjectName : LocalFSState [ "validateFSObjectName" ] = (
201- name
202+ name ,
202203 ) => {
203204 if ( ! name ) {
204205 return "A value is required" ;
@@ -221,7 +222,7 @@ export const useLocalFS = create<LocalFSState>()(
221222
222223 const fsObjectNameIsAvailable : LocalFSState [ "fsObjectNameIsAvailable" ] = (
223224 name ,
224- directory
225+ directory ,
225226 ) => {
226227 return ! directory . contents [ name ] ;
227228 } ;
@@ -262,7 +263,7 @@ export const useLocalFS = create<LocalFSState>()(
262263
263264 const deleteFSObject : LocalFSState [ "delete" ] = (
264265 parentDirectory ,
265- fsObject
266+ fsObject ,
266267 ) => {
267268 delete parentDirectory . contents [ fsObject . name ] ;
268269 get ( ) . removeFromFavorites ( fsObject . path ) ;
@@ -272,7 +273,7 @@ export const useLocalFS = create<LocalFSState>()(
272273 const rename : LocalFSState [ "rename" ] = (
273274 parentDirectory ,
274275 fsObject ,
275- newName
276+ newName ,
276277 ) => {
277278 const oldName = fsObject . name ;
278279 const oldPath = fsObject . path ;
@@ -326,7 +327,7 @@ export const useLocalFS = create<LocalFSState>()(
326327 set ( { favorites } ) ;
327328 } ;
328329 const removeFromFavorites : LocalFSState [ "removeFromFavorites" ] = (
329- path
330+ path ,
330331 ) => {
331332 const oldFavorites = get ( ) . favorites ;
332333 const favorites = [ ...oldFavorites ] ;
@@ -338,6 +339,7 @@ export const useLocalFS = create<LocalFSState>()(
338339 } ;
339340 return {
340341 root : rootDir ,
342+ separator : pathSeparator ,
341343 favorites : [
342344 userDir . path ,
343345 documentsDir . path ,
@@ -362,8 +364,13 @@ export const useLocalFS = create<LocalFSState>()(
362364 } ,
363365 {
364366 name : "local-fs" ,
365- }
366- )
367+ partialize : ( state ) => {
368+ const updated = { ...state } as Partial < LocalFSState > ;
369+ delete updated . separator ;
370+ return updated ;
371+ } ,
372+ } ,
373+ ) ,
367374) ;
368375
369376export default useLocalFS ;
0 commit comments