Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions packages/devtools-kit/src/_types/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ServerFunctions {
// Static RPCs (can be provide on production build in the future)
getServerConfig: () => NuxtOptions
getServerDebugContext: () => Promise<ServerDebugContext | undefined>
getServerData: (token: string) => Promise<NuxtServerData>
getServerData: () => Promise<NuxtServerData>
getServerRuntimeConfig: () => Record<string, any>
getModuleOptions: () => ModuleOptions
getComponents: () => Component[]
Expand All @@ -36,46 +36,46 @@ export interface ServerFunctions {
// Updates
checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>
getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>
runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{ processId: string } | undefined>
runNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{ processId: string } | undefined>

// Terminal
getTerminals: () => TerminalInfo[]
getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>
runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>
getTerminalDetail: (id: string) => Promise<TerminalInfo | undefined>
runTerminalAction: (id: string, action: TerminalAction) => Promise<boolean>

// Storage
getStorageMounts: () => Promise<StorageMounts>
getStorageKeys: (base?: string) => Promise<string[]>
getStorageItem: (token: string, key: string) => Promise<StorageValue>
setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>
removeStorageItem: (token: string, key: string) => Promise<void>
getStorageItem: (key: string) => Promise<StorageValue>
setStorageItem: (key: string, value: StorageValue) => Promise<void>
removeStorageItem: (key: string) => Promise<void>

// Analyze
getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>
generateAnalyzeBuildName: () => Promise<string>
startAnalyzeBuild: (token: string, name: string) => Promise<string>
clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>
startAnalyzeBuild: (name: string) => Promise<string>
clearAnalyzeBuilds: (names?: string[]) => Promise<void>

// Queries
getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>
getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>
writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>
deleteStaticAsset: (token: string, filepath: string) => Promise<void>
renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>
getImageMeta: (filepath: string) => Promise<ImageMeta | undefined>
getTextAssetContent: (filepath: string, limit?: number) => Promise<string | undefined>
writeStaticAssets: (file: AssetEntry[], folder: string) => Promise<string[]>
deleteStaticAsset: (filepath: string) => Promise<void>
renameStaticAsset: (oldPath: string, newPath: string) => Promise<void>

// Actions
telemetryEvent: (payload: object, immediate?: boolean) => void
customTabAction: (name: string, action: number) => Promise<boolean>
enablePages: (token: string) => Promise<void>
enablePages: () => Promise<void>
openInEditor: (filepath: string) => Promise<boolean>
restartNuxt: (token: string, hard?: boolean) => Promise<void>
installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>
uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>
restartNuxt: (hard?: boolean) => Promise<void>
installNuxtModule: (name: string, dry?: boolean) => Promise<InstallModuleReturn>
uninstallNuxtModule: (name: string, dry?: boolean) => Promise<InstallModuleReturn>
enableTimeline: (dry: boolean) => Promise<[string, string]>

// Dev Token
requestForAuth: (info?: string, origin?: string) => Promise<void>
verifyAuthToken: (token: string) => Promise<boolean>
verifyAuthToken: () => Promise<boolean>
}

export interface ClientFunctions {
Expand Down
5 changes: 0 additions & 5 deletions packages/devtools-kit/src/_types/server-ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export interface NuxtDevtoolsServerContext {
*/
refresh: (event: keyof ServerFunctions) => void

/**
* @deprecated Auth is now handled by Vite DevTools. This is a noop.
*/
ensureDevAuthToken: (token: string) => Promise<void>

extendServerRpc: <ClientFunctions extends object = Record<string, unknown>, ServerFunctions extends object = Record<string, unknown>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ onMounted(async () => {

if (!isDevAuthed.value) {
if (devAuthToken.value) {
const result = await rpc.verifyAuthToken(devAuthToken.value)
const result = await rpc.verifyAuthToken()
if (result)
isDevAuthed.value = true
}
Expand Down
11 changes: 5 additions & 6 deletions packages/devtools/client/components/AssetDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { AssetInfo, CodeSnippet } from '~/../src/types'
import { devtoolsUiShowNotification } from '#imports'
import { computedAsync, useTimeAgo, useVModel } from '@vueuse/core'
import { computed, ref } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { useCopy, useOpenInEditor } from '~/composables/editor'
import { rpc } from '~/composables/rpc'
import { useServerConfig } from '~/composables/state'
Expand All @@ -18,7 +17,7 @@ const asset = useVModel(props, 'modelValue', emit, { passive: true })
const imageMeta = computedAsync(async () => {
if (asset.value.type !== 'image')
return undefined
return rpc.getImageMeta(await ensureDevAuthToken(), asset.value.filePath)
return rpc.getImageMeta(asset.value.filePath)
})

const editDialog = ref(false)
Expand All @@ -31,15 +30,15 @@ const textContent = computedAsync(async () => {
// eslint-disable-next-line ts/no-unused-expressions
textContentCounter.value

const content = await rpc.getTextAssetContent(await ensureDevAuthToken(), asset.value.filePath)
const content = await rpc.getTextAssetContent(asset.value.filePath)
newTextContent.value = content
return content
})

async function saveTextContent() {
if (textContent.value !== newTextContent.value) {
try {
await rpc.writeStaticAssets(await ensureDevAuthToken(), [{
await rpc.writeStaticAssets([{
path: asset.value.path,
content: newTextContent.value,
override: true,
Expand Down Expand Up @@ -134,7 +133,7 @@ const supportsPreview = computed(() => {
const deleteDialog = ref(false)
async function deleteAsset() {
try {
await rpc.deleteStaticAsset(await ensureDevAuthToken(), asset.value.filePath)
await rpc.deleteStaticAsset(asset.value.filePath)
asset.value = undefined as any
deleteDialog.value = false
devtoolsUiShowNotification({
Expand Down Expand Up @@ -170,7 +169,7 @@ async function renameAsset() {
try {
const extension = parts.slice(-1)[0]?.split('.').slice(-1)[0]
const fullPath = `${parts.slice(0, -1).join('/')}/${newName.value}.${extension}`
await rpc.renameStaticAsset(await ensureDevAuthToken(), asset.value.filePath, fullPath)
await rpc.renameStaticAsset(asset.value.filePath, fullPath)
asset.value = undefined as any
renameDialog.value = false
devtoolsUiShowNotification({
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools/client/components/AssetDropZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { AssetEntry } from '~/../src/types'
import { devtoolsUiShowNotification } from '#imports'
import { useEventListener, useVModel } from '@vueuse/core'
import { ref } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { rpc, wsConnecting, wsError } from '~/composables/rpc'
import { telemetry } from '~/composables/telemetry'

Expand Down Expand Up @@ -95,7 +94,7 @@ async function uploadFiles() {
content,
})
}
await rpc.writeStaticAssets(await ensureDevAuthToken(), [...uploadFiles], props.folder).then(() => {
await rpc.writeStaticAssets([...uploadFiles], props.folder).then(() => {
close()
devtoolsUiShowNotification({
message: 'Files uploaded successfully!',
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools/client/components/BuildAnalyzeDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { AnalyzeBuildMeta } from '../../src/types'
import { useRuntimeConfig } from '#imports'
import { formatTimeAgo } from '@vueuse/core'
import { computed, ref } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { rpc } from '~/composables/rpc'

const props = defineProps<{
Expand Down Expand Up @@ -46,7 +45,7 @@ function formatFileSize(bytes: number) {
}

async function clear(name: string) {
return rpc.clearAnalyzeBuilds(await ensureDevAuthToken(), [name])
return rpc.clearAnalyzeBuilds([name])
}
</script>

Expand Down
5 changes: 2 additions & 3 deletions packages/devtools/client/components/ModuleItemInstall.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import type { ModuleActionType, ModuleStaticInfo } from '../../src/types'
import { computed } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { ModuleDialog } from '~/composables/dialog'
import { rpc } from '~/composables/rpc'
import { useInstalledModules } from '~/composables/state-modules'
Expand All @@ -21,7 +20,7 @@ const isUninstallable = computed(() => installedInfo.value && installedInfo.valu

async function useModuleAction(item: ModuleStaticInfo, type: ModuleActionType) {
const method = type === 'install' ? rpc.installNuxtModule : rpc.uninstallNuxtModule
const result = await method(await ensureDevAuthToken(), item.npm, true)
const result = await method(item.npm, true)

telemetry(`modules:${type}`, {
moduleName: item.npm,
Expand All @@ -41,7 +40,7 @@ async function useModuleAction(item: ModuleStaticInfo, type: ModuleActionType) {

emit('start')

await method(await ensureDevAuthToken(), item.npm, false)
await method(item.npm, false)
}

const anyObj = {} as any
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools/client/components/RestartDialogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { useNuxtApp } from '#app/nuxt'
import { createTemplatePromise } from '@vueuse/core'
import { useClient } from '~/composables/client'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { useRestartDialogs } from '~/composables/dialog'
import { rpc } from '~/composables/rpc'

Expand All @@ -22,7 +21,7 @@ nuxt.hook('devtools:terminal:exit', ({ id, code }) => {
.start(dialog.message)
.then(async (result) => {
if (result) {
rpc.restartNuxt(await ensureDevAuthToken())
rpc.restartNuxt()
setTimeout(() => {
client.value?.app.reload()
}, 500)
Expand Down
14 changes: 6 additions & 8 deletions packages/devtools/client/components/StorageDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import { getColorMode } from '~/composables/client'
import { rpc } from '~/composables/rpc'
import { useSessionState } from '~/composables/utils'
import { ensureDevAuthToken } from '../composables/dev-auth'

const colorMode = getColorMode()
const nuxtApp = useNuxtApp()
Expand Down Expand Up @@ -71,7 +70,7 @@ const filteredKeys = computed(() => {
})

async function fetchItem(key: string) {
const content = await rpc.getStorageItem(await ensureDevAuthToken(), key)
const content = await rpc.getStorageItem(key)
currentItem.value = {
key,
updatedKey: keyName(key),
Expand All @@ -87,7 +86,7 @@ async function saveNewItem() {
// If does not exists
const key = `${currentStorage.value}:${newKey.value}`
if (!storageKeys.value?.includes(key))
await rpc.setStorageItem(await ensureDevAuthToken(), key, '')
await rpc.setStorageItem(key, '')

router.replace({ query: { storage: currentStorage.value, key } })
newKey.value = ''
Expand All @@ -96,24 +95,23 @@ async function saveNewItem() {
async function saveCurrentItem() {
if (!currentItem.value)
return
await rpc.setStorageItem(await ensureDevAuthToken(), currentItem.value.key, currentItem.value.updatedContent)
await rpc.setStorageItem(currentItem.value.key, currentItem.value.updatedContent)
await fetchItem(currentItem.value.key)
}

async function removeCurrentItem() {
if (!currentItem.value || !currentStorage.value)
return
await rpc.removeStorageItem(await ensureDevAuthToken(), currentItem.value.key)
await rpc.removeStorageItem(currentItem.value.key)
currentItem.value = null
}

async function renameCurrentItem() {
if (!currentItem.value || !currentStorage.value)
return
const renamedKey = `${currentStorage.value}:${currentItem.value.updatedKey}`
const token = await ensureDevAuthToken()
await rpc.setStorageItem(token, renamedKey, currentItem.value.updatedContent)
await rpc.removeStorageItem(token, currentItem.value.key)
await rpc.setStorageItem(renamedKey, currentItem.value.updatedContent)
await rpc.removeStorageItem(currentItem.value.key)
router.replace({ query: { storage: currentStorage.value, key: renamedKey } })
}
</script>
Expand Down
5 changes: 2 additions & 3 deletions packages/devtools/client/components/TerminalPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { computed, watchEffect } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { rpc } from '~/composables/rpc'
import { useTerminals } from '~/composables/state'
import { useCurrentTerminalId } from '~/composables/state-routes'
Expand All @@ -9,8 +8,8 @@ const terminals = useTerminals()
const terminalId = useCurrentTerminalId()
const selected = computed(() => terminals.value?.find(t => t.id === terminalId.value))

async function remove(id: string) {
rpc.runTerminalAction(await ensureDevAuthToken(), id, 'remove')
function remove(id: string) {
rpc.runTerminalAction(id, 'remove')
}

watchEffect(() => {
Expand Down
15 changes: 7 additions & 8 deletions packages/devtools/client/components/TerminalView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useEventListener } from '@vueuse/core'
import { FitAddon } from '@xterm/addon-fit'
import { Terminal } from '@xterm/xterm'
import { onMounted, ref } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { rpc } from '~/composables/rpc'
import '@xterm/xterm/css/xterm.css'

Expand Down Expand Up @@ -33,7 +32,7 @@ onMounted(async () => {
fitAddon.fit()
})

info.value = await rpc.getTerminalDetail(await ensureDevAuthToken(), props.id)
info.value = await rpc.getTerminalDetail(props.id)
if (info.value?.buffer)
term.write(info.value.buffer)

Expand All @@ -44,17 +43,17 @@ onMounted(async () => {
})
})

async function clear() {
rpc.runTerminalAction(await ensureDevAuthToken(), props.id, 'clear')
function clear() {
rpc.runTerminalAction(props.id, 'clear')
term?.clear()
}

async function restart() {
rpc.runTerminalAction(await ensureDevAuthToken(), props.id, 'restart')
function restart() {
rpc.runTerminalAction(props.id, 'restart')
}

async function terminate() {
rpc.runTerminalAction(await ensureDevAuthToken(), props.id, 'terminate')
function terminate() {
rpc.runTerminalAction(props.id, 'terminate')
}
</script>

Expand Down
6 changes: 0 additions & 6 deletions packages/devtools/client/composables/dev-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ export function updateDevAuthToken(_token: string) {
console.warn('[nuxt-devtools] `updateDevAuthToken` is deprecated. Auth is now handled by Vite DevTools.')
}

/** @deprecated Auth is now handled by Vite DevTools */
export async function ensureDevAuthToken() {
console.warn('[nuxt-devtools] `ensureDevAuthToken` is deprecated. Auth is now handled by Vite DevTools.')
return ''
}

export const userAgentInfo = parseUA(navigator.userAgent)

/** @deprecated Auth is now handled by Vite DevTools */
Expand Down
5 changes: 2 additions & 3 deletions packages/devtools/client/composables/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { NpmCommandOptions } from '../../src/types'
import { useNuxtApp } from '#app/nuxt'
import semver from 'semver'
import { computed, ref } from 'vue'
import { ensureDevAuthToken } from './dev-auth'
import { rpc } from './rpc'
import { useAsyncState } from './utils'

Expand Down Expand Up @@ -58,15 +57,15 @@ function getPackageUpdate(name: string, options?: NpmCommandOptions) {

state.value = 'running'

processId.value = (await rpc.runNpmCommand(await ensureDevAuthToken(), 'update', name, options))?.processId
processId.value = (await rpc.runNpmCommand('update', name, options))?.processId

return processId.value
}

async function restart() {
if (state.value !== 'updated')
return
await rpc.restartNuxt(await ensureDevAuthToken())
await rpc.restartNuxt()
}

return {
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools/client/pages/modules/analyze-build.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useRouter } from '#app/composables/router'
import { definePageMeta } from '#imports'
import { createTemplatePromise, formatTimeAgo } from '@vueuse/core'
import { computed, ref } from 'vue'
import { ensureDevAuthToken } from '~/composables/dev-auth'
import { satisfyNuxtVersion } from '~/composables/npm'
import { rpc } from '~/composables/rpc'
import { useAnalyzeBuildInfo } from '~/composables/state'
Expand Down Expand Up @@ -46,7 +45,7 @@ async function start() {
processAnalyzeBuildInfo.value = {
name: buildNameInput.value,
processId: await rpc.startAnalyzeBuild(await ensureDevAuthToken(), buildNameInput.value),
processId: await rpc.startAnalyzeBuild(buildNameInput.value),
}
if (shouldGotoTerminal.value)
gotoTerminal()
Expand Down
Loading
Loading