sliveshow 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sliveshow-0.1.3/.copier-answers.yml +14 -0
- sliveshow-0.1.3/.devcontainer/Dockerfile +17 -0
- sliveshow-0.1.3/.devcontainer/devcontainer.json +33 -0
- sliveshow-0.1.3/.gitignore +129 -0
- sliveshow-0.1.3/.prettierignore +6 -0
- sliveshow-0.1.3/.yarnrc.yml +1 -0
- sliveshow-0.1.3/CHANGELOG.md +31 -0
- sliveshow-0.1.3/Demo/.gitignore +2 -0
- sliveshow-0.1.3/Demo/SVG.png +0 -0
- sliveshow-0.1.3/Demo/SVG_anim.png +0 -0
- sliveshow-0.1.3/Demo/animation_demo.ipynb +42 -0
- sliveshow-0.1.3/Demo/code_cell.png +0 -0
- sliveshow-0.1.3/Demo/common_tools.png +0 -0
- sliveshow-0.1.3/Demo/mathjax.png +0 -0
- sliveshow-0.1.3/Demo/myst.yml +9 -0
- sliveshow-0.1.3/Demo/start_slideshow.png +0 -0
- sliveshow-0.1.3/Demo/svg-animate.mjs +180 -0
- sliveshow-0.1.3/Demo/transition.png +0 -0
- sliveshow-0.1.3/LICENSE +29 -0
- sliveshow-0.1.3/PKG-INFO +198 -0
- sliveshow-0.1.3/README.md +142 -0
- sliveshow-0.1.3/RELEASE.md +80 -0
- sliveshow-0.1.3/babel.config.js +1 -0
- sliveshow-0.1.3/custom_slideshow/_version.py +4 -0
- sliveshow-0.1.3/custom_slideshow/labextension/build_log.json +732 -0
- sliveshow-0.1.3/custom_slideshow/labextension/package.json +206 -0
- sliveshow-0.1.3/custom_slideshow/labextension/schemas/custom-slideshow/package.json.orig +201 -0
- sliveshow-0.1.3/custom_slideshow/labextension/schemas/custom-slideshow/plugin.json +125 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_index_js-data_image_gif_base64_R0lGODlhIAAgAPMAAJmZmf_2F_2F_2F6_2Bvr8nJybW1tcDAwOjo6Nvb26-baaebe.d0ae3f6ff7c5fb4e87d0.js +698 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_index_js-data_image_gif_base64_R0lGODlhIAAgAPMAAJmZmf_2F_2F_2F6_2Bvr8nJybW1tcDAwOjo6Nvb26-baaebe.d0ae3f6ff7c5fb4e87d0.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_rajgoel_animate_js.79a3cbe0137d3193df47.js +488 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_rajgoel_animate_js.79a3cbe0137d3193df47.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_rajgoel_loadcontent_js.e923c36a752e11a5cf8a.js +99 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/lib_rajgoel_loadcontent_js.e923c36a752e11a5cf8a.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/remoteEntry.4db33c6c7b1f485debf2.js +558 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/remoteEntry.4db33c6c7b1f485debf2.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/style.js +4 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/style_index_js.9929588164089cdad618.js +622 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/style_index_js.9929588164089cdad618.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_mathjax_src_mjs_adaptors_browserAdaptor_js-node_modules_mathjax_src_mjs_-af6e73.eb98a7e22513d321047d.js +30814 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_mathjax_src_mjs_adaptors_browserAdaptor_js-node_modules_mathjax_src_mjs_-af6e73.eb98a7e22513d321047d.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_reveal_js_dist_reveal_esm_js.3dfa07cfe8a43b5c5ab8.js +27 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_reveal_js_dist_reveal_esm_js.3dfa07cfe8a43b5c5ab8.js.map +1 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_svgdotjs_svg_js_src_main_js.03581806155b1fd0d3f5.js +9623 -0
- sliveshow-0.1.3/custom_slideshow/labextension/static/vendors-node_modules_svgdotjs_svg_js_src_main_js.03581806155b1fd0d3f5.js.map +1 -0
- sliveshow-0.1.3/environment.yml +12 -0
- sliveshow-0.1.3/install.json +5 -0
- sliveshow-0.1.3/jest.config.js +28 -0
- sliveshow-0.1.3/package.json +201 -0
- sliveshow-0.1.3/pyproject.toml +77 -0
- sliveshow-0.1.3/schema/plugin.json +125 -0
- sliveshow-0.1.3/setup.py +1 -0
- sliveshow-0.1.3/sliveshow/__init__.py +16 -0
- sliveshow-0.1.3/sliveshow/_version.py +4 -0
- sliveshow-0.1.3/sliveshow/labextension/package.json +206 -0
- sliveshow-0.1.3/sliveshow/labextension/schemas/sliveshow/package.json.orig +201 -0
- sliveshow-0.1.3/sliveshow/labextension/schemas/sliveshow/plugin.json +125 -0
- sliveshow-0.1.3/sliveshow/labextension/static/399.856324315434eec63212.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/408.877863204af624202a68.js +2 -0
- sliveshow-0.1.3/sliveshow/labextension/static/408.877863204af624202a68.js.LICENSE.txt +7 -0
- sliveshow-0.1.3/sliveshow/labextension/static/626.7ccd3fd7917ab8abb96f.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/645.22f99615d2108f1f4f1f.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/851.e8b44e0bce1cf5355894.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/863.8ff9879cc50492569466.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/91.be61a6d202cea9a3a468.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/remoteEntry.10d4f52574b83a5efa30.js +1 -0
- sliveshow-0.1.3/sliveshow/labextension/static/style.js +4 -0
- sliveshow-0.1.3/sliveshow/labextension/static/third-party-licenses.json +46 -0
- sliveshow-0.1.3/src/__tests__/custom_slideshow.spec.ts +9 -0
- sliveshow-0.1.3/src/constants.ts +20 -0
- sliveshow-0.1.3/src/declare.d.ts +2 -0
- sliveshow-0.1.3/src/index.ts +42 -0
- sliveshow-0.1.3/src/mathjax4/LICENSE +31 -0
- sliveshow-0.1.3/src/mathjax4/plugin.ts +61 -0
- sliveshow-0.1.3/src/plugin.ts +605 -0
- sliveshow-0.1.3/src/rajgoel/LICENSE +24 -0
- sliveshow-0.1.3/src/rajgoel/animate.js +546 -0
- sliveshow-0.1.3/src/rajgoel/loadcontent.js +97 -0
- sliveshow-0.1.3/src/slideType.ts +75 -0
- sliveshow-0.1.3/style/base.css +52 -0
- sliveshow-0.1.3/style/index.js +2 -0
- sliveshow-0.1.3/style/reveal.css +42 -0
- sliveshow-0.1.3/tsconfig.json +27 -0
- sliveshow-0.1.3/tsconfig.test.json +3 -0
- sliveshow-0.1.3/ui-tests/README.md +167 -0
- sliveshow-0.1.3/ui-tests/jupyter_server_test_config.py +12 -0
- sliveshow-0.1.3/ui-tests/package.json +15 -0
- sliveshow-0.1.3/ui-tests/playwright.config.js +14 -0
- sliveshow-0.1.3/ui-tests/tests/custom_slideshow.spec.ts +23 -0
- sliveshow-0.1.3/ui-tests/yarn.lock +0 -0
- sliveshow-0.1.3/yarn.lock +11156 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
|
|
2
|
+
_commit: v4.4.0
|
|
3
|
+
_src_path: https://github.com/jupyterlab/extension-template
|
|
4
|
+
author_email: ltshum6-c@my.cityu.edu.hk
|
|
5
|
+
author_name: ltshum
|
|
6
|
+
has_binder: false
|
|
7
|
+
has_settings: true
|
|
8
|
+
kind: frontend
|
|
9
|
+
labextension_name: dive-custom-slideshow
|
|
10
|
+
project_short_description: JupyterLab extension for animated slideshow.
|
|
11
|
+
python_name: custom_slideshow
|
|
12
|
+
repository: https://github.com/ltshum/fyp-dive-custom-slideshow
|
|
13
|
+
test: true
|
|
14
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
FROM mcr.microsoft.com/devcontainers/miniconda:0-3
|
|
2
|
+
|
|
3
|
+
# Copy environment.yml (if found) to a temp location so we update the environment.
|
|
4
|
+
COPY environment.yml /tmp/conda-tmp/
|
|
5
|
+
RUN /opt/conda/bin/conda config --add channels conda-forge \
|
|
6
|
+
&& /opt/conda/bin/conda config --remove channels defaults \
|
|
7
|
+
&& /opt/conda/bin/conda install -y mamba
|
|
8
|
+
RUN umask 0002 && /opt/conda/bin/mamba env update -n base -f /tmp/conda-tmp/environment.yml
|
|
9
|
+
|
|
10
|
+
# [Optional] Uncomment to install a different version of Python than the default
|
|
11
|
+
# RUN mamba install -y python=3.6 \
|
|
12
|
+
# && pip install --no-cache-dir pipx \
|
|
13
|
+
# && pipx reinstall-all
|
|
14
|
+
|
|
15
|
+
# [Optional] Uncomment this section to install additional OS packages.
|
|
16
|
+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|
17
|
+
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda
|
|
3
|
+
{
|
|
4
|
+
"name": "Miniconda (Python 3)",
|
|
5
|
+
"build": {
|
|
6
|
+
"context": "..",
|
|
7
|
+
"dockerfile": "Dockerfile"
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
11
|
+
// "features": {},
|
|
12
|
+
|
|
13
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
14
|
+
// "forwardPorts": [],
|
|
15
|
+
|
|
16
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
17
|
+
// "postCreateCommand": "python --version",
|
|
18
|
+
|
|
19
|
+
// Configure tool-specific properties.
|
|
20
|
+
"customizations": {
|
|
21
|
+
"vscode": {
|
|
22
|
+
"extensions": [
|
|
23
|
+
"dbaeumer.vscode-eslint",
|
|
24
|
+
"esbenp.prettier-vscode",
|
|
25
|
+
"meganrogge.template-string-converter",
|
|
26
|
+
"ms-python.python"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
32
|
+
// "remoteUser": "root"
|
|
33
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
*.bundle.*
|
|
2
|
+
lib/
|
|
3
|
+
node_modules/
|
|
4
|
+
*.log
|
|
5
|
+
.eslintcache
|
|
6
|
+
.stylelintcache
|
|
7
|
+
*.egg-info/
|
|
8
|
+
.ipynb_checkpoints
|
|
9
|
+
*.tsbuildinfo
|
|
10
|
+
dive_custom_slideshow/labextension
|
|
11
|
+
# Version file is handled by hatchling
|
|
12
|
+
dive_custom_slideshow/_version.py
|
|
13
|
+
|
|
14
|
+
# Integration tests
|
|
15
|
+
ui-tests/test-results/
|
|
16
|
+
ui-tests/playwright-report/
|
|
17
|
+
|
|
18
|
+
# Created by https://www.gitignore.io/api/python
|
|
19
|
+
# Edit at https://www.gitignore.io/?templates=python
|
|
20
|
+
|
|
21
|
+
### Python ###
|
|
22
|
+
# Byte-compiled / optimized / DLL files
|
|
23
|
+
__pycache__/
|
|
24
|
+
*.py[cod]
|
|
25
|
+
*$py.class
|
|
26
|
+
|
|
27
|
+
# C extensions
|
|
28
|
+
*.so
|
|
29
|
+
|
|
30
|
+
# Distribution / packaging
|
|
31
|
+
.Python
|
|
32
|
+
build/
|
|
33
|
+
develop-eggs/
|
|
34
|
+
dist/
|
|
35
|
+
downloads/
|
|
36
|
+
eggs/
|
|
37
|
+
.eggs/
|
|
38
|
+
lib/
|
|
39
|
+
lib64/
|
|
40
|
+
parts/
|
|
41
|
+
sdist/
|
|
42
|
+
var/
|
|
43
|
+
wheels/
|
|
44
|
+
pip-wheel-metadata/
|
|
45
|
+
share/python-wheels/
|
|
46
|
+
.installed.cfg
|
|
47
|
+
*.egg
|
|
48
|
+
MANIFEST
|
|
49
|
+
|
|
50
|
+
# PyInstaller
|
|
51
|
+
# Usually these files are written by a python script from a template
|
|
52
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
53
|
+
*.manifest
|
|
54
|
+
*.spec
|
|
55
|
+
|
|
56
|
+
# Installer logs
|
|
57
|
+
pip-log.txt
|
|
58
|
+
pip-delete-this-directory.txt
|
|
59
|
+
|
|
60
|
+
# Unit test / coverage reports
|
|
61
|
+
htmlcov/
|
|
62
|
+
.tox/
|
|
63
|
+
.nox/
|
|
64
|
+
.coverage
|
|
65
|
+
.coverage.*
|
|
66
|
+
.cache
|
|
67
|
+
nosetests.xml
|
|
68
|
+
coverage/
|
|
69
|
+
coverage.xml
|
|
70
|
+
*.cover
|
|
71
|
+
.hypothesis/
|
|
72
|
+
.pytest_cache/
|
|
73
|
+
|
|
74
|
+
# Translations
|
|
75
|
+
*.mo
|
|
76
|
+
*.pot
|
|
77
|
+
|
|
78
|
+
# Scrapy stuff:
|
|
79
|
+
.scrapy
|
|
80
|
+
|
|
81
|
+
# Sphinx documentation
|
|
82
|
+
docs/_build/
|
|
83
|
+
|
|
84
|
+
# PyBuilder
|
|
85
|
+
target/
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
.python-version
|
|
89
|
+
|
|
90
|
+
# celery beat schedule file
|
|
91
|
+
celerybeat-schedule
|
|
92
|
+
|
|
93
|
+
# SageMath parsed files
|
|
94
|
+
*.sage.py
|
|
95
|
+
|
|
96
|
+
# Spyder project settings
|
|
97
|
+
.spyderproject
|
|
98
|
+
.spyproject
|
|
99
|
+
|
|
100
|
+
# Rope project settings
|
|
101
|
+
.ropeproject
|
|
102
|
+
|
|
103
|
+
# Mr Developer
|
|
104
|
+
.mr.developer.cfg
|
|
105
|
+
.project
|
|
106
|
+
.pydevproject
|
|
107
|
+
|
|
108
|
+
# mkdocs documentation
|
|
109
|
+
/site
|
|
110
|
+
|
|
111
|
+
# mypy
|
|
112
|
+
.mypy_cache/
|
|
113
|
+
.dmypy.json
|
|
114
|
+
dmypy.json
|
|
115
|
+
|
|
116
|
+
# Pyre type checker
|
|
117
|
+
.pyre/
|
|
118
|
+
|
|
119
|
+
# End of https://www.gitignore.io/api/python
|
|
120
|
+
|
|
121
|
+
# OSX files
|
|
122
|
+
.DS_Store
|
|
123
|
+
|
|
124
|
+
# Yarn cache
|
|
125
|
+
.yarn/
|
|
126
|
+
|
|
127
|
+
# VS Code
|
|
128
|
+
.vscode/
|
|
129
|
+
.copier-answer.vscode.yml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!-- <START NEW CHANGELOG ENTRY> -->
|
|
4
|
+
|
|
5
|
+
<!-- <END NEW CHANGELOG ENTRY> -->
|
|
6
|
+
|
|
7
|
+
## 0.1.3 - 2026/5/14
|
|
8
|
+
|
|
9
|
+
- Compile with jupyterlab 4.5.x to make it work with xeus kernel that requires 4.5.x.
|
|
10
|
+
|
|
11
|
+
## 0.1.2 - 2026/4/22
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Add class labelling for MathJax expressions (Details: [MathJax html extension](https://docs.mathjax.org/en/latest/input/tex/extensions/html.html))
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Fix SVG reset error when no animation is created
|
|
20
|
+
- Fix error initializing multiple SVG images in the same cell
|
|
21
|
+
|
|
22
|
+
## 0.1.1 - 2026/3/27
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Fix MathJax selector for "animation" object in SVG animations
|
|
27
|
+
- Fix README.md image links
|
|
28
|
+
|
|
29
|
+
## 0.1.0 - 2026/3/22
|
|
30
|
+
|
|
31
|
+
- Initial release
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# SVG Animation Demo\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"This notebook demonstrates `data-animate` style SVG animation working in a **mystmd jupyterbook**\n",
|
|
10
|
+
"using the `{svg-animate}` directive from the `svg-animate` plugin.\n",
|
|
11
|
+
"\n",
|
|
12
|
+
"The same animation config format used by the Reveal.js `dive-custom-slideshow` extension\n",
|
|
13
|
+
"works here — the plugin wraps it in a self-contained iframe.\n",
|
|
14
|
+
"\n",
|
|
15
|
+
":::{svg-animate} Circle animation\n",
|
|
16
|
+
":height: 320px\n",
|
|
17
|
+
":background: white\n",
|
|
18
|
+
"<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'>\n",
|
|
19
|
+
" <circle id='c1' cx='150' cy='150' r='60' style='fill:steelblue'/>\n",
|
|
20
|
+
"</svg>\n",
|
|
21
|
+
"<!--\n",
|
|
22
|
+
"{\n",
|
|
23
|
+
" \"setup\": [{\n",
|
|
24
|
+
" \"element\": \"#c1\",\n",
|
|
25
|
+
" \"modifier\": \"attr\",\n",
|
|
26
|
+
" \"parameters\": [{ \"r\": 100 }],\n",
|
|
27
|
+
" \"duration\": 1500,\n",
|
|
28
|
+
" \"begin\": 0\n",
|
|
29
|
+
" }]\n",
|
|
30
|
+
"}\n",
|
|
31
|
+
"-->\n",
|
|
32
|
+
":::\n"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"metadata": {
|
|
37
|
+
"kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" },
|
|
38
|
+
"language_info": { "name": "python", "version": "3.10.0" }
|
|
39
|
+
},
|
|
40
|
+
"nbformat": 4,
|
|
41
|
+
"nbformat_minor": 5
|
|
42
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* svg-animate.mjs
|
|
3
|
+
* A standalone mystmd / Jupyter Book 2 plugin for SVG animations.
|
|
4
|
+
*
|
|
5
|
+
* Adds a {svg-animate} directive that embeds data-animate style SVG
|
|
6
|
+
* animations using SVG.js. Works by packaging the animation into a
|
|
7
|
+
* self-contained data URI iframe — no external files, no mystmd
|
|
8
|
+
* internal imports, robust against future mystmd updates.
|
|
9
|
+
*
|
|
10
|
+
* Usage in a markdown cell or .md file:
|
|
11
|
+
*
|
|
12
|
+
* :::{svg-animate}
|
|
13
|
+
* :height: 300px
|
|
14
|
+
* <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300">
|
|
15
|
+
* <circle id="c1" cx="150" cy="150" r="60" fill="steelblue"/>
|
|
16
|
+
* </svg>
|
|
17
|
+
* <!--
|
|
18
|
+
* {
|
|
19
|
+
* "setup": [{
|
|
20
|
+
* "element": "#c1",
|
|
21
|
+
* "modifier": "attr",
|
|
22
|
+
* "parameters": [{ "fill": "tomato", "r": 100 }],
|
|
23
|
+
* "duration": 1500,
|
|
24
|
+
* "begin": 0
|
|
25
|
+
* }]
|
|
26
|
+
* }
|
|
27
|
+
* -->
|
|
28
|
+
* :::
|
|
29
|
+
*
|
|
30
|
+
* Register in myst.yml:
|
|
31
|
+
* project:
|
|
32
|
+
* plugins:
|
|
33
|
+
* - svg-animate.mjs
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// Pinned to a specific version for stability.
|
|
37
|
+
// Upgrade intentionally by bumping this string.
|
|
38
|
+
const SVG_JS_CDN = 'https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js@3.1.2/dist/svg.min.js';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Build a fully self-contained HTML page that runs the data-animate animation.
|
|
42
|
+
* This page is embedded as a data URI inside an iframe, so it is completely
|
|
43
|
+
* isolated from the parent page's CSS and JS.
|
|
44
|
+
*/
|
|
45
|
+
function buildAnimationPage(svgContent, bgColor) {
|
|
46
|
+
return `<!DOCTYPE html>
|
|
47
|
+
<html>
|
|
48
|
+
<head>
|
|
49
|
+
<meta charset="utf-8">
|
|
50
|
+
<style>
|
|
51
|
+
html, body {
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
background: ${bgColor};
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
}
|
|
62
|
+
svg { max-width: 100%; max-height: 100%; }
|
|
63
|
+
</style>
|
|
64
|
+
<script src="${SVG_JS_CDN}"></script>
|
|
65
|
+
</head>
|
|
66
|
+
<body>
|
|
67
|
+
<div data-animate>
|
|
68
|
+
${svgContent}
|
|
69
|
+
</div>
|
|
70
|
+
<script>
|
|
71
|
+
(function () {
|
|
72
|
+
function tryAnimate() {
|
|
73
|
+
if (typeof SVG === 'undefined') { setTimeout(tryAnimate, 100); return; }
|
|
74
|
+
document.querySelectorAll('[data-animate]').forEach(function (el) {
|
|
75
|
+
var match = el.innerHTML.match(/<!--([\\s\\S]*?)-->/);
|
|
76
|
+
if (!match) return;
|
|
77
|
+
var config;
|
|
78
|
+
try { config = JSON.parse(match[1].trim()); } catch (e) {
|
|
79
|
+
console.error('svg-animate: invalid JSON config', e);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var svgEl = el.querySelector('svg');
|
|
83
|
+
if (!svgEl) return;
|
|
84
|
+
var draw = SVG(svgEl);
|
|
85
|
+
(config.setup || []).forEach(function (step) {
|
|
86
|
+
var target = draw.findOne(step.element);
|
|
87
|
+
if (!target) return;
|
|
88
|
+
var anim = target.animate(step.duration || 1000, step.begin || 0);
|
|
89
|
+
if (typeof anim[step.modifier] === 'function') {
|
|
90
|
+
anim[step.modifier](step.parameters[0]);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (document.readyState === 'loading') {
|
|
96
|
+
document.addEventListener('DOMContentLoaded', tryAnimate);
|
|
97
|
+
} else {
|
|
98
|
+
tryAnimate();
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
</script>
|
|
102
|
+
</body>
|
|
103
|
+
</html>`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Encode a unicode string as base64.
|
|
108
|
+
* Works in Node.js 16+ and modern browsers.
|
|
109
|
+
*/
|
|
110
|
+
function toBase64(str) {
|
|
111
|
+
const bytes = new TextEncoder().encode(str);
|
|
112
|
+
let binary = '';
|
|
113
|
+
bytes.forEach(function (b) { binary += String.fromCharCode(b); });
|
|
114
|
+
return btoa(binary);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const svgAnimateDirective = {
|
|
118
|
+
name: 'svg-animate',
|
|
119
|
+
doc: [
|
|
120
|
+
'Embed an SVG animation using data-animate syntax (SVG.js).',
|
|
121
|
+
'The animation runs in a self-contained iframe and works in',
|
|
122
|
+
'mystmd jupyterbooks, Jupyter Book 2, and static HTML exports.',
|
|
123
|
+
].join(' '),
|
|
124
|
+
alias: ['animate-svg'],
|
|
125
|
+
arg: {
|
|
126
|
+
type: String,
|
|
127
|
+
doc: 'Optional accessible title for the animation frame.',
|
|
128
|
+
},
|
|
129
|
+
options: {
|
|
130
|
+
width: {
|
|
131
|
+
type: String,
|
|
132
|
+
doc: 'Width of the animation frame in CSS units (default: 100%).',
|
|
133
|
+
},
|
|
134
|
+
height: {
|
|
135
|
+
type: String,
|
|
136
|
+
doc: 'Height of the animation frame in CSS units (default: 300px).',
|
|
137
|
+
},
|
|
138
|
+
background: {
|
|
139
|
+
type: String,
|
|
140
|
+
doc: 'Background colour of the animation frame (default: transparent).',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
body: {
|
|
144
|
+
type: String,
|
|
145
|
+
required: true,
|
|
146
|
+
doc: [
|
|
147
|
+
'SVG element with animation config. Place the JSON config inside',
|
|
148
|
+
'an HTML comment (<!-- ... -->) inside or after the SVG, following',
|
|
149
|
+
'the data-animate convention.',
|
|
150
|
+
].join(' '),
|
|
151
|
+
},
|
|
152
|
+
run(data) {
|
|
153
|
+
const svgContent = data.body || '';
|
|
154
|
+
const width = (data.options && data.options.width) || '100%';
|
|
155
|
+
const height = (data.options && data.options.height) || '300px';
|
|
156
|
+
const bg = (data.options && data.options.background) || 'transparent';
|
|
157
|
+
const title = data.arg || 'SVG Animation';
|
|
158
|
+
|
|
159
|
+
const htmlPage = buildAnimationPage(svgContent, bg);
|
|
160
|
+
const encoded = toBase64(htmlPage);
|
|
161
|
+
const src = 'data:text/html;base64,' + encoded;
|
|
162
|
+
|
|
163
|
+
return [{
|
|
164
|
+
type: 'iframe',
|
|
165
|
+
src: src,
|
|
166
|
+
width: width,
|
|
167
|
+
height: height,
|
|
168
|
+
title: title,
|
|
169
|
+
}];
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const plugin = {
|
|
174
|
+
name: 'SVG Animate',
|
|
175
|
+
author: 'Alyan Ahmedani',
|
|
176
|
+
license: 'MIT',
|
|
177
|
+
directives: [svgAnimateDirective],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export default plugin;
|
|
Binary file
|
sliveshow-0.1.3/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, ltshum
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|