Skip to content

Commit 69d06d2

Browse files
committed
refactor: use $call style of birpc
1 parent e6e0a04 commit 69d06d2

19 files changed

Lines changed: 164 additions & 120 deletions

File tree

packages/core/src/client/inject/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function init(): Promise<void> {
1515
// eslint-disable-next-line no-console
1616
console.log('[VITE DEVTOOLS] RPC', rpc)
1717

18-
const rpcFunctions = await rpc['vite:core:list-rpc-functions']()
18+
const rpcFunctions = await rpc.$call('vite:core:list-rpc-functions')
1919
// eslint-disable-next-line no-console
2020
console.log('[VITE DEVTOOLS] RPC Functions', rpcFunctions)
2121

packages/core/src/client/webcomponents/state/dock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function createDocksContext(
5858
panelStore?: Ref<DockPanelStorage>,
5959
): Promise<DocksContext> {
6060
const selected = ref<DevToolsDockEntry | null>(null)
61-
const dockEntries = shallowRef((await rpc['vite:core:list-dock-entries']()).map(entry => Object.freeze(entry)))
61+
const dockEntries = shallowRef((await rpc.$call('vite:core:list-dock-entries')).map(entry => Object.freeze(entry)))
6262
// eslint-disable-next-line no-console
6363
console.log('[VITE DEVTOOLS] Docks Entries', [...dockEntries.value])
6464
// TODO: get board case from rpc when entries updates

packages/vite/src/app/components/data/AssetDetails.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ const { state } = useAsyncState(
2727
if (!props.lazy)
2828
return
2929
30-
const res = await rpc.value!['vite:rolldown:get-asset-details']?.({
31-
session: props.session.id,
32-
id: props.asset.filename,
33-
})
30+
const res = await rpc.value.$call(
31+
'vite:rolldown:get-asset-details',
32+
{
33+
session: props.session.id,
34+
id: props.asset.filename,
35+
},
36+
)
3437
if ('chunk' in res) {
3538
return {
3639
chunks: [{ ...res?.chunk, type: 'chunk' }],
@@ -61,7 +64,10 @@ const _importers = computed(() => props.lazy ? state.value?.importers : props.im
6164
const _imports = computed(() => props.lazy ? state.value?.imports : props.imports)
6265
6366
function openInEditor() {
64-
rpc.value!['vite:core:open-in-editor'](`${props.session.meta.dir}/${props.asset.filename}`)
67+
rpc.value.$call(
68+
'vite:core:open-in-editor',
69+
`${props.session.meta.dir}/${props.asset.filename}`,
70+
)
6571
}
6672
</script>
6773

packages/vite/src/app/components/data/AssetDetailsLoader.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ const emit = defineEmits<{
1616
const rpc = useRpc()
1717
const { state } = useAsyncState(
1818
async () => {
19-
const res = await rpc.value!['vite:rolldown:get-asset-details']?.({
20-
session: props.session.id,
21-
id: props.asset,
22-
})
19+
const res = await rpc.value.$call(
20+
'vite:rolldown:get-asset-details',
21+
{
22+
session: props.session.id,
23+
id: props.asset,
24+
},
25+
)
2326
if ('chunk' in res) {
2427
return {
2528
asset: { ...res?.asset, type: 'asset' },

packages/vite/src/app/components/data/ChunkDetails.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ const { state, isLoading } = useAsyncState(
3535
if (props.chunks)
3636
return
3737
38-
return await rpc.value!['vite:rolldown:get-chunks-graph']?.({
39-
session: props.session.id,
40-
})
38+
return await rpc.value.$call(
39+
'vite:rolldown:get-chunks-graph',
40+
{ session: props.session.id },
41+
)
4142
},
4243
null,
4344
)

packages/vite/src/app/components/data/ChunkDetailsLoader.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const emit = defineEmits<{
1515
const rpc = useRpc()
1616
const { state, isLoading } = useAsyncState(
1717
async () => {
18-
return await rpc.value!['vite:rolldown:get-chunk-info']?.({
19-
session: props.session.id,
20-
id: props.chunk,
21-
})
18+
return await rpc.value.$call(
19+
'vite:rolldown:get-chunk-info',
20+
{
21+
session: props.session.id,
22+
id: props.chunk,
23+
},
24+
)
2225
},
2326
null,
2427
)

packages/vite/src/app/components/data/ModuleDetailsLoader.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ watchEffect(async () => {
2828
nextTick(async () => {
2929
transforms.value = []
3030
transformsLoading.value = true
31-
transforms.value = await rpc.value!['vite:rolldown:get-module-transforms']?.(arg)
31+
transforms.value = await rpc.value.$call(
32+
'vite:rolldown:get-module-transforms',
33+
arg,
34+
)
3235
transformsLoading.value = false
3336
})
3437
})
@@ -40,7 +43,10 @@ const info = computedAsync(async () => {
4043
}
4144
return {
4245
transforms: transforms.value,
43-
...(await rpc.value!['vite:rolldown:get-module-info']?.(arg)),
46+
...(await rpc.value.$call(
47+
'vite:rolldown:get-module-info',
48+
arg,
49+
)),
4450
} as ModuleInfo
4551
})
4652

packages/vite/src/app/components/data/PackageDetailsLoader.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ const parsedPackage = computed(() => {
1919
const rpc = useRpc()
2020
const { state, isLoading } = useAsyncState(
2121
async () => {
22-
return await rpc.value!['vite:rolldown:get-package-details']?.({
23-
session: props.session.id,
24-
id: props.package,
25-
})
22+
return await rpc.value.$call(
23+
'vite:rolldown:get-package-details',
24+
{
25+
session: props.session.id,
26+
id: props.package,
27+
},
28+
)
2629
},
2730
null,
2831
)

packages/vite/src/app/components/data/PluginDetailsLoader.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ const route = useRoute()
2525
const rpc = useRpc()
2626
const { state, isLoading } = useAsyncState(
2727
async () => {
28-
const res = await rpc.value!['vite:rolldown:get-plugin-details']?.({
29-
session: props.session.id,
30-
id: route.query.plugin as string,
31-
})
28+
const res = await rpc.value.$call(
29+
'vite:rolldown:get-plugin-details',
30+
{
31+
session: props.session.id,
32+
id: route.query.plugin as string,
33+
},
34+
)
3235
return res
3336
},
3437
null,

packages/vite/src/app/pages/compare/[sessions]/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const sessions = ref<SessionCompareContext[]>([])
1515
onMounted(async () => {
1616
isLoading.value = true
1717
18-
const summary = await rpc.value!['vite:rolldown:get-session-compare-summary']!({
19-
sessions: params.sessions.split(','),
20-
})
18+
const summary = await rpc.value.$call(
19+
'vite:rolldown:get-session-compare-summary',
20+
{ sessions: params.sessions.split(',') },
21+
)
2122
2223
sessions.value = summary
2324

0 commit comments

Comments
 (0)