-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove height and width from cell * Positive conditions * Remove HTML views * Lay the ground work inside the Lua filter for the insertion point logic. * Add logic that handles removing empty space after code options * Hand off cell data into JS * Add default cell options * Inject the cell information at the end of the document * Simplify if condition inside of cell * More compartmentalization. Switch to using a dynamic import. * Remove unused version check * Aim to do only one configuration substitution instead of two. Re-arrange eval definition. * Suppress HTML from entrying the examples/ directory * Clean up generic HTML element creation tool * Test out adding interactive cells on the page. * Associate cellData instead of init code & qwebR counter information with MonacoEditor initialization * Re-add status helpers * Add interactive cell unlock * Handle cell evaluation for non-interactive information * Add some more proofing logic * Restore install/load inside of engine initialization * :'( * Update status when being worked on... * Add new test case * Add a tibble... * Mirror other options * Bump version * Rename for non-interactive tests * Add a test with just output * Add another test on the non-interactive side * Improve the rigor of the test... * Ensure each result is evaluated asynchronously in sequence by opting for a for() loop * Add another longer form test document showing chained setup and output contexts * Add non-interactive area visualization * Smaller tweaks to propagate status updates * Mirror the demo in the test file * Add some release notes
- Loading branch information
Showing
22 changed files
with
753 additions
and
2,249 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ webr-serviceworker.js | |
/.luarc.json | ||
docs/_site/* | ||
tests/_site/* | ||
examples/*/*.html |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Handle cell initialization initialization | ||
qwebrCellDetails.map( | ||
(entry) => { | ||
// Handle the creation of the element | ||
qwebrCreateHTMLElement(entry); | ||
// In the event of interactive, initialize the monaco editor | ||
if (entry.options.context == EvalTypes.Interactive) { | ||
qwebrCreateMonacoEditorInstance(entry); | ||
} | ||
} | ||
); | ||
|
||
// Identify non-interactive cells (in order) | ||
const filteredEntries = qwebrCellDetails.filter(entry => { | ||
const contextOption = entry.options && entry.options.context; | ||
return ['output', 'setup'].includes(contextOption); | ||
}); | ||
|
||
// Condition non-interactive cells to only be run after webR finishes its initialization. | ||
qwebrInstance.then( | ||
async () => { | ||
const nHiddenCells = filteredEntries.length; | ||
var currentHiddenCell = 0; | ||
|
||
|
||
// Modify button state | ||
qwebrSetInteractiveButtonState(`🟡 Running hidden code cells ...`, false); | ||
|
||
// Begin processing non-interactive sections | ||
// Due to the iteration policy, we must use a for() loop. | ||
// Otherwise, we would need to switch to using reduce with an empty | ||
// starting promise | ||
for (const entry of filteredEntries) { | ||
|
||
// Determine cell being examined | ||
currentHiddenCell = currentHiddenCell + 1; | ||
const formattedMessage = `Evaluating hidden cell ${currentHiddenCell} out of ${nHiddenCells}`; | ||
|
||
// Update the document status header | ||
if (qwebrShowStartupMessage) { | ||
qwebrUpdateStatusHeader(formattedMessage); | ||
} | ||
|
||
// Display the update in non-active areas | ||
qwebrUpdateStatusMessage(formattedMessage); | ||
|
||
// Extract details on the active cell | ||
const evalType = entry.options.context; | ||
const cellCode = entry.code; | ||
const qwebrCounter = entry.id; | ||
|
||
// Disable further global status updates | ||
const activeContainer = document.getElementById(`qwebr-non-interactive-loading-container-${qwebrCounter}`); | ||
activeContainer.classList.remove('qwebr-cell-needs-evaluation'); | ||
activeContainer.classList.add('qwebr-cell-evaluated'); | ||
|
||
// Update status on the code cell | ||
const activeStatus = document.getElementById(`qwebr-status-text-${qwebrCounter}`); | ||
activeStatus.innerText = " Evaluating hidden code cell..."; | ||
activeStatus.classList.remove('qwebr-cell-needs-evaluation'); | ||
activeStatus.classList.add('qwebr-cell-evaluated'); | ||
|
||
switch (evalType) { | ||
case 'output': | ||
// Run the code in a non-interactive state that is geared to displaying output | ||
await qwebrExecuteCode(`${cellCode}`, qwebrCounter, EvalTypes.Output); | ||
break; | ||
case 'setup': | ||
const activeDiv = document.getElementById(`qwebr-noninteractive-setup-area-${qwebrCounter}`); | ||
//activeDiv.textContent = "Computing hidden webR Startup ..."; | ||
// Run the code in a non-interactive state with all output thrown away | ||
await mainWebR.evalRVoid(`${cellCode}`); | ||
//activeDiv.textContent = ""; | ||
break; | ||
default: | ||
break; | ||
} | ||
// Disable visibility | ||
activeContainer.style.visibility = 'hidden'; | ||
activeContainer.style.display = 'none'; | ||
} | ||
} | ||
).then( | ||
() => { | ||
// Release document status as ready | ||
|
||
if (qwebrShowStartupMessage) { | ||
qwebrStartupMessage.innerText = "🟢 Ready!" | ||
} | ||
|
||
qwebrSetInteractiveButtonState( | ||
`<i class="fa-solid fa-play qwebr-icon-run-code"></i> <span>Run Code</span>`, | ||
true | ||
); | ||
} | ||
); |
This file contains 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
Oops, something went wrong.