/ concept-collection / jupyterlite-numbl-kernel
Sign in
concept-collection / jupyterlite-numbl-kernel
jupyterlite-numbl-kernel / src / index.ts
46 lines · 2.2 KBCodeBlameHistory
2 JupyterFrontEnd,
3 JupyterFrontEndPlugin
4} from '@jupyterlab/application';
6import { IKernelSpecs } from '@jupyterlite/services';
7import type { IKernel } from '@jupyterlite/services';
9import { NumblKernel } from './kernel';
cf2d698Add cooperative cell interrupt (Stop button)Jeremy Magland 10import { installInterruptBridge } from './interruptBridge';
12/** numbl's matrix logo, inlined so the spec needs no served resources. */
13const NUMBL_LOGO =
14 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8IS0tIEJhY2tncm91bmQgLS0+CiAgPHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiBmaWxsPSIjNjQ3NDhiIiByeD0iNCIvPgoKICA8IS0tIE1hdHJpeCBicmFja2V0cyBhbmQgZG90cyAod2hpdGUgb24gYmx1ZSkgLS0+CiAgPGcgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiPgogICAgPCEtLSBMZWZ0IGJyYWNrZXQgLS0+CiAgICA8cGF0aCBkPSJNIDggOSBMIDYgOSBMIDYgMjMgTCA4IDIzIi8+CiAgICA8IS0tIFJpZ2h0IGJyYWNrZXQgLS0+CiAgICA8cGF0aCBkPSJNIDI0IDkgTCAyNiA5IEwgMjYgMjMgTCAyNCAyMyIvPgogIDwvZz4KCiAgPCEtLSBNYXRyaXggZG90cyAtLT4KICA8ZyBmaWxsPSJ3aGl0ZSI+CiAgICA8Y2lyY2xlIGN4PSIxMiIgY3k9IjEzIiByPSIxLjUiLz4KICAgIDxjaXJjbGUgY3g9IjE2IiBjeT0iMTMiIHI9IjEuNSIvPgogICAgPGNpcmNsZSBjeD0iMjAiIGN5PSIxMyIgcj0iMS41Ii8+CgogICAgPGNpcmNsZSBjeD0iMTIiIGN5PSIxOSIgcj0iMS41Ii8+CiAgICA8Y2lyY2xlIGN4PSIxNiIgY3k9IjE5IiByPSIxLjUiLz4KICAgIDxjaXJjbGUgY3g9IjIwIiBjeT0iMTkiIHI9IjEuNSIvPgogIDwvZz4KPC9zdmc+Cg==';
16/**
f44f6a3Rebrand numbl-first: this runs numbl (which uses MATLAB syntax)Jeremy Magland 17 * A plugin to register the numbl kernel.
19const kernel: JupyterFrontEndPlugin<void> = {
20 id: 'jupyterlite-numbl-kernel:kernel',
21 autoStart: true,
22 requires: [IKernelSpecs],
23 activate: (app: JupyterFrontEnd, kernelspecs: IKernelSpecs) => {
cf2d698Add cooperative cell interrupt (Stop button)Jeremy Magland 24 // Route the Stop button to the running numbl session (see interruptBridge).
25 installInterruptBridge();
41c072cjupyterlite-numbl-kernel: MATLAB-syntax kernel for JupyterLiteJeremy Magland 26 kernelspecs.register({
27 spec: {
28 name: 'numbl',
f44f6a3Rebrand numbl-first: this runs numbl (which uses MATLAB syntax)Jeremy Magland 29 display_name: 'numbl (MATLAB syntax)',
30 language: 'numbl',
32 resources: {
33 'logo-32x32': NUMBL_LOGO,
34 'logo-64x64': NUMBL_LOGO
35 }
36 },
37 create: async (options: IKernel.IOptions): Promise<IKernel> => {
6b31a9aSync .m workspace files from the notebook directory into the sessionJeremy Magland 38 return new NumblKernel(options, app.serviceManager.contents);
40 });
41 }
42};
44const plugins: JupyterFrontEndPlugin<unknown>[] = [kernel];
46export default plugins;
moveopenescclose