Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/devtools-ui-kit/src/unocss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export function unocssPreset(): Preset {
}),
rules: [
[/^n-(.*)$/, ([, body]: string[], { theme }: RuleContext<Theme>) => {
const color = parseColor(body, theme)
const color = parseColor(body!, theme)
if (color?.cssColor?.type === 'rgb' && color.cssColor.components) {
return {
'--nui-c-context': `${color.cssColor.components.join(',')}`,
}
}
}],
[/^n-(.*)$/, fonts[1][1] as any],
[/^n-(.*)$/, fonts[1]![1] as any],
['n-dashed', { 'border-style': 'dashed' }],
['n-solid', {
'background-color': 'rgba(var(--nui-c-context), 1) !important',
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/client/components/AssetDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const renameDialog = ref(false)
const newName = ref('')
async function renameAsset() {
const parts = asset.value.filePath.split('/')
const oldName = parts.slice(-1)[0].split('.').slice(0, -1).join('.')
const oldName = parts.slice(-1)[0]?.split('.').slice(0, -1).join('.')

if (!newName.value || newName.value === oldName) {
return devtoolsUiShowNotification({
Expand All @@ -168,7 +168,7 @@ async function renameAsset() {
}

try {
const extension = parts.slice(-1)[0].split('.').slice(-1)[0]
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)
asset.value = undefined as any
Expand Down
6 changes: 5 additions & 1 deletion packages/devtools/client/components/CommandPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function moveSelected(delta: number) {
}

function scrollToITem() {
const item = document.getElementById(filtered.value[selectedIndex.value]?.id)
const id = filtered.value[selectedIndex.value]?.id
if (!id)
return

const item = document.getElementById(id)
item?.scrollIntoView({
block: 'center',
})
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/DataSchemaDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function copyToClipboard() {
<NSwitch
v-for="item, index of options"
:key="item.name"
v-model="options[index].defaultValue"
v-model="options[index]!.defaultValue"
flex="~ gap-2" rounded px2 py2
>
<span text-xs capitalize op75>
Expand Down
8 changes: 4 additions & 4 deletions packages/devtools/client/components/ServerRouteDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const finalPath = computed(() => {
})
const finalURL = computed(() => domain.value + finalPath.value)

function parseInputs(inputs: ServerRouteInput[]) {
function parseInputs(inputs: ServerRouteInput[] = []) {
const formatted = Object.fromEntries(
inputs.filter(({ active, key, value }) => active && key && value !== undefined).map(({ key, value }) => [key, value]),
)
Expand Down Expand Up @@ -433,7 +433,7 @@ const copy = useCopy()
{{ tab.name }}
{{ tab?.length ? `(${tab.length})` : '' }}
<span>
{{ inputDefaults[tab.slug]?.length ? `(${inputDefaults[tab.slug].length})` : '' }}
{{ inputDefaults[tab.slug]?.length ? `(${inputDefaults[tab.slug]!.length})` : '' }}
</span>
</div>
</NButton>
Expand Down Expand Up @@ -485,9 +485,9 @@ const copy = useCopy()
placeholder="Value..."
:model-value="cookie.value"
flex-1 n="primary"
@input="updateCookie(cookie.key, ($event as any).target?.value)"
@input="updateCookie(cookie.key!, ($event as any).target?.value)"
/>
<NButton title="Delete" n="red" @click="updateCookie(cookie.key, undefined)">
<NButton title="Delete" n="red" @click="updateCookie(cookie.key!, undefined)">
<NIcon icon="i-carbon-trash-can" />
</NButton>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/client/components/ServerTaskDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const finalPath = computed(() => {
})
const finalURL = computed(() => domain.value + finalPath.value)

function parseInputs(inputs: ServerRouteInput[]) {
function parseInputs(inputs: ServerRouteInput[] = []) {
const formatted = Object.fromEntries(
inputs.filter(({ active, key, value }) => active && key && value !== undefined).map(({ key, value }) => [key, value]),
)
Expand Down Expand Up @@ -272,7 +272,7 @@ const copy = useCopy()
{{ tab.name }}
{{ tab?.length ? `(${tab.length})` : '' }}
<span>
{{ inputDefaults[tab.slug]?.length ? `(${inputDefaults[tab.slug].length})` : '' }}
{{ inputDefaults[tab.slug]?.length ? `(${inputDefaults[tab.slug]!.length})` : '' }}
</span>
</div>
</NButton>
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/TerminalPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function remove(id: string) {

watchEffect(() => {
if (!terminalId.value && terminals.value?.length)
terminalId.value = terminals.value[0].id
terminalId.value = terminals.value[0]!.id
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/composables/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function segmentTimelineEvents(events: TimelineEvent[]) {
const layers: number[] = []

segment.duration = duration
segment.previousGap = idx > 0 ? segment.start - segments[idx - 1].end : 0
segment.previousGap = idx > 0 ? segment.start - segments[idx - 1]!.end : 0
segment.events
.forEach((event) => {
const end = (event.end || event.start)
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/client/pages/modules/server-routes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const filterByCollection = computed(() => {
}
}

if (collectionNames.length > 0 && collectionNames[collectionNames.length - 1].includes('.'))
if (collectionNames.length > 0 && collectionNames[collectionNames.length - 1]!.includes('.'))
collectionNames.pop()

collectionNames.forEach((collectionName) => {
Expand Down Expand Up @@ -192,7 +192,7 @@ function capitalize(str: string) {
<NSectionBlock
v-for="tab of Object.keys(inputDefaults)"
:key="tab"
:text="`${capitalize(tab)} ${inputDefaults[tab].length ? `(${inputDefaults[tab].length})` : ''}`"
:text="`${capitalize(tab)} ${inputDefaults[tab]?.length ? `(${inputDefaults[tab]!.length})` : ''}`"
:padding="false"
:icon="ServerRouteTabIcons[tab]"
>
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools/client/pages/modules/server-tasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const inputDefaultsDrawer = ref(false)
const serverTasks = useServerTasks()
const tasks = computed<ServerTaskInfo[]>(() => Object.keys(serverTasks.value?.tasks ?? {}).map(taskKey => ({
name: taskKey,
...serverTasks.value!.tasks[taskKey],
...serverTasks.value!.tasks[taskKey]!,
type: 'task',
})))

Expand Down Expand Up @@ -121,7 +121,7 @@ const filterByCollection = computed(() => {
const taskParts = item.name.split(':')
const collectionNames = taskParts.concat()

if (collectionNames.length > 0 && collectionNames[collectionNames.length - 1].includes('.'))
if (collectionNames.length > 0 && collectionNames[collectionNames.length - 1]?.includes('.'))
collectionNames.pop()

collectionNames.forEach((collectionName) => {
Expand Down Expand Up @@ -215,7 +215,7 @@ function toggleView() {
<span text-white op50>Merged as default for every task in DevTools</span>
</div>
<NSectionBlock
:text="`Query ${inputDefaults.query.length ? `(${inputDefaults.query.length})` : ''}`"
:text="`Query ${inputDefaults.query?.length ? `(${inputDefaults.query.length})` : ''}`"
:padding="false"
:icon="ServerRouteTabIcons.query"
>
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools/src/integrations/vite-inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export async function setup({ nuxt, rpc }: NuxtDevtoolsServerContext) {
async function getComponentsRelationships() {
const meta = await api?.rpc.getMetadata()
const modules = (
meta
meta && meta.instances[0]
? await api?.rpc.getModulesList({
vite: meta?.instances[0].vite,
env: meta?.instances[0].environments[0],
vite: meta.instances[0].vite,
env: meta.instances[0].environments[0]!,
})
: null
) || []
Expand Down
12 changes: 7 additions & 5 deletions packages/devtools/src/runtime/shared/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ export function setupHooksDebug<T extends Hookable<any>>(hooks: T) {
}
else {
const hook = serverHooks[event.name]
if (hook.duration != null)
hook.executions.push(hook.duration)
hook.start = now()
hook.end = undefined
hook.duration = undefined
if (hook) {
if (hook.duration != null)
hook.executions.push(hook.duration)
hook.start = now()
hook.end = undefined
hook.duration = undefined
}
}
})

Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/src/server-rpc/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export function setupGeneralRPC({
const match = input.match(/^(.*?)(:[:\d]*)$/)
let suffix = ''
if (match) {
input = match[1]
suffix = match[2]
input = match[1]!
suffix = match[2]!
}

// search for existing path
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/server-rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function setupRPC(nuxt: Nuxt, options: ModuleOptions) {
return

const [namespace, fnName] = name.split(':')
return extendedRpcMap.get(namespace)?.[fnName]
return extendedRpcMap.get(namespace!)?.[fnName!]
},
onError(error, name) {
logger.error(
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools/src/server-rpc/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function setupNpmRPC({ nuxt, ensureDevAuthToken }: NuxtDevtoolsServerCont
const processId = `npm:${command}:${packageName}`

startSubprocess({
command: args[0],
command: args[0]!,
args: args.slice(1),
}, {
id: processId,
Expand Down Expand Up @@ -112,7 +112,7 @@ export function setupNpmRPC({ nuxt, ensureDevAuthToken }: NuxtDevtoolsServerCont
installSet.add(name)

const process = startSubprocess({
command: commands[0],
command: commands[0]!,
args: commands.slice(1),
}, {
id: processId,
Expand Down Expand Up @@ -177,7 +177,7 @@ export function setupNpmRPC({ nuxt, ensureDevAuthToken }: NuxtDevtoolsServerCont

if (!dry) {
const process = startSubprocess({
command: commands[0],
command: commands[0]!,
args: commands.slice(1),
}, {
id: processId,
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/src/server-rpc/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { NuxtDevtoolsServerContext, ServerFunctions } from '../types'

const IGNORE_STORAGE_MOUNTS = ['root', 'build', 'src', 'cache']
function shouldIgnoreStorageKey(key: string) {
return IGNORE_STORAGE_MOUNTS.includes(key.split(':')[0])
return IGNORE_STORAGE_MOUNTS.includes(key.split(':')[0]!)
}

export function setupStorageRPC({
Expand Down Expand Up @@ -37,7 +37,7 @@ export function setupStorageRPC({
for (const name of Object.keys(mounts)) {
if (shouldIgnoreStorageKey(name))
continue
storageMounts[name] = mounts[name]
storageMounts[name] = mounts[name]!
}
})

Expand Down
4 changes: 2 additions & 2 deletions scripts/bump-nightly.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from 'node:child_process'
import { promises as fsp } from 'node:fs'
import { globby } from 'globby'
import { resolve } from 'pathe'
import { glob } from 'tinyglobby'

// Temporary forked from nuxt/framework

Expand Down Expand Up @@ -37,7 +37,7 @@ type Package = ThenArg<ReturnType<typeof loadPackage>>

async function loadWorkspace(dir: string) {
const workspacePkg = await loadPackage(dir)
const pkgDirs = (await globby(['packages/*'], { onlyDirectories: true })).sort()
const pkgDirs = (await glob(['packages/*'], { onlyDirectories: true })).sort()

const packages: Package[] = []

Expand Down