-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·57 lines (45 loc) · 1.49 KB
/
build.sh
File metadata and controls
executable file
·57 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# build.sh - Genera index_monolithic.html da index.html + JS sorgenti
#
# Uso: ./build.sh
#
# Prende index.html (template) e produce index_monolithic.html
# con CartiaTTS.js, tts-worker.js e cartia.js inlineati.
# Il risultato è un singolo file HTML portatile.
set -euo pipefail
cd "$(dirname "$0")"
SRC="index.html"
OUT="index_monolithic.html"
if [ ! -f "$SRC" ]; then
echo "Errore: $SRC non trovato" >&2
exit 1
fi
echo "Building $OUT ..."
python3 << 'PYEOF'
import re
with open("index.html", "r") as f:
html = f.read()
with open("CartiaTTS.js", "r") as f:
cartia_tts = f.read()
with open("tts-worker.js", "r") as f:
tts_worker = f.read()
with open("cartia.js", "r") as f:
cartia_js = f.read()
# Inline tts-worker.js as a global string (for Blob Worker)
worker_inline = '<script>\n// tts-worker.js (inlined for monolithic build)\nwindow.__TTS_WORKER_CODE__ = ' + repr(tts_worker) + ';\n </script>'
# Replace <script src="CartiaTTS.js"></script> with worker global + CartiaTTS inline
html = html.replace(
'<script src="CartiaTTS.js"></script>',
worker_inline + '\n <script>\n' + cartia_tts + '\n </script>'
)
# Replace <script src="cartia.js"></script> with inline
html = html.replace(
'<script src="cartia.js"></script>',
'<script>\n' + cartia_js + '\n </script>'
)
with open("index_monolithic.html", "w") as f:
f.write(html)
print("OK: index_monolithic.html generato")
PYEOF
ls -lh "$OUT" | awk '{print "Dimensione:", $5}'
echo "Done!"