diff --git a/src/misc/wasm/Makefile b/src/misc/wasm/Makefile --- a/src/misc/wasm/Makefile +++ b/src/misc/wasm/Makefile @@ -37,10 +37,36 @@ OUT := out-femtolisp endif +# Keep the embedded distribution separate so packaging can never delete +# the full distribution's packs when switching profiles. +ifeq ($(TESSERA_WEB),1) +OUT := $(OUT)-tessera +WEB_EMBEDDED := true +WEB_EXTRAS := +WEB_PLUGIN_PACKS := +else +WEB_EMBEDDED := false +WEB_EXTRAS := workers.js wallet.js +WEB_PLUGIN_PACKS := tikzjax asymptote +endif + SOURCES := $(shell cat $(W)/sources.txt) # the Scheme interpreter: S7 (the default) or femtolisp (SCHEME=femtolisp, # src/Scheme/Femtolisp, docs/femtolisp), whose objects go to obj-femtolisp ifeq ($(SCHEME),femtolisp) +# Keep the embedded distribution separate so packaging can never delete +# the full distribution's packs when switching profiles. +ifeq ($(TESSERA_WEB),1) +OUT := $(OUT)-tessera +WEB_EMBEDDED := true +WEB_EXTRAS := +WEB_PLUGIN_PACKS := +else +WEB_EMBEDDED := false +WEB_EXTRAS := workers.js wallet.js +WEB_PLUGIN_PACKS := tikzjax asymptote +endif + SOURCES := $(filter-out Scheme/S7/%,$(SOURCES)) \ Scheme/Femtolisp/fl_core.c Scheme/Femtolisp/fl_llt.c \ Scheme/Femtolisp/femtolisp_tm.cpp @@ -131,6 +157,13 @@ web: $(OUT)/web/texmacs.html $(OUT)/web/texmacs-files.json $(WEB_ICONS) $(OUT)/web/index.html $(OUT)/web/downloads.html $(OUT)/web/features.html $(SCREENSHOTS) $(OUT)/web/changes.html $(OUT)/web/changes.md $(OUT)/web/thanks.html $(OUT)/web/thanks.md $(OUT)/web/fixes.html $(OUT)/web/texmacs-64.png licenses tikzjax asymptote python r +# Browser editor assets only. The full web target also builds the public site, +# documentation screenshots and external computational runtimes. +tessera-web: + $(MAKE) -f $(W)/Makefile TESSERA_WEB=1 tessera-assets + +tessera-assets: $(OUT)/web/texmacs-files.json $(WEB_ICONS) licenses + # the licenses of the components (TeXmacs/misc/licenses, also in the # packages of the page), as files of the site: out/web/licenses/ licenses: $(OUT)/web/licenses/README.md @@ -278,11 +311,12 @@ @mkdir -p $(OUT)/web/screenshots cp $< $@ -$(OUT)/web/texmacs.html: $(OBJECTS) $(LIBDEPS) $(W)/progress.js $(W)/packages.js $(W)/web-pre.js $(W)/files.js $(W)/frame.js $(W)/clipboard.js $(W)/print.js $(W)/workers.js $(W)/javascript.js $(W)/ime.js $(W)/wallet.js $(W)/shell.html +$(OUT)/web/texmacs.html: $(OBJECTS) $(LIBDEPS) $(W)/progress.js $(W)/packages.js $(W)/web-pre.js $(W)/files.js $(W)/frame.js $(W)/clipboard.js $(W)/print.js $(W)/workers.js $(W)/javascript.js $(W)/ime.js $(addprefix $(W)/,$(WEB_EXTRAS)) $(W)/shell.html @mkdir -p $(OUT)/web em++ $(LDFLAGS) -lidbfs.js --pre-js $(W)/progress.js --pre-js $(W)/packages.js --pre-js $(W)/web-pre.js \ - --pre-js $(W)/files.js --pre-js $(W)/frame.js --pre-js $(W)/clipboard.js --pre-js $(W)/print.js --pre-js $(W)/workers.js --pre-js $(W)/javascript.js --pre-js $(W)/ime.js --pre-js $(W)/wallet.js --shell-file $(W)/shell.html \ + --pre-js $(W)/files.js --pre-js $(W)/frame.js --pre-js $(W)/clipboard.js --pre-js $(W)/print.js --pre-js $(W)/javascript.js --pre-js $(W)/ime.js $(foreach f,$(WEB_EXTRAS),--pre-js $(W)/$(f)) --shell-file $(W)/shell.html \ $(OBJECTS) $(LIBS) -o $@ + perl -pi -e "s/\@TM_EMBEDDED\@/$(WEB_EMBEDDED)/" $@ perl -pi -e "s/\@TM_WASM_SIZE\@/$$(wc -c < $(OUT)/web/texmacs.wasm | tr -d ' ')/" $@ perl -pi -e "s/\@TM_VERSION\@/$$(sed -n 's/^#define TEXMACS_VERSION \"\(.*\)\"/\1/p' $(W)/tm_configure.hpp)/" $@ -command -v brotli > /dev/null && brotli -f -q 9 -k $(OUT)/web/texmacs.wasm $(OUT)/web/texmacs.js @@ -313,12 +347,12 @@ # (misc/wasm/build-info.py: the commit, the versions, the sizes), written # once the program and the files are there, then packaged again BUILD_INFO := $(TM)/TeXmacs/doc/about/welcome/texmacs-vue-build.en.tm -$(OUT)/web/texmacs-files.json: FORCE plugins-sync $(OUT)/web/texmacs.html tikzjax asymptote $(PACKAGE_DEPS) - @mkdir -p $(OUT)/web - python3 $(W)/package.py $(TM)/TeXmacs $(OUT)/web $(W)/boot-files.txt $(PACKAGE_EXTRA) +$(OUT)/web/texmacs-files.json: FORCE plugins-sync $(OUT)/web/texmacs.html $(WEB_PLUGIN_PACKS) $(PACKAGE_DEPS) + @mkdir -p $(OUT)/web + TESSERA_WEB=$(TESSERA_WEB) python3 $(W)/package.py $(TM)/TeXmacs $(OUT)/web $(W)/boot-files.txt $(PACKAGE_EXTRA) $(BROTLI_PACKS) - python3 $(W)/build-info.py $(TM) $(CURDIR) $(MUPDF) "$(THORVG)" $(BUILD_INFO) - python3 $(W)/package.py $(TM)/TeXmacs $(OUT)/web $(W)/boot-files.txt $(PACKAGE_EXTRA) + python3 $(W)/build-info.py $(TM) $(CURDIR) $(MUPDF) "$(THORVG)" $(BUILD_INFO) $(OUT)/web + TESSERA_WEB=$(TESSERA_WEB) python3 $(W)/package.py $(TM)/TeXmacs $(OUT)/web $(W)/boot-files.txt $(PACKAGE_EXTRA) $(BROTLI_PACKS) BROTLI_PACKS = -command -v brotli > /dev/null && for f in $(OUT)/web/tm-*.pack $(OUT)/web/tm-font-*; do \ @@ -422,4 +456,4 @@ clean: rm -rf $(OBJ) $(OUT) -.PHONY: all web node clean licenses tikzjax asymptote python r plugins-sync femtolisp-cache +.PHONY: all web tessera-web tessera-assets node clean licenses tikzjax asymptote python r plugins-sync femtolisp-cache diff --git a/src/misc/wasm/package.py b/src/misc/wasm/package.py --- a/src/misc/wasm/package.py +++ b/src/misc/wasm/package.py @@ -78,7 +78,19 @@ return (any (rel.startswith (d) for d in LAZY_DIRS) and os.path.splitext (rel)[1].lower () in LAZY_EXTS) +# Tessera handles document storage and has no execution-session UI. Keep +# conversion plug-ins, styles, fonts and the native editing resources. +EMBEDDED = os.environ.get ('TESSERA_WEB') == '1' +EMBEDDED_EXCLUDE = ['plugins/' + p for p in ('ai', 'python', 'r', 'tikz', 'asymptote')] +EMBEDDED_EXCLUDE += ['misc/font-samples'] +# The core's lazy format registry loads this even for regular manuscripts. +EMBEDDED_KEEP = ['plugins/python/progs/python-format.scm'] + def excluded (rel): + if EMBEDDED and any (p == rel or p.startswith (rel + '/') for p in EMBEDDED_KEEP): + return False + if EMBEDDED and any (rel == d or rel.startswith (d + '/') for d in EMBEDDED_EXCLUDE): + return True if any (rel == d or rel.startswith (d + '/') for d in PLUGIN_DOCS): return False return any (fnmatch.fnmatch (rel, e) or rel.startswith (e + '/') for e in EXCLUDE) diff --git a/src/misc/wasm/shell.html b/src/misc/wasm/shell.html --- a/src/misc/wasm/shell.html +++ b/src/misc/wasm/shell.html @@ -4,6 +4,7 @@ TeXmacs Upsilon + @@ -21,6 +22,8 @@ canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; outline: none; } /* until the panel of misc/wasm/progress.js replaces it */ + .tessera-embedded #tm-frame, .tessera-embedded #tm-loading, + .tessera-embedded #status { display: none !important; } #status { position: fixed; left: 0; right: 0; top: 40%; text-align: center; font: 16px -apple-system, "Helvetica Neue", sans-serif; color: #222; } @@ -31,7 +34,10 @@
Loading TeXmacs Upsilon…