From cd4b2a84f8d873d384e4af39c94b0c9288d02d44 Mon Sep 17 00:00:00 2001 From: sheepmax <guichardmax@gmail.com> Date: Thu, 20 Jul 2023 12:49:35 +0200 Subject: [PATCH] Restructured thebe_lite folder, improved copying criteria, fixed bugs when adding cells --- book/thebe_lite/{libs => }/106.index.js | 0 book/thebe_lite/{libs => }/106.index.js.map | 0 .../{libs => }/328.thebe-lite.min.js | 0 .../{libs => }/328.thebe-lite.min.js.map | 0 book/thebe_lite/{libs => }/330.index.js | 0 book/thebe_lite/{libs => }/330.index.js.map | 0 .../{libs => }/562.thebe-lite.min.js | 0 .../{libs => }/562.thebe-lite.min.js.map | 0 .../{libs => }/609.thebe-lite.min.js | 0 .../{libs => }/609.thebe-lite.min.js.map | 0 .../{libs => }/686.thebe-lite.min.js | 0 .../{libs => }/686.thebe-lite.min.js.map | 0 book/thebe_lite/{ => _static}/code.css | 0 book/thebe_lite/{ => _static}/sphinx-thebe.js | 26 ++++++++++++++---- .../{libs => }/api/contents/all.json | 0 book/thebe_lite/{libs => }/index.js | 0 book/thebe_lite/{libs => }/index.js.map | 0 book/thebe_lite/{libs => }/pypi/all.json | 0 .../pypi/ipykernel-6.9.2-py3-none-any.whl | Bin .../pypi/piplite-0.0.8-py3-none-any.whl | Bin .../pyodide_kernel-0.0.8-py3-none-any.whl | Bin .../widgetsnbextension-3.6.4-py3-none-any.whl | Bin .../widgetsnbextension-4.0.7-py3-none-any.whl | Bin .../{libs => }/service-worker-dddfe83.js | 0 book/thebe_lite/{libs => }/thebe-lite.min.js | 0 .../{libs => }/thebe-lite.min.js.map | 0 book/thebe_lite/{libs => }/thebe.css | 0 .../thebe_lite/{libs => }/types/activate.d.ts | 0 .../{libs => }/types/codemirror.d.ts | 0 book/thebe_lite/{libs => }/types/index.d.ts | 0 book/thebe_lite/{libs => }/types/options.d.ts | 0 book/thebe_lite/{libs => }/types/render.d.ts | 0 book/thebe_lite/{libs => }/types/status.d.ts | 0 book/thebe_lite/{libs => }/types/thebe.d.ts | 0 book/thebe_lite/{libs => }/types/types.d.ts | 0 book/thebe_lite/{libs => }/types/utils.d.ts | 0 build-lite.sh | 7 ++--- 37 files changed, 23 insertions(+), 10 deletions(-) rename book/thebe_lite/{libs => }/106.index.js (100%) rename book/thebe_lite/{libs => }/106.index.js.map (100%) rename book/thebe_lite/{libs => }/328.thebe-lite.min.js (100%) rename book/thebe_lite/{libs => }/328.thebe-lite.min.js.map (100%) rename book/thebe_lite/{libs => }/330.index.js (100%) rename book/thebe_lite/{libs => }/330.index.js.map (100%) rename book/thebe_lite/{libs => }/562.thebe-lite.min.js (100%) rename book/thebe_lite/{libs => }/562.thebe-lite.min.js.map (100%) rename book/thebe_lite/{libs => }/609.thebe-lite.min.js (100%) rename book/thebe_lite/{libs => }/609.thebe-lite.min.js.map (100%) rename book/thebe_lite/{libs => }/686.thebe-lite.min.js (100%) rename book/thebe_lite/{libs => }/686.thebe-lite.min.js.map (100%) rename book/thebe_lite/{ => _static}/code.css (100%) rename book/thebe_lite/{ => _static}/sphinx-thebe.js (93%) rename book/thebe_lite/{libs => }/api/contents/all.json (100%) rename book/thebe_lite/{libs => }/index.js (100%) rename book/thebe_lite/{libs => }/index.js.map (100%) rename book/thebe_lite/{libs => }/pypi/all.json (100%) rename book/thebe_lite/{libs => }/pypi/ipykernel-6.9.2-py3-none-any.whl (100%) rename book/thebe_lite/{libs => }/pypi/piplite-0.0.8-py3-none-any.whl (100%) rename book/thebe_lite/{libs => }/pypi/pyodide_kernel-0.0.8-py3-none-any.whl (100%) rename book/thebe_lite/{libs => }/pypi/widgetsnbextension-3.6.4-py3-none-any.whl (100%) rename book/thebe_lite/{libs => }/pypi/widgetsnbextension-4.0.7-py3-none-any.whl (100%) rename book/thebe_lite/{libs => }/service-worker-dddfe83.js (100%) rename book/thebe_lite/{libs => }/thebe-lite.min.js (100%) rename book/thebe_lite/{libs => }/thebe-lite.min.js.map (100%) rename book/thebe_lite/{libs => }/thebe.css (100%) rename book/thebe_lite/{libs => }/types/activate.d.ts (100%) rename book/thebe_lite/{libs => }/types/codemirror.d.ts (100%) rename book/thebe_lite/{libs => }/types/index.d.ts (100%) rename book/thebe_lite/{libs => }/types/options.d.ts (100%) rename book/thebe_lite/{libs => }/types/render.d.ts (100%) rename book/thebe_lite/{libs => }/types/status.d.ts (100%) rename book/thebe_lite/{libs => }/types/thebe.d.ts (100%) rename book/thebe_lite/{libs => }/types/types.d.ts (100%) rename book/thebe_lite/{libs => }/types/utils.d.ts (100%) diff --git a/book/thebe_lite/libs/106.index.js b/book/thebe_lite/106.index.js similarity index 100% rename from book/thebe_lite/libs/106.index.js rename to book/thebe_lite/106.index.js diff --git a/book/thebe_lite/libs/106.index.js.map b/book/thebe_lite/106.index.js.map similarity index 100% rename from book/thebe_lite/libs/106.index.js.map rename to book/thebe_lite/106.index.js.map diff --git a/book/thebe_lite/libs/328.thebe-lite.min.js b/book/thebe_lite/328.thebe-lite.min.js similarity index 100% rename from book/thebe_lite/libs/328.thebe-lite.min.js rename to book/thebe_lite/328.thebe-lite.min.js diff --git a/book/thebe_lite/libs/328.thebe-lite.min.js.map b/book/thebe_lite/328.thebe-lite.min.js.map similarity index 100% rename from book/thebe_lite/libs/328.thebe-lite.min.js.map rename to book/thebe_lite/328.thebe-lite.min.js.map diff --git a/book/thebe_lite/libs/330.index.js b/book/thebe_lite/330.index.js similarity index 100% rename from book/thebe_lite/libs/330.index.js rename to book/thebe_lite/330.index.js diff --git a/book/thebe_lite/libs/330.index.js.map b/book/thebe_lite/330.index.js.map similarity index 100% rename from book/thebe_lite/libs/330.index.js.map rename to book/thebe_lite/330.index.js.map diff --git a/book/thebe_lite/libs/562.thebe-lite.min.js b/book/thebe_lite/562.thebe-lite.min.js similarity index 100% rename from book/thebe_lite/libs/562.thebe-lite.min.js rename to book/thebe_lite/562.thebe-lite.min.js diff --git a/book/thebe_lite/libs/562.thebe-lite.min.js.map b/book/thebe_lite/562.thebe-lite.min.js.map similarity index 100% rename from book/thebe_lite/libs/562.thebe-lite.min.js.map rename to book/thebe_lite/562.thebe-lite.min.js.map diff --git a/book/thebe_lite/libs/609.thebe-lite.min.js b/book/thebe_lite/609.thebe-lite.min.js similarity index 100% rename from book/thebe_lite/libs/609.thebe-lite.min.js rename to book/thebe_lite/609.thebe-lite.min.js diff --git a/book/thebe_lite/libs/609.thebe-lite.min.js.map b/book/thebe_lite/609.thebe-lite.min.js.map similarity index 100% rename from book/thebe_lite/libs/609.thebe-lite.min.js.map rename to book/thebe_lite/609.thebe-lite.min.js.map diff --git a/book/thebe_lite/libs/686.thebe-lite.min.js b/book/thebe_lite/686.thebe-lite.min.js similarity index 100% rename from book/thebe_lite/libs/686.thebe-lite.min.js rename to book/thebe_lite/686.thebe-lite.min.js diff --git a/book/thebe_lite/libs/686.thebe-lite.min.js.map b/book/thebe_lite/686.thebe-lite.min.js.map similarity index 100% rename from book/thebe_lite/libs/686.thebe-lite.min.js.map rename to book/thebe_lite/686.thebe-lite.min.js.map diff --git a/book/thebe_lite/code.css b/book/thebe_lite/_static/code.css similarity index 100% rename from book/thebe_lite/code.css rename to book/thebe_lite/_static/code.css diff --git a/book/thebe_lite/sphinx-thebe.js b/book/thebe_lite/_static/sphinx-thebe.js similarity index 93% rename from book/thebe_lite/sphinx-thebe.js rename to book/thebe_lite/_static/sphinx-thebe.js index 45a81e68..cd4e18b0 100644 --- a/book/thebe_lite/sphinx-thebe.js +++ b/book/thebe_lite/_static/sphinx-thebe.js @@ -62,15 +62,23 @@ function finalizeCodeCells(cells) { }; const exampleCell = thebe.notebook.lastCell(); - const newNotebookCell = Object.assign({}, exampleCell); - newNotebookCell.__proto__ = exampleCell.__proto__; - newNotebookCell.id = newCellInfo.id; - newNotebookCell.events._id = newCellInfo.id; - newNotebookCell.events._object = newNotebookCell; - newNotebookCell.source = ""; + const newNotebookCell = new exampleCell.constructor( + newCellInfo.id, + thebe.notebook.id, + "", + exampleCell.events._config, + exampleCell.metadata, + exampleCell.rendermine + ); + + // Manually attach kernel session + // The attachSession function only sends out a couple of events we don't care about + newNotebookCell.session = exampleCell.session; thebe.notebook.cells.push(newNotebookCell); + console.log(newNotebookCell.area); + thebe.renderAllCells( { mountRunButton: true, @@ -90,6 +98,12 @@ function finalizeCodeCells(cells) { addToThebeControls(newCell, deleteCell); deleteCell.onclick = () => { newCell.remove(); + let cells = thebe.notebook.cells; + // Remove cell from notebook too, otherwise their side-effects will still be present when running all + cells.splice( + cells.findIndex((cell) => cell.id === newCellInfo.id), + 1 + ); }; }; }); diff --git a/book/thebe_lite/libs/api/contents/all.json b/book/thebe_lite/api/contents/all.json similarity index 100% rename from book/thebe_lite/libs/api/contents/all.json rename to book/thebe_lite/api/contents/all.json diff --git a/book/thebe_lite/libs/index.js b/book/thebe_lite/index.js similarity index 100% rename from book/thebe_lite/libs/index.js rename to book/thebe_lite/index.js diff --git a/book/thebe_lite/libs/index.js.map b/book/thebe_lite/index.js.map similarity index 100% rename from book/thebe_lite/libs/index.js.map rename to book/thebe_lite/index.js.map diff --git a/book/thebe_lite/libs/pypi/all.json b/book/thebe_lite/pypi/all.json similarity index 100% rename from book/thebe_lite/libs/pypi/all.json rename to book/thebe_lite/pypi/all.json diff --git a/book/thebe_lite/libs/pypi/ipykernel-6.9.2-py3-none-any.whl b/book/thebe_lite/pypi/ipykernel-6.9.2-py3-none-any.whl similarity index 100% rename from book/thebe_lite/libs/pypi/ipykernel-6.9.2-py3-none-any.whl rename to book/thebe_lite/pypi/ipykernel-6.9.2-py3-none-any.whl diff --git a/book/thebe_lite/libs/pypi/piplite-0.0.8-py3-none-any.whl b/book/thebe_lite/pypi/piplite-0.0.8-py3-none-any.whl similarity index 100% rename from book/thebe_lite/libs/pypi/piplite-0.0.8-py3-none-any.whl rename to book/thebe_lite/pypi/piplite-0.0.8-py3-none-any.whl diff --git a/book/thebe_lite/libs/pypi/pyodide_kernel-0.0.8-py3-none-any.whl b/book/thebe_lite/pypi/pyodide_kernel-0.0.8-py3-none-any.whl similarity index 100% rename from book/thebe_lite/libs/pypi/pyodide_kernel-0.0.8-py3-none-any.whl rename to book/thebe_lite/pypi/pyodide_kernel-0.0.8-py3-none-any.whl diff --git a/book/thebe_lite/libs/pypi/widgetsnbextension-3.6.4-py3-none-any.whl b/book/thebe_lite/pypi/widgetsnbextension-3.6.4-py3-none-any.whl similarity index 100% rename from book/thebe_lite/libs/pypi/widgetsnbextension-3.6.4-py3-none-any.whl rename to book/thebe_lite/pypi/widgetsnbextension-3.6.4-py3-none-any.whl diff --git a/book/thebe_lite/libs/pypi/widgetsnbextension-4.0.7-py3-none-any.whl b/book/thebe_lite/pypi/widgetsnbextension-4.0.7-py3-none-any.whl similarity index 100% rename from book/thebe_lite/libs/pypi/widgetsnbextension-4.0.7-py3-none-any.whl rename to book/thebe_lite/pypi/widgetsnbextension-4.0.7-py3-none-any.whl diff --git a/book/thebe_lite/libs/service-worker-dddfe83.js b/book/thebe_lite/service-worker-dddfe83.js similarity index 100% rename from book/thebe_lite/libs/service-worker-dddfe83.js rename to book/thebe_lite/service-worker-dddfe83.js diff --git a/book/thebe_lite/libs/thebe-lite.min.js b/book/thebe_lite/thebe-lite.min.js similarity index 100% rename from book/thebe_lite/libs/thebe-lite.min.js rename to book/thebe_lite/thebe-lite.min.js diff --git a/book/thebe_lite/libs/thebe-lite.min.js.map b/book/thebe_lite/thebe-lite.min.js.map similarity index 100% rename from book/thebe_lite/libs/thebe-lite.min.js.map rename to book/thebe_lite/thebe-lite.min.js.map diff --git a/book/thebe_lite/libs/thebe.css b/book/thebe_lite/thebe.css similarity index 100% rename from book/thebe_lite/libs/thebe.css rename to book/thebe_lite/thebe.css diff --git a/book/thebe_lite/libs/types/activate.d.ts b/book/thebe_lite/types/activate.d.ts similarity index 100% rename from book/thebe_lite/libs/types/activate.d.ts rename to book/thebe_lite/types/activate.d.ts diff --git a/book/thebe_lite/libs/types/codemirror.d.ts b/book/thebe_lite/types/codemirror.d.ts similarity index 100% rename from book/thebe_lite/libs/types/codemirror.d.ts rename to book/thebe_lite/types/codemirror.d.ts diff --git a/book/thebe_lite/libs/types/index.d.ts b/book/thebe_lite/types/index.d.ts similarity index 100% rename from book/thebe_lite/libs/types/index.d.ts rename to book/thebe_lite/types/index.d.ts diff --git a/book/thebe_lite/libs/types/options.d.ts b/book/thebe_lite/types/options.d.ts similarity index 100% rename from book/thebe_lite/libs/types/options.d.ts rename to book/thebe_lite/types/options.d.ts diff --git a/book/thebe_lite/libs/types/render.d.ts b/book/thebe_lite/types/render.d.ts similarity index 100% rename from book/thebe_lite/libs/types/render.d.ts rename to book/thebe_lite/types/render.d.ts diff --git a/book/thebe_lite/libs/types/status.d.ts b/book/thebe_lite/types/status.d.ts similarity index 100% rename from book/thebe_lite/libs/types/status.d.ts rename to book/thebe_lite/types/status.d.ts diff --git a/book/thebe_lite/libs/types/thebe.d.ts b/book/thebe_lite/types/thebe.d.ts similarity index 100% rename from book/thebe_lite/libs/types/thebe.d.ts rename to book/thebe_lite/types/thebe.d.ts diff --git a/book/thebe_lite/libs/types/types.d.ts b/book/thebe_lite/types/types.d.ts similarity index 100% rename from book/thebe_lite/libs/types/types.d.ts rename to book/thebe_lite/types/types.d.ts diff --git a/book/thebe_lite/libs/types/utils.d.ts b/book/thebe_lite/types/utils.d.ts similarity index 100% rename from book/thebe_lite/libs/types/utils.d.ts rename to book/thebe_lite/types/utils.d.ts diff --git a/build-lite.sh b/build-lite.sh index eeeb7be6..9a0a9d1f 100755 --- a/build-lite.sh +++ b/build-lite.sh @@ -1,8 +1,7 @@ #!/bin/sh jupyter-book build book -cp book/thebe_lite/libs/* book/_build/html -r -cp book/thebe_lite/* book/_build/html/_static +cp book/thebe_lite/* book/_build/html/ -r if command -v python > /dev/null 2>&1 then @@ -18,7 +17,7 @@ else fi # Copy all non notebook, markdown or build files into the build for local access in pyodide etc. -find book/ | grep -v "^book/_.*\|.*\.\(md\|ipynb\)\|thebe_lite" | grep "\." | cut -c 6- | xargs -i sh -c 'echo "book/_build/html/{}" | grep -o "^.*/" | xargs -d "\n" mkdir -p; cp book/"{}" book/_build/html/"{}"' +find book/ -exec test -f {} \; -print | grep -v "^book/_.*\|.*\.\(md\|ipynb\)\|thebe_lite" | cut -c 6- | xargs -i sh -c 'echo "book/_build/html/{}" | grep -o "^.*/" | xargs -d "\n" mkdir -p; cp book/"{}" book/_build/html/"{}"' -$python_command -m http.server 8000 --directory book/_build/html & +$python_command -m http.server 8000 --directory book/_build/html -- GitLab