The classifier re-scanned the source on every session; on cloud-backed mounts (OneDrive/Samba) that's minutes of per-op latency. Workspaces fix it: scan a folder ONCE, snapshot the completed tree, and resume instantly — all classification runs on the data model; the filesystem is only touched at copy. - persist.js v2: multi-workspace IndexedDB (tiny 'index' store for the welcome list + 'data' store holding the source handle, tree snapshot, and map). DB v2. - scanner.js: snapshotTree()/loadSnapshot() (compact, handle-less, marked done, totals recomputed) + lazy resolveFileHandle/resolveDirHandle from the root. - workspace.js: welcome manager (new/open/rename/delete), debounced autosave of the active workspace, 'Refresh from disk' (re-scan → re-snapshot, path-keyed map carries over). New workspace = the one slow full scan; reopen = instant. - copy.js: resolves snapshot files' handles from the workspace root with a one-click read permission re-grant; missing-on-disk files surface as errors. - app.js: enterAppShell() shared by rename/workspace flows; exposes setMode; classify.js decoupled from persistence. - template/css: welcome workspace list + header 'Workspaces' button. - tests: snapshot round-trip, persist CRUD + classify-only-preserves-tree, copy-from-snapshot via mock root handle (28 classify/classifier tests green). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
117 lines
3.1 KiB
Bash
Executable file
117 lines
3.1 KiB
Bash
Executable file
#!/bin/sh
|
|
set -eu
|
|
|
|
root_dir=$(cd "$(dirname "$0")" && pwd)
|
|
. "$root_dir/../shared/build-lib.sh"
|
|
|
|
src_html="$root_dir/template.html"
|
|
output_dir="$root_dir/dist"
|
|
output_html="$output_dir/classifier.html"
|
|
|
|
mkdir -p "$output_dir"
|
|
ensure_exists "$src_html"
|
|
|
|
css_temp=$(mktemp)
|
|
js_raw=$(mktemp)
|
|
js_temp=$(mktemp)
|
|
cleanup() { rm -f "$css_temp" "$js_raw" "$js_temp"; }
|
|
trap cleanup EXIT
|
|
|
|
# CSS files to concatenate in order
|
|
concat_files \
|
|
"../shared/fonts.css" \
|
|
"../shared/base.css" \
|
|
"../shared/toast.css" \
|
|
"../shared/elevation.css" \
|
|
"../shared/profile-menu.css" \
|
|
"../shared/logo.css" \
|
|
"css/base.css" \
|
|
"css/layout.css" \
|
|
"css/spreadsheet.css" \
|
|
> "$css_temp"
|
|
|
|
# JavaScript files to concatenate in order. Vendored libraries first
|
|
# (jszip, docx-preview) so window.JSZip + window.docx are defined before
|
|
# any tool code runs. Replaces the previous <script src="cdn..."> tag in
|
|
# template.html plus the loadLibrary CDN calls in preview.js. xlsx stays
|
|
# CDN-loaded on demand (~900 KB; too large to inline).
|
|
concat_files \
|
|
"../shared/vendor/jszip.min.js" \
|
|
"../shared/vendor/docx-preview.min.js" \
|
|
"../shared/vendor/xlsx.full.min.js" \
|
|
"../shared/vendor/utif.min.js" \
|
|
"../shared/zddc.js" \
|
|
"../shared/hash.js" \
|
|
"../shared/zddc-source.js" \
|
|
"../shared/theme.js" \
|
|
"../shared/toast.js" \
|
|
"../shared/logo.js" \
|
|
"../shared/preview-lib.js" \
|
|
"js/app.js" \
|
|
"js/utils.js" \
|
|
"../shared/zddc-filter.js" \
|
|
"js/store.js" \
|
|
"js/persist.js" \
|
|
"js/classify.js" \
|
|
"js/workspace.js" \
|
|
"js/dnd.js" \
|
|
"js/validator.js" \
|
|
"js/scanner.js" \
|
|
"js/tree.js" \
|
|
"js/target-tree.js" \
|
|
"js/copy.js" \
|
|
"js/spreadsheet.js" \
|
|
"js/selection.js" \
|
|
"js/preview.js" \
|
|
"js/resize.js" \
|
|
"js/filter.js" \
|
|
"js/sort.js" \
|
|
"js/excel.js" \
|
|
"../shared/help.js" \
|
|
"../shared/elevation.js" \
|
|
"../shared/profile-menu.js" \
|
|
"../shared/cap.js" \
|
|
> "$js_raw"
|
|
|
|
# Escape '</' in inlined JS so the HTML parser cannot mistake string contents
|
|
# for a closing </script> tag. Required for any tool with template literals.
|
|
escape_js_close_tags "$js_raw" "$js_temp"
|
|
|
|
compute_build_label "classifier" "${1:-}" "${2:-}"
|
|
|
|
# Process template: inject CSS/JS, substitute build label, strip CDN refs.
|
|
awk -v css_file="$css_temp" -v js_file="$js_temp" -v build_label="$build_label" -v is_red="$is_red" -v favicon_uri="$favicon_data_uri" '
|
|
/\{\{CSS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < css_file) > 0) print line
|
|
close(css_file)
|
|
next
|
|
}
|
|
/\{\{JS_PLACEHOLDER\}\}/ {
|
|
while ((getline line < js_file) > 0) print line
|
|
close(js_file)
|
|
next
|
|
}
|
|
/\{\{BUILD_LABEL\}\}/ {
|
|
if (is_red == "1") {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, "<span style=\"color:red;font-weight:bold\">" build_label "</span>")
|
|
} else {
|
|
gsub(/\{\{BUILD_LABEL\}\}/, build_label)
|
|
}
|
|
print
|
|
next
|
|
}
|
|
/\{\{FAVICON\}\}/ {
|
|
gsub(/\{\{FAVICON\}\}/, favicon_uri)
|
|
print
|
|
next
|
|
}
|
|
/<script src="https?:\/\// { next }
|
|
/<link rel="stylesheet" href="https?:\/\// { next }
|
|
{ print }
|
|
' "$src_html" > "$output_html"
|
|
|
|
echo "Wrote $output_html"
|
|
|
|
if [ "$is_release" = "1" ]; then
|
|
promote_release "classifier"
|
|
fi
|