tokens.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { CodeEditor, CodeEditorWrapper } from '@jupyterlab/codeeditor';
  4. import { KernelMessage, Session } from '@jupyterlab/services';
  5. import { ReadonlyJSONObject, Token } from '@lumino/coreutils';
  6. import { IObservableDisposable } from '@lumino/disposable';
  7. import { ISignal, Signal } from '@lumino/signaling';
  8. import { Widget } from '@lumino/widgets';
  9. import { DebugProtocol } from 'vscode-debugprotocol';
  10. import { DebuggerHandler } from './handler';
  11. /**
  12. * An interface describing an application's visual debugger.
  13. */
  14. export interface IDebugger {
  15. /**
  16. * Signal emitted for debug event messages.
  17. */
  18. readonly eventMessage: ISignal<IDebugger, IDebugger.ISession.Event>;
  19. /**
  20. * Whether the current debugger is started.
  21. */
  22. readonly isStarted: boolean;
  23. /**
  24. * The debugger service's model.
  25. */
  26. readonly model: IDebugger.Model.IService;
  27. /**
  28. * The current debugger session.
  29. */
  30. session: IDebugger.ISession | null;
  31. /**
  32. * Signal emitted upon session changed.
  33. */
  34. readonly sessionChanged: ISignal<IDebugger, IDebugger.ISession | null>;
  35. /**
  36. * Removes all the breakpoints from the current notebook or console
  37. */
  38. clearBreakpoints(): Promise<void>;
  39. /**
  40. * Continues the execution of the current thread.
  41. */
  42. continue(): Promise<void>;
  43. /**
  44. * Evaluate an expression.
  45. */
  46. evaluate(
  47. expression: string
  48. ): Promise<DebugProtocol.EvaluateResponse['body'] | null>;
  49. /**
  50. * Computes an id based on the given code.
  51. */
  52. getCodeId(code: string): string;
  53. /**
  54. * Retrieve the content of a source file.
  55. *
  56. * @param source The source object containing the path to the file.
  57. */
  58. getSource(source: DebugProtocol.Source): Promise<IDebugger.Source>;
  59. /**
  60. * Whether there exist a thread in stopped state.
  61. */
  62. hasStoppedThreads(): boolean;
  63. /**
  64. * Request variables for a given variable reference.
  65. *
  66. * @param variablesReference The variable reference to request.
  67. */
  68. inspectVariable(
  69. variablesReference: number
  70. ): Promise<DebugProtocol.Variable[]>;
  71. /**
  72. * Request rich representation of a variable.
  73. *
  74. * @param variableName The variable name to request
  75. * @param variablesReference The variable reference to request
  76. * @returns The mime renderer data model
  77. */
  78. inspectRichVariable(
  79. variableName: string,
  80. variablesReference?: number
  81. ): Promise<IDebugger.IRichVariable>;
  82. /**
  83. * Requests all the defined variables and display them in the
  84. * table view.
  85. */
  86. displayDefinedVariables(): Promise<void>;
  87. /**
  88. * Request whether debugging is available for the given session connection.
  89. *
  90. * @param connection The session connection.
  91. */
  92. isAvailable(connection: Session.ISessionConnection): Promise<boolean>;
  93. /**
  94. * Makes the current thread run again for one step.
  95. */
  96. next(): Promise<void>;
  97. /**
  98. * Restart the debugger.
  99. * Precondition: isStarted
  100. */
  101. restart(): Promise<void>;
  102. /**
  103. * Restore the state of a debug session.
  104. *
  105. * @param autoStart - when true, starts the debugger
  106. * if it has not been started yet.
  107. */
  108. restoreState(autoStart: boolean): Promise<void>;
  109. /**
  110. * Starts a debugger.
  111. * Precondition: !isStarted
  112. */
  113. start(): Promise<void>;
  114. /**
  115. * Makes the current thread step in a function / method if possible.
  116. */
  117. stepIn(): Promise<void>;
  118. /**
  119. * Makes the current thread step out a function / method if possible.
  120. */
  121. stepOut(): Promise<void>;
  122. /**
  123. * Stops the debugger.
  124. * Precondition: isStarted
  125. */
  126. stop(): Promise<void>;
  127. /**
  128. * Update all breakpoints of a cell at once.
  129. *
  130. * @param code - The code in the cell where the breakpoints are set.
  131. * @param breakpoints - The list of breakpoints to set.
  132. * @param path - Optional path to the file where to set the breakpoints.
  133. */
  134. updateBreakpoints(
  135. code: string,
  136. breakpoints: IDebugger.IBreakpoint[],
  137. path?: string
  138. ): Promise<void>;
  139. /**
  140. * Get the debugger state
  141. *
  142. * @returns Debugger state
  143. */
  144. getDebuggerState(): IDebugger.State;
  145. /**
  146. * Restore the debugger state
  147. *
  148. * @param state Debugger state
  149. * @returns Whether the state has been restored successfully or not
  150. */
  151. restoreDebuggerState(state: IDebugger.State): Promise<boolean>;
  152. }
  153. /**
  154. * A namespace for visual debugger types.
  155. */
  156. export namespace IDebugger {
  157. /**
  158. * The type for a source file.
  159. */
  160. export type Source = {
  161. /**
  162. * The content of the source.
  163. */
  164. content: string;
  165. /**
  166. * The mimeType of the source.
  167. */
  168. mimeType?: string;
  169. /**
  170. * The path of the source.
  171. */
  172. path: string;
  173. };
  174. /**
  175. * Single breakpoint in an editor.
  176. */
  177. export interface IBreakpoint extends DebugProtocol.Breakpoint {}
  178. /*
  179. * The state of the debugger, used for restoring a debugging session
  180. * after restarting the kernel.
  181. */
  182. export type State = {
  183. /**
  184. * List of cells to dump after the kernel has restarted
  185. */
  186. cells: string[];
  187. /**
  188. * Map of breakpoints to send back to the kernel after it has restarted
  189. */
  190. breakpoints: Map<string, IDebugger.IBreakpoint[]>;
  191. };
  192. /**
  193. * Debugger file and hashing configuration.
  194. */
  195. export interface IConfig {
  196. /**
  197. * Returns an id based on the given code.
  198. *
  199. * @param code The source code.
  200. * @param kernel The kernel name from current session.
  201. */
  202. getCodeId(code: string, kernel: string): string;
  203. /**
  204. * Sets the hash parameters for a kernel.
  205. *
  206. * @param params - Hashing parameters for a kernel.
  207. */
  208. setHashParams(params: IConfig.HashParams): void;
  209. /**
  210. * Sets the parameters used for the temp files (e.g. cells) for a kernel.
  211. *
  212. * @param params - Temporary file prefix and suffix for a kernel.
  213. */
  214. setTmpFileParams(params: IConfig.FileParams): void;
  215. /**
  216. * Gets the parameters used for the temp files (e.e. cells) for a kernel.
  217. *
  218. * @param kernel - The kernel name from current session.
  219. */
  220. getTmpFileParams(kernel: string): IConfig.FileParams;
  221. }
  222. /**
  223. * An interface for debugger handler.
  224. */
  225. export interface IHandler extends DebuggerHandler.IHandler {}
  226. /**
  227. * An interface for a scope.
  228. */
  229. export interface IScope {
  230. /**
  231. * The name of the scope.
  232. */
  233. name: string;
  234. /**
  235. * The list of variables.
  236. */
  237. variables: IVariable[];
  238. }
  239. /**
  240. * A visual debugger session.
  241. */
  242. export interface ISession extends IObservableDisposable {
  243. /**
  244. * The API session connection to connect to a debugger.
  245. */
  246. connection: Session.ISessionConnection | null;
  247. /**
  248. * Whether the debug session is started
  249. */
  250. readonly isStarted: boolean;
  251. /**
  252. * Signal emitted for debug event messages.
  253. */
  254. readonly eventMessage: ISignal<
  255. IDebugger.ISession,
  256. IDebugger.ISession.Event
  257. >;
  258. /**
  259. * Restore the state of a debug session.
  260. */
  261. restoreState(): Promise<IDebugger.ISession.Response['debugInfo']>;
  262. /**
  263. * Send a debug request to the kernel.
  264. */
  265. sendRequest<K extends keyof IDebugger.ISession.Request>(
  266. command: K,
  267. args: IDebugger.ISession.Request[K]
  268. ): Promise<IDebugger.ISession.Response[K]>;
  269. /**
  270. * Start a new debug session.
  271. */
  272. start(): Promise<void>;
  273. /**
  274. * Stop a running debug session.
  275. */
  276. stop(): Promise<void>;
  277. }
  278. /**
  279. * A utility to find text editors used by the debugger.
  280. */
  281. export interface ISources {
  282. /**
  283. * Returns an array of editors for a source matching the current debug
  284. * session by iterating through all the widgets in each of the supported
  285. * debugger types (i.e., consoles, files, notebooks).
  286. *
  287. * @param params - The editor find parameters.
  288. */
  289. find(params: ISources.FindParams): CodeEditor.IEditor[];
  290. /**
  291. * Open a read-only editor in the main area.
  292. *
  293. * @param params - The editor open parameters.
  294. */
  295. open(params: ISources.OpenParams): void;
  296. }
  297. /**
  298. * The type for a stack frame
  299. */
  300. export interface IStackFrame extends DebugProtocol.StackFrame {}
  301. /**
  302. * A reply to an rich inspection request.
  303. */
  304. export interface IRichVariable {
  305. /**
  306. * The MIME bundle data returned from an rich inspection request.
  307. */
  308. data: ReadonlyJSONObject;
  309. /**
  310. * Any metadata that accompanies the MIME bundle returning from a rich inspection request.
  311. */
  312. metadata: ReadonlyJSONObject;
  313. }
  314. /**
  315. * An interface for a variable.
  316. */
  317. export interface IVariable extends DebugProtocol.Variable {
  318. /**
  319. * Whether the variable is expanded.
  320. */
  321. expanded?: boolean;
  322. }
  323. /**
  324. * Debugger file and hashing configuration.
  325. */
  326. export namespace IConfig {
  327. /**
  328. * Temporary file prefix and suffix for a kernel.
  329. */
  330. export type FileParams = {
  331. /**
  332. * The kernel name.
  333. */
  334. kernel: string;
  335. /**
  336. * Prefix added to temporary files created by the kernel per cell.
  337. */
  338. prefix: string;
  339. /**
  340. * Suffix added temporary files created by the kernel per cell.
  341. */
  342. suffix: string;
  343. };
  344. /**
  345. * Hashing parameters for a kernel.
  346. */
  347. export type HashParams = {
  348. /**
  349. * The kernel name.
  350. */
  351. kernel: string;
  352. /**
  353. * The hashing method.
  354. */
  355. method: string;
  356. /**
  357. * An optional hashing seed provided by the kernel.
  358. */
  359. seed?: any;
  360. };
  361. }
  362. export namespace ISession {
  363. /**
  364. * A generic debug event.
  365. */
  366. export type Event = DebugProtocol.Event;
  367. /**
  368. * Expose all the debug requests types.
  369. */
  370. export type Request = {
  371. attach: DebugProtocol.AttachRequestArguments;
  372. completions: DebugProtocol.CompletionsArguments;
  373. configurationDone: DebugProtocol.ConfigurationDoneArguments;
  374. continue: DebugProtocol.ContinueArguments;
  375. debugInfo: {};
  376. disconnect: DebugProtocol.DisconnectArguments;
  377. dumpCell: IDumpCellArguments;
  378. evaluate: DebugProtocol.EvaluateArguments;
  379. exceptionInfo: DebugProtocol.ExceptionInfoArguments;
  380. goto: DebugProtocol.GotoArguments;
  381. gotoTargets: DebugProtocol.GotoTargetsArguments;
  382. initialize: DebugProtocol.InitializeRequestArguments;
  383. inspectVariables: {};
  384. launch: DebugProtocol.LaunchRequestArguments;
  385. loadedSources: DebugProtocol.LoadedSourcesArguments;
  386. modules: DebugProtocol.ModulesArguments;
  387. next: DebugProtocol.NextArguments;
  388. pause: DebugProtocol.PauseArguments;
  389. restart: DebugProtocol.RestartArguments;
  390. restartFrame: DebugProtocol.RestartFrameArguments;
  391. reverseContinue: DebugProtocol.ReverseContinueArguments;
  392. richInspectVariables: IRichVariablesArguments;
  393. scopes: DebugProtocol.ScopesArguments;
  394. setBreakpoints: DebugProtocol.SetBreakpointsArguments;
  395. setExceptionBreakpoints: DebugProtocol.SetExceptionBreakpointsArguments;
  396. setExpression: DebugProtocol.SetExpressionArguments;
  397. setFunctionBreakpoints: DebugProtocol.SetFunctionBreakpointsArguments;
  398. setVariable: DebugProtocol.SetVariableArguments;
  399. source: DebugProtocol.SourceArguments;
  400. stackTrace: DebugProtocol.StackTraceArguments;
  401. stepBack: DebugProtocol.StepBackArguments;
  402. stepIn: DebugProtocol.StepInArguments;
  403. stepInTargets: DebugProtocol.StepInTargetsArguments;
  404. stepOut: DebugProtocol.StepOutArguments;
  405. terminate: DebugProtocol.TerminateArguments;
  406. terminateThreads: DebugProtocol.TerminateThreadsArguments;
  407. threads: {};
  408. variables: DebugProtocol.VariablesArguments;
  409. };
  410. /**
  411. * Expose all the debug response types.
  412. */
  413. export type Response = {
  414. attach: DebugProtocol.AttachResponse;
  415. completions: DebugProtocol.CompletionsResponse;
  416. configurationDone: DebugProtocol.ConfigurationDoneResponse;
  417. continue: DebugProtocol.ContinueResponse;
  418. debugInfo: IDebugInfoResponse;
  419. disconnect: DebugProtocol.DisconnectResponse;
  420. dumpCell: IDumpCellResponse;
  421. evaluate: DebugProtocol.EvaluateResponse;
  422. exceptionInfo: DebugProtocol.ExceptionInfoResponse;
  423. goto: DebugProtocol.GotoResponse;
  424. gotoTargets: DebugProtocol.GotoTargetsResponse;
  425. initialize: DebugProtocol.InitializeResponse;
  426. inspectVariables: IInspectVariablesResponse;
  427. launch: DebugProtocol.LaunchResponse;
  428. loadedSources: DebugProtocol.LoadedSourcesResponse;
  429. modules: DebugProtocol.ModulesResponse;
  430. next: DebugProtocol.NextResponse;
  431. pause: DebugProtocol.PauseResponse;
  432. restart: DebugProtocol.RestartResponse;
  433. restartFrame: DebugProtocol.RestartFrameResponse;
  434. reverseContinue: DebugProtocol.ReverseContinueResponse;
  435. richInspectVariables: IRichVariablesResponse;
  436. scopes: DebugProtocol.ScopesResponse;
  437. setBreakpoints: DebugProtocol.SetBreakpointsResponse;
  438. setExceptionBreakpoints: DebugProtocol.SetExceptionBreakpointsResponse;
  439. setExpression: DebugProtocol.SetExpressionResponse;
  440. setFunctionBreakpoints: DebugProtocol.SetFunctionBreakpointsResponse;
  441. setVariable: DebugProtocol.SetVariableResponse;
  442. source: DebugProtocol.SourceResponse;
  443. stackTrace: DebugProtocol.StackTraceResponse;
  444. stepBack: DebugProtocol.StepBackResponse;
  445. stepIn: DebugProtocol.StepInResponse;
  446. stepInTargets: DebugProtocol.StepInTargetsResponse;
  447. stepOut: DebugProtocol.StepOutResponse;
  448. terminate: DebugProtocol.TerminateResponse;
  449. terminateThreads: DebugProtocol.TerminateThreadsResponse;
  450. threads: DebugProtocol.ThreadsResponse;
  451. variables: DebugProtocol.VariablesResponse;
  452. };
  453. /**
  454. * List of breakpoints in a source file.
  455. */
  456. export interface IDebugInfoBreakpoints {
  457. source: string;
  458. breakpoints: DebugProtocol.SourceBreakpoint[];
  459. }
  460. /**
  461. * Response to 'debugInfo' request.
  462. * This is an addition to the Debug Adapter Protocol to be able
  463. * to retrieve the debugger state when restoring a session.
  464. */
  465. export interface IDebugInfoResponse extends DebugProtocol.Response {
  466. body: {
  467. breakpoints: IDebugInfoBreakpoints[];
  468. hashMethod: string;
  469. hashSeed: number;
  470. isStarted: boolean;
  471. /**
  472. * Whether the kernel supports variable rich rendering or not.
  473. */
  474. richRendering?: boolean;
  475. stoppedThreads: number[];
  476. tmpFilePrefix: string;
  477. tmpFileSuffix: string;
  478. };
  479. }
  480. /**
  481. * Arguments for 'dumpCell' request.
  482. * This is an addition to the Debug Adapter Protocol to support
  483. * setting breakpoints for cells.
  484. */
  485. export interface IDumpCellArguments {
  486. code: string;
  487. }
  488. /**
  489. * Response to 'dumpCell' request.
  490. * This is an addition to the Debug Adapter Protocol to support
  491. * setting breakpoints for cells.
  492. */
  493. export interface IDumpCellResponse extends DebugProtocol.Response {
  494. body: {
  495. sourcePath: string;
  496. };
  497. }
  498. export interface IInspectVariablesResponse extends DebugProtocol.Response {
  499. body: {
  500. variables: DebugProtocol.Variable[];
  501. };
  502. }
  503. /**
  504. * Arguments for 'richVariables' request
  505. *
  506. * This is an addition to the Debug Adapter Protocol to support
  507. * render rich variable representation.
  508. */
  509. export interface IRichVariablesArguments {
  510. /**
  511. * Variable name
  512. */
  513. variableName: string;
  514. /**
  515. * Frame Id
  516. */
  517. frameId?: number;
  518. }
  519. /**
  520. * Arguments for 'richVariables' request
  521. *
  522. * This is an addition to the Debug Adapter Protocol to support
  523. * rich rendering of variables.
  524. */
  525. export interface IRichVariablesResponse extends DebugProtocol.Response {
  526. /**
  527. * Variable mime type data
  528. */
  529. body: IRichVariable;
  530. }
  531. /**
  532. * Response to the 'kernel_info_request' request.
  533. * This interface extends the IInfoReply by adding the `debugger` key
  534. * that isn't part of the protocol yet.
  535. * See this pull request for more info: https://github.com/jupyter/jupyter_client/pull/486
  536. */
  537. export interface IInfoReply extends KernelMessage.IInfoReply {
  538. debugger: boolean;
  539. }
  540. }
  541. /**
  542. * Select variable in the variables explorer.
  543. */
  544. export interface IVariableSelection
  545. extends Pick<
  546. DebugProtocol.Variable,
  547. 'name' | 'type' | 'variablesReference' | 'value'
  548. > {}
  549. /**
  550. * Debugger variables explorer interface.
  551. */
  552. export interface IVariablesPanel {
  553. /**
  554. * Select variable in the variables explorer.
  555. */
  556. latestSelection: IVariableSelection | null;
  557. /**
  558. * Variable view mode.
  559. */
  560. viewMode: 'tree' | 'table';
  561. }
  562. /**
  563. * Debugger sidebar interface.
  564. */
  565. export interface ISidebar extends Widget {
  566. /**
  567. * Debugger variables explorer.
  568. */
  569. variables: IVariablesPanel;
  570. /**
  571. * Add item at the end of the sidebar.
  572. */
  573. addItem(widget: Widget): void;
  574. /**
  575. * Insert item at a specified index.
  576. */
  577. insertItem(index: number, widget: Widget): void;
  578. /**
  579. * Return all items that were added to sidebar.
  580. */
  581. readonly items: readonly Widget[];
  582. }
  583. /**
  584. * A utility to find text editors used by the debugger.
  585. */
  586. export namespace ISources {
  587. /**
  588. * Unified parameters for the find method
  589. */
  590. export type FindParams = {
  591. /**
  592. * Extra flag to focus on the parent widget of the editor.
  593. */
  594. focus: boolean;
  595. /**
  596. * Name of current kernel.
  597. */
  598. kernel: string;
  599. /**
  600. * Path of session connection.
  601. */
  602. path: string;
  603. /**
  604. * Source path
  605. */
  606. source: string;
  607. };
  608. /**
  609. * Unified parameters for the open method
  610. */
  611. export type OpenParams = {
  612. /**
  613. * The caption for the read-only editor.
  614. */
  615. caption: string;
  616. /**
  617. * The code editor wrapper to add to the main area.
  618. */
  619. editorWrapper: CodeEditorWrapper;
  620. /**
  621. * The label for the read-only editor.
  622. */
  623. label: string;
  624. };
  625. }
  626. /**
  627. * A namespace for UI model definitions.
  628. */
  629. export namespace Model {
  630. /**
  631. * The breakpoints UI model.
  632. */
  633. export interface IBreakpoints {
  634. /**
  635. * Get all the breakpoints.
  636. */
  637. readonly breakpoints: Map<string, IDebugger.IBreakpoint[]>;
  638. /**
  639. * Signal emitted when the model changes.
  640. */
  641. readonly changed: ISignal<this, IDebugger.IBreakpoint[]>;
  642. /**
  643. * Signal emitted when a breakpoint is clicked.
  644. */
  645. readonly clicked: Signal<this, IDebugger.IBreakpoint>;
  646. /**
  647. * Signal emitted when the breakpoints are restored.
  648. */
  649. readonly restored: ISignal<this, void>;
  650. /**
  651. * Get the breakpoints for a given id (path).
  652. *
  653. * @param id The code id (path).
  654. */
  655. getBreakpoints(id: string): IBreakpoint[];
  656. /**
  657. * Restore a map of breakpoints.
  658. *
  659. * @param breakpoints The map of breakpoints
  660. */
  661. restoreBreakpoints(breakpoints: Map<string, IBreakpoint[]>): void;
  662. /**
  663. * Set the breakpoints for a given id (path).
  664. *
  665. * @param id The code id (path).
  666. * @param breakpoints The list of breakpoints.
  667. */
  668. setBreakpoints(id: string, breakpoints: IBreakpoint[]): void;
  669. }
  670. /**
  671. * The callstack UI model.
  672. */
  673. export interface ICallstack {
  674. /**
  675. * Signal emitted when the current frame has changed.
  676. */
  677. readonly currentFrameChanged: ISignal<this, IDebugger.IStackFrame | null>;
  678. /**
  679. * The current frame.
  680. */
  681. frame: IDebugger.IStackFrame | null;
  682. /**
  683. * The frames for the callstack.
  684. */
  685. frames: IDebugger.IStackFrame[];
  686. /**
  687. * Signal emitted when the frames have changed.
  688. */
  689. readonly framesChanged: ISignal<this, IDebugger.IStackFrame[]>;
  690. }
  691. /**
  692. * The data model for the debugger service.
  693. */
  694. export interface IService {
  695. /**
  696. * The breakpoints UI model.
  697. */
  698. readonly breakpoints: IBreakpoints;
  699. /**
  700. * The callstack UI model.
  701. */
  702. readonly callstack: ICallstack;
  703. /**
  704. * Whether the kernel support rich variable rendering based on mime type.
  705. */
  706. hasRichVariableRendering: boolean;
  707. /**
  708. * The variables UI model.
  709. */
  710. readonly variables: IVariables;
  711. /**
  712. * The sources UI model.
  713. */
  714. readonly sources: ISources;
  715. /**
  716. * The set of threads in stopped state.
  717. */
  718. stoppedThreads: Set<number>;
  719. /**
  720. * The current debugger title.
  721. */
  722. title: string;
  723. /**
  724. * A signal emitted when the title changes.
  725. */
  726. titleChanged: ISignal<this, string>;
  727. /**
  728. * Clear the model.
  729. */
  730. clear(): void;
  731. }
  732. /**
  733. * The sources UI model.
  734. */
  735. export interface ISources {
  736. /**
  737. * Signal emitted when the current frame changes.
  738. */
  739. readonly currentFrameChanged: ISignal<
  740. IDebugger.Model.ICallstack,
  741. IDebugger.IStackFrame | null
  742. >;
  743. /**
  744. * Return the current source.
  745. */
  746. currentSource: IDebugger.Source | null;
  747. /**
  748. * Signal emitted when the current source changes.
  749. */
  750. readonly currentSourceChanged: ISignal<
  751. IDebugger.Model.ISources,
  752. IDebugger.Source | null
  753. >;
  754. /**
  755. * Signal emitted when a source should be open in the main area.
  756. */
  757. readonly currentSourceOpened: ISignal<
  758. IDebugger.Model.ISources,
  759. IDebugger.Source | null
  760. >;
  761. /**
  762. * Open a source in the main area.
  763. */
  764. open(): void;
  765. }
  766. /**
  767. * The variables UI model.
  768. */
  769. export interface IVariables {
  770. /**
  771. * Signal emitted when the current variable has changed.
  772. */
  773. readonly changed: ISignal<this, void>;
  774. /**
  775. * The variable scopes.
  776. */
  777. scopes: IDebugger.IScope[];
  778. /**
  779. * Signal emitted when the current variable has been expanded.
  780. */
  781. readonly variableExpanded: ISignal<this, IDebugger.IVariable>;
  782. /**
  783. * Expand a variable.
  784. *
  785. * @param variable The variable to expand.
  786. */
  787. expandVariable(variable: IDebugger.IVariable): void;
  788. }
  789. }
  790. }
  791. /**
  792. * The visual debugger token.
  793. */
  794. export const IDebugger = new Token<IDebugger>('@jupyterlab/debugger:IDebugger');
  795. /**
  796. * The debugger configuration token.
  797. */
  798. export const IDebuggerConfig = new Token<IDebugger.IConfig>(
  799. '@jupyterlab/debugger:IDebuggerConfig'
  800. );
  801. /**
  802. * The debugger sources utility token.
  803. */
  804. export const IDebuggerSources = new Token<IDebugger.ISources>(
  805. '@jupyterlab/debugger:IDebuggerSources'
  806. );
  807. /**
  808. * The debugger configuration token.
  809. */
  810. export const IDebuggerSidebar = new Token<IDebugger.ISidebar>(
  811. '@jupyterlab/debugger:IDebuggerSidebar'
  812. );
  813. /**
  814. * The debugger handler token.
  815. */
  816. export const IDebuggerHandler = new Token<IDebugger.IHandler>(
  817. '@jupyterlab/debugger:IDebuggerHandler'
  818. );