|
| 1 | +// src/core/api/jupyter.ts |
| 2 | + |
| 3 | +import { globalRegistry } from "./registry.ts"; |
| 4 | +import type { JupyterNamespace } from "./types.ts"; |
| 5 | + |
| 6 | +// Import implementations |
| 7 | +import { |
| 8 | + executeResultEngineDependencies, |
| 9 | + executeResultIncludes, |
| 10 | + isJupyterNotebook, |
| 11 | + jupyterAssets, |
| 12 | + jupyterFromJSON, |
| 13 | + jupyterKernelspecFromMarkdown, |
| 14 | + jupyterToMarkdown, |
| 15 | + kJupyterNotebookExtensions, |
| 16 | + quartoMdToJupyter, |
| 17 | +} from "../jupyter/jupyter.ts"; |
| 18 | +import { |
| 19 | + jupyterNotebookFiltered, |
| 20 | + markdownFromNotebookFile, |
| 21 | + markdownFromNotebookJSON, |
| 22 | +} from "../jupyter/jupyter-filters.ts"; |
| 23 | +import { includesForJupyterWidgetDependencies } from "../jupyter/widgets.ts"; |
| 24 | +import { pythonExec } from "../jupyter/exec.ts"; |
| 25 | +import { jupyterCapabilities } from "../jupyter/capabilities.ts"; |
| 26 | +import { jupyterKernelspecForLanguage } from "../jupyter/kernels.ts"; |
| 27 | +import { |
| 28 | + jupyterCapabilitiesJson, |
| 29 | + jupyterCapabilitiesMessage, |
| 30 | + jupyterInstallationMessage, |
| 31 | + jupyterUnactivatedEnvMessage, |
| 32 | + pythonInstallationMessage, |
| 33 | +} from "../jupyter/jupyter-shared.ts"; |
| 34 | +import { |
| 35 | + isJupyterPercentScript, |
| 36 | + markdownFromJupyterPercentScript, |
| 37 | +} from "../jupyter/percent.ts"; |
| 38 | +import type { JupyterWidgetDependencies } from "../jupyter/types.ts"; |
| 39 | + |
| 40 | +// Register jupyter namespace |
| 41 | +globalRegistry.register("jupyter", (): JupyterNamespace => { |
| 42 | + return { |
| 43 | + // 1. Notebook Detection & Introspection |
| 44 | + isJupyterNotebook, |
| 45 | + isPercentScript: isJupyterPercentScript, |
| 46 | + notebookExtensions: kJupyterNotebookExtensions, |
| 47 | + kernelspecFromMarkdown: jupyterKernelspecFromMarkdown, |
| 48 | + kernelspecForLanguage: jupyterKernelspecForLanguage, |
| 49 | + fromJSON: jupyterFromJSON, |
| 50 | + |
| 51 | + // 2. Notebook Conversion |
| 52 | + toMarkdown: jupyterToMarkdown, |
| 53 | + markdownFromNotebookFile, |
| 54 | + markdownFromNotebookJSON, |
| 55 | + percentScriptToMarkdown: markdownFromJupyterPercentScript, |
| 56 | + quartoMdToJupyter, |
| 57 | + |
| 58 | + // 3. Notebook Processing & Assets |
| 59 | + notebookFiltered: jupyterNotebookFiltered, |
| 60 | + assets: jupyterAssets, |
| 61 | + widgetDependencyIncludes: includesForJupyterWidgetDependencies, |
| 62 | + resultIncludes: ( |
| 63 | + tempDir: string, |
| 64 | + dependencies?: JupyterWidgetDependencies, |
| 65 | + ) => { |
| 66 | + return executeResultIncludes(tempDir, dependencies) || {}; |
| 67 | + }, |
| 68 | + resultEngineDependencies: (dependencies?: JupyterWidgetDependencies) => { |
| 69 | + const result = executeResultEngineDependencies(dependencies); |
| 70 | + return result as Array<JupyterWidgetDependencies> | undefined; |
| 71 | + }, |
| 72 | + |
| 73 | + // 4. Runtime & Environment |
| 74 | + pythonExec, |
| 75 | + capabilities: jupyterCapabilities, |
| 76 | + capabilitiesMessage: jupyterCapabilitiesMessage, |
| 77 | + capabilitiesJson: jupyterCapabilitiesJson, |
| 78 | + installationMessage: jupyterInstallationMessage, |
| 79 | + unactivatedEnvMessage: jupyterUnactivatedEnvMessage, |
| 80 | + pythonInstallationMessage, |
| 81 | + }; |
| 82 | +}); |
0 commit comments