@jupyterlite/services 0.1.0 → 0.7.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/lib/contents/drive.d.ts +278 -0
  2. package/lib/contents/drive.js +888 -0
  3. package/lib/contents/drive.js.map +1 -0
  4. package/lib/contents/drivecontents.d.ts +92 -0
  5. package/lib/contents/drivecontents.js +132 -0
  6. package/lib/contents/drivecontents.js.map +1 -0
  7. package/lib/contents/drivefs.d.ts +245 -0
  8. package/lib/contents/drivefs.js +481 -0
  9. package/lib/contents/drivefs.js.map +1 -0
  10. package/lib/contents/emscripten.d.ts +96 -0
  11. package/lib/contents/emscripten.js +10 -0
  12. package/lib/contents/emscripten.js.map +1 -0
  13. package/lib/contents/index.d.ts +5 -0
  14. package/lib/contents/index.js +8 -0
  15. package/lib/contents/index.js.map +1 -0
  16. package/lib/contents/tokens.d.ts +21 -0
  17. package/lib/contents/tokens.js +55 -0
  18. package/lib/contents/tokens.js.map +1 -0
  19. package/lib/index.d.ts +9 -0
  20. package/lib/index.js +12 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib/kernel/base.d.ts +245 -0
  23. package/lib/kernel/base.js +457 -0
  24. package/lib/kernel/base.js.map +1 -0
  25. package/lib/kernel/client.d.ts +115 -0
  26. package/lib/kernel/client.js +375 -0
  27. package/lib/kernel/client.js.map +1 -0
  28. package/lib/kernel/index.d.ts +5 -0
  29. package/lib/kernel/index.js +8 -0
  30. package/lib/kernel/index.js.map +1 -0
  31. package/lib/kernel/kernelspecclient.d.ts +40 -0
  32. package/lib/kernel/kernelspecclient.js +37 -0
  33. package/lib/kernel/kernelspecclient.js.map +1 -0
  34. package/lib/kernel/kernelspecs.d.ts +59 -0
  35. package/lib/kernel/kernelspecs.js +62 -0
  36. package/lib/kernel/kernelspecs.js.map +1 -0
  37. package/lib/kernel/tokens.d.ts +163 -0
  38. package/lib/kernel/tokens.js +20 -0
  39. package/lib/kernel/tokens.js.map +1 -0
  40. package/lib/nbconvert/exporters.d.ts +80 -0
  41. package/lib/nbconvert/exporters.js +154 -0
  42. package/lib/nbconvert/exporters.js.map +1 -0
  43. package/lib/nbconvert/index.d.ts +3 -0
  44. package/lib/nbconvert/index.js +6 -0
  45. package/lib/nbconvert/index.js.map +1 -0
  46. package/lib/nbconvert/manager.d.ts +67 -0
  47. package/lib/nbconvert/manager.js +77 -0
  48. package/lib/nbconvert/manager.js.map +1 -0
  49. package/lib/nbconvert/tokens.d.ts +49 -0
  50. package/lib/nbconvert/tokens.js +8 -0
  51. package/lib/nbconvert/tokens.js.map +1 -0
  52. package/lib/session/client.d.ts +86 -0
  53. package/lib/session/client.js +200 -0
  54. package/lib/session/client.js.map +1 -0
  55. package/lib/session/index.d.ts +1 -0
  56. package/lib/session/index.js +4 -0
  57. package/lib/session/index.js.map +1 -0
  58. package/lib/settings/index.d.ts +1 -0
  59. package/lib/settings/index.js +4 -0
  60. package/lib/settings/index.js.map +1 -0
  61. package/lib/settings/settings.d.ts +92 -0
  62. package/lib/settings/settings.js +185 -0
  63. package/lib/settings/settings.js.map +1 -0
  64. package/package.json +67 -8
  65. package/src/contents/drive.ts +1032 -0
  66. package/src/contents/drivecontents.ts +254 -0
  67. package/src/contents/drivefs.ts +821 -0
  68. package/src/contents/emscripten.ts +148 -0
  69. package/src/contents/index.ts +8 -0
  70. package/src/contents/tokens.ts +61 -0
  71. package/src/index.ts +13 -0
  72. package/src/kernel/base.ts +638 -0
  73. package/src/kernel/client.ts +483 -0
  74. package/src/kernel/index.ts +8 -0
  75. package/src/kernel/kernelspecclient.ts +65 -0
  76. package/src/kernel/kernelspecs.ts +105 -0
  77. package/src/kernel/tokens.ts +222 -0
  78. package/src/nbconvert/exporters.ts +177 -0
  79. package/src/nbconvert/index.ts +6 -0
  80. package/src/nbconvert/manager.ts +106 -0
  81. package/src/nbconvert/tokens.ts +60 -0
  82. package/src/session/client.ts +252 -0
  83. package/src/session/index.ts +4 -0
  84. package/src/settings/index.ts +4 -0
  85. package/src/settings/settings.ts +237 -0
  86. package/style/index.css +6 -0
  87. package/style/index.js +6 -0
@@ -0,0 +1,163 @@
1
+ import type { Remote } from 'comlink';
2
+ import type { IObservableMap } from '@jupyterlab/observables';
3
+ import type { Kernel, KernelMessage, KernelSpec } from '@jupyterlab/services';
4
+ import { Token } from '@lumino/coreutils';
5
+ import type { IObservableDisposable } from '@lumino/disposable';
6
+ import type { ISignal } from '@lumino/signaling';
7
+ import type { KernelSpecs } from './kernelspecs';
8
+ /**
9
+ * The kernel name of last resort.
10
+ */
11
+ export declare const FALLBACK_KERNEL = "javascript";
12
+ /**
13
+ * The token for the kernel client.
14
+ */
15
+ export declare const IKernelClient: Token<IKernelClient>;
16
+ /**
17
+ * An interface for the Kernels service.
18
+ */
19
+ export interface IKernelClient extends Kernel.IKernelAPIClient {
20
+ /**
21
+ * Signal emitted when the kernels map changes
22
+ */
23
+ readonly changed: ISignal<IKernelClient, IObservableMap.IChangedArgs<IKernel>>;
24
+ /**
25
+ * Handle stdin request received from Service Worker.
26
+ */
27
+ handleStdin(inputRequest: KernelMessage.IInputRequestMsg): Promise<KernelMessage.IInputReplyMsg>;
28
+ /**
29
+ * Shut down all kernels.
30
+ */
31
+ shutdownAll: () => Promise<void>;
32
+ }
33
+ /**
34
+ * The token for the kernel spec client.
35
+ */
36
+ export declare const IKernelSpecClient: Token<IKernelSpecClient>;
37
+ /**
38
+ * An interface for the kernel spec client.
39
+ */
40
+ export interface IKernelSpecClient extends KernelSpec.IKernelSpecAPIClient {
41
+ }
42
+ /**
43
+ * An interface for a kernel running in the browser.
44
+ */
45
+ export interface IKernel extends IObservableDisposable {
46
+ /**
47
+ * The id of the server-side kernel.
48
+ */
49
+ readonly id: string;
50
+ /**
51
+ * The name of the server-side kernel.
52
+ */
53
+ readonly name: string;
54
+ /**
55
+ * The location in the virtual filesystem from which the kernel was started.
56
+ */
57
+ readonly location: string;
58
+ /**
59
+ * A promise that is fulfilled when the kernel is ready.
60
+ */
61
+ readonly ready: Promise<void>;
62
+ /**
63
+ * Handle an incoming message from the client.
64
+ *
65
+ * @param msg The message to handle
66
+ */
67
+ handleMessage(msg: KernelMessage.IMessage): Promise<void>;
68
+ }
69
+ /**
70
+ * A namespace for IKernel statics.
71
+ */
72
+ export declare namespace IKernel {
73
+ /**
74
+ * The type for the send message function.
75
+ */
76
+ type SendMessage = (msg: KernelMessage.IMessage) => void;
77
+ /**
78
+ * The instantiation options for an IKernel.
79
+ */
80
+ interface IOptions {
81
+ /**
82
+ * The kernel id.
83
+ */
84
+ id: string;
85
+ /**
86
+ * The name of the kernel.
87
+ */
88
+ name: string;
89
+ /**
90
+ * The location in the virtual filesystem from which the kernel was started.
91
+ */
92
+ location: string;
93
+ /**
94
+ * The method to send messages back to the server.
95
+ */
96
+ sendMessage: SendMessage;
97
+ }
98
+ }
99
+ /**
100
+ * The token for the kernel spec service.
101
+ */
102
+ export declare const IKernelSpecs: Token<IKernelSpecs>;
103
+ /**
104
+ * The interface for the kernel specs service.
105
+ */
106
+ export interface IKernelSpecs {
107
+ /**
108
+ * Get the kernel specs.
109
+ */
110
+ readonly specs: KernelSpec.ISpecModels | null;
111
+ /**
112
+ * Get the default kernel name.
113
+ */
114
+ readonly defaultKernelName: string;
115
+ /**
116
+ * Get the kernel factories for the current kernels.
117
+ */
118
+ readonly factories: KernelSpecs.KernelFactories;
119
+ /**
120
+ * Signal emitted when the specs change.
121
+ */
122
+ readonly changed: ISignal<IKernelSpecs, KernelSpec.ISpecModels | null>;
123
+ /**
124
+ * Register a new kernel spec
125
+ *
126
+ * @param options The kernel spec options.
127
+ */
128
+ register: (options: KernelSpecs.IKernelOptions) => void;
129
+ }
130
+ /**
131
+ * An interface for a comlink-based worker kernel
132
+ */
133
+ export interface IWorkerKernel {
134
+ /**
135
+ * Handle any lazy setup activities.
136
+ */
137
+ initialize(options: IWorkerKernel.IOptions): Promise<void>;
138
+ execute(content: KernelMessage.IExecuteRequestMsg['content'], parent: any): Promise<KernelMessage.IExecuteReplyMsg['content']>;
139
+ complete(content: KernelMessage.ICompleteRequestMsg['content'], parent: any): Promise<KernelMessage.ICompleteReplyMsg['content']>;
140
+ inspect(content: KernelMessage.IInspectRequestMsg['content'], parent: any): Promise<KernelMessage.IInspectReplyMsg['content']>;
141
+ isComplete(content: KernelMessage.IIsCompleteRequestMsg['content'], parent: any): Promise<KernelMessage.IIsCompleteReplyMsg['content']>;
142
+ commInfo(content: KernelMessage.ICommInfoRequestMsg['content'], parent: any): Promise<KernelMessage.ICommInfoReplyMsg['content']>;
143
+ commOpen(content: KernelMessage.ICommOpenMsg, parent: any): Promise<void>;
144
+ commMsg(content: KernelMessage.ICommMsgMsg, parent: any): Promise<void>;
145
+ commClose(content: KernelMessage.ICommCloseMsg, parent: any): Promise<void>;
146
+ inputReply(content: KernelMessage.IInputReplyMsg['content'], parent: any): Promise<void>;
147
+ }
148
+ /**
149
+ * A namespace for worker kernels.
150
+ **/
151
+ export declare namespace IWorkerKernel {
152
+ /**
153
+ * Common values likely to be required by all kernels.
154
+ */
155
+ interface IOptions {
156
+ /**
157
+ * The base URL of the kernel server.
158
+ */
159
+ baseUrl: string;
160
+ }
161
+ }
162
+ export interface IRemoteKernel extends Remote<IWorkerKernel> {
163
+ }
@@ -0,0 +1,20 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { Token } from '@lumino/coreutils';
4
+ /**
5
+ * The kernel name of last resort.
6
+ */
7
+ export const FALLBACK_KERNEL = 'javascript';
8
+ /**
9
+ * The token for the kernel client.
10
+ */
11
+ export const IKernelClient = new Token('@jupyterlite/services:IKernelClient');
12
+ /**
13
+ * The token for the kernel spec client.
14
+ */
15
+ export const IKernelSpecClient = new Token('@jupyterlite/services:IKernelSpecClient');
16
+ /**
17
+ * The token for the kernel spec service.
18
+ */
19
+ export const IKernelSpecs = new Token('@jupyterlite/services:IKernelSpecs');
20
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/kernel/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAQ3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAQ1C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACpC,qCAAqC,CACtC,CAAC;AAwBF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,KAAK,CACxC,yCAAyC,CAC1C,CAAC;AA0EF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,KAAK,CACnC,oCAAoC,CACrC,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { Contents } from '@jupyterlab/services';
2
+ import type { IExporter } from './tokens';
3
+ /**
4
+ * Base class for notebook exporters.
5
+ */
6
+ export declare abstract class BaseExporter implements IExporter {
7
+ /**
8
+ * The MIME type of the exported format.
9
+ */
10
+ abstract readonly mimeType: string;
11
+ /**
12
+ * Export a notebook to this format.
13
+ *
14
+ * @param model The notebook model to export
15
+ * @param path The path to the notebook
16
+ */
17
+ abstract export(model: Contents.IModel, path: string): Promise<void>;
18
+ /**
19
+ * Trigger a browser download of the exported content.
20
+ *
21
+ * @param content The content to download
22
+ * @param mimeType The MIME type of the content
23
+ * @param filename The filename for the download
24
+ */
25
+ protected triggerDownload(content: string, mimeType: string, filename: string): void;
26
+ }
27
+ /**
28
+ * Exporter for notebook format (.ipynb).
29
+ */
30
+ export declare class NotebookExporter extends BaseExporter {
31
+ /**
32
+ * The MIME type of the exported format.
33
+ */
34
+ readonly mimeType = "application/x-ipynb+json";
35
+ /**
36
+ * Export a notebook to .ipynb format.
37
+ *
38
+ * @param model The notebook model to export
39
+ * @param path The path to the notebook
40
+ */
41
+ export(model: Contents.IModel, path: string): Promise<void>;
42
+ }
43
+ /**
44
+ * Exporter for executable script format.
45
+ */
46
+ export declare class ScriptExporter extends BaseExporter {
47
+ /**
48
+ * The MIME type of the exported format.
49
+ */
50
+ readonly mimeType = "text/x-script";
51
+ /**
52
+ * Export a notebook to executable script format.
53
+ *
54
+ * @param model The notebook model to export
55
+ * @param path The path to the notebook
56
+ */
57
+ export(model: Contents.IModel, path: string): Promise<void>;
58
+ /**
59
+ * Convert a notebook to a script file.
60
+ *
61
+ * @param content The notebook content
62
+ * @returns The script content and file extension
63
+ */
64
+ private convertToScript;
65
+ /**
66
+ * Comment out lines based on the language.
67
+ *
68
+ * @param text The text to comment
69
+ * @param language The programming language
70
+ * @returns The commented text
71
+ */
72
+ private commentLines;
73
+ /**
74
+ * Get the comment character for a given language.
75
+ *
76
+ * @param language The programming language
77
+ * @returns The comment character(s) for that language
78
+ */
79
+ private getCommentChar;
80
+ }
@@ -0,0 +1,154 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * Base class for notebook exporters.
5
+ */
6
+ export class BaseExporter {
7
+ /**
8
+ * Trigger a browser download of the exported content.
9
+ *
10
+ * @param content The content to download
11
+ * @param mimeType The MIME type of the content
12
+ * @param filename The filename for the download
13
+ */
14
+ triggerDownload(content, mimeType, filename) {
15
+ const element = document.createElement('a');
16
+ element.href = `data:${mimeType};charset=utf-8,${encodeURIComponent(content)}`;
17
+ element.download = filename;
18
+ document.body.appendChild(element);
19
+ element.click();
20
+ document.body.removeChild(element);
21
+ }
22
+ }
23
+ /**
24
+ * Exporter for notebook format (.ipynb).
25
+ */
26
+ export class NotebookExporter extends BaseExporter {
27
+ constructor() {
28
+ super(...arguments);
29
+ /**
30
+ * The MIME type of the exported format.
31
+ */
32
+ this.mimeType = 'application/x-ipynb+json';
33
+ }
34
+ /**
35
+ * Export a notebook to .ipynb format.
36
+ *
37
+ * @param model The notebook model to export
38
+ * @param path The path to the notebook
39
+ */
40
+ async export(model, path) {
41
+ var _a;
42
+ const mime = (_a = model.mimetype) !== null && _a !== void 0 ? _a : 'application/json';
43
+ const content = JSON.stringify(model.content, null, 2);
44
+ this.triggerDownload(content, mime, path);
45
+ }
46
+ }
47
+ /**
48
+ * Exporter for executable script format.
49
+ */
50
+ export class ScriptExporter extends BaseExporter {
51
+ constructor() {
52
+ super(...arguments);
53
+ /**
54
+ * The MIME type of the exported format.
55
+ */
56
+ this.mimeType = 'text/x-script';
57
+ }
58
+ /**
59
+ * Export a notebook to executable script format.
60
+ *
61
+ * @param model The notebook model to export
62
+ * @param path The path to the notebook
63
+ */
64
+ async export(model, path) {
65
+ const { content, extension } = this.convertToScript(model.content);
66
+ const filename = path.replace(/\.ipynb$/, extension);
67
+ this.triggerDownload(content, 'text/plain', filename);
68
+ }
69
+ /**
70
+ * Convert a notebook to a script file.
71
+ *
72
+ * @param content The notebook content
73
+ * @returns The script content and file extension
74
+ */
75
+ convertToScript(content) {
76
+ var _a;
77
+ // Get the language from the notebook metadata
78
+ const languageInfo = (_a = content.metadata) === null || _a === void 0 ? void 0 : _a.language_info;
79
+ const language = (languageInfo === null || languageInfo === void 0 ? void 0 : languageInfo.name) || 'python';
80
+ const fileExtension = (languageInfo === null || languageInfo === void 0 ? void 0 : languageInfo.file_extension) || '.py';
81
+ // Extract code cells and convert to script
82
+ const cells = content.cells || [];
83
+ const scriptLines = [];
84
+ for (const cell of cells) {
85
+ if (cell.cell_type === 'code') {
86
+ // Add code cell content
87
+ const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source;
88
+ scriptLines.push(source);
89
+ // Add blank line between cells
90
+ scriptLines.push('');
91
+ }
92
+ else if (cell.cell_type === 'markdown' || cell.cell_type === 'raw') {
93
+ // Add markdown and raw cells as comments
94
+ const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source;
95
+ const commentedSource = this.commentLines(source, language);
96
+ scriptLines.push(commentedSource);
97
+ // Add blank line between cells
98
+ scriptLines.push('');
99
+ }
100
+ }
101
+ return {
102
+ content: scriptLines.join('\n') + '\n',
103
+ extension: fileExtension,
104
+ };
105
+ }
106
+ /**
107
+ * Comment out lines based on the language.
108
+ *
109
+ * @param text The text to comment
110
+ * @param language The programming language
111
+ * @returns The commented text
112
+ */
113
+ commentLines(text, language) {
114
+ const lines = text.split('\n');
115
+ const commentChar = this.getCommentChar(language);
116
+ return lines.map((line) => `${commentChar} ${line}`).join('\n');
117
+ }
118
+ /**
119
+ * Get the comment character for a given language.
120
+ *
121
+ * @param language The programming language
122
+ * @returns The comment character(s) for that language
123
+ */
124
+ getCommentChar(language) {
125
+ // Map of languages to their comment characters
126
+ const commentMap = {
127
+ python: '#',
128
+ r: '#',
129
+ julia: '#',
130
+ ruby: '#',
131
+ bash: '#',
132
+ shell: '#',
133
+ perl: '#',
134
+ javascript: '//',
135
+ typescript: '//',
136
+ java: '//',
137
+ c: '//',
138
+ cpp: '//',
139
+ 'c++': '//',
140
+ scala: '//',
141
+ go: '//',
142
+ rust: '//',
143
+ swift: '//',
144
+ kotlin: '//',
145
+ matlab: '%',
146
+ octave: '%',
147
+ lua: '--',
148
+ sql: '--',
149
+ haskell: '--',
150
+ };
151
+ return commentMap[language.toLowerCase()] || '#';
152
+ }
153
+ }
154
+ //# sourceMappingURL=exporters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exporters.js","sourceRoot":"","sources":["../../src/nbconvert/exporters.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAM3D;;GAEG;AACH,MAAM,OAAgB,YAAY;IAchC;;;;;;OAMG;IACO,eAAe,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB;QAC3E,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,GAAG,QAAQ,QAAQ,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC5B,QAAQ,CAAC,IA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upyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ export * from './exporters';
4
+ export * from './manager';
5
+ export * from './tokens';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nbconvert/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Contents, NbConvert } from '@jupyterlab/services';
2
+ import { NbConvertManager } from '@jupyterlab/services';
3
+ import type { IExporter, INbConvertExporters } from './tokens';
4
+ /**
5
+ * Options for creating a LiteNbConvertManager.
6
+ */
7
+ export interface ILiteNbConvertManagerOptions extends NbConvertManager.IOptions {
8
+ /**
9
+ * The contents manager.
10
+ */
11
+ contentsManager: Contents.IManager;
12
+ /**
13
+ * The exporter registry.
14
+ */
15
+ exporters: INbConvertExporters;
16
+ }
17
+ /**
18
+ * Custom NbConvert manager for JupyterLite with client-side export.
19
+ */
20
+ export declare class LiteNbConvertManager extends NbConvertManager {
21
+ /**
22
+ * Construct a new LiteNbConvertManager.
23
+ *
24
+ * @param options The manager options
25
+ */
26
+ constructor(options: ILiteNbConvertManagerOptions);
27
+ /**
28
+ * Get the list of export formats available.
29
+ */
30
+ getExportFormats(): Promise<NbConvert.IExportFormats>;
31
+ /**
32
+ * Export a notebook to a given format.
33
+ *
34
+ * @param options The export options
35
+ */
36
+ exportAs(options: NbConvert.IExportOptions): Promise<void>;
37
+ private _contentsManager;
38
+ private _exporters;
39
+ }
40
+ /**
41
+ * Implementation of the exporter registry.
42
+ */
43
+ export declare class Exporters implements INbConvertExporters {
44
+ /**
45
+ * Register a new exporter.
46
+ *
47
+ * @param format The export format name
48
+ * @param exporter The exporter instance
49
+ */
50
+ register(format: string, exporter: IExporter): void;
51
+ /**
52
+ * Get an exporter by format.
53
+ *
54
+ * @param format The export format name
55
+ * @returns The exporter or undefined if not found
56
+ */
57
+ get(format: string): IExporter | undefined;
58
+ /**
59
+ * Get all registered export formats.
60
+ *
61
+ * @returns A map of format names to their MIME types
62
+ */
63
+ getExportFormats(): Record<string, {
64
+ output_mimetype: string;
65
+ }>;
66
+ private _exporters;
67
+ }
@@ -0,0 +1,77 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { NbConvertManager } from '@jupyterlab/services';
4
+ /**
5
+ * Custom NbConvert manager for JupyterLite with client-side export.
6
+ */
7
+ export class LiteNbConvertManager extends NbConvertManager {
8
+ /**
9
+ * Construct a new LiteNbConvertManager.
10
+ *
11
+ * @param options The manager options
12
+ */
13
+ constructor(options) {
14
+ super(options);
15
+ this._contentsManager = options.contentsManager;
16
+ this._exporters = options.exporters;
17
+ }
18
+ /**
19
+ * Get the list of export formats available.
20
+ */
21
+ async getExportFormats() {
22
+ return this._exporters.getExportFormats();
23
+ }
24
+ /**
25
+ * Export a notebook to a given format.
26
+ *
27
+ * @param options The export options
28
+ */
29
+ async exportAs(options) {
30
+ const { format, path } = options;
31
+ const model = await this._contentsManager.get(path, { content: true });
32
+ const exporter = this._exporters.get(format);
33
+ if (!exporter) {
34
+ throw new Error(`Unknown export format: ${format}`);
35
+ }
36
+ await exporter.export(model, path);
37
+ }
38
+ }
39
+ /**
40
+ * Implementation of the exporter registry.
41
+ */
42
+ export class Exporters {
43
+ constructor() {
44
+ this._exporters = new Map();
45
+ }
46
+ /**
47
+ * Register a new exporter.
48
+ *
49
+ * @param format The export format name
50
+ * @param exporter The exporter instance
51
+ */
52
+ register(format, exporter) {
53
+ this._exporters.set(format, exporter);
54
+ }
55
+ /**
56
+ * Get an exporter by format.
57
+ *
58
+ * @param format The export format name
59
+ * @returns The exporter or undefined if not found
60
+ */
61
+ get(format) {
62
+ return this._exporters.get(format);
63
+ }
64
+ /**
65
+ * Get all registered export formats.
66
+ *
67
+ * @returns A map of format names to their MIME types
68
+ */
69
+ getExportFormats() {
70
+ const formats = {};
71
+ for (const [format, exporter] of this._exporters) {
72
+ formats[format] = { output_mimetype: exporter.mimeType };
73
+ }
74
+ return formats;
75
+ }
76
+ }
77
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/nbconvert/manager.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAmBxD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IACxD;;;;OAIG;IACH,YAAY,OAAqC;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAiC;QAC9C,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAEjC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;CAIF;AAED;;GAEG;AACH,MAAM,OAAO,SAAS;IAAtB;QAoCU,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;IACpD,CAAC;IApCC;;;;;OAKG;IACH,QAAQ,CAAC,MAAc,EAAE,QAAmB;QAC1C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,MAAM,OAAO,GAAgD,EAAE,CAAC;QAEhE,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACjD,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC3D,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAGF"}
@@ -0,0 +1,49 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ import type { Contents } from '@jupyterlab/services';
3
+ /**
4
+ * The token for the exporter registry.
5
+ */
6
+ export declare const INbConvertExporters: Token<INbConvertExporters>;
7
+ /**
8
+ * Interface for the exporter registry.
9
+ */
10
+ export interface INbConvertExporters {
11
+ /**
12
+ * Register a new exporter.
13
+ *
14
+ * @param format The export format name
15
+ * @param exporter The exporter instance
16
+ */
17
+ register(format: string, exporter: IExporter): void;
18
+ /**
19
+ * Get an exporter by format.
20
+ *
21
+ * @param format The export format name
22
+ * @returns The exporter or undefined if not found
23
+ */
24
+ get(format: string): IExporter | undefined;
25
+ /**
26
+ * Get all registered export formats.
27
+ *
28
+ * @returns A map of format names to their MIME types
29
+ */
30
+ getExportFormats(): Record<string, {
31
+ output_mimetype: string;
32
+ }>;
33
+ }
34
+ /**
35
+ * Interface for a notebook exporter.
36
+ */
37
+ export interface IExporter {
38
+ /**
39
+ * The MIME type of the exported format.
40
+ */
41
+ readonly mimeType: string;
42
+ /**
43
+ * Export a notebook to this format.
44
+ *
45
+ * @param model The notebook model to export
46
+ * @param path The path to the notebook
47
+ */
48
+ export(model: Contents.IModel, path: string): Promise<void>;
49
+ }
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { Token } from '@lumino/coreutils';
4
+ /**
5
+ * The token for the exporter registry.
6
+ */
7
+ export const INbConvertExporters = new Token('@jupyterlite/services:INbConvertExporters', 'A service for managing notebook exporters in JupyterLite');
8
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/nbconvert/tokens.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,KAAK,CAC1C,2CAA2C,EAC3C,0DAA0D,CAC3D,CAAC"}