Skip to content

Commit 293b95b

Browse files
committed
refactor!: change internal rpc and storage namespaces
1 parent 1a4fff3 commit 293b95b

File tree

20 files changed

+269
-120
lines changed

20 files changed

+269
-120
lines changed

‎packages/core/src/client/webcomponents/components/ViewBuiltinTerminalPanel.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ onMounted(async () => {
4646
props.terminal.terminal = term
4747
4848
if (props.terminal.buffer == null) {
49-
const { buffer } = await props.context.rpc.call('vite:internal:terminals:read', props.terminal.info.id)
49+
const { buffer } = await props.context.rpc.call('devtoolskit:internal:terminals:read', props.terminal.info.id)
5050
props.terminal.buffer = markRaw(buffer)
5151
}
5252

‎packages/core/src/client/webcomponents/components/ViewLauncher.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const props = defineProps<{
1010
}>()
1111
1212
function onLaunch() {
13-
props.context.rpc.call('vite:internal:docks:on-launch', props.entry.id)
13+
props.context.rpc.call('devtoolskit:internal:docks:on-launch', props.entry.id)
1414
}
1515
1616
const status = computed(() => props.entry.launcher.status || 'idle')

‎packages/core/src/client/webcomponents/state/context.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function createDocksContext(
8686
const getSettingsStore = async () => {
8787
if (!_settingsStorePromise) {
8888
_settingsStorePromise = rpc.sharedState.get(
89-
'vite:internal:user-settings',
89+
'devtoolskit:internal:user-settings',
9090
{ initialValue: DEFAULT_STATE_DOCKS_SETTINGS() },
9191
)
9292
}

‎packages/core/src/client/webcomponents/state/docks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function useDocksEntries(rpc: DevToolsRpcClient): Promise<Ref<DevTo
7878
if (_docksEntriesRef) {
7979
return _docksEntriesRef
8080
}
81-
const state = await rpc.sharedState.get('vite:internal:docks', { initialValue: [] })
81+
const state = await rpc.sharedState.get('devtoolskit:internal:docks', { initialValue: [] })
8282
_docksEntriesRef = sharedStateToRef(state)
8383
return _docksEntriesRef
8484
}

‎packages/core/src/client/webcomponents/state/terminals.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function useTerminals(context: DocksContext): Reactive<Map<string, Termin
1717
}
1818
const map: Reactive<Map<string, TerminalState>> = _terminalsMap = reactive(new Map())
1919
async function updateTerminals() {
20-
const terminals = await context.rpc.call('vite:internal:terminals:list')
20+
const terminals = await context.rpc.call('devtoolskit:internal:terminals:list')
2121

2222
for (const terminal of terminals) {
2323
if (map.has(terminal.id)) {
@@ -35,12 +35,12 @@ export function useTerminals(context: DocksContext): Reactive<Map<string, Termin
3535
console.log('[VITE DEVTOOLS] Terminals Updated', [...map.values()])
3636
}
3737
context.rpc.client.register({
38-
name: 'vite:internal:terminals:updated' satisfies keyof DevToolsRpcClientFunctions,
38+
name: 'devtoolskit:internal:terminals:updated' satisfies keyof DevToolsRpcClientFunctions,
3939
type: 'action',
4040
handler: () => updateTerminals(),
4141
})
4242
context.rpc.client.register({
43-
name: 'vite:internal:terminals:stream-chunk' satisfies keyof DevToolsRpcClientFunctions,
43+
name: 'devtoolskit:internal:terminals:stream-chunk' satisfies keyof DevToolsRpcClientFunctions,
4444
type: 'action',
4545
handler: (data: DevToolsTerminalSessionStreamChunkEvent) => {
4646
const terminal = map.get(data.id)

‎packages/core/src/node/context.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function createDevToolsContext(
4646

4747
await docksHost.init()
4848

49-
const docksSharedState = await rpcHost.sharedState.get('vite:internal:docks', { initialValue: [] })
49+
const docksSharedState = await rpcHost.sharedState.get('devtoolskit:internal:docks', { initialValue: [] })
5050

5151
// Register hosts side effects
5252
docksHost.events.on('dock:entry:updated', debounce(() => {
@@ -55,14 +55,14 @@ export async function createDevToolsContext(
5555

5656
terminalsHost.events.on('terminal:session:updated', debounce(() => {
5757
rpcHost.broadcast({
58-
method: 'vite:internal:terminals:updated',
58+
method: 'devtoolskit:internal:terminals:updated',
5959
args: [],
6060
})
6161
docksSharedState.mutate(() => context.docks.values())
6262
}, 10))
6363
terminalsHost.events.on('terminal:session:stream-chunk', (data) => {
6464
rpcHost.broadcast({
65-
method: 'vite:internal:terminals:stream-chunk',
65+
method: 'devtoolskit:internal:terminals:stream-chunk',
6666
args: [data],
6767
})
6868
})

‎packages/core/src/node/host-docks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class DevToolsDockHost implements DevToolsDockHostType {
1616
}
1717

1818
async init() {
19-
this.userSettings = await this.context.rpc.sharedState.get('vite:internal:user-settings', {
19+
this.userSettings = await this.context.rpc.sharedState.get('devtoolskit:internal:user-settings', {
2020
sharedState: createStorage({
2121
filepath: join(this.context.workspaceRoot, 'node_modules/.vite/devtools/settings.json'),
2222
initialValue: {

‎packages/core/src/node/rpc-shared-state.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export function createRpcSharedStateServerHost(
1818
if (patches) {
1919
debug('patch', { key, syncId })
2020
rpc.broadcast({
21-
method: 'vite:internal:rpc:client-state:patch',
21+
method: 'devtoolskit:internal:rpc:client-state:patch',
2222
args: [key, patches, syncId],
2323
filter: client => client.$meta.subscribedStates.has(key),
2424
})
2525
}
2626
else {
2727
debug('updated', { key, syncId })
2828
rpc.broadcast({
29-
method: 'vite:internal:rpc:client-state:updated',
29+
method: 'devtoolskit:internal:rpc:client-state:updated',
3030
args: [key, fullState, syncId],
3131
filter: client => client.$meta.subscribedStates.has(key),
3232
})

‎packages/core/src/node/rpc/index.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ declare module '@vitejs/devtools-kit' {
5555

5656
// @keep-sorted
5757
export interface DevToolsRpcClientFunctions {
58-
'vite:internal:rpc:client-state:patch': (key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>
59-
'vite:internal:rpc:client-state:updated': (key: string, fullState: any, syncId: string) => Promise<void>
58+
'devtoolskit:internal:rpc:client-state:patch': (key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>
59+
'devtoolskit:internal:rpc:client-state:updated': (key: string, fullState: any, syncId: string) => Promise<void>
6060

61-
'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>
62-
'vite:internal:terminals:updated': () => Promise<void>
61+
'devtoolskit:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>
62+
'devtoolskit:internal:terminals:updated': () => Promise<void>
6363
}
6464

6565
// @keep-sorted
6666
export interface DevToolsRpcSharedStates {
67-
'vite:internal:docks': DevToolsDockEntry[]
68-
'vite:internal:user-settings': DevToolsDocksUserSettings
67+
'devtoolskit:internal:docks': DevToolsDockEntry[]
68+
'devtoolskit:internal:user-settings': DevToolsDocksUserSettings
6969
}
7070
}

‎packages/core/src/node/rpc/internal/docks-on-launch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineRpcFunction } from '@vitejs/devtools-kit'
22

33
export const docksOnLaunch = defineRpcFunction({
4-
name: 'vite:internal:docks:on-launch',
4+
name: 'devtoolskit:internal:docks:on-launch',
55
type: 'action',
66
setup: (context) => {
77
const launchMap = new Map<string, Promise<void>>()

0 commit comments

Comments
 (0)