-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '01-12-feat_task_and_use_task_for_better_asyncio_task_a_…
…thread_execution' into 02-05-feat_support_theming_solara
- Loading branch information
Showing
36 changed files
with
1,288 additions
and
395 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
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"CDN assets for Solara" | ||
__version__ = "1.25.1" | ||
__version__ = "1.26.1" |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"Enterprise features for Solara" | ||
__version__ = "1.25.1" | ||
__version__ = "1.26.1" |
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "solara" | ||
readme = "README.md" | ||
authors = [{name = "Maarten A. Breddels", email = "[email protected]"}] | ||
license = {file = "LICENSE"} | ||
classifiers = ["License :: OSI Approved :: MIT License"] | ||
|
@@ -49,6 +50,18 @@ path = "solara/__init__.py" | |
[tool.hatch.build] | ||
ignore-vcs = true | ||
|
||
[tool.hatch.build.targets.sdist] | ||
# unclear from hatch docs, but README.md and LICENSE are included by default | ||
# even when we explicitly have an include list | ||
include = [ | ||
"solara", | ||
"tests", | ||
"prefix", | ||
] | ||
# and even when we have an include list, we still need to exclude | ||
# packages (which I think makes no sense) | ||
exclude = ["packages"] | ||
|
||
[project.optional-dependencies] | ||
extra = [ | ||
"pygments", | ||
|
@@ -84,7 +97,7 @@ dev = [ | |
"pytest-playwright; python_version > '3.6'", | ||
] | ||
assets = [ | ||
"solara-assets==1.25.1" | ||
"solara-assets==1.26.1" | ||
] | ||
flask = [ | ||
"flask", | ||
|
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
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 |
---|---|---|
|
@@ -66,24 +66,42 @@ def _run_solara(code): | |
) | ||
|
||
|
||
def _markdown_template(html, style=""): | ||
return ( | ||
def _markdown_template( | ||
html, | ||
style="", | ||
): | ||
template = ( | ||
""" | ||
<template> | ||
<div class="solara-markdown rendered_html jp-RenderedHTMLCommon" style=\"""" | ||
+ style | ||
+ """\">""" | ||
+ html | ||
+ """</div> | ||
+ r"""</div> | ||
</template> | ||
<script> | ||
module.exports = { | ||
mounted() { | ||
if(window.mermaid) | ||
mermaid.init() | ||
if(window.MathJax && MathJax.Hub) { | ||
async mounted() { | ||
await this.loadRequire(); | ||
this.mermaid = await this.loadMermaid(); | ||
this.mermaid.init(); | ||
this.latexSettings = { | ||
delimiters: [ | ||
{left: "$$", right: "$$", display: true}, | ||
{left: "$", right: "$", display: false}, | ||
{left: "\\[", right: "\\]", display: true}, | ||
{left: "\\(", right: "\\)", display: false} | ||
] | ||
}; | ||
if (window.renderMathInElement) { | ||
window.renderMathInElement(this.$el, this.latexSettings); | ||
} else if (window.MathJax && MathJax.Hub) { | ||
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]); | ||
} else { | ||
console.log("MathJax not loaded, loading Katex instead") | ||
window.renderMathInElement = await this.loadKatexExt(); | ||
window.renderMathInElement(this.$el, this.latexSettings); | ||
} | ||
this.$el.querySelectorAll("a").forEach(a => this.setupRouter(a)) | ||
window.md = this.$el | ||
|
@@ -95,10 +113,8 @@ def _markdown_template(html, style=""): | |
// TODO: should we really do this? | ||
href = location.pathname + href.substr(1); | ||
a.attributes['href'].href = href; | ||
// console.log("change href to", href); | ||
} | ||
if(href.startsWith("./") || href.startsWith("/")) { | ||
// console.log("connect link with href=", href, "to router") | ||
a.onclick = e => { | ||
console.log("clicked", href) | ||
if(href.startsWith("./")) { | ||
|
@@ -109,26 +125,99 @@ def _markdown_template(html, style=""): | |
e.preventDefault() | ||
} | ||
} else if(href.startsWith("#")) { | ||
// console.log("connect anchor with href=", href, "to custom javascript due to using <base>") | ||
href = location.pathname + href; | ||
a.attributes['href'].value = href; | ||
} else { | ||
console.log("href", href, "is not a local link") | ||
} | ||
}, | ||
async loadKatex() { | ||
require.config({ | ||
map: { | ||
'*': { | ||
'katex': `${this.getCdn()}/[email protected]/dist/katex.min.js`, | ||
} | ||
} | ||
}); | ||
const link = document.createElement('link'); | ||
link.type = "text/css"; | ||
link.rel = "stylesheet"; | ||
link.href = `${this.getCdn()}/[email protected]/dist/katex.min.css`; | ||
document.head.appendChild(link); | ||
}, | ||
async loadKatexExt() { | ||
this.loadKatex(); | ||
return (await this.import([`${this.getCdn()}/[email protected]/dist/contrib/auto-render.min.js`]))[0] | ||
}, | ||
async loadMermaid() { | ||
return (await this.import([`${this.getCdn()}/[email protected]/dist/mermaid.min.js`]))[0] | ||
}, | ||
import(dependencies) { | ||
return this.loadRequire().then( | ||
() => { | ||
if (window.jupyterVue) { | ||
// in jupyterlab, we take Vue from ipyvue/jupyterVue | ||
define("vue", [], () => window.jupyterVue.Vue); | ||
} else { | ||
define("vue", ['jupyter-vue'], jupyterVue => jupyterVue.Vue); | ||
} | ||
return new Promise((resolve, reject) => { | ||
requirejs(dependencies, (...modules) => resolve(modules)); | ||
}) | ||
} | ||
); | ||
}, | ||
loadRequire() { | ||
if (window.requirejs) { | ||
console.log('require found'); | ||
return Promise.resolve(); | ||
} | ||
return new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
script.src = `${this.getCdn()}/[email protected]/require.min.js`; | ||
script.onload = resolve; | ||
script.onerror = reject; | ||
document.head.appendChild(script); | ||
}); | ||
}, | ||
getBaseUrl() { | ||
if (window.solara && window.solara.rootPath !== undefined) { | ||
return solara.rootPath + "/"; | ||
} | ||
// if base url is set, we use ./ for relative paths compared to the base url | ||
if (document.getElementsByTagName("base").length) { | ||
return "./"; | ||
} | ||
const labConfigData = document.getElementById('jupyter-config-data'); | ||
if (labConfigData) { | ||
/* lab and Voila */ | ||
return JSON.parse(labConfigData.textContent).baseUrl; | ||
} | ||
let base = document.body.dataset.baseUrl || document.baseURI; | ||
if (!base.endsWith('/')) { | ||
base += '/'; | ||
} | ||
return base | ||
}, | ||
getCdn() { | ||
return this.cdn || (typeof solara_cdn !== "undefined" && solara_cdn) || `${this.getBaseUrl()}_solara/cdn`; | ||
} | ||
}, | ||
updated() { | ||
// if the html gets update, re-run mermaid | ||
if(window.mermaid) | ||
mermaid.init() | ||
this.mermaid.init(); | ||
if(window.MathJax && MathJax.Hub) { | ||
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]); | ||
} else { | ||
window.renderMathInElement(this.$el, this.latexSettings); | ||
} | ||
} | ||
} | ||
</script> | ||
""" | ||
) | ||
return template | ||
|
||
|
||
def _highlight(src, language, unsafe_solara_execute, extra, *args, **kwargs): | ||
|
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.