@davoodmehraban89 / Aram / commits / 2fce09d
Fork 0

feat(pilot): vendor Excel wheels + dual-CDN boot; permanent commit-pinned links

- boot() installs vendored openpyxl/et_xmlfile wheels directly into site-packages (no PyPI/micropip at runtime) and falls back jsDelivr->unpkg - docs/vendor/ carries the two pure-Python wheels (268KB) - Pages workflow is dispatch-only (site creation requires owner action); app is served permanently via rawcdn.githack.com / cdn.jsdelivr.net gh - Final Node+Pyodide test of deployed bundle: full journey to COMPLETE_APPROVED, lossless workspace round-trip, 12 audit entries Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>

davoodmehraban89 committed Dec 3, 2026 at 08:23 UTC 2fce09d70f8a4465637171f22722838649e1ee2c
11 files changed +92 -20
.github/workflows/pilot-pages.yml
+4 -7
@@ -1,13 +1,10 @@
1 name: Deploy Pilot Workbench (browser edition) to Pages
2
3 +# Manual trigger only: GitHub allows enabling a Pages site solely by the repo
4 +# owner (Settings -> Pages -> Source: GitHub Actions). Once enabled, dispatch
5 +# this workflow to publish docs/. The app is meanwhile served permanently via
6 +# commit-pinned CDN URLs (see webapp/README.md).
7 on:
4 - push:
5 - branches: [arena/094f314c-aram]
6 - paths:
7 - - "docs/**"
8 - - "webapp/**"
9 - - "scripts/build_webapp.py"
10 - - ".github/workflows/pilot-pages.yml"
8 workflow_dispatch:
9
10 permissions:
docs/app.js
+34 -4
@@ -63,18 +63,48 @@ function downloadB64(b64, filename) {
63 }
64
65 /* ---------------- boot ---------------- */
66 +const PYODIDE_VERSION = "0.26.4";
67 +const PYODIDE_BASES = [
68 + `https://cdn.jsdelivr.net/pyodide/v${PYODIDE_VERSION}/full/`,
69 + `https://unpkg.com/pyodide@${PYODIDE_VERSION}/`,
70 +];
71 +const VENDOR_WHEELS = ["et_xmlfile-2.0.0-py3-none-any.whl", "openpyxl-3.1.5-py2.py3-none-any.whl"];
72 +
73 function bootProgress(pct, msg) {
74 $("#boot-progress").style.width = pct + "%";
75 if (msg) $("#boot-status").textContent = msg;
76 }
77 +function loadScript(src) {
78 + return new Promise((resolve, reject) => {
79 + const s = document.createElement("script");
80 + s.src = src;
81 + s.onload = resolve;
82 + s.onerror = () => reject(new Error("بارگذاری اسکریپت ناموفق: " + src));
83 + document.head.appendChild(s);
84 + });
85 +}
86 +async function loadPyodideRuntime() {
87 + let lastErr = null;
88 + for (const base of PYODIDE_BASES) {
89 + try {
90 + if (typeof globalThis.loadPyodide !== "function") await loadScript(base + "pyodide.js");
91 + return await loadPyodide({ indexURL: base });
92 + } catch (err) { lastErr = err; }
93 + }
94 + throw lastErr || new Error("بارگذاری پایتون ناموفق بود.");
95 +}
96 async function boot() {
97 try {
98 bootProgress(10, "در حال بارگذاری پایتون در مرورگر…");
73 - PY = await loadPyodide({ indexURL: "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/" });
99 + PY = await loadPyodideRuntime();
100 bootProgress(45, "در حال نصب کتابخانهٔ اکسل…");
75 - await PY.loadPackage("micropip");
76 - const micropip = PY.pyimport("micropip");
77 - await micropip.install("openpyxl");
101 + const site = PY.runPython("import site; site.getsitepackages()[0]");
102 + for (const w of VENDOR_WHEELS) {
103 + const resp = await fetch(`vendor/${w}`);
104 + if (!resp.ok) throw new Error("بارگذاری کتابخانه ناموفق: " + w);
105 + PY.FS.writeFile(`/tmp/${w}`, new Uint8Array(await resp.arrayBuffer()));
106 + PY.runPython(`import zipfile; zipfile.ZipFile('/tmp/${w}').extractall('${site}')`);
107 + }
108 bootProgress(70, "در حال بارگذاری موتور آرام…");
109 PY.FS.mkdirTree("/pkg/aram_backend");
110 const files = ["__init__.py", "pilot_workbook.py", "pilot_engine.py", "pilot_editing.py", "pilot_demo.py", "pilot_store.py"];
docs/index.html
-1
@@ -134,7 +134,6 @@
134 خروجی پیش‌نویس کاری است؛ برای گزارشگری رسمی استفاده نکنید.
135 </footer>
136
137 - <script src="https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js"></script>
137 <script src="app.js"></script>
138 </body>
139 </html>
docs/vendor/et_xmlfile-2.0.0-py3-none-any.whl
Binary files /dev/null and b/docs/vendor/et_xmlfile-2.0.0-py3-none-any.whl differ
docs/vendor/openpyxl-3.1.5-py2.py3-none-any.whl
Binary files /dev/null and b/docs/vendor/openpyxl-3.1.5-py2.py3-none-any.whl differ
scripts/build_webapp.py
+4
@@ -35,6 +35,10 @@ def main() -> None:
35 shutil.copyfile(SRC / name, pkg / name)
36 for name in UI_FILES:
37 shutil.copyfile(WEB / name, OUT / name)
38 + vendor = OUT / "vendor"
39 + vendor.mkdir(parents=True, exist_ok=True)
40 + for whl in sorted((WEB / "vendor").glob("*.whl")):
41 + shutil.copyfile(whl, vendor / whl.name)
42 # GitHub Pages: skip Jekyll so every file is served verbatim.
43 (OUT / ".nojekyll").write_text("")
44 print("Built browser edition into docs/:")
webapp/README.md
+16 -3
@@ -24,11 +24,24 @@ served at `https://davoodmehraban89.github.io/Aram/`.
24
25 ## Runtime
26
27 -On first load the page fetches Pyodide from jsDelivr and `openpyxl` from PyPI
28 -(via micropip), then loads the engine modules from `py/aram_backend/`. All data
29 -stays in the browser's memory; the durable artifacts are the downloaded
27 +On first load the page fetches the Pyodide runtime (jsDelivr, with an unpkg
28 +fallback), installs the **vendored** pure-Python wheels in `vendor/`
29 +(openpyxl + et_xmlfile, extracted straight into site-packages — no PyPI or
30 +micropip needed), then loads the engine modules from `py/aram_backend/`. All
31 +data stays in the browser's memory; the durable artifacts are the downloaded
32 workbooks (`ذخیرهٔ کارگاه` is a lossless, re-uploadable v0.1 workbook).
33
34 +## Permanent links (no setup required)
35 +
36 +The bundle is served verbatim, with correct MIME types, at commit-pinned URLs:
37 +
38 +- `https://rawcdn.githack.com/davoodmehraban89/Aram/<commit>/docs/index.html`
39 +- `https://cdn.jsdelivr.net/gh/davoodmehraban89/Aram@<commit>/docs/index.html`
40 +
41 +If the owner enables GitHub Pages (Settings → Pages → Source: GitHub Actions),
42 +dispatch `.github/workflows/pilot-pages.yml` to also publish at
43 +`https://davoodmehraban89.github.io/Aram/`.
44 +
45 ## Verification
46
47 - Bridge parity + full workflow tested under Node + Pyodide 0.26.4 (same version as the CDN).
webapp/app.js
+34 -4
@@ -63,18 +63,48 @@ function downloadB64(b64, filename) {
63 }
64
65 /* ---------------- boot ---------------- */
66 +const PYODIDE_VERSION = "0.26.4";
67 +const PYODIDE_BASES = [
68 + `https://cdn.jsdelivr.net/pyodide/v${PYODIDE_VERSION}/full/`,
69 + `https://unpkg.com/pyodide@${PYODIDE_VERSION}/`,
70 +];
71 +const VENDOR_WHEELS = ["et_xmlfile-2.0.0-py3-none-any.whl", "openpyxl-3.1.5-py2.py3-none-any.whl"];
72 +
73 function bootProgress(pct, msg) {
74 $("#boot-progress").style.width = pct + "%";
75 if (msg) $("#boot-status").textContent = msg;
76 }
77 +function loadScript(src) {
78 + return new Promise((resolve, reject) => {
79 + const s = document.createElement("script");
80 + s.src = src;
81 + s.onload = resolve;
82 + s.onerror = () => reject(new Error("بارگذاری اسکریپت ناموفق: " + src));
83 + document.head.appendChild(s);
84 + });
85 +}
86 +async function loadPyodideRuntime() {
87 + let lastErr = null;
88 + for (const base of PYODIDE_BASES) {
89 + try {
90 + if (typeof globalThis.loadPyodide !== "function") await loadScript(base + "pyodide.js");
91 + return await loadPyodide({ indexURL: base });
92 + } catch (err) { lastErr = err; }
93 + }
94 + throw lastErr || new Error("بارگذاری پایتون ناموفق بود.");
95 +}
96 async function boot() {
97 try {
98 bootProgress(10, "در حال بارگذاری پایتون در مرورگر…");
73 - PY = await loadPyodide({ indexURL: "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/" });
99 + PY = await loadPyodideRuntime();
100 bootProgress(45, "در حال نصب کتابخانهٔ اکسل…");
75 - await PY.loadPackage("micropip");
76 - const micropip = PY.pyimport("micropip");
77 - await micropip.install("openpyxl");
101 + const site = PY.runPython("import site; site.getsitepackages()[0]");
102 + for (const w of VENDOR_WHEELS) {
103 + const resp = await fetch(`vendor/${w}`);
104 + if (!resp.ok) throw new Error("بارگذاری کتابخانه ناموفق: " + w);
105 + PY.FS.writeFile(`/tmp/${w}`, new Uint8Array(await resp.arrayBuffer()));
106 + PY.runPython(`import zipfile; zipfile.ZipFile('/tmp/${w}').extractall('${site}')`);
107 + }
108 bootProgress(70, "در حال بارگذاری موتور آرام…");
109 PY.FS.mkdirTree("/pkg/aram_backend");
110 const files = ["__init__.py", "pilot_workbook.py", "pilot_engine.py", "pilot_editing.py", "pilot_demo.py", "pilot_store.py"];
webapp/index.html
-1
@@ -134,7 +134,6 @@
134 خروجی پیش‌نویس کاری است؛ برای گزارشگری رسمی استفاده نکنید.
135 </footer>
136
137 - <script src="https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js"></script>
137 <script src="app.js"></script>
138 </body>
139 </html>
webapp/vendor/et_xmlfile-2.0.0-py3-none-any.whl
Binary files /dev/null and b/webapp/vendor/et_xmlfile-2.0.0-py3-none-any.whl differ
webapp/vendor/openpyxl-3.1.5-py2.py3-none-any.whl
Binary files /dev/null and b/webapp/vendor/openpyxl-3.1.5-py2.py3-none-any.whl differ