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 devframe/docs/guide/terminals.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ ctx.terminals.events.on('terminal:session:updated', (session) => {
})
```

Output chunks aren't delivered as host events anymore — terminals now use the [streaming](./streaming) channel `devtoolskit:internal:terminals` keyed by session id. From the browser:
Output chunks aren't delivered as host events anymore — terminals now use the [streaming](./streaming) channel `devframe:terminals` keyed by session id. From the browser:

```ts
const reader = rpc.streaming.subscribe<string>(
'devtoolskit:internal:terminals',
'devframe:terminals',
sessionId,
)
for await (const chunk of reader) writeToTerminal(chunk)
Expand Down
14 changes: 7 additions & 7 deletions devframe/packages/devframe/src/client/rpc-shared-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createRpcSharedStateClientHost(rpc: DevToolsRpcClient): RpcShare
}

rpc.client.register({
name: 'devtoolskit:internal:rpc:client-state:updated',
name: 'devframe:rpc:client-state:updated',
type: 'event',
handler: (key: string, fullState: any, syncId: string) => {
const state = sharedState.get(key)
Expand All @@ -30,7 +30,7 @@ export function createRpcSharedStateClientHost(rpc: DevToolsRpcClient): RpcShare
})

rpc.client.register({
name: 'devtoolskit:internal:rpc:client-state:patch',
name: 'devframe:rpc:client-state:patch',
type: 'event',
handler: (key: string, patches: SharedStatePatch[], syncId: string) => {
const state = sharedState.get(key)
Expand All @@ -46,10 +46,10 @@ export function createRpcSharedStateClientHost(rpc: DevToolsRpcClient): RpcShare
if (isStaticBackend)
return
if (patches) {
rpc.callEvent('devtoolskit:internal:rpc:server-state:patch', key, patches, syncId)
rpc.callEvent('devframe:rpc:server-state:patch', key, patches, syncId)
}
else {
rpc.callEvent('devtoolskit:internal:rpc:server-state:set', key, fullState, syncId)
rpc.callEvent('devframe:rpc:server-state:set', key, fullState, syncId)
}
}))

Expand Down Expand Up @@ -83,13 +83,13 @@ export function createRpcSharedStateClientHost(rpc: DevToolsRpcClient): RpcShare

async function initSharedState() {
if (!isStaticBackend) {
rpc.callEvent('devtoolskit:internal:rpc:server-state:subscribe', key)
rpc.callEvent('devframe:rpc:server-state:subscribe', key)
}
if (options?.initialValue !== undefined) {
sharedState.set(key, state)
for (const fn of keyAddedListeners)
fn(key)
rpc.call('devtoolskit:internal:rpc:server-state:get', key)
rpc.call('devframe:rpc:server-state:get', key)
.then((serverState) => {
if (serverState !== undefined)
state.mutate(() => mergeWithInitialValue(key, serverState))
Expand All @@ -101,7 +101,7 @@ export function createRpcSharedStateClientHost(rpc: DevToolsRpcClient): RpcShare
return state
}
else {
const serverValue = await rpc.call('devtoolskit:internal:rpc:server-state:get', key) as T
const serverValue = await rpc.call('devframe:rpc:server-state:get', key) as T
state.mutate(() => mergeWithInitialValue(key, serverValue))
sharedState.set(key, state)
for (const fn of keyAddedListeners)
Expand Down
18 changes: 9 additions & 9 deletions devframe/packages/devframe/src/client/rpc-streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
const uploads = new Map<string, StreamSink<any>>()

rpc.client.register({
name: 'devtoolskit:internal:streaming:chunk',
name: 'devframe:streaming:chunk',
type: 'event',
handler(channel: string, id: string, seq: number, chunk: any) {
const reader = readers.get(streamKey(channel, id))
Expand All @@ -55,7 +55,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
})

rpc.client.register({
name: 'devtoolskit:internal:streaming:end',
name: 'devframe:streaming:end',
type: 'event',
handler(channel: string, id: string, error?: StreamErrorPayload) {
const key = streamKey(channel, id)
Expand All @@ -68,7 +68,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
})

rpc.client.register({
name: 'devtoolskit:internal:streaming:upload-cancel',
name: 'devframe:streaming:upload-cancel',
type: 'event',
handler(channel: string, id: string) {
const key = streamKey(channel, id)
Expand Down Expand Up @@ -99,7 +99,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
const channel = key.slice(0, sepIdx)
const id = key.slice(sepIdx + 1)
rpc.callEvent(
'devtoolskit:internal:streaming:subscribe',
'devframe:streaming:subscribe',
channel,
id,
{ afterSeq: reader.lastSeenSeq },
Expand Down Expand Up @@ -127,7 +127,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
)
},
onCancel() {
rpc.callEvent('devtoolskit:internal:streaming:cancel', channel, id)
rpc.callEvent('devframe:streaming:cancel', channel, id)
readers.delete(key)
},
})
Expand All @@ -137,7 +137,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
// Subscribe immediately if already trusted; otherwise wait for trust.
// Mirrors `client/rpc-shared-state.ts` behavior.
if (rpc.isTrusted) {
rpc.callEvent('devtoolskit:internal:streaming:subscribe', channel, id, {
rpc.callEvent('devframe:streaming:subscribe', channel, id, {
afterSeq: 0,
})
}
Expand All @@ -146,7 +146,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
if (trusted) {
off()
if (readers.has(key) && !reader.cancelled && !reader.done) {
rpc.callEvent('devtoolskit:internal:streaming:subscribe', channel, id, {
rpc.callEvent('devframe:streaming:subscribe', channel, id, {
afterSeq: reader.lastSeenSeq,
})
}
Expand All @@ -167,7 +167,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami

sink.events.on('chunk', (seq, chunk) => {
rpc.callEvent(
'devtoolskit:internal:streaming:upload-chunk',
'devframe:streaming:upload-chunk',
channel,
id,
seq,
Expand All @@ -176,7 +176,7 @@ export function createRpcStreamingClientHost(rpc: DevToolsRpcClient): RpcStreami
})
sink.events.on('end', (error) => {
rpc.callEvent(
'devtoolskit:internal:streaming:upload-end',
'devframe:streaming:upload-end',
channel,
id,
error,
Expand Down
2 changes: 1 addition & 1 deletion devframe/packages/devframe/src/client/rpc-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function createWsRpcClientMode(

// Handle server-initiated auth revocation
clientRpc.register({
name: 'devtoolskit:internal:auth:revoked',
name: 'devframe:auth:revoked',
type: 'event',
handler: () => {
isTrusted = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ describe('rpcFunctionsHost', () => {
it('should not throw in build mode', async () => {
const host = new RpcFunctionsHost({ mode: 'build' } as DevToolsNodeContext)
await expect(host.broadcast({
method: 'devtoolskit:internal:terminals:updated',
method: 'devframe:terminals:updated',
args: [],
})).resolves.toBeUndefined()
})

it('should not throw in dev mode when rpc group is not yet set', async () => {
const host = new RpcFunctionsHost({ mode: 'dev' } as DevToolsNodeContext)
await expect(host.broadcast({
method: 'devtoolskit:internal:terminals:updated',
method: 'devframe:terminals:updated',
args: [],
})).resolves.toBeUndefined()
})
Expand Down
2 changes: 1 addition & 1 deletion devframe/packages/devframe/src/node/auth-revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function revokeActiveConnectionsForToken(
return

await rpcHost.broadcast({
method: 'devtoolskit:internal:auth:revoked',
method: 'devframe:auth:revoked',
args: [],
filter: client => affectedSessionIds.has(client.$meta.id),
})
Expand Down
10 changes: 5 additions & 5 deletions devframe/packages/devframe/src/node/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function createHostContext(options: CreateHostContextOptions): Prom

let jrCounter = 0
context.createJsonRenderer = (initialSpec: JsonRenderSpec): JsonRenderer => {
const stateKey = `devtoolskit:internal:json-render:${jrCounter++}`
const stateKey = `devframe:json-render:${jrCounter++}`
const statePromise = rpcHost.sharedState.get(stateKey as any, {
initialValue: initialSpec as any,
})
Expand Down Expand Up @@ -123,23 +123,23 @@ export async function createHostContext(options: CreateHostContextOptions): Prom

await docksHost.init()

const docksSharedState = await rpcHost.sharedState.get('devtoolskit:internal:docks', { initialValue: [] })
const docksSharedState = await rpcHost.sharedState.get('devframe:docks', { initialValue: [] })

docksHost.events.on('dock:entry:updated', debounce(() => {
docksSharedState.mutate(() => context.docks.values())
}, mode === 'build' ? 0 : 10))

terminalsHost.events.on('terminal:session:updated', debounce(() => {
rpcHost.broadcast({
method: 'devtoolskit:internal:terminals:updated',
method: 'devframe:terminals:updated',
args: [],
})
docksSharedState.mutate(() => context.docks.values())
}, mode === 'build' ? 0 : 10))

const debouncedMessagesUpdate = debounce(() => {
rpcHost.broadcast({
method: 'devtoolskit:internal:messages:updated',
method: 'devframe:messages:updated',
args: [],
})
docksSharedState.mutate(() => context.docks.values())
Expand All @@ -150,7 +150,7 @@ export async function createHostContext(options: CreateHostContextOptions): Prom
messagesHost.events.on('message:removed', () => debouncedMessagesUpdate())
messagesHost.events.on('message:cleared', () => debouncedMessagesUpdate())

const commandsSharedState = await rpcHost.sharedState.get('devtoolskit:internal:commands', { initialValue: [] })
const commandsSharedState = await rpcHost.sharedState.get('devframe:commands', { initialValue: [] })
const debouncedCommandsSync = debounce(() => {
commandsSharedState.mutate(() => commandsHost.list())
}, mode === 'build' ? 0 : 10)
Expand Down
2 changes: 1 addition & 1 deletion devframe/packages/devframe/src/node/host-docks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class DevToolsDockHost implements DevToolsDockHostType {
}

async init() {
this.userSettings = await this.context.rpc.sharedState.get('devtoolskit:internal:user-settings', {
this.userSettings = await this.context.rpc.sharedState.get('devframe:user-settings', {
sharedState: createStorage({
filepath: join(this.context.workspaceRoot, 'node_modules/.vite/devtools/settings.json'),
initialValue: DEFAULT_STATE_USER_SETTINGS(),
Expand Down
4 changes: 2 additions & 2 deletions devframe/packages/devframe/src/node/host-terminals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { logger } from './diagnostics'
* standalone client (`packages/core/src/client/webcomponents/state/terminals.ts`)
* can subscribe by a stable, well-known name.
*/
const TERMINAL_STREAM_CHANNEL = 'devtoolskit:internal:terminals' as const
const TERMINAL_STREAM_CHANNEL = 'devframe:terminals' as const
const TERMINAL_REPLAY_WINDOW = 1000

export class DevToolsTerminalHost implements DevToolsTerminalHostType {
Expand Down Expand Up @@ -92,7 +92,7 @@ export class DevToolsTerminalHost implements DevToolsTerminalHostType {
const channel = this.getStreamingChannel()
// The streaming channel reuses `session.id` as the stream id so clients
// can subscribe immediately after seeing the session in
// `devtoolskit:internal:terminals:list`.
// `devframe:terminals:list`.
const sink = channel?.start({ id: session.id })

const writer = new WritableStream<string>({
Expand Down
12 changes: 6 additions & 6 deletions devframe/packages/devframe/src/node/rpc-shared-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export function createRpcSharedStateServerHost(
if (patches) {
debug('patch', { key, syncId })
rpc.broadcast({
method: 'devtoolskit:internal:rpc:client-state:patch',
method: 'devframe:rpc:client-state:patch',
args: [key, patches, syncId],
filter: client => client.$meta.subscribedStates.has(key),
})
}
else {
debug('updated', { key, syncId })
rpc.broadcast({
method: 'devtoolskit:internal:rpc:client-state:updated',
method: 'devframe:rpc:client-state:updated',
args: [key, fullState, syncId],
filter: client => client.$meta.subscribedStates.has(key),
})
Expand Down Expand Up @@ -80,7 +80,7 @@ export function createRpcSharedStateServerHost(
// server built on `RpcFunctionsHost` (devframe standalone or kit /
// core) gets the full sync protocol out of the box.
rpc.register({
name: 'devtoolskit:internal:rpc:server-state:subscribe',
name: 'devframe:rpc:server-state:subscribe',
type: 'event',
handler(key: string) {
const session = rpc.getCurrentRpcSession()
Expand All @@ -92,7 +92,7 @@ export function createRpcSharedStateServerHost(
})

rpc.register({
name: 'devtoolskit:internal:rpc:server-state:get',
name: 'devframe:rpc:server-state:get',
type: 'query',
handler: async (key: string) => {
if (!sharedState.has(key))
Expand All @@ -108,7 +108,7 @@ export function createRpcSharedStateServerHost(
})

rpc.register({
name: 'devtoolskit:internal:rpc:server-state:set',
name: 'devframe:rpc:server-state:set',
type: 'query',
handler: async (key: string, value: any, syncId: string) => {
const state = await host.get(key as keyof DevToolsRpcSharedStates, {
Expand All @@ -119,7 +119,7 @@ export function createRpcSharedStateServerHost(
})

rpc.register({
name: 'devtoolskit:internal:rpc:server-state:patch',
name: 'devframe:rpc:server-state:patch',
type: 'query',
handler: async (key: string, patches: SharedStatePatch[], syncId: string) => {
if (!sharedState.has(key))
Expand Down
Loading
Loading