|
| 1 | +<script setup lang="ts"> |
| 2 | +import type { ServerDebugModuleMutationRecord } from '@nuxt/devtools-kit/types' |
| 3 | +import { computed, ref } from 'vue' |
| 4 | +
|
| 5 | +const props = defineProps<{ |
| 6 | + moduleMutationRecords: ServerDebugModuleMutationRecord[] |
| 7 | +}>() |
| 8 | +
|
| 9 | +function isPath(path: string) { |
| 10 | + return path.startsWith('/') || path.match(/^[a-z]:[\\/]/i) |
| 11 | +} |
| 12 | +
|
| 13 | +// const search = ref('') |
| 14 | +const showBuiltin = ref(false) |
| 15 | +const showTemplates = ref(false) |
| 16 | +const showTranspile = ref(false) |
| 17 | +const showPlugins = ref(false) |
| 18 | +const showEmptyInitial = ref(false) |
| 19 | +const moduleFilter = ref('') |
| 20 | +
|
| 21 | +const items = computed(() => { |
| 22 | + let arr = props.moduleMutationRecords |
| 23 | + if (!showBuiltin.value) { |
| 24 | + arr = arr.filter(i => !i.name.startsWith('nuxt:') && i.name !== '@nuxt/devtools') |
| 25 | + } |
| 26 | + if (!showTemplates.value) { |
| 27 | + arr = arr.filter(i => i.keys.join('.') !== 'build.templates') |
| 28 | + } |
| 29 | + if (!showTranspile.value) { |
| 30 | + arr = arr.filter(i => i.keys.join('.') !== 'build.transpile') |
| 31 | + } |
| 32 | + if (!showPlugins.value) { |
| 33 | + arr = arr.filter(i => i.keys.join('.') !== 'plugins') |
| 34 | + } |
| 35 | + if (!showEmptyInitial.value) { |
| 36 | + arr = arr.filter(i => i.method || (i.value !== '[]' && i.value !== '{}')) |
| 37 | + } |
| 38 | + if (moduleFilter.value) { |
| 39 | + arr = arr.filter(i => i.name === moduleFilter.value) |
| 40 | + } |
| 41 | + return arr |
| 42 | +}) |
| 43 | +</script> |
| 44 | + |
| 45 | +<template> |
| 46 | + <div flex="~ gap-2 col" mb4> |
| 47 | + <!-- <NTextInput v-model="search" placeholder="Search" w-full /> --> |
| 48 | + <div flex="~ gap-3 items-center"> |
| 49 | + <NCheckbox v-model="showBuiltin" n="primary"> |
| 50 | + <span ws-nowrap op75>Builtin Modules</span> |
| 51 | + </NCheckbox> |
| 52 | + <NCheckbox v-model="showTemplates" n="primary"> |
| 53 | + <span ws-nowrap op75>Templates</span> |
| 54 | + </NCheckbox> |
| 55 | + <NCheckbox v-model="showTranspile" n="primary"> |
| 56 | + <span ws-nowrap op75>Transpile</span> |
| 57 | + </NCheckbox> |
| 58 | + <NCheckbox v-model="showPlugins" n="primary"> |
| 59 | + <span ws-nowrap op75>Plugins</span> |
| 60 | + </NCheckbox> |
| 61 | + <NCheckbox v-model="showEmptyInitial" n="primary"> |
| 62 | + <span ws-nowrap op75>Empty Initial</span> |
| 63 | + </NCheckbox> |
| 64 | + <div v-if="moduleFilter" flex="~ gap-1" items-center p1 border="~ base rounded"> |
| 65 | + <NBadgeHashed font-mono :text="moduleFilter" /> |
| 66 | + <NButton icon="carbon-close" :border="false" @click="moduleFilter = ''" /> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + <table max-w-full of-auto> |
| 71 | + <thead border="b base"> |
| 72 | + <tr> |
| 73 | + <th ws-nowrap p1 text-center font-bold> |
| 74 | + Index |
| 75 | + </th> |
| 76 | + <th ws-nowrap p1 text-center font-bold> |
| 77 | + Module |
| 78 | + </th> |
| 79 | + <th ws-nowrap p1 text-center font-bold> |
| 80 | + Key Path |
| 81 | + </th> |
| 82 | + <th ws-nowrap p1 text-center font-bold> |
| 83 | + Method |
| 84 | + </th> |
| 85 | + <th ws-nowrap p1 text-center font-bold> |
| 86 | + Value |
| 87 | + </th> |
| 88 | + </tr> |
| 89 | + </thead> |
| 90 | + <tbody> |
| 91 | + <tr |
| 92 | + v-for="record of items" |
| 93 | + :key="moduleMutationRecords.indexOf(record)" |
| 94 | + border="b dashed transparent hover:base" |
| 95 | + > |
| 96 | + <td text-center op50> |
| 97 | + <div>{{ moduleMutationRecords.indexOf(record) + 1 }}</div> |
| 98 | + </td> |
| 99 | + <td> |
| 100 | + <FilepathItem v-if="record.name && isPath(record.name)" :filepath="record.name" /> |
| 101 | + <NBadgeHashed |
| 102 | + v-else |
| 103 | + role="button" font-mono |
| 104 | + :text="record.name" |
| 105 | + @click="moduleFilter = record.name" |
| 106 | + /> |
| 107 | + </td> |
| 108 | + <td> |
| 109 | + <code flex="~" px4> |
| 110 | + <template v-for="key, idy of record.keys" :key="idy"> |
| 111 | + <span>{{ key }}</span> |
| 112 | + <span v-if="idy < record.keys.length - 1" op50> |
| 113 | + . |
| 114 | + </span> |
| 115 | + </template> |
| 116 | + </code> |
| 117 | + </td> |
| 118 | + <td px2 text-center> |
| 119 | + <NBadgeHashed font-mono :text="record.method || '='" :class="record.method ? '' : 'saturate-0'" /> |
| 120 | + </td> |
| 121 | + <td of-auto> |
| 122 | + <NCodeBlock |
| 123 | + :code="String(record.value)" |
| 124 | + lang="ts" |
| 125 | + grammar-context-code="let a = " |
| 126 | + ws-normal break-all py1 |
| 127 | + :lines="false" :inline="true" |
| 128 | + /> |
| 129 | + </td> |
| 130 | + </tr> |
| 131 | + </tbody> |
| 132 | + </table> |
| 133 | +</template> |
0 commit comments