Feature/jupyterlite bridge extension#146
Open
mohab-elshamy wants to merge 11 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
This PR addresses the following issues:
IndexedDB.readme.ipynbis saved.For example, if a file is added in a JupyterLite notebook in project A, it will also appear in the notebook of project B.
Open Notebookopened two notebook instances.Solution
1. Add a Frontend Extension for Standardized Communication Between Angular and JupyterLite
This PR adds a JupyterLite frontend extension to standardize the communication between the Angular app and the JupyterLite iframe.
Instead of accessing
IndexedDBdirectly from Angular, the communication now happens through a clearpostMessageprotocol.For example:
This message is sent to the Angular app after
app.restored.This replaces the previous approach that depended on checking console output:
The extension also provides messages such as:
Instead of dealing directly with
IndexedDB.Previous Direct IndexedDB Access
Previously, Angular used a service that directly accessed JupyterLite storage through
localforage.Previous IndexedDB service
2. Add File Tracking Support
The extension now allows the user to choose which files should be tracked.
This is needed because after closing the iframe, Angular should save only the tracked files to the backend.
Angular gets the tracked file paths, then loops over them and requests each file using:
After that, the files are saved into the backend.
File Tracking
The extension provides a small AnalySim panel inside JupyterLite.
The panel lists files inside the current project root and lets users choose which files are tracked.
Tracked file paths are stored in iframe
localStorageusing a project-specific key:Angular asks the extension for tracked paths using:
Only tracked files are eligible for backend commit.
Commit Workflow
There are now two commit paths:
CommitCommit on CloseBoth paths use the same commit implementation.
The commit flow is:
model.content.Untracked files are not committed.
Extension Packaging
This PR also uses a simple packaging approach for the extension.
Scripts were added to make the extension setup and build process automatic.
The build approach has been updated in the root
README.mdfile.