refactor: move svelte files into app folder

This commit is contained in:
Huakun Shen 2024-12-20 09:43:16 -05:00
parent 8ee1a13c6d
commit 92d1df4928
No known key found for this signature in database
43 changed files with 39 additions and 39 deletions

View File

@ -24,7 +24,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Go to Extension Store", description: "Go to Extension Store",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appextension/store") goto("/app/extension/store")
} }
}, },
{ {
@ -35,7 +35,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
}, },
description: "", description: "",
function: async () => { function: async () => {
goto("/appauth") goto("/app/auth")
} }
}, },
{ {
@ -97,7 +97,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
}, },
description: "", description: "",
function: async () => { function: async () => {
goto("/appextension/file-transfer") goto("/app/extension/file-transfer")
appState.clearSearchTerm() appState.clearSearchTerm()
} }
}, },
@ -111,7 +111,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "", description: "",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appsettings/add-dev-extension") goto("/app/settings/add-dev-extension")
} }
}, },
{ {
@ -136,7 +136,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
function: async () => { function: async () => {
// const appStateStore = useAppStateStore() // const appStateStore = useAppStateStore()
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appsettings/set-dev-ext-path") goto("/app/settings/set-dev-ext-path")
} }
}, },
{ {
@ -148,11 +148,11 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "", description: "",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
// goto("/appwindow-troubleshooter") // goto("/app/window-troubleshooter")
const winLabel = `main:extension-window-troubleshooter-${uuidv4()}` const winLabel = `main:extension-window-troubleshooter-${uuidv4()}`
console.log(winLabel) console.log(winLabel)
new WebviewWindow(winLabel, { new WebviewWindow(winLabel, {
url: "/troubleshooters/extension-window", url: "/app/troubleshooters/extension-window",
title: "Extension Window Troubleshooter" title: "Extension Window Troubleshooter"
}) })
}, },
@ -167,7 +167,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "", description: "",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appextension/permission-inspector") goto("/app/extension/permission-inspector")
}, },
keywords: ["extension"] keywords: ["extension"]
}, },
@ -180,7 +180,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "", description: "",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/apptroubleshooters/extension-loading") goto("/app/troubleshooters/extension-loading")
}, },
keywords: ["extension", "troubleshooter"] keywords: ["extension", "troubleshooter"]
}, },
@ -193,7 +193,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Create a Quicklink", description: "Create a Quicklink",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appextension/create-quick-link") goto("/app/extension/create-quick-link")
} }
}, },
{ {
@ -204,7 +204,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
}, },
description: "Open Settings", description: "Open Settings",
function: async () => { function: async () => {
goto("/appsettings") goto("/app/settings")
appState.clearSearchTerm() appState.clearSearchTerm()
} }
}, },
@ -264,7 +264,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
}, },
description: "Dance", description: "Dance",
function: async () => { function: async () => {
goto("/appdance") goto("/app/dance")
} }
}, },
{ {
@ -305,7 +305,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Clipboard History", description: "Clipboard History",
function: async () => { function: async () => {
appState.clearSearchTerm() appState.clearSearchTerm()
goto("/appextension/clipboard") goto("/app/extension/clipboard")
} }
}, },
{ {
@ -322,7 +322,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
return return
} }
const window = new WebviewWindow(`main:pinned-screenshot-${uuidv4()}`, { const window = new WebviewWindow(`main:pinned-screenshot-${uuidv4()}`, {
url: "/extension/pin-screenshot", url: "/app/extension/pin-screenshot",
title: "Pinned Screenshot", title: "Pinned Screenshot",
hiddenTitle: true, hiddenTitle: true,
titleBarStyle: "transparent", titleBarStyle: "transparent",
@ -342,7 +342,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
}, },
description: "MDNS Debugger", description: "MDNS Debugger",
function: async () => { function: async () => {
goto("/apptroubleshooters/mdns-debugger") goto("/app/troubleshooters/mdns-debugger")
}, },
flags: { flags: {
developer: true developer: true

View File

@ -24,7 +24,7 @@ export async function onTemplateUiCmdSelect(
) { ) {
await createExtSupportDir(ext.extPath) await createExtSupportDir(ext.extPath)
// console.log("onTemplateUiCmdSelect", ext, cmd, isDev, hmr) // console.log("onTemplateUiCmdSelect", ext, cmd, isDev, hmr)
const url = `/extension/ui-worker?extPath=${encodeURIComponent(ext.extPath)}&cmdName=${encodeURIComponent(cmd.name)}` const url = `/app/extension/ui-worker?extPath=${encodeURIComponent(ext.extPath)}&cmdName=${encodeURIComponent(cmd.name)}`
if (cmd.window) { if (cmd.window) {
const winLabel = await winExtMap.registerExtensionWithWindow({ extPath: ext.extPath }) const winLabel = await winExtMap.registerExtensionWithWindow({ extPath: ext.extPath })
const window = launchNewExtWindow(winLabel, url, cmd.window) const window = launchNewExtWindow(winLabel, url, cmd.window)
@ -52,7 +52,7 @@ export async function onCustomUiCmdSelect(
} else { } else {
url = decodeURIComponent(convertFileSrc(`${trimSlash(cmd.main)}`, "ext")) url = decodeURIComponent(convertFileSrc(`${trimSlash(cmd.main)}`, "ext"))
} }
let url2 = `/extension/ui-iframe?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}` let url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(url)}&extPath=${encodeURIComponent(ext.extPath)}`
if (cmd.window) { if (cmd.window) {
const winLabel = await winExtMap.registerExtensionWithWindow({ const winLabel = await winExtMap.registerExtensionWithWindow({
extPath: ext.extPath, extPath: ext.extPath,
@ -61,7 +61,7 @@ export async function onCustomUiCmdSelect(
if (platform() === "windows" && !useDevMain) { if (platform() === "windows" && !useDevMain) {
const addr = await spawnExtensionFileServer(winLabel) const addr = await spawnExtensionFileServer(winLabel)
const newUrl = `http://${addr}` const newUrl = `http://${addr}`
url2 = `/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}` url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
} }
const window = launchNewExtWindow(winLabel, url2, cmd.window) const window = launchNewExtWindow(winLabel, url2, cmd.window)
window.onCloseRequested(async (event) => { window.onCloseRequested(async (event) => {
@ -78,7 +78,7 @@ export async function onCustomUiCmdSelect(
const addr = await spawnExtensionFileServer(winLabel) // addr has format "127.0.0.1:<port>" const addr = await spawnExtensionFileServer(winLabel) // addr has format "127.0.0.1:<port>"
console.log("Extension file server address: ", addr) console.log("Extension file server address: ", addr)
const newUrl = `http://${addr}` const newUrl = `http://${addr}`
url2 = `/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}` url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
} }
goto(url2) goto(url2)
} }

View File

@ -87,7 +87,7 @@
async function pickExtFiles() { async function pickExtFiles() {
if (!$appConfig.devExtensionPath) { if (!$appConfig.devExtensionPath) {
toast.warning("Please set the dev extension path in the settings") toast.warning("Please set the dev extension path in the settings")
return goto("/appsettings/set-dev-ext-path") return goto("/app/settings/set-dev-ext-path")
} }
const selected = await openFileSelector({ const selected = await openFileSelector({
directory: false, directory: false,

View File

@ -17,7 +17,7 @@
toast.warning( toast.warning(
"Please set the dev extension path in the settings to install tarball extension" "Please set the dev extension path in the settings to install tarball extension"
) )
return goto("/appsettings/set-dev-ext-path") return goto("/app/settings/set-dev-ext-path")
} }
await extensions await extensions
.installFromNpmPackageName(data.name, $appConfig.devExtensionPath) .installFromNpmPackageName(data.name, $appConfig.devExtensionPath)

View File

@ -19,7 +19,7 @@
toast.warning( toast.warning(
"Please set the dev extension path in the settings to install tarball extension" "Please set the dev extension path in the settings to install tarball extension"
) )
return goto("/appsettings/set-dev-ext-path") return goto("/app/settings/set-dev-ext-path")
} }
await extensions await extensions
.installFromTarballUrl(data.url, $appConfig.devExtensionPath) .installFromTarballUrl(data.url, $appConfig.devExtensionPath)

View File

@ -59,7 +59,7 @@ export async function handleKunkunProtocol(parsedUrl: URL) {
if (parsed.identifier) { if (parsed.identifier) {
goto(`/extension/store/${parsed.identifier}`) goto(`/extension/store/${parsed.identifier}`)
} else { } else {
goto("/appextension/store") goto("/app/extension/store")
} }
} else if (href.startsWith(DEEP_LINK_PATH_REFRESH_DEV_EXTENSION)) { } else if (href.startsWith(DEEP_LINK_PATH_REFRESH_DEV_EXTENSION)) {
emitRefreshDevExt() emitRefreshDevExt()

View File

@ -76,7 +76,7 @@ export async function globalKeyDownHandler(e: KeyboardEvent) {
if ((_platform === "macos" && e.metaKey) || (_platform === "windows" && e.ctrlKey)) { if ((_platform === "macos" && e.metaKey) || (_platform === "windows" && e.ctrlKey)) {
if (e.key === ",") { if (e.key === ",") {
e.preventDefault() e.preventDefault()
goto("/appsettings") goto("/app/settings")
} }
} }
// Toggle Devtools with control + shift + I // Toggle Devtools with control + shift + I

View File

@ -7,7 +7,7 @@ export function goBack() {
} }
export function goHome() { export function goHome() {
goto("/app") goto("/app/")
} }
export function goHomeOrCloseDependingOnWindow() { export function goHomeOrCloseDependingOnWindow() {

View File

@ -44,7 +44,7 @@
function onSignOut() { function onSignOut() {
auth auth
.signOut() .signOut()
.then(() => goto("/appauth")) .then(() => goto("/app/auth"))
.catch((err) => toast.error("Failed to sign out", { description: err.message })) .catch((err) => toast.error("Failed to sign out", { description: err.message }))
} }
</script> </script>
@ -56,7 +56,7 @@
size="icon" size="icon"
onclick={() => { onclick={() => {
console.log("go Home") console.log("go Home")
goto("/app") goto("/app/")
}} }}
> >
<ArrowLeft class="size-4" /> <ArrowLeft class="size-4" />

View File

@ -5,7 +5,7 @@
function handleKeyDown(event: KeyboardEvent) { function handleKeyDown(event: KeyboardEvent) {
if (event.key === "Enter") { if (event.key === "Enter") {
goto("/app") goto("/app/")
} }
} }
</script> </script>
@ -17,7 +17,7 @@
title="Fail to Load Extension" title="Fail to Load Extension"
class="w-fit max-w-screen-sm border-2 border-red-500" class="w-fit max-w-screen-sm border-2 border-red-500"
message={$page.error?.message ?? "Unknown Error"} message={$page.error?.message ?? "Unknown Error"}
onGoBack={() => goto("/app")} onGoBack={() => goto("/app/")}
rawJsonError={JSON.stringify($page, null, 2)} rawJsonError={JSON.stringify($page, null, 2)}
/> />
</Layouts.Center> </Layouts.Center>

View File

@ -136,7 +136,7 @@
function handleKeydown(e: KeyboardEvent) { function handleKeydown(e: KeyboardEvent) {
if (e.key === "Escape") { if (e.key === "Escape") {
if (!delayedImageDialogOpen) { if (!delayedImageDialogOpen) {
goto("/appextension/store") goto("/app/extension/store")
} }
} }
} }
@ -148,7 +148,7 @@
size="icon" size="icon"
class={cn("fixed left-3 top-3", Constants.CLASSNAMES.BACK_BUTTON)} class={cn("fixed left-3 top-3", Constants.CLASSNAMES.BACK_BUTTON)}
data-flip-id={Constants.CLASSNAMES.BACK_BUTTON} data-flip-id={Constants.CLASSNAMES.BACK_BUTTON}
onclick={() => goto("/appextension/store")} onclick={() => goto("/app/extension/store")}
> >
<ArrowLeftIcon /> <ArrowLeftIcon />
</Button> </Button>

View File

@ -51,7 +51,7 @@
const iframeUiAPI: IUiIframeServer2 = { const iframeUiAPI: IUiIframeServer2 = {
goBack: async () => { goBack: async () => {
if (isInMainWindow()) { if (isInMainWindow()) {
goto("/app") goto("/app/")
} else { } else {
appWin.close() appWin.close()
} }

View File

@ -24,7 +24,7 @@ export const load: PageLoad = async ({
if (!_extPath || !_extUrl) { if (!_extPath || !_extUrl) {
toast.error("Invalid extension path or url") toast.error("Invalid extension path or url")
error("Invalid extension path or url") error("Invalid extension path or url")
goto("/app") goto("/app/")
} }
const extPath = z.string().parse(_extPath) const extPath = z.string().parse(_extPath)
const extUrl = z.string().parse(_extUrl) const extUrl = z.string().parse(_extUrl)
@ -36,7 +36,7 @@ export const load: PageLoad = async ({
toast.error("Error loading extension manifest", { toast.error("Error loading extension manifest", {
description: `${err}` description: `${err}`
}) })
goto("/app") goto("/app/")
} }
const loadedExt = _loadedExt! const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath) const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -44,7 +44,7 @@ export const load: PageLoad = async ({
toast.error("Unexpected Error", { toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.` description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
}) })
goto("/app") goto("/app/")
} }
return { extPath, url: extUrl, loadedExt, extInfoInDB: extInfoInDB! } return { extPath, url: extUrl, loadedExt, extInfoInDB: extInfoInDB! }
} }

View File

@ -63,7 +63,7 @@
async function goBack() { async function goBack() {
if (isInMainWindow()) { if (isInMainWindow()) {
goto("/app") goto("/app/")
} else { } else {
appWin.close() appWin.close()
} }

View File

@ -27,7 +27,7 @@ export const load: PageLoad = async ({ url }) => {
if (!extPath || !cmdName) { if (!extPath || !cmdName) {
toast.error("Invalid extension path or url") toast.error("Invalid extension path or url")
error("Invalid extension path or url") error("Invalid extension path or url")
goto("/app") goto("/app/")
} }
let _loadedExt: ExtPackageJsonExtra | undefined let _loadedExt: ExtPackageJsonExtra | undefined
@ -38,7 +38,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Error loading extension manifest", { toast.error("Error loading extension manifest", {
description: `${err}` description: `${err}`
}) })
goto("/app") goto("/app/")
} }
const loadedExt = _loadedExt! const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath) const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -46,7 +46,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Unexpected Error", { toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.` description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
}) })
goto("/app") goto("/app/")
} }
const pkgJsonPath = await join(extPath!, "package.json") const pkgJsonPath = await join(extPath!, "package.json")
if (!(await exists(extPath!))) { if (!(await exists(extPath!))) {