Bootstrap filesystem and add filesystem store
Co-authored-by: Jess Martin <jessmartin@gmail.com>
This commit is contained in:
parent
264476b004
commit
046c80be44
|
|
@ -3,11 +3,12 @@
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
bootstrapFilesystem,
|
||||||
isUsernameValid,
|
isUsernameValid,
|
||||||
isUsernameAvailable,
|
isUsernameAvailable,
|
||||||
register
|
register
|
||||||
} from '$lib/common/webnative'
|
} from '$lib/common/webnative'
|
||||||
import { sessionStore } from '../../stores'
|
import { filesystemStore, sessionStore } from '../../stores'
|
||||||
import type { Session } from '$lib/session'
|
import type { Session } from '$lib/session'
|
||||||
import CheckIcon from '$components/icons/CheckIcon.svelte'
|
import CheckIcon from '$components/icons/CheckIcon.svelte'
|
||||||
import XIcon from '$components/icons/XIcon.svelte'
|
import XIcon from '$components/icons/XIcon.svelte'
|
||||||
|
|
@ -54,6 +55,9 @@
|
||||||
|
|
||||||
console.log('session after registration', $sessionStore)
|
console.log('session after registration', $sessionStore)
|
||||||
|
|
||||||
|
const fs = await bootstrapFilesystem()
|
||||||
|
filesystemStore.set(fs)
|
||||||
|
|
||||||
goto('/linkDevice')
|
goto('/linkDevice')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import * as webnative from 'webnative'
|
import * as webnative from 'webnative'
|
||||||
// import type FileSystem from 'webnative/fs/index'
|
import type FileSystem from 'webnative/fs/index'
|
||||||
import { setup } from 'webnative'
|
import { setup } from 'webnative'
|
||||||
|
|
||||||
import { asyncDebounce } from '$lib/common/utils'
|
import { asyncDebounce } from '$lib/common/utils'
|
||||||
import { sessionStore } from '../../stores'
|
import { filesystemStore, sessionStore } from '../../stores'
|
||||||
|
|
||||||
// runfission.net = staging
|
// runfission.net = staging
|
||||||
setup.endpoints({ api: 'https://runfission.net', user: 'fissionuser.net' })
|
setup.endpoints({ api: 'https://runfission.net', lobby: 'https://auth.runfission.net', user: 'fissionuser.net' })
|
||||||
|
|
||||||
let state: webnative.AppState
|
let state: webnative.AppState
|
||||||
|
|
||||||
// TODO: Add a flag or script to turn debugging on/off
|
// TODO: Add a flag or script to turn debugging on/off
|
||||||
setup.debug({ enabled: true })
|
setup.debug({ enabled: false })
|
||||||
|
|
||||||
export const initialize = async (): Promise<void> => {
|
export const initialize = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -32,6 +32,7 @@ export const initialize = async (): Promise<void> => {
|
||||||
authed: state.authenticated,
|
authed: state.authenticated,
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
|
filesystemStore.set(state.fs)
|
||||||
break
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -79,6 +80,10 @@ export const register = async (username: string): Promise<boolean> => {
|
||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const bootstrapFilesystem = async (): Promise<FileSystem> => {
|
||||||
|
return await webnative.bootstrapRootFileSystem()
|
||||||
|
}
|
||||||
|
|
||||||
// interface StateFS {
|
// interface StateFS {
|
||||||
// fs?: FileSystem
|
// fs?: FileSystem
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
import type { Writable } from 'svelte/store'
|
||||||
|
import type FileSystem from 'webnative/fs/index'
|
||||||
|
|
||||||
import { loadTheme } from '$lib/theme'
|
import { loadTheme } from '$lib/theme'
|
||||||
import type { Session } from '$lib/session'
|
import type { Session } from '$lib/session'
|
||||||
import type { Theme } from '$lib/theme'
|
import type { Theme } from '$lib/theme'
|
||||||
import type { Writable } from 'svelte/store'
|
|
||||||
|
|
||||||
export const theme: Writable<Theme> = writable(loadTheme())
|
export const theme: Writable<Theme> = writable(loadTheme())
|
||||||
|
|
||||||
|
|
@ -10,4 +12,6 @@ export const sessionStore: Writable<Session> = writable({
|
||||||
username: '',
|
username: '',
|
||||||
authed: false,
|
authed: false,
|
||||||
loading: true
|
loading: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const filesystemStore: Writable<FileSystem | null> = writable(null)
|
||||||
Loading…
Reference in New Issue