Skip to content

Commit

Permalink
Smaller fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jul 24, 2023
1 parent 0141f5e commit 5c5bf1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 7 additions & 4 deletions panel/io/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
BOKEH_VERSION = base_version(bokeh.__version__)
PY_VERSION = base_version(__version__)
PYODIDE_VERSION = 'v0.23.4'
PYSCRIPT_VERSION = '2023.05.1'
PYSCRIPT_VERSION = '2023.03.1'
PANEL_LOCAL_WHL = DIST_DIR / 'wheels' / f'panel-{__version__.replace("-dirty", "")}-py3-none-any.whl'
BOKEH_LOCAL_WHL = DIST_DIR / 'wheels' / f'bokeh-{BOKEH_VERSION}-py3-none-any.whl'
PANEL_CDN_WHL = f'{CDN_DIST}wheels/panel-{PY_VERSION}-py3-none-any.whl'
Expand Down Expand Up @@ -181,7 +181,8 @@ def script_to_html(
panel_version: Literal['auto', 'local'] | str = 'auto',
manifest: str | None = None,
http_patch: bool = True,
inline: bool = False
inline: bool = False,
compiled: bool = True
) -> str:
"""
Converts a Panel or Bokeh script to a standalone WASM Python
Expand All @@ -208,6 +209,8 @@ def script_to_html(
to allow urllib3 and requests to work.
inline: bool
Whether to inline resources.
compiled: bool
Whether to use pre-compiled pyodide bundles.
"""
# Run script
if hasattr(filename, 'read'):
Expand Down Expand Up @@ -294,14 +297,14 @@ def script_to_html(
'loading_spinner': config.loading_spinner
})
web_worker = WEB_WORKER_TEMPLATE.render({
'PYODIDE_URL': PYODIDE_PYC_URL,
'PYODIDE_URL': PYODIDE_PYC_URL if compiled else PYODIDE_URL,
'env_spec': env_spec,
'code': code
})
plot_script = wrap_in_script_tag(worker_handler)
else:
if js_resources == 'auto':
js_resources = [PYODIDE_PYC_JS]
js_resources = [PYODIDE_PYC_JS if compiled else PYODIDE_JS]
script_template = _pn_env.from_string(PYODIDE_SCRIPT)
plot_script = script_template.render({
'env_spec': env_spec,
Expand Down
10 changes: 7 additions & 3 deletions panel/io/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ def pysync(event):
jsdoc.apply_json_patch(json_patch, buffer_map)

pydoc.on_change(pysync)
pydoc.unhold()
pydoc.callbacks.trigger_event(DocumentReady())

try:
pydoc.unhold()
pydoc.callbacks.trigger_event(DocumentReady())
except Exception as e:
print(f'Error raised while processing Document events: {e}')

def _link_docs_worker(doc: Document, dispatch_fn: Any, msg_id: str | None = None, setter: str | None = None):
"""
Expand Down Expand Up @@ -458,7 +462,7 @@ def hide_loader() -> None:
from js import document

body = document.getElementsByTagName('body')[0]
body.classList.remove(LOADING_INDICATOR_CSS_CLASS, config.loading_spinner)
body.classList.remove(LOADING_INDICATOR_CSS_CLASS, f'pn-{config.loading_spinner}')

def sync_location():
"""
Expand Down

0 comments on commit 5c5bf1a

Please sign in to comment.