File size: 882 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { AppRecord } from './app-record'
import { DevtoolsApi } from './api'
import type { BackendContext } from './backend-context'

export enum BuiltinBackendFeature {
  /**
   * @deprecated
   */
  FLUSH = 'flush',
}

export interface DevtoolsBackendOptions {
  frameworkVersion: 1 | 2 | 3
  features: (BuiltinBackendFeature | string)[]
  setup: (api: DevtoolsApi) => void
  setupApp?: (api: DevtoolsApi, app: AppRecord) => void
}

export function defineBackend(options: DevtoolsBackendOptions) {
  return options
}

export interface DevtoolsBackend {
  options: DevtoolsBackendOptions
  api: DevtoolsApi
}

export function createBackend(options: DevtoolsBackendOptions, ctx: BackendContext): DevtoolsBackend {
  const backend: DevtoolsBackend = {
    options,
    api: null,
  }
  backend.api = new DevtoolsApi(backend, ctx)
  options.setup(backend.api)
  return backend
}