Initial commit
This commit is contained in:
commit
7f6e16f5d1
27
.gitignore
vendored
Normal file
27
.gitignore
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Installed packages (recreated by `npm install`)
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Built app (recreated by `npm run build`)
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# Data written by the local dev server: test profiles, password hashes and
|
||||||
|
# photos. The real data lives in the container on n0m.org.
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Deploy credentials and other secrets
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Claude Code per-machine settings
|
||||||
|
.claude/settings.local.json
|
||||||
|
|
||||||
|
# Editor and OS clutter
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
210
cgi/api.sh
Normal file
210
cgi/api.sh
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Data API for the Climbing Tracker when hosted in an n0m.org files container.
|
||||||
|
# Each person has their own file: data/users/<id>.json
|
||||||
|
# GET api.sh -> everyone's data as one JSON object, keyed by id
|
||||||
|
# GET api.sh?check=<id> -> whether that person has a password, and whether
|
||||||
|
# the one sent with this request is correct
|
||||||
|
# PUT api.sh?user=<id> -> replaces that person's data with the request body
|
||||||
|
# (needs their password; the first save sets it)
|
||||||
|
# PUT api.sh?user=<id>&photo=<photo id>
|
||||||
|
# -> saves a photo for one of that person's climbs as
|
||||||
|
# data/photos/<id>-<photo id>.jpg. The body is
|
||||||
|
# {"photo":"<base64 JPEG>"}, or {"photo":""} to
|
||||||
|
# delete it. Photos are shrunk in the browser first
|
||||||
|
# because n0m only accepts JSON bodies up to 100 KB.
|
||||||
|
# (Query strings are used instead of paths like api.sh/users/<id> because n0m
|
||||||
|
# never responds to a path that continues past a script's file name)
|
||||||
|
#
|
||||||
|
# Passwords: the browser never sends the password itself. It sends a token (a
|
||||||
|
# SHA-256 of the profile id and password) in the X-Auth header. What is kept in
|
||||||
|
# data/.auth/<id> is a SHA-256 of that token, hashed again together with a
|
||||||
|
# random secret (data/.auth/_pepper) that is created on first use.
|
||||||
|
#
|
||||||
|
# n0m will happily serve any ordinary file in the container, including ones in
|
||||||
|
# dot folders. It runs executable files instead of sending their contents
|
||||||
|
# though, so the secret files are made executable with a "#!/bin/true" first
|
||||||
|
# line: requesting one over the web runs "true" and returns nothing.
|
||||||
|
source exprash.sh
|
||||||
|
|
||||||
|
redirect_stdout
|
||||||
|
|
||||||
|
data_dir='data'
|
||||||
|
users_dir="$data_dir/users"
|
||||||
|
backups_dir="$data_dir/backups"
|
||||||
|
auth_dir="$data_dir/.auth"
|
||||||
|
photos_dir="$data_dir/photos"
|
||||||
|
max_photo_bytes=72000
|
||||||
|
legacy_file="$data_dir/climbing-data.json"
|
||||||
|
pepper_file="$auth_dir/_pepper"
|
||||||
|
token="${HTTP_X_AUTH:-}"
|
||||||
|
|
||||||
|
mkdir -p "$users_dir" "$backups_dir" "$auth_dir" "$photos_dir"
|
||||||
|
|
||||||
|
sha256() {
|
||||||
|
sha256sum | cut -d ' ' -f 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: file path
|
||||||
|
# $2: secret value
|
||||||
|
write_secret() {
|
||||||
|
local secret_tmp
|
||||||
|
secret_tmp="$(mktemp "$data_dir/tmp.XXXXXX")"
|
||||||
|
printf '#!/bin/true\n%s\n' "$2" > "$secret_tmp"
|
||||||
|
chmod 700 "$secret_tmp"
|
||||||
|
mv "$secret_tmp" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: file path
|
||||||
|
read_secret() {
|
||||||
|
tail -n 1 "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -s "$pepper_file" ]; then
|
||||||
|
write_secret "$pepper_file" "$(head -c 32 /dev/urandom | sha256)"
|
||||||
|
fi
|
||||||
|
pepper="$(read_secret "$pepper_file")"
|
||||||
|
|
||||||
|
# $1: SHA-256 of a token
|
||||||
|
pepper_hash() {
|
||||||
|
printf '%s:%s' "$pepper" "$1" | sha256
|
||||||
|
}
|
||||||
|
|
||||||
|
# One-off upgrade of password files saved before the secret existed
|
||||||
|
for auth_file in "$auth_dir"/*; do
|
||||||
|
[ -f "$auth_file" ] || continue
|
||||||
|
if [ "$(head -c 2 "$auth_file")" != '#!' ]; then
|
||||||
|
write_secret "$auth_file" "$(pepper_hash "$(head -n 1 "$auth_file")")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# $1: user id
|
||||||
|
valid_id() {
|
||||||
|
[[ "$1" =~ ^[a-z0-9]{4,24}$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
valid_token() {
|
||||||
|
[[ "$token" =~ ^[a-f0-9]{64}$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
token_hash() {
|
||||||
|
pepper_hash "$(printf '%s' "$token" | sha256)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: user id
|
||||||
|
has_password() {
|
||||||
|
[ -s "$auth_dir/$1" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: user id
|
||||||
|
password_correct() {
|
||||||
|
valid_token && has_password "$1" &&
|
||||||
|
[ "$(read_secret "$auth_dir/$1")" == "$(token_hash)" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# One-off move of the original single-person data into Alysia's profile
|
||||||
|
if [ -s "$legacy_file" ] && [ ! -e "$users_dir/alysia.json" ] &&
|
||||||
|
[ "$(head -c 1 "$legacy_file")" == '{' ] && [ "$(cat "$legacy_file")" != '{}' ]
|
||||||
|
then
|
||||||
|
migrate_tmp="$(mktemp "$data_dir/tmp.XXXXXX")"
|
||||||
|
{ printf '{"name":"Alysia",'; tail -c +2 "$legacy_file"; } > "$migrate_tmp"
|
||||||
|
mv "$migrate_tmp" "$users_dir/alysia.json"
|
||||||
|
mv "$legacy_file" "$backups_dir/original-climbing-data.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
get '/' && {
|
||||||
|
set_header 'Cache-Control' 'no-store'
|
||||||
|
if has_query 'check'; then
|
||||||
|
check_id="$(query 'check')"
|
||||||
|
ok='false'
|
||||||
|
has='false'
|
||||||
|
if valid_id "$check_id"; then
|
||||||
|
has_password "$check_id" && has='true'
|
||||||
|
password_correct "$check_id" && ok='true'
|
||||||
|
fi
|
||||||
|
printf '{"ok":%s,"hasPassword":%s}' "$ok" "$has" | send_json
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf '{'
|
||||||
|
separator=''
|
||||||
|
for user_file in "$users_dir"/*.json; do
|
||||||
|
[ -s "$user_file" ] || continue
|
||||||
|
user_id="$(basename "$user_file" .json)"
|
||||||
|
[[ "$user_id" =~ ^[a-z0-9]+$ ]] || continue
|
||||||
|
printf '%s"%s":' "$separator" "$user_id"
|
||||||
|
cat "$user_file"
|
||||||
|
separator=','
|
||||||
|
done
|
||||||
|
printf '}'
|
||||||
|
} | send_json
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
put '/' && {
|
||||||
|
user_id="$(query 'user')"
|
||||||
|
tmp_file="$(mktemp "$data_dir/tmp.XXXXXX")"
|
||||||
|
cat > "$tmp_file"
|
||||||
|
|
||||||
|
# n0m only passes the body through for valid JSON requests, so this is just
|
||||||
|
# a sanity check that we aren't about to save something empty or truncated
|
||||||
|
first_char="$(head -c 1 "$tmp_file")"
|
||||||
|
last_char="$(tail -c 1 "$tmp_file")"
|
||||||
|
if ! valid_id "$user_id" ||
|
||||||
|
[ "$first_char" != '{' ] || [ "$last_char" != '}' ]
|
||||||
|
then
|
||||||
|
rm -f "$tmp_file"
|
||||||
|
status '400'
|
||||||
|
printf '{"ok":false}' | send_json
|
||||||
|
elif has_query 'photo'; then
|
||||||
|
photo_id="$(query 'photo')"
|
||||||
|
photo_file="$photos_dir/$user_id-$photo_id.jpg"
|
||||||
|
photo_tmp="$(mktemp "$data_dir/tmp.XXXXXX")"
|
||||||
|
sed -n 's/^{"photo":"\([A-Za-z0-9+\/=]*\)"}$/\1/p' "$tmp_file" |
|
||||||
|
base64 -d > "$photo_tmp" 2>/dev/null
|
||||||
|
photo_start="$(head -c 3 "$photo_tmp" | od -An -tx1 | tr -d ' \n')"
|
||||||
|
photo_bytes="$(wc -c < "$photo_tmp")"
|
||||||
|
|
||||||
|
if ! valid_id "$photo_id"; then
|
||||||
|
status '400'
|
||||||
|
printf '{"ok":false}' | send_json
|
||||||
|
elif ! password_correct "$user_id"; then
|
||||||
|
status '403'
|
||||||
|
printf '{"ok":false,"auth":false}' | send_json
|
||||||
|
elif [ "$(cat "$tmp_file")" == '{"photo":""}' ]; then
|
||||||
|
rm -f "$photo_file"
|
||||||
|
printf '{"ok":true}' | send_json
|
||||||
|
# Only real JPEG files (they all start with the bytes FF D8 FF) are kept
|
||||||
|
elif [ "$photo_start" == 'ffd8ff' ] && [ "$photo_bytes" -le "$max_photo_bytes" ]
|
||||||
|
then
|
||||||
|
chmod 644 "$photo_tmp"
|
||||||
|
mv "$photo_tmp" "$photo_file"
|
||||||
|
printf '{"ok":true}' | send_json
|
||||||
|
else
|
||||||
|
status '400'
|
||||||
|
printf '{"ok":false}' | send_json
|
||||||
|
fi
|
||||||
|
rm -f "$tmp_file" "$photo_tmp"
|
||||||
|
elif ! valid_token || { has_password "$user_id" && ! password_correct "$user_id"; }
|
||||||
|
then
|
||||||
|
rm -f "$tmp_file"
|
||||||
|
status '403'
|
||||||
|
printf '{"ok":false,"auth":false}' | send_json
|
||||||
|
else
|
||||||
|
# A profile without a password yet is claimed by the first save
|
||||||
|
if ! has_password "$user_id"; then
|
||||||
|
write_secret "$auth_dir/$user_id" "$(token_hash)"
|
||||||
|
fi
|
||||||
|
user_file="$users_dir/$user_id.json"
|
||||||
|
# Keep one backup per person per day: their data before that day's first save
|
||||||
|
backup_file="$backups_dir/$user_id-$(date +'%Y%m%d').json"
|
||||||
|
if [ -s "$user_file" ] && [ ! -e "$backup_file" ]; then
|
||||||
|
cp "$user_file" "$backup_file"
|
||||||
|
fi
|
||||||
|
mv "$tmp_file" "$user_file"
|
||||||
|
printf '{"ok":true}' | send_json
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(use || use_error) && {
|
||||||
|
status '404'
|
||||||
|
printf '{"ok":false}' | send_json
|
||||||
|
}
|
||||||
570
cgi/exprash.sh
Normal file
570
cgi/exprash.sh
Normal file
@ -0,0 +1,570 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# shellcheck disable=SC2034 # false flags nameref params
|
||||||
|
# shellcheck disable=SC2178 # false flags nameref params
|
||||||
|
|
||||||
|
# ======================
|
||||||
|
# Required shell options
|
||||||
|
# ======================
|
||||||
|
|
||||||
|
# Necessary for piping to "send" funciton
|
||||||
|
shopt -s lastpipe
|
||||||
|
|
||||||
|
# ===============
|
||||||
|
# Setup Functions
|
||||||
|
# ===============
|
||||||
|
|
||||||
|
# $1: Log file for redirecting stdout to
|
||||||
|
function redirect_stdout() {
|
||||||
|
local output="$1";
|
||||||
|
[ -z "$output" ] && output="/dev/null";
|
||||||
|
|
||||||
|
exec 5<&1;
|
||||||
|
_exprash_redirect_stdout="$output";
|
||||||
|
exec 1>>"$_exprash_redirect_stdout";
|
||||||
|
printf '%s: %s\n' "${REQUEST_METHOD:-UNKNOWN}" "${PATH_INFO:-/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# Route Function
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function get() {
|
||||||
|
[ "$REQUEST_METHOD" != "GET" ] && return 1;
|
||||||
|
all "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function post() {
|
||||||
|
[ "$REQUEST_METHOD" != "POST" ] && return 1;
|
||||||
|
all "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function put() {
|
||||||
|
[ "$REQUEST_METHOD" != "PUT" ] && return 1;
|
||||||
|
all "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function delete() {
|
||||||
|
[ "$REQUEST_METHOD" != "DELETE" ] && return 1;
|
||||||
|
all "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function all() {
|
||||||
|
[ "$_exprash_route_handled" -eq 1 ] && return 1;
|
||||||
|
[ -n "$_exprash_error_message" ] && return 1;
|
||||||
|
|
||||||
|
# Reset params
|
||||||
|
_exprash_params=();
|
||||||
|
|
||||||
|
_path_match "$1" _exprash_params || return 1;
|
||||||
|
_exprash_route_handled=1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function use() {
|
||||||
|
[ "$_exprash_route_handled" -eq 1 ] && return 1;
|
||||||
|
[ -n "$_exprash_error_message" ] && return 1;
|
||||||
|
|
||||||
|
_exprash_route_handled=1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# =====================
|
||||||
|
# Error Route Functions
|
||||||
|
# =====================
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function get_error() {
|
||||||
|
[ "$REQUEST_METHOD" != "GET" ] && return 1;
|
||||||
|
all_error "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function post_error() {
|
||||||
|
[ "$REQUEST_METHOD" != "POST" ] && return 1;
|
||||||
|
all_error "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function put_error() {
|
||||||
|
[ "$REQUEST_METHOD" != "PUT" ] && return 1;
|
||||||
|
all_error "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function delete_error() {
|
||||||
|
[ "$REQUEST_METHOD" != "DELETE" ] && return 1;
|
||||||
|
all_error "$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
function all_error() {
|
||||||
|
[ "$_exprash_route_handled" -eq 1 ] && return 1;
|
||||||
|
[ -z "$_exprash_error_message" ] && return 1;
|
||||||
|
|
||||||
|
# Reset params
|
||||||
|
_exprash_params=();
|
||||||
|
|
||||||
|
_path_match "$1" _exprash_params || return 1;
|
||||||
|
_exprash_route_handled=1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function use_error() {
|
||||||
|
[ "$_exprash_route_handled" -eq 1 ] && return 1;
|
||||||
|
[ -z "$_exprash_error_message" ] && return 1;
|
||||||
|
|
||||||
|
_exprash_route_handled=1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ====
|
||||||
|
# Next
|
||||||
|
# ====
|
||||||
|
|
||||||
|
# $1 (optional): error message
|
||||||
|
function next() {
|
||||||
|
_exprash_route_handled=0;
|
||||||
|
[ -n "$1" ] && _exprash_error_message="$1";
|
||||||
|
}
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# App Functions
|
||||||
|
# =============
|
||||||
|
|
||||||
|
function get_error_message() {
|
||||||
|
printf '%s' "$_exprash_error_message";
|
||||||
|
}
|
||||||
|
|
||||||
|
function has_error_message() {
|
||||||
|
[ -n "$_exprash_error_message" ];
|
||||||
|
}
|
||||||
|
|
||||||
|
# =================
|
||||||
|
# Request Functions
|
||||||
|
# =================
|
||||||
|
|
||||||
|
# $1: param name
|
||||||
|
function param() {
|
||||||
|
printf '%s\n' "${_exprash_params[$1]}";
|
||||||
|
}
|
||||||
|
|
||||||
|
function has_param() {
|
||||||
|
[[ -v "_exprash_params[$1]" ]];
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: key
|
||||||
|
# $2: (optional) index for accessing array parameters
|
||||||
|
function query() {
|
||||||
|
_multi_get _exprash_query "$1" "$2"
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
function has_query() {
|
||||||
|
_multi_has _exprash_query "$1"
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
function len_query() {
|
||||||
|
_multi_len _exprash_query "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Call this function to parse URLencoded request bodies
|
||||||
|
function use_body() {
|
||||||
|
if [[ "${HTTP_CONTENT_TYPE,,}" == "application/x-www-form-urlencoded" ]];
|
||||||
|
then
|
||||||
|
_parse_url_encoded _exprash_body
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
# $2: (optional) index for accessing array parameters
|
||||||
|
function body() {
|
||||||
|
_multi_get _exprash_body "$1" "$2"
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
function has_body() {
|
||||||
|
_multi_has _exprash_body "$1"
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
function len_body() {
|
||||||
|
_multi_len _exprash_body "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: key
|
||||||
|
function cookie() {
|
||||||
|
printf '%s' "${_exprash_cookies[$1]}"
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
function has_cookie() {
|
||||||
|
[[ -v "_exprash_cookies[$1]" ]]
|
||||||
|
}
|
||||||
|
# $1: key
|
||||||
|
# $2: value
|
||||||
|
function set_cookie() {
|
||||||
|
_exprash_set_cookies["$1"]="$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==================
|
||||||
|
# Response Functions
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
function send() {
|
||||||
|
if [ "$_exprash_headers_sent" -eq 0 ]; then
|
||||||
|
send_headers
|
||||||
|
_exprash_headers_sent=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_send_raw
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_json() {
|
||||||
|
set_header 'Content-Type' 'application/json'
|
||||||
|
send
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: Path
|
||||||
|
function redirect() {
|
||||||
|
local path="$1"
|
||||||
|
if [ "$path" == 'back' ]; then
|
||||||
|
path="${HTTP_REFERER:-/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
status '302'
|
||||||
|
set_header 'Location' "$path"
|
||||||
|
printf 'Redirecting to: %s' "$path" | send
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: satus code
|
||||||
|
function status() {
|
||||||
|
set_header "Status" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: Header Name
|
||||||
|
# $2: Header Value
|
||||||
|
function set_header() {
|
||||||
|
_exprash_headers["$1"]="$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_headers() {
|
||||||
|
printf '%s\n' "Content-Type: ${_exprash_headers['Content-Type']}" | \
|
||||||
|
_send_raw
|
||||||
|
for key in "${!_exprash_headers[@]}"; do
|
||||||
|
[ "$key" == 'Content-Type' ] && continue
|
||||||
|
printf '%s\n' "${key}: ${_exprash_headers[$key]}" | \
|
||||||
|
_send_raw
|
||||||
|
done;
|
||||||
|
for key in "${!_exprash_set_cookies[@]}"; do
|
||||||
|
printf '%s\n' "Set-Cookie: ${key}=${_exprash_set_cookies[$key]}" | \
|
||||||
|
_send_raw
|
||||||
|
done;
|
||||||
|
printf '\n' | _send_raw
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# =======
|
||||||
|
# Session
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# Call this function to automatically manage sessions
|
||||||
|
# $1: (optional) session dir, defaults to "session" in the current directory
|
||||||
|
function use_session() {
|
||||||
|
local session_dir=$1
|
||||||
|
|
||||||
|
# Create default session directory
|
||||||
|
if [ -z "$session_dir" ]; then
|
||||||
|
session_dir="./session"
|
||||||
|
mkdir -p "$session_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup session globals
|
||||||
|
_exprash_use_session=1
|
||||||
|
_exprash_session_dir=$session_dir
|
||||||
|
|
||||||
|
_load_session || _create_session || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set a session variable
|
||||||
|
# $1: variable name
|
||||||
|
# $2: (optional) vairable value
|
||||||
|
function session() {
|
||||||
|
local name="$1"
|
||||||
|
if [[ -v 2 ]]; then
|
||||||
|
local value="$2"
|
||||||
|
_exprash_session["$name"]="$value"
|
||||||
|
else
|
||||||
|
printf '%s' "${_exprash_session["$name"]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# =========
|
||||||
|
# Internals
|
||||||
|
# =========
|
||||||
|
|
||||||
|
function _send_raw() {
|
||||||
|
[ -n "$_exprash_redirect_stdout" ] && exec >&5;
|
||||||
|
cat;
|
||||||
|
[ -n "$_exprash_redirect_stdout" ] && exec 1>>"$_exprash_redirect_stdout";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: path
|
||||||
|
# $2: (nameref) array
|
||||||
|
function _path_to_array() {
|
||||||
|
readarray -t "$2" < <(printf '%s\n' "$1" | tr '/' '\n' | grep .);
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: route
|
||||||
|
# $2: (nameref) associative array for params
|
||||||
|
function _path_match() {
|
||||||
|
[ -z ${PATH_INFO+x} ] && return 1;
|
||||||
|
[ -z ${1+x} ] && return 1;
|
||||||
|
|
||||||
|
local path="$PATH_INFO";
|
||||||
|
local route="$1";
|
||||||
|
|
||||||
|
# Params associative array
|
||||||
|
local -n route_params="$2";
|
||||||
|
|
||||||
|
local path_arr;
|
||||||
|
_path_to_array "$path" path_arr;
|
||||||
|
|
||||||
|
local route_arr;
|
||||||
|
_path_to_array "$route" route_arr;
|
||||||
|
|
||||||
|
# Get max path length
|
||||||
|
local route_len=${#route_arr[@]};
|
||||||
|
local path_len=${#path_arr[@]};
|
||||||
|
local maxLen=$(( route_len >= path_len ? route_len : path_len ));
|
||||||
|
|
||||||
|
for ((i=0; i<maxLen; i++)); do
|
||||||
|
local route_component="${route_arr[$i]}";
|
||||||
|
local path_component="${path_arr[$i]}";
|
||||||
|
|
||||||
|
# If route component starts with ":"
|
||||||
|
if [[ "$route_component" == :* ]] && [ -n "$path_component" ]; then
|
||||||
|
route_params["${route_component:1}"]="$path_component";
|
||||||
|
elif [[ "$route_component" == '*' ]] && [ -n "$path_component" ]; then
|
||||||
|
continue;
|
||||||
|
elif [[ "$route_component" == '**' ]] && [ -n "$path_component" ]; then
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
# Confirm paths match
|
||||||
|
[ "$route_component" != "$path_component" ] && return 1;
|
||||||
|
fi;
|
||||||
|
done;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==================================
|
||||||
|
# Multi-dimensional Parameter Arrays
|
||||||
|
# ==================================
|
||||||
|
|
||||||
|
# $1: (nameref) associative array
|
||||||
|
# $2: key
|
||||||
|
# $3: value
|
||||||
|
function _multi_add() {
|
||||||
|
local -n multi_arr="$1"
|
||||||
|
local key="$2"
|
||||||
|
local value="$3"
|
||||||
|
local i=0
|
||||||
|
while [[ -v "multi_arr[$i,$key]" ]]; do
|
||||||
|
(( i++ ))
|
||||||
|
done
|
||||||
|
multi_arr["$i,$key"]="$value"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: (nameref) associative array
|
||||||
|
# $2: key
|
||||||
|
function _multi_len() {
|
||||||
|
local -n multi_arr="$1"
|
||||||
|
local key="$2"
|
||||||
|
local i=0
|
||||||
|
while [[ -v "multi_arr[$i,$key]" ]]; do
|
||||||
|
(( i++ ))
|
||||||
|
done
|
||||||
|
printf '%s' "$i"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: (nameref) associative array
|
||||||
|
# $2: key
|
||||||
|
function _multi_has() {
|
||||||
|
local -n multi_arr="$1"
|
||||||
|
local key="$2"
|
||||||
|
[[ -v "multi_arr[0,$key]" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: (nameref) associative array
|
||||||
|
# $2: key
|
||||||
|
# $3: index
|
||||||
|
function _multi_get() {
|
||||||
|
local -n multi_arr="$1"
|
||||||
|
local key="$2"
|
||||||
|
local i="${3:-0}";
|
||||||
|
printf '%s' "${multi_arr[$i,$key]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==================
|
||||||
|
# URL Encoded Parser
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
# $1 | stdin: urlencoded string
|
||||||
|
decode_uri () {
|
||||||
|
local input_str="${1-"$(cat)"}"
|
||||||
|
input_str="${input_str//+/ }";
|
||||||
|
echo -e "${input_str//%/\\x}";
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: (nameref) multi associative array
|
||||||
|
# $2 | stdin: url encoded data
|
||||||
|
function _parse_url_encoded() {
|
||||||
|
local -n parsedArr="$1"
|
||||||
|
local url_encoded_str="${2-"$(cat)"}"
|
||||||
|
local pair name value
|
||||||
|
|
||||||
|
while IFS= read -d '&' -r pair || [ "$pair" ]; do
|
||||||
|
name=$(decode_uri "${pair%%=*}")
|
||||||
|
value=$(decode_uri "${pair#*=}")
|
||||||
|
if [ -n "$name" ]; then
|
||||||
|
_multi_add parsedArr "$name" "$value"
|
||||||
|
fi;
|
||||||
|
done <<< "$url_encoded_str"
|
||||||
|
}
|
||||||
|
|
||||||
|
# =======
|
||||||
|
# Cookies
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# $1: (nameref) associative array
|
||||||
|
# $2 | stdin: cookie string to parse
|
||||||
|
function _parse_cookies() {
|
||||||
|
local -n parsedArr="$1"
|
||||||
|
local cookie_str="${2-"$(< /dev/stdin)"}"
|
||||||
|
|
||||||
|
local pair name value
|
||||||
|
|
||||||
|
while IFS= read -d ';' -r pair || [ "$pair" ]; do
|
||||||
|
name="$(_trim "${pair%%=*}" | decode_uri)"
|
||||||
|
value="$(_trim "${pair#*=}" | decode_uri)"
|
||||||
|
if [ -n "$name" ]; then
|
||||||
|
parsedArr["$name"]="$value"
|
||||||
|
fi
|
||||||
|
done <<< "$cookie_str"
|
||||||
|
}
|
||||||
|
|
||||||
|
# =======
|
||||||
|
# Session
|
||||||
|
# =======
|
||||||
|
|
||||||
|
function _load_session() {
|
||||||
|
[ "$_exprash_use_session" -eq 1 ] || return 1
|
||||||
|
[ -n "$_exprash_session_dir" ] || return 1
|
||||||
|
has_cookie "$_exprash_session_cookie_name" || return 1
|
||||||
|
|
||||||
|
local session_id
|
||||||
|
session_id="$(cookie "$_exprash_session_cookie_name")"
|
||||||
|
local session_file="${_exprash_session_dir%/}/$session_id.session"
|
||||||
|
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$session_file" || return 1
|
||||||
|
|
||||||
|
# Set globals
|
||||||
|
_exprash_sessionId=$session_id
|
||||||
|
}
|
||||||
|
|
||||||
|
function _create_session() {
|
||||||
|
[ "$_exprash_use_session" -eq 1 ] || return 1
|
||||||
|
[ -n "$_exprash_session_dir" ] || return 1
|
||||||
|
|
||||||
|
# mktemp args
|
||||||
|
local args=()
|
||||||
|
args+=('-p' "$_exprash_session_dir")
|
||||||
|
args+=("$(printf 'X%.0s' {1..32}).session")
|
||||||
|
|
||||||
|
local session_file
|
||||||
|
session_file=$(mktemp -u "${args[@]}") || return 1
|
||||||
|
local session_file_name=${session_file##*/}
|
||||||
|
local session_id=${session_file_name%%.*}
|
||||||
|
|
||||||
|
# Set cookie
|
||||||
|
set_cookie "$_exprash_session_cookie_name" "$session_id"
|
||||||
|
|
||||||
|
# Set globals
|
||||||
|
_exprash_sessionId=$session_id
|
||||||
|
_exprash_session=()
|
||||||
|
}
|
||||||
|
|
||||||
|
function _save_session() {
|
||||||
|
[ "$_exprash_use_session" -eq 1 ] || return 1
|
||||||
|
[ -n "$_exprash_session_dir" ] || return 1
|
||||||
|
[ -n "$_exprash_sessionId" ] || return 1
|
||||||
|
|
||||||
|
local session_file="${_exprash_session_dir%/}/${_exprash_sessionId}.session"
|
||||||
|
|
||||||
|
declare -p _exprash_session | sed '1 s/\([^-]*-\)/\1g/' > "$session_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# =================
|
||||||
|
# Utility Functions
|
||||||
|
# =================
|
||||||
|
|
||||||
|
# $1 | stdin: string to trim
|
||||||
|
function _trim() {
|
||||||
|
local str="${1-"$(< /dev/stdin)"}"
|
||||||
|
|
||||||
|
# trim leading spaces
|
||||||
|
str="${str#"${str%%[![:space:]]*}"}"
|
||||||
|
# trim trailing spaces
|
||||||
|
str="${str%"${str##*[![:space:]]}"}"
|
||||||
|
|
||||||
|
printf '%s' "$str"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ========
|
||||||
|
# Shutdown
|
||||||
|
# ========
|
||||||
|
|
||||||
|
function _exprash_shutdown() {
|
||||||
|
_save_session
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==============
|
||||||
|
# Initialization
|
||||||
|
# ==============
|
||||||
|
function _exprash_init() {
|
||||||
|
_exprash_redirect_stdout=''
|
||||||
|
|
||||||
|
declare -gA _exprash_params=()
|
||||||
|
declare -gA _exprash_body=()
|
||||||
|
declare -gA _exprash_query=()
|
||||||
|
declare -gA _exprash_headers=()
|
||||||
|
declare -gA _exprash_cookies=()
|
||||||
|
declare -gA _exprash_set_cookies=()
|
||||||
|
|
||||||
|
_exprash_use_session=0
|
||||||
|
_exprash_session_dir=''
|
||||||
|
_exprash_sessionId=''
|
||||||
|
declare -gA _exprash_session=()
|
||||||
|
_exprash_session_cookie_name='exprash_session'
|
||||||
|
|
||||||
|
_exprash_route_handled=0
|
||||||
|
_exprash_error_message=''
|
||||||
|
_exprash_headers_sent=0
|
||||||
|
_exprash_headers['Content-Type']='text/html'
|
||||||
|
|
||||||
|
# Parse query string
|
||||||
|
_parse_url_encoded _exprash_query "$QUERY_STRING"
|
||||||
|
|
||||||
|
# Parse cookies
|
||||||
|
_parse_cookies _exprash_cookies "$HTTP_COOKIE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shutdown trap
|
||||||
|
trap _exprash_shutdown EXIT
|
||||||
|
|
||||||
|
# Initialize exprash
|
||||||
|
_exprash_init
|
||||||
|
|
||||||
16
index.html
Normal file
16
index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="theme-color" content="#2f6f5e" />
|
||||||
|
<link rel="manifest" href="manifest.webmanifest" />
|
||||||
|
<link rel="icon" href="icon.svg" type="image/svg+xml" />
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
|
||||||
|
<title>Climbing Tracker</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
882
package-lock.json
generated
Normal file
882
package-lock.json
generated
Normal file
@ -0,0 +1,882 @@
|
|||||||
|
{
|
||||||
|
"name": "climbing-tracker",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "climbing-tracker",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@vitejs/plugin-react": "^6.3.0",
|
||||||
|
"react": "^19.3.1",
|
||||||
|
"react-dom": "^19.3.1",
|
||||||
|
"vite": "^8.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@oxc-project/types": {
|
||||||
|
"version": "0.160.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.160.0.tgz",
|
||||||
|
"integrity": "sha512-gw4k9syEmnckbOgw2A2FU1TBDdX9hfwV9jEn/uio65pguPzwWiXQS3OIJDMEhv9m06tj9XiEe6RoD0YA+LgreA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/oxc-project"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-android-arm-eabi": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-xCW8CkL/ualx/SbYqeG9iK87lJCZGDQ0soE+kaORJ0Bd+pHALyE4qK7BStmEAyYWLEzZ3/biSIpA6/7GDFvzIg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-android-arm64": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-5lifIO+b/prcM9sx/bkPN4w6UEToEfQ3gjhx0+0neuL+dkYskI792CfAq03T51jc8JFcaYXs2hi3l8RjiH/VWQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-darwin-arm64": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-RCgxTI4AJQxhVF//BI3ImQOsXTHrF4Eg+f99jBy8WoETA2kSEGFxpnrVmW0leQq/2aBR4R5AC6csmy3rc66e3Q==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-darwin-x64": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-zNPJVVPUaDEj+L0lImoK3rFv2b+Z5gNijI6DWu/fcD3/1TfmRXKb9ZyxbSN+2AhlctqjbNzUvCsMa+EBhnEM4Q==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-freebsd-x64": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-upP6g7ZIRy5by1RDQ/EphHIdJ5xK0eUD7sUgfZFWJ49s4XdbYsIvIlAPtrFpayR70Hhf9J22lb4Pm8/9FhrZmg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-SAX5C5+poMLCxu8dkPF6h5yst40rkzs+9Y3cbPn2OFSydmHjAEprrGi64zGgnYyPIVZfdGUFqJ2fJbfbnHI+mA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-arm64-gnu": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-nwHqdlRZS6GWBef3dG5/pMY6RNTBBUjj7s0Da+m6xsFpe7jx6IC46SLZcCu8f46JOfCovZmwnrz51EzGE+7Fyw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-arm64-musl": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-Gr78X2ur/AgLCkmZgHffk/FerIX8S5zb/eII4bCcvJo0ANzeXhTShahdNbpnY6bpiszIAgIfiuKS9ziziWsamw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-o9Wcn8nWrsQasaBRYM4d//FwhlBsTJYWkPVlhlt6FwzpwEoovY4IopRZjk5Fq3+ntRuSDORJjF/nA8sFeF2q6w==",
|
||||||
|
"cpu": [
|
||||||
|
"ppc64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-s390x-gnu": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-UDWu4jkVcx2kiBKm3Ec//4lVCbeTWj8gmJ9SyLWCdLWtTlyq7fQVeVV/14nXvRtSLErvJ2+yA/Ux5taS31Y17Q==",
|
||||||
|
"cpu": [
|
||||||
|
"s390x"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-x64-gnu": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-W9mGtTa0w4fWh8RLMNPyaEhhcuqUfO07Q4I1bBc4PDMNg7gQSw0yPQNQ3D0qwbkXwxbyL4YrIzc8n6k1vuFExQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-linux-x64-musl": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-8B+ofyQZ7/aCmkqnyMonPr5zKLqMVNczhRGFNtdIuItiwNn8iQWJawMq2E58r7bxD1XEbtRRsULY/eCWwZQ01Q==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-openharmony-arm64": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-TlD0FSZaC7o2B4NCe9V5N11ugTnhzTM9ksj4sgRLvrKosDzjEkvlsTX3ehkw4ZlPv8AADimZZTvJGEa16pfXug==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"openharmony"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-wasm32-wasi": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-jwO8P3o53ygo7b5061B7BeaJ1BGv3BKZ6jroFdw/01qWry7Z+qNBlDvulzbTle5s/A0Fc1FRgsTxrke9DvsSbA==",
|
||||||
|
"cpu": [
|
||||||
|
"wasm32"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@oxc-project/types": "0.160.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.13.0 || >=23.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-win32-arm64-msvc": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-8adGMrNtrdzi2WD1ozhYapER59gD8Q/DV6SCKJlyG2HqULPdeQUBvMa33lTsiEYwIqTZUaIU2MmvPp5f1wbtXA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/binding-win32-x64-msvc": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-rIMjtESdXJCIoOiUTroQ1Y1rjVDZkuUVRUxs3APX2vNv175D7TDWvzdELiIhzGq9cUNUFat+co+PTmPHPqSREg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rolldown/pluginutils": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@vitejs/plugin-react": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-H9E955aVvD2F4zNHCw4eIZbIfF6xKldlh7MNu+hSU7xwQzh65lI/N+CJWqmfhi0PEjDXIt/H7T7J/4wU63KJiw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@rolldown/pluginutils": "^1.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@rolldown/plugin-babel": "^0.1.7 || ^0.2.0 || ^0.3.0",
|
||||||
|
"babel-plugin-react-compiler": "^1.0.0",
|
||||||
|
"oxc-transform-react": ">=0.152.0 <0.157.0",
|
||||||
|
"vite": "^8.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@rolldown/plugin-babel": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"babel-plugin-react-compiler": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"oxc-transform-react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/detect-libc": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fdir": {
|
||||||
|
"version": "6.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||||
|
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"picomatch": "^3 || ^4"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"picomatch": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fsevents": {
|
||||||
|
"version": "2.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
|
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"detect-libc": "^2.0.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"lightningcss-android-arm64": "1.33.0",
|
||||||
|
"lightningcss-darwin-arm64": "1.33.0",
|
||||||
|
"lightningcss-darwin-x64": "1.33.0",
|
||||||
|
"lightningcss-freebsd-x64": "1.33.0",
|
||||||
|
"lightningcss-linux-arm-gnueabihf": "1.33.0",
|
||||||
|
"lightningcss-linux-arm64-gnu": "1.33.0",
|
||||||
|
"lightningcss-linux-arm64-musl": "1.33.0",
|
||||||
|
"lightningcss-linux-x64-gnu": "1.33.0",
|
||||||
|
"lightningcss-linux-x64-musl": "1.33.0",
|
||||||
|
"lightningcss-win32-arm64-msvc": "1.33.0",
|
||||||
|
"lightningcss-win32-x64-msvc": "1.33.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-android-arm64": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-darwin-arm64": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-darwin-x64": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-freebsd-x64": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-linux-arm-gnueabihf": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-linux-arm64-gnu": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-linux-arm64-musl": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-linux-x64-gnu": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-linux-x64-musl": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-win32-arm64-msvc": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lightningcss-win32-x64-msvc": {
|
||||||
|
"version": "1.33.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
|
||||||
|
"integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/nanoid": {
|
||||||
|
"version": "3.3.20",
|
||||||
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
|
||||||
|
"integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"nanoid": "bin/nanoid.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/napi-windows-process-start-time": {
|
||||||
|
"version": "0.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/napi-windows-process-start-time/-/napi-windows-process-start-time-0.1.0.tgz",
|
||||||
|
"integrity": "sha512-zHxhzKsIFu3elch3eFw69WEUGc79DFhbc3nD/WEOzWL/pFFLZRW13EHnuO0c+0YjncE5uCaS9ICHxOBXkb6vPw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64",
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/picocolors": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/picomatch": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
|
||||||
|
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/postcss": {
|
||||||
|
"version": "8.5.34",
|
||||||
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.34.tgz",
|
||||||
|
"integrity": "sha512-P1Qzj0XXZjMda74C7qiVnBG90UKNbyNUAOeQRBW8X63RsIMV57gevRqjnkELdwtZ/S2/uQFksJhmwuN8xShLPw==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/postcss/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tidelift",
|
||||||
|
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"nanoid": "^3.3.20",
|
||||||
|
"picocolors": "^1.1.1",
|
||||||
|
"source-map-js": "^1.2.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^10 || ^12 || >=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/react": {
|
||||||
|
"version": "19.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz",
|
||||||
|
"integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/react-dom": {
|
||||||
|
"version": "19.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz",
|
||||||
|
"integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"scheduler": "^0.28.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rolldown": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-p2rq4bfBmF0M6yaR8+A89fbkBQynZI2fxUW4G07eq9kpctAkpo7q5BZ4X4Mo4XZ7HHROu33cX9PeopUFN6u+2Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@oxc-project/types": "=0.160.0",
|
||||||
|
"@rolldown/pluginutils": "^1.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"rolldown": "bin/cli.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@rolldown/binding-android-arm-eabi": "1.3.4",
|
||||||
|
"@rolldown/binding-android-arm64": "1.3.4",
|
||||||
|
"@rolldown/binding-darwin-arm64": "1.3.4",
|
||||||
|
"@rolldown/binding-darwin-x64": "1.3.4",
|
||||||
|
"@rolldown/binding-freebsd-x64": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-arm-gnueabihf": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-arm64-gnu": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-arm64-musl": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-ppc64-gnu": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-s390x-gnu": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-x64-gnu": "1.3.4",
|
||||||
|
"@rolldown/binding-linux-x64-musl": "1.3.4",
|
||||||
|
"@rolldown/binding-openharmony-arm64": "1.3.4",
|
||||||
|
"@rolldown/binding-wasm32-wasi": "1.3.4",
|
||||||
|
"@rolldown/binding-win32-arm64-msvc": "1.3.4",
|
||||||
|
"@rolldown/binding-win32-x64-msvc": "1.3.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/scheduler": {
|
||||||
|
"version": "0.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz",
|
||||||
|
"integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/source-map-js": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-pdUVfIWcK0kCgK831ibqkZDcL7I9zljjOu0TQFnA+fiQ6y1CYqYB7RkTOHHO45FGMg5P/Mvk/+4ToQ7gAYAL5Q==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tinyglobby": {
|
||||||
|
"version": "0.2.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
||||||
|
"integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fdir": "^6.5.0",
|
||||||
|
"picomatch": "^4.0.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vite": {
|
||||||
|
"version": "8.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/vite/-/vite-8.4.0.tgz",
|
||||||
|
"integrity": "sha512-X2nUJg+9cutlz3hzqyO6p+WTwk9H257DjwAEf9EQYUFrQbDItmetadi9gYmb+l7VDy4r3VXLUnmLTwuPmzejDw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"lightningcss": "^1.33.0",
|
||||||
|
"picomatch": "^4.0.7",
|
||||||
|
"postcss": "^8.5.33",
|
||||||
|
"rolldown": "~1.3.2",
|
||||||
|
"tinyglobby": "^0.2.17"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"vite": "bin/vite.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/vitejs/vite?sponsor=1"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "~2.3.3",
|
||||||
|
"napi-windows-process-start-time": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": "^20.19.0 || >=22.12.0",
|
||||||
|
"@vitejs/devtools": "^0.7.1 || ^0.8.0",
|
||||||
|
"esbuild": "^0.27.0 || ^0.28.0",
|
||||||
|
"jiti": ">=1.21.0",
|
||||||
|
"less": "^4.0.0",
|
||||||
|
"sass": "^1.70.0",
|
||||||
|
"sass-embedded": "^1.70.0",
|
||||||
|
"stylus": ">=0.54.8",
|
||||||
|
"sugarss": "^5.0.0",
|
||||||
|
"terser": "^5.16.0",
|
||||||
|
"tsx": "^4.8.1",
|
||||||
|
"yaml": "^2.4.2"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@vitejs/devtools": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"jiti": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"less": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"sass": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"sass-embedded": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"stylus": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"sugarss": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"terser": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"tsx": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"yaml": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "climbing-tracker",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.1.0",
|
||||||
|
"type": "module",
|
||||||
|
"config": {
|
||||||
|
"slug": "act"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vite build && cp cgi/api.sh cgi/exprash.sh dist/ && chmod 755 dist/api.sh",
|
||||||
|
"upload": "npm run build && rsync -avH --exclude 'data/' -e 'ssh -p 24' ./dist/ \"ben@n0m.org:/home/ben/n0m/current/files/$npm_package_config_slug/\""
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@vitejs/plugin-react": "^6.3.0",
|
||||||
|
"react": "^19.3.1",
|
||||||
|
"react-dom": "^19.3.1",
|
||||||
|
"vite": "^8.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
public/apple-touch-icon.png
Normal file
BIN
public/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
public/icon-192.png
Normal file
BIN
public/icon-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
public/icon-512.png
Normal file
BIN
public/icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
6
public/icon.svg
Normal file
6
public/icon.svg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||||
|
<rect width="512" height="512" fill="#2f6f5e"/>
|
||||||
|
<path d="M96 372 L216 188 L272 268 L312 212 L416 372 Z" fill="#f6f4ef"/>
|
||||||
|
<path d="M216 188 L184 237 L206 228 L222 246 L242 225 Z" fill="#2f6f5e" opacity="0.35"/>
|
||||||
|
<circle cx="356" cy="150" r="26" fill="#f2c14e"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 338 B |
15
public/manifest.webmanifest
Normal file
15
public/manifest.webmanifest
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "Climbing Tracker",
|
||||||
|
"short_name": "Climbing",
|
||||||
|
"description": "Log climbs, see progress and plan sessions",
|
||||||
|
"start_url": "./",
|
||||||
|
"scope": "./",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#f6f4ef",
|
||||||
|
"theme_color": "#2f6f5e",
|
||||||
|
"icons": [
|
||||||
|
{ "src": "icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
||||||
|
]
|
||||||
|
}
|
||||||
931
src/App.jsx
Normal file
931
src/App.jsx
Normal file
@ -0,0 +1,931 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
// ---------- Settings you can easily change ----------
|
||||||
|
const GRADES = ['VB', 'V0', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12']
|
||||||
|
const STYLES = ['Slab', 'Vertical', 'Overhang', 'Roof', 'Other']
|
||||||
|
// Hold colours you can pick for a climb, and the shade used for the little dot
|
||||||
|
const COLOURS = {
|
||||||
|
Red: '#d64545', Orange: '#e8862e', Yellow: '#e9c935', Green: '#3f9b57', Blue: '#3a7bd5', Purple: '#8457c2',
|
||||||
|
Pink: '#e57fb0', Black: '#222222', White: '#ffffff', Grey: '#8d9299', Brown: '#8a5a3c',
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Date helpers ----------
|
||||||
|
const pad = (n) => String(n).padStart(2, '0')
|
||||||
|
const toStr = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||||
|
const today = () => toStr(new Date())
|
||||||
|
const parse = (s) => { const [y, m, d] = s.split('-').map(Number); return new Date(y, m - 1, d) }
|
||||||
|
const dayIndex = (s) => (parse(s).getDay() + 6) % 7 // 0 = Monday
|
||||||
|
const weekStart = (s) => { const d = parse(s); d.setDate(d.getDate() - dayIndex(s)); return toStr(d) }
|
||||||
|
const niceDate = (s) => parse(s).toLocaleDateString(undefined, { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' })
|
||||||
|
const newId = () => Date.now().toString(36) + Math.random().toString(36).slice(2, 6)
|
||||||
|
|
||||||
|
const EMPTY = { climbs: [], goals: [], planChecks: {}, sessions: [], rsvps: {}, groupItems: [], seenSessions: [] }
|
||||||
|
|
||||||
|
const LOGIN_KEY = 'climbing-tracker-login'
|
||||||
|
const TAB_KEY = 'climbing-tracker-tab'
|
||||||
|
const TABS = [['log', 'Log a climb'], ['sessions', 'Sessions'], ['progress', 'Progress'], ['goals', 'Goals'], ['friends', 'Friends']]
|
||||||
|
const MIN_PASSWORD = 4
|
||||||
|
const withDefaults = (p) => ({ ...EMPTY, ...p, name: p.name || 'Unnamed' })
|
||||||
|
|
||||||
|
// The password itself never leaves this device. What gets sent (and remembered
|
||||||
|
// here so you stay signed in) is a scrambled version of it.
|
||||||
|
async function makeToken(id, password) {
|
||||||
|
const bytes = new TextEncoder().encode(`climbing-tracker:${id}:${password}`)
|
||||||
|
const hash = await crypto.subtle.digest('SHA-256', bytes)
|
||||||
|
return [...new Uint8Array(hash)].map((b) => b.toString(16).padStart(2, '0')).join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Photos are shrunk on your device before they are sent, so they upload quickly
|
||||||
|
// and stay under the website's size limit (about 64 KB each)
|
||||||
|
const MAX_PHOTO_BYTES = 64000
|
||||||
|
const photoUrl = (owner, photoId) => `data/photos/${owner}-${photoId}.jpg`
|
||||||
|
|
||||||
|
async function compressPhoto(file) {
|
||||||
|
const img = new Image()
|
||||||
|
const url = URL.createObjectURL(file)
|
||||||
|
try {
|
||||||
|
await new Promise((resolve, reject) => { img.onload = resolve; img.onerror = reject; img.src = url })
|
||||||
|
// Try big and sharp first, then step down until the photo is small enough
|
||||||
|
for (const longest of [1280, 1024, 800, 640, 480, 320]) {
|
||||||
|
const scale = Math.min(1, longest / Math.max(img.naturalWidth, img.naturalHeight))
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
canvas.width = Math.round(img.naturalWidth * scale)
|
||||||
|
canvas.height = Math.round(img.naturalHeight * scale)
|
||||||
|
canvas.getContext('2d').drawImage(img, 0, 0, canvas.width, canvas.height)
|
||||||
|
for (const quality of [0.8, 0.65, 0.5, 0.4]) {
|
||||||
|
const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/jpeg', quality))
|
||||||
|
if (blob && blob.size <= MAX_PHOTO_BYTES) return blob
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error('Photo could not be made small enough')
|
||||||
|
} finally {
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toBase64 = (blob) => new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = () => resolve(reader.result.split(',')[1])
|
||||||
|
reader.onerror = reject
|
||||||
|
reader.readAsDataURL(blob)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Talks to the saved data. query is e.g. '' or '?user=abc'
|
||||||
|
function api(query, token, body) {
|
||||||
|
const headers = {}
|
||||||
|
if (token) headers['X-Auth'] = token
|
||||||
|
if (body) headers['Content-Type'] = 'application/json'
|
||||||
|
return fetch(`api.sh${query}`, { method: body ? 'PUT' : 'GET', cache: 'no-store', headers, body }).then((r) => r.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const [all, setAll] = useState(null) // everyone's data, by profile id
|
||||||
|
const [login, setLogin] = useState(() => {
|
||||||
|
try { return JSON.parse(localStorage.getItem(LOGIN_KEY)) } catch { return null }
|
||||||
|
})
|
||||||
|
// The tab you were last on is remembered on this device, so a refresh keeps you there
|
||||||
|
const [tab, setTabState] = useState(() => {
|
||||||
|
const saved = localStorage.getItem(TAB_KEY)
|
||||||
|
return TABS.some(([k]) => k === saved) ? saved : 'log'
|
||||||
|
})
|
||||||
|
const setTab = (k) => { localStorage.setItem(TAB_KEY, k); setTabState(k) }
|
||||||
|
const [saveError, setSaveError] = useState(false)
|
||||||
|
const [notice, setNotice] = useState('')
|
||||||
|
|
||||||
|
const load = () => api('').then((d) => { if (d.ok === false) throw new Error(); setAll(d); setSaveError(false) })
|
||||||
|
.catch(() => setSaveError(true))
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load()
|
||||||
|
// Reload when coming back to the page, and every minute while it's open,
|
||||||
|
// so everyone's climbs and new sessions show up without refreshing
|
||||||
|
const onVisible = () => { if (document.visibilityState === 'visible') load() }
|
||||||
|
document.addEventListener('visibilitychange', onVisible)
|
||||||
|
const timer = setInterval(onVisible, 60000)
|
||||||
|
return () => { document.removeEventListener('visibilitychange', onVisible); clearInterval(timer) }
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const logIn = (id, token) => {
|
||||||
|
localStorage.setItem(LOGIN_KEY, JSON.stringify({ id, token }))
|
||||||
|
setLogin({ id, token }); setNotice('')
|
||||||
|
}
|
||||||
|
const logOut = (message = '') => { localStorage.removeItem(LOGIN_KEY); setLogin(null); setNotice(message) }
|
||||||
|
|
||||||
|
// Saves one person's profile. The server refuses it unless the password matches.
|
||||||
|
const save = (id, person, token) => {
|
||||||
|
setAll((a) => ({ ...a, [id]: person }))
|
||||||
|
return api(`?user=${id}`, token, JSON.stringify(person))
|
||||||
|
.then((r) => {
|
||||||
|
if (r.auth === false) { logOut('That password was not accepted. Please sign in again.'); load() } else setSaveError(!r.ok)
|
||||||
|
return r
|
||||||
|
})
|
||||||
|
.catch(() => { setSaveError(true); return { ok: false } })
|
||||||
|
}
|
||||||
|
|
||||||
|
const me = login?.id
|
||||||
|
const data = all && login?.token && all[me] ? withDefaults(all[me]) : null
|
||||||
|
// Only ever saves your own profile, never anyone else's
|
||||||
|
const update = (changes) => save(me, { ...data, ...changes }, login.token)
|
||||||
|
|
||||||
|
// New sessions: upcoming ones someone else added that you haven't looked at or answered yet
|
||||||
|
const [fresh, setFresh] = useState([]) // shown with a "New" tag for the rest of this visit
|
||||||
|
const sessionList = data ? allSessions(all) : []
|
||||||
|
const unseen = data ? sessionList.filter((s) => s.date >= today() && s.owner !== me && !data.rsvps[s.id] && !data.seenSessions.includes(s.id)) : []
|
||||||
|
useEffect(() => {
|
||||||
|
// Opening the Sessions tab counts as having seen them
|
||||||
|
if (tab !== 'sessions' || unseen.length === 0) return
|
||||||
|
const ids = unseen.map((s) => s.id)
|
||||||
|
setFresh((f) => [...f, ...ids])
|
||||||
|
update({ seenSessions: [...data.seenSessions.filter((id) => sessionList.some((s) => s.id === id)), ...ids] })
|
||||||
|
}, [tab, unseen.length])
|
||||||
|
|
||||||
|
const photos = {
|
||||||
|
upload: async (photoId, blob) => api(`?user=${me}&photo=${photoId}`, login.token, JSON.stringify({ photo: await toBase64(blob) })).catch(() => ({ ok: false })),
|
||||||
|
remove: (photoId) => api(`?user=${me}&photo=${photoId}`, login.token, JSON.stringify({ photo: '' })).catch(() => ({ ok: false })),
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="app">
|
||||||
|
<header>
|
||||||
|
<h1>🧗 Climbing Tracker</h1>
|
||||||
|
{data && (
|
||||||
|
<>
|
||||||
|
<p className="whoami muted">Climbing as <strong>{data.name}</strong> · <button className="link" onClick={() => logOut()}>sign out</button></p>
|
||||||
|
<nav>
|
||||||
|
{TABS.map(([k, label]) => (
|
||||||
|
<button key={k} className={tab === k ? 'tab active' : 'tab'} onClick={() => setTab(k)}>{label}{k === 'sessions' && unseen.length > 0 && <span className="badge">{unseen.length}</span>}</button>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</header>
|
||||||
|
{saveError && <p className="error">Couldn't reach your saved data, so recent changes may not be saved. Try refreshing the page.</p>}
|
||||||
|
{data && tab !== 'sessions' && unseen.length > 0 && (
|
||||||
|
<div className="notice">
|
||||||
|
<div>
|
||||||
|
<strong>🔔 {unseen.length === 1 ? 'New session' : `${unseen.length} new sessions`}</strong>
|
||||||
|
{unseen.map((s) => <p className="line" key={s.id}>{sessionWhen(s)}{s.gym && ` · ${s.gym}`} <span className="muted">· added by {s.ownerName}</span></p>)}
|
||||||
|
</div>
|
||||||
|
<button className="primary" onClick={() => setTab('sessions')}>View</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!all ? (!saveError && <p>Loading…</p>) : !data ? <Welcome all={all} notice={notice} logIn={logIn} save={save} /> : (
|
||||||
|
<main>
|
||||||
|
{tab === 'log' && <Log data={data} all={all} me={me} update={update} photos={photos} />}
|
||||||
|
{tab === 'sessions' && <Sessions all={all} me={me} data={data} update={update} fresh={fresh} />}
|
||||||
|
{tab === 'progress' && <Progress data={data} />}
|
||||||
|
{tab === 'goals' && <Goals data={data} update={update} />}
|
||||||
|
{tab === 'friends' && <Friends all={all} me={me} />}
|
||||||
|
</main>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Welcome screen (sign in or create a profile) ----------
|
||||||
|
function Welcome({ all, notice, logIn, save }) {
|
||||||
|
const [picked, setPicked] = useState(null) // { id, hasPassword }
|
||||||
|
const [name, setName] = useState('')
|
||||||
|
const [password, setPassword] = useState('')
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
|
||||||
|
const people = Object.entries(all).map(([id, p]) => [id, withDefaults(p)]).sort((a, b) => a[1].name.localeCompare(b[1].name))
|
||||||
|
const taken = people.some(([, p]) => p.name.toLowerCase() === name.trim().toLowerCase())
|
||||||
|
const tooShort = password.length < MIN_PASSWORD
|
||||||
|
|
||||||
|
const pick = async (id) => {
|
||||||
|
setError(''); setPassword('')
|
||||||
|
const r = await api(`?check=${id}`).catch(() => null)
|
||||||
|
if (!r) return setError("Couldn't reach the saved data. Please try again.")
|
||||||
|
setPicked({ id, hasPassword: r.hasPassword })
|
||||||
|
}
|
||||||
|
const back = () => { setPicked(null); setPassword(''); setError('') }
|
||||||
|
|
||||||
|
const signIn = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (tooShort) return setError(`Passwords have at least ${MIN_PASSWORD} characters.`)
|
||||||
|
setBusy(true); setError('')
|
||||||
|
const token = await makeToken(picked.id, password)
|
||||||
|
// A profile with no password yet gets this one, by saving it once
|
||||||
|
const r = picked.hasPassword
|
||||||
|
? await api(`?check=${picked.id}`, token).catch(() => ({}))
|
||||||
|
: await save(picked.id, all[picked.id], token)
|
||||||
|
setBusy(false)
|
||||||
|
if (r.ok) logIn(picked.id, token)
|
||||||
|
else setError(picked.hasPassword ? "That password isn't right. Please try again." : "Couldn't set the password. Please try again.")
|
||||||
|
}
|
||||||
|
|
||||||
|
const create = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!name.trim() || taken) return
|
||||||
|
if (tooShort) return setError(`Choose a password with at least ${MIN_PASSWORD} characters.`)
|
||||||
|
setBusy(true); setError('')
|
||||||
|
const id = newId()
|
||||||
|
const token = await makeToken(id, password)
|
||||||
|
const r = await save(id, { name: name.trim(), ...EMPTY }, token)
|
||||||
|
setBusy(false)
|
||||||
|
if (r.ok) logIn(id, token)
|
||||||
|
else setError("Couldn't create your profile. Please try again.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (picked) {
|
||||||
|
const person = withDefaults(all[picked.id] || {})
|
||||||
|
return (
|
||||||
|
<div className="card">
|
||||||
|
<h2>Hi {person.name}!</h2>
|
||||||
|
<form className="form goal-form" onSubmit={signIn}>
|
||||||
|
<label className="wide">{picked.hasPassword ? 'Enter your password' : 'This profile has no password yet. Choose one now'}
|
||||||
|
<input type="password" autoFocus value={password} autoComplete={picked.hasPassword ? 'current-password' : 'new-password'} onChange={(e) => setPassword(e.target.value)} />
|
||||||
|
</label>
|
||||||
|
{!picked.hasPassword && <p className="muted small">You'll need it to sign in on another phone or computer, so pick something you'll remember.</p>}
|
||||||
|
{error && <p className="form-error">{error}</p>}
|
||||||
|
<button className="primary" disabled={busy}>{picked.hasPassword ? 'Sign in' : 'Set password'}</button>
|
||||||
|
<button type="button" className="link" onClick={back}>Back</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card">
|
||||||
|
<h2>Who's climbing?</h2>
|
||||||
|
{notice && <p className="form-error">{notice}</p>}
|
||||||
|
{people.length > 0 && (
|
||||||
|
<>
|
||||||
|
<p className="muted">Tap your name if you've been here before.</p>
|
||||||
|
<div className="toggle">
|
||||||
|
{people.map(([id, p]) => <button key={id} className="pill" onClick={() => pick(id)}>{p.name}</button>)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<form className="form goal-form" onSubmit={create}>
|
||||||
|
<label>New here? Enter your name
|
||||||
|
<input value={name} maxLength={30} placeholder="Your name" autoComplete="off" onChange={(e) => setName(e.target.value)} />
|
||||||
|
</label>
|
||||||
|
<label>Choose a password
|
||||||
|
<input type="password" value={password} autoComplete="new-password" onChange={(e) => setPassword(e.target.value)} />
|
||||||
|
</label>
|
||||||
|
{taken && <p className="muted wide">That name is already taken. Tap it above, or pick a different one.</p>}
|
||||||
|
{error && <p className="form-error">{error}</p>}
|
||||||
|
<button className="primary" disabled={busy || !name.trim() || taken}>Start tracking</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Log tab ----------
|
||||||
|
// A drop-down whose options are shared by everyone, with a way to add a new one
|
||||||
|
function ListPicker({ value, onChange, options, noun }) {
|
||||||
|
const [adding, setAdding] = useState(false)
|
||||||
|
const list = [...options]
|
||||||
|
if (value && !adding && !list.includes(value)) list.push(value)
|
||||||
|
list.sort((x, y) => x.localeCompare(y))
|
||||||
|
if (adding || list.length === 0) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<input autoFocus={adding} value={value} maxLength={60} placeholder={`Name of the ${noun}`} onChange={(e) => onChange(e.target.value)} />
|
||||||
|
{list.length > 0 && <button type="button" className="link back-to-list" onClick={() => { setAdding(false); onChange('') }}>Back to the list</button>}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<select value={value} onChange={(e) => { if (e.target.value === '+new') { setAdding(true); onChange('') } else onChange(e.target.value) }}>
|
||||||
|
<option value="">Choose a {noun}…</option>
|
||||||
|
{list.map((o) => <option key={o}>{o}</option>)}
|
||||||
|
<option value="+new">+ Add a new {noun}…</option>
|
||||||
|
</select>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sameText = (x, y) => (x || '').trim().toLowerCase() === (y || '').trim().toLowerCase()
|
||||||
|
// Collects one field from everyone's climbs, without repeats
|
||||||
|
function sharedList(all, field, keep = () => true) {
|
||||||
|
const list = []
|
||||||
|
Object.values(all).forEach((p) => (p.climbs || []).forEach((c) => {
|
||||||
|
if (c[field] && keep(c) && !list.some((x) => sameText(x, c[field]))) list.push(c[field])
|
||||||
|
}))
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
// If a typed name is already on the list, use the list's spelling
|
||||||
|
const tidy = (list, name) => list.find((x) => sameText(x, name)) ?? name.trim()
|
||||||
|
|
||||||
|
const ColourDot = ({ colour }) => (COLOURS[colour] ? <span className="dot" style={{ background: COLOURS[colour] }} title={colour} /> : null)
|
||||||
|
|
||||||
|
// The description of one climb, used in your list and when viewing a friend
|
||||||
|
function ClimbInfo({ c }) {
|
||||||
|
return (
|
||||||
|
<div className="info">
|
||||||
|
<strong><ColourDot colour={c.colour} />{c.colour && `${c.colour} · `}{c.style} {c.sent ? '· ✅ Sent' : '· 🔁 Project'}</strong>
|
||||||
|
<span className="muted">{niceDate(c.date)}{c.gym && ` · ${c.gym}`}{c.wall && ` · ${c.wall}`}</span>
|
||||||
|
{c.notes && <span className="notes">{c.notes}</span>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A small picture of the climb; tap it to see it full size
|
||||||
|
function Photo({ owner, c }) {
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
if (!c.photo) return null
|
||||||
|
const src = photoUrl(owner, c.photo)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<img className="thumb" loading="lazy" src={src} alt="Photo of this climb" onClick={() => setOpen(true)} />
|
||||||
|
{open && <div className="lightbox" onClick={() => setOpen(false)}><img src={src} alt="Photo of this climb" /></div>}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Log({ data, all, me, update, photos }) {
|
||||||
|
const last = data.climbs[0]
|
||||||
|
const blank = () => ({ date: today(), grade: last?.grade ?? 2, style: 'Slab', colour: '', gym: last?.gym ?? '', wall: '', sent: true, notes: '', photo: '' })
|
||||||
|
const [form, setForm] = useState(blank)
|
||||||
|
const [newPhoto, setNewPhoto] = useState(null) // a photo just chosen: { blob, url }
|
||||||
|
const [photoBusy, setPhotoBusy] = useState(false)
|
||||||
|
const [photoError, setPhotoError] = useState('')
|
||||||
|
const [editingId, setEditingId] = useState(null)
|
||||||
|
const [formKey, setFormKey] = useState(0) // changing this resets the drop-downs
|
||||||
|
const set = (k, v) => setForm((f) => ({ ...f, [k]: v }))
|
||||||
|
|
||||||
|
// Shared lists: every gym anyone has climbed at, and every wall logged at the chosen gym
|
||||||
|
const gyms = sharedList(all, 'gym')
|
||||||
|
const walls = sharedList(all, 'wall', (c) => sameText(c.gym, form.gym))
|
||||||
|
|
||||||
|
const pickPhoto = async (e) => {
|
||||||
|
const file = e.target.files[0]
|
||||||
|
e.target.value = ''
|
||||||
|
if (!file) return
|
||||||
|
setPhotoError(''); setPhotoBusy(true)
|
||||||
|
try {
|
||||||
|
const blob = await compressPhoto(file)
|
||||||
|
setNewPhoto({ blob, url: URL.createObjectURL(blob) })
|
||||||
|
} catch {
|
||||||
|
setPhotoError("Couldn't read that photo. Please try a different one.")
|
||||||
|
}
|
||||||
|
setPhotoBusy(false)
|
||||||
|
}
|
||||||
|
const clearPhoto = () => { setNewPhoto(null); setPhotoError(''); set('photo', '') }
|
||||||
|
|
||||||
|
const add = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
if (photoBusy) return
|
||||||
|
const gym = tidy(gyms, form.gym)
|
||||||
|
const wall = tidy(walls, form.wall)
|
||||||
|
// Upload a newly chosen photo first, so a climb never points at a missing picture
|
||||||
|
const oldPhoto = editingId ? data.climbs.find((c) => c.id === editingId)?.photo : ''
|
||||||
|
let photo = form.photo
|
||||||
|
if (newPhoto) {
|
||||||
|
setPhotoBusy(true)
|
||||||
|
photo = newId()
|
||||||
|
const r = await photos.upload(photo, newPhoto.blob)
|
||||||
|
setPhotoBusy(false)
|
||||||
|
if (!r.ok) return setPhotoError("Couldn't upload the photo. Please try again, or remove it and save without one.")
|
||||||
|
}
|
||||||
|
const climb = { ...form, id: editingId ?? newId(), discipline: 'Bouldering', gym, wall, photo }
|
||||||
|
const others = data.climbs.filter((c) => c.id !== editingId)
|
||||||
|
const climbs = [climb, ...others].sort((a, b) => b.date.localeCompare(a.date))
|
||||||
|
update({ climbs })
|
||||||
|
setEditingId(null)
|
||||||
|
setFormKey((k) => k + 1)
|
||||||
|
setForm(editingId ? blank() : { ...form, gym, wall, colour: '', notes: '', photo: '' })
|
||||||
|
setNewPhoto(null); setPhotoError('')
|
||||||
|
if (oldPhoto && oldPhoto !== photo) photos.remove(oldPhoto)
|
||||||
|
}
|
||||||
|
const remove = (id) => {
|
||||||
|
if (!confirm('Delete this climb?')) return
|
||||||
|
const photo = data.climbs.find((c) => c.id === id)?.photo
|
||||||
|
update({ climbs: data.climbs.filter((c) => c.id !== id) })
|
||||||
|
if (photo) photos.remove(photo)
|
||||||
|
if (id === editingId) cancelEdit()
|
||||||
|
}
|
||||||
|
const edit = (c) => {
|
||||||
|
setEditingId(c.id)
|
||||||
|
setFormKey((k) => k + 1)
|
||||||
|
setForm({ date: c.date, grade: c.grade, style: c.style, colour: c.colour || '', gym: c.gym || '', wall: c.wall || '', sent: c.sent, notes: c.notes || '', photo: c.photo || '' })
|
||||||
|
setNewPhoto(null); setPhotoError('')
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
}
|
||||||
|
const cancelEdit = () => { setEditingId(null); setFormKey((k) => k + 1); setForm(blank()); setNewPhoto(null); setPhotoError('') }
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<form className="card form" onSubmit={add}>
|
||||||
|
<h2>{editingId ? 'Edit climb' : 'Add a climb'}</h2>
|
||||||
|
<div className="grid">
|
||||||
|
<label>Date<input type="date" required value={form.date} max={today()} onChange={(e) => set('date', e.target.value)} /></label>
|
||||||
|
<label>Grade
|
||||||
|
<select value={form.grade} onChange={(e) => set('grade', Number(e.target.value))}>
|
||||||
|
{GRADES.map((g, i) => <option key={g} value={i}>{g}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Type of climb
|
||||||
|
<select value={form.style} onChange={(e) => set('style', e.target.value)}>
|
||||||
|
{STYLES.map((s) => <option key={s}>{s}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label><span>Colour <ColourDot colour={form.colour} /></span>
|
||||||
|
<select value={form.colour} onChange={(e) => set('colour', e.target.value)}>
|
||||||
|
<option value="">Choose a colour…</option>
|
||||||
|
{Object.keys(COLOURS).map((c) => <option key={c}>{c}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Gym
|
||||||
|
<ListPicker key={`gym${formKey}`} noun="gym" value={form.gym} options={gyms} onChange={(v) => setForm((f) => ({ ...f, gym: v, wall: '' }))} />
|
||||||
|
</label>
|
||||||
|
<label>Wall
|
||||||
|
<ListPicker key={`wall${formKey}${form.gym}`} noun="wall" value={form.wall} options={walls} onChange={(v) => set('wall', v)} />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="toggle">
|
||||||
|
<button type="button" className={form.sent ? 'pill on' : 'pill'} onClick={() => set('sent', true)}>✅ Sent it</button>
|
||||||
|
<button type="button" className={!form.sent ? 'pill on' : 'pill'} onClick={() => set('sent', false)}>🔁 Still a project</button>
|
||||||
|
</div>
|
||||||
|
<label>Notes<textarea rows="2" value={form.notes} placeholder="How did it feel? What would you try next time?" onChange={(e) => set('notes', e.target.value)} /></label>
|
||||||
|
<div className="photo-field">
|
||||||
|
<span className="muted small">Photo (optional)</span>
|
||||||
|
{(newPhoto || form.photo) ? (
|
||||||
|
<div className="photo-preview">
|
||||||
|
<img src={newPhoto ? newPhoto.url : photoUrl(me, form.photo)} alt="Photo for this climb" />
|
||||||
|
<button type="button" className="link" onClick={clearPhoto}>Remove photo</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<label className="pill photo-button">{photoBusy ? 'Preparing photo…' : '📷 Add a photo'}
|
||||||
|
<input type="file" accept="image/*" hidden disabled={photoBusy} onChange={pickPhoto} />
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
{photoError && <p className="form-error">{photoError}</p>}
|
||||||
|
</div>
|
||||||
|
<button className="primary" disabled={photoBusy}>{photoBusy && newPhoto ? 'Uploading photo…' : editingId ? 'Save changes' : 'Save climb'}</button>
|
||||||
|
{editingId && <button type="button" className="link cancel" onClick={cancelEdit}>Cancel</button>}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div className="card">
|
||||||
|
<h2>Your climbs</h2>
|
||||||
|
{data.climbs.length === 0 ? <p className="muted">No climbs yet. Add your first one above!</p> : (
|
||||||
|
<ul className="climbs">
|
||||||
|
{data.climbs.map((c) => (
|
||||||
|
<li key={c.id} className={c.id === editingId ? 'editing' : ''}>
|
||||||
|
<span className="grade">{GRADES[c.grade]}</span>
|
||||||
|
<ClimbInfo c={c} />
|
||||||
|
<Photo owner={me} c={c} />
|
||||||
|
<button className="link" onClick={() => edit(c)} aria-label="Edit climb">Edit</button>
|
||||||
|
<button className="link" onClick={() => remove(c.id)} aria-label="Delete climb">Delete</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Progress tab ----------
|
||||||
|
function Bars({ rows, max, unit = '' }) {
|
||||||
|
// rows: [{ label, value, text }]
|
||||||
|
return (
|
||||||
|
<div className="bars">
|
||||||
|
{rows.map((r) => (
|
||||||
|
<div className="bar-row" key={r.label} title={`${r.label}: ${r.text ?? r.value}${unit}`}>
|
||||||
|
<span className="bar-label">{r.label}</span>
|
||||||
|
<div className="bar-track"><div className="bar" style={{ width: `${max ? (r.value / max) * 100 : 0}%` }} /></div>
|
||||||
|
<span className="bar-value">{r.text ?? r.value}{unit}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Progress({ data }) {
|
||||||
|
const { climbs } = data
|
||||||
|
const sends = climbs.filter((c) => c.sent)
|
||||||
|
if (climbs.length === 0) return <div className="card"><p className="muted">Log some climbs and your progress will show up here.</p></div>
|
||||||
|
|
||||||
|
const hardest = sends.length ? Math.max(...sends.map((c) => c.grade)) : null
|
||||||
|
const sessions = new Set(climbs.map((c) => c.date)).size
|
||||||
|
|
||||||
|
// Hardest send in each month
|
||||||
|
const byMonth = {}
|
||||||
|
sends.forEach((c) => { const m = c.date.slice(0, 7); byMonth[m] = Math.max(byMonth[m] ?? 0, c.grade) })
|
||||||
|
const monthRows = Object.keys(byMonth).sort().slice(-12).map((m) => ({
|
||||||
|
label: parse(m + '-01').toLocaleDateString(undefined, { month: 'short', year: '2-digit' }),
|
||||||
|
value: byMonth[m] + 1, text: GRADES[byMonth[m]],
|
||||||
|
}))
|
||||||
|
|
||||||
|
// Sends at each grade
|
||||||
|
const gradeCounts = GRADES.map((g, i) => ({ label: g, value: sends.filter((c) => c.grade === i).length })).filter((r) => r.value)
|
||||||
|
|
||||||
|
// Send rate for each type of climb
|
||||||
|
const styleRows = STYLES.map((s) => {
|
||||||
|
const all = climbs.filter((c) => c.style === s)
|
||||||
|
const sent = all.filter((c) => c.sent)
|
||||||
|
return all.length && {
|
||||||
|
label: s, value: Math.round((sent.length / all.length) * 100),
|
||||||
|
text: `${Math.round((sent.length / all.length) * 100)}% (${sent.length}/${all.length})` +
|
||||||
|
(sent.length ? ` · best ${GRADES[Math.max(...sent.map((c) => c.grade))]}` : ''),
|
||||||
|
}
|
||||||
|
}).filter(Boolean)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="tiles">
|
||||||
|
<Tile label="Hardest send" value={hardest === null ? '–' : GRADES[hardest]} />
|
||||||
|
<Tile label="Climbs sent" value={sends.length} />
|
||||||
|
<Tile label="Send rate" value={`${Math.round((sends.length / climbs.length) * 100)}%`} />
|
||||||
|
<Tile label="Sessions" value={sessions} />
|
||||||
|
</div>
|
||||||
|
{monthRows.length > 0 && <div className="card"><h2>Hardest send each month</h2><Bars rows={monthRows} max={Math.max(...monthRows.map((r) => r.value))} /></div>}
|
||||||
|
{gradeCounts.length > 0 && <div className="card"><h2>Sends at each grade</h2><Bars rows={gradeCounts} max={Math.max(...gradeCounts.map((r) => r.value))} /></div>}
|
||||||
|
<div className="card"><h2>Send rate by type of climb</h2><Bars rows={styleRows} max={100} /></div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const Tile = ({ label, value }) => <div className="tile"><span className="muted">{label}</span><strong>{value}</strong></div>
|
||||||
|
|
||||||
|
// ---------- Goals & plan tab ----------
|
||||||
|
function goalText(g) {
|
||||||
|
if (g.type === 'grade') return `Send a ${GRADES[g.grade]}${g.style !== 'Any' ? ` ${g.style.toLowerCase()}` : ''}`
|
||||||
|
if (g.type === 'sessions') return `Climb ${g.count} time${g.count > 1 ? 's' : ''} a week`
|
||||||
|
return g.text
|
||||||
|
}
|
||||||
|
|
||||||
|
function goalProgress(g, data) {
|
||||||
|
if (g.type === 'grade') {
|
||||||
|
const matching = data.climbs.filter((c) => c.sent && (g.style === 'Any' || c.style === g.style))
|
||||||
|
const best = matching.length ? Math.max(...matching.map((c) => c.grade)) : null
|
||||||
|
if (best !== null && best >= g.grade) return { done: true, text: 'Achieved! 🎉' }
|
||||||
|
return { done: false, text: best === null ? 'No sends yet' : `Best so far: ${GRADES[best]}` }
|
||||||
|
}
|
||||||
|
if (g.type === 'sessions') {
|
||||||
|
const wk = weekStart(today())
|
||||||
|
const n = new Set(data.climbs.filter((c) => weekStart(c.date) === wk).map((c) => c.date)).size
|
||||||
|
return { done: n >= g.count, text: `${n} of ${g.count} this week${n >= g.count ? ' 🎉' : ''}` }
|
||||||
|
}
|
||||||
|
return { done: !!g.done, text: g.done ? 'Done 🎉' : 'In progress' }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Goals({ data, update }) {
|
||||||
|
const [type, setType] = useState('grade')
|
||||||
|
const [grade, setGrade] = useState(4)
|
||||||
|
const [style, setStyle] = useState('Any')
|
||||||
|
const [count, setCount] = useState(3)
|
||||||
|
const [text, setText] = useState('')
|
||||||
|
|
||||||
|
const add = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
let goal = { id: newId(), type }
|
||||||
|
if (type === 'grade') goal = { ...goal, grade, style }
|
||||||
|
if (type === 'sessions') goal = { ...goal, count }
|
||||||
|
if (type === 'custom') { if (!text.trim()) return; goal = { ...goal, text: text.trim() } }
|
||||||
|
// Only one "times a week" goal makes sense, so a new one replaces the old one
|
||||||
|
const others = type === 'sessions' ? data.goals.filter((g) => g.type !== 'sessions') : data.goals
|
||||||
|
update({ goals: [...others, goal] })
|
||||||
|
setText('')
|
||||||
|
}
|
||||||
|
const remove = (id) => update({ goals: data.goals.filter((g) => g.id !== id) })
|
||||||
|
const toggleDone = (id) => update({ goals: data.goals.map((g) => (g.id === id ? { ...g, done: !g.done } : g)) })
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card">
|
||||||
|
<h2>Your goals</h2>
|
||||||
|
<p className="muted">Your goals shape your personal plan for each session on the Sessions tab.</p>
|
||||||
|
{data.goals.length === 0 && <p className="muted">No goals yet. Add one below.</p>}
|
||||||
|
<ul className="goals">
|
||||||
|
{data.goals.map((g) => {
|
||||||
|
const p = goalProgress(g, data)
|
||||||
|
return (
|
||||||
|
<li key={g.id} className={p.done ? 'done' : ''}>
|
||||||
|
<div className="info"><strong>{goalText(g)}</strong><span className="muted">{p.text}</span></div>
|
||||||
|
{g.type === 'custom' && <button className="link" onClick={() => toggleDone(g.id)}>{g.done ? 'Not done yet' : 'Mark as done'}</button>}
|
||||||
|
<button className="link" onClick={() => remove(g.id)}>Remove</button>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
<form className="form goal-form" onSubmit={add}>
|
||||||
|
<label>New goal
|
||||||
|
<select value={type} onChange={(e) => setType(e.target.value)}>
|
||||||
|
<option value="grade">Send a grade</option>
|
||||||
|
<option value="sessions">Climb a number of times a week</option>
|
||||||
|
<option value="custom">Something else (in my own words)</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{type === 'grade' && <>
|
||||||
|
<label>Grade<select value={grade} onChange={(e) => setGrade(Number(e.target.value))}>{GRADES.map((g, i) => <option key={g} value={i}>{g}</option>)}</select></label>
|
||||||
|
<label>Type of climb<select value={style} onChange={(e) => setStyle(e.target.value)}>{['Any', ...STYLES].map((s) => <option key={s}>{s}</option>)}</select></label>
|
||||||
|
</>}
|
||||||
|
{type === 'sessions' && <label>Times a week<select value={count} onChange={(e) => setCount(Number(e.target.value))}>{[1, 2, 3, 4, 5, 6, 7].map((n) => <option key={n}>{n}</option>)}</select></label>}
|
||||||
|
{type === 'custom' && <label className="wide">Goal<input value={text} placeholder="e.g. Improve my footwork" onChange={(e) => setText(e.target.value)} /></label>}
|
||||||
|
<button className="primary">Add goal</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Sessions tab ----------
|
||||||
|
// A session belongs to whoever created it and is saved in their profile.
|
||||||
|
// Everyone's "I'm in / can't make it" answers and group plan ideas are saved
|
||||||
|
// in their own profiles too, so nobody ever needs to change someone else's data.
|
||||||
|
const listNames = (names) => (names.length < 2 ? names.join('') : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`)
|
||||||
|
const hardestSend = (p) => { const g = p.climbs.filter((c) => c.sent).map((c) => c.grade); return g.length ? Math.max(...g) : null }
|
||||||
|
const openGoals = (p) => p.goals.filter((g) => g.type !== 'sessions' && !goalProgress(g, p).done)
|
||||||
|
const describeClimb = (c) => `${c.colour ? `${c.colour.toLowerCase()} ` : ''}${GRADES[c.grade]} ${c.style.toLowerCase()}`
|
||||||
|
|
||||||
|
function allSessions(all) {
|
||||||
|
return Object.entries(all)
|
||||||
|
.flatMap(([owner, p]) => (p.sessions || []).map((s) => ({ ...s, owner, ownerName: p.name || 'Unnamed' })))
|
||||||
|
.sort((a, b) => (a.date + (a.time || '')).localeCompare(b.date + (b.time || '')))
|
||||||
|
}
|
||||||
|
const peopleWho = (all, sessionId, answer) => Object.entries(all)
|
||||||
|
.filter(([, p]) => (p.rsvps || {})[sessionId] === answer)
|
||||||
|
.map(([id, p]) => ({ id, ...withDefaults(p) }))
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
|
||||||
|
// Your own plan for a session. Each session you're going to focuses on the next of your goals in turn.
|
||||||
|
function personalPlan(person, turn) {
|
||||||
|
const focuses = openGoals(person)
|
||||||
|
const g = focuses.length ? focuses[turn % focuses.length] : null
|
||||||
|
const items = ['Warm up: 10 minutes of easy climbs, a few grades below your best']
|
||||||
|
if (!g) {
|
||||||
|
items.push('Free session: climb whatever looks fun', 'Try one problem that is a little outside your comfort zone')
|
||||||
|
} else if (g.type === 'grade') {
|
||||||
|
const style = g.style !== 'Any' ? `${g.style.toLowerCase()} ` : ''
|
||||||
|
items.push(
|
||||||
|
`Project: pick 2–3 ${style}problems at ${GRADES[g.grade]} and give each a few good attempts, resting 3 minutes between tries`,
|
||||||
|
`Volume: climb 4–5 ${style}problems at ${GRADES[Math.max(0, g.grade - 1)]} to build confidence`,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
items.push(`Focus for today: ${g.text} (spend about 20–30 minutes on this)`, 'Then climb freely at a comfortable grade')
|
||||||
|
}
|
||||||
|
items.push('Cool down: a couple of easy climbs and some stretching')
|
||||||
|
return { focus: g ? goalText(g) : 'Free session', items }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ideas for the group, worked out from the goals and climbs of everyone who's coming
|
||||||
|
function groupSuggestions(people, session) {
|
||||||
|
if (people.length < 2) return []
|
||||||
|
const out = []
|
||||||
|
const sends = people.map(hardestSend).filter((g) => g !== null)
|
||||||
|
const easy = sends.length ? GRADES[Math.max(0, Math.min(...sends) - 2)] : GRADES[0]
|
||||||
|
out.push(`Warm up together: 10 minutes on easy problems everyone can do (around ${easy})`)
|
||||||
|
|
||||||
|
const gradeGoals = people.flatMap((p) => openGoals(p).filter((g) => g.type === 'grade').map((g) => ({ p, g })))
|
||||||
|
// People working on the same type of climb
|
||||||
|
STYLES.forEach((style) => {
|
||||||
|
const names = [...new Set(gradeGoals.filter((x) => x.g.style === style).map((x) => x.p.name))]
|
||||||
|
if (names.length > 1) out.push(`${listNames(names)} are ${names.length === 2 ? 'both' : 'all'} working on ${style.toLowerCase()} climbs: spend some time on ${/^[aeiou]/i.test(style) ? 'an' : 'a'} ${style.toLowerCase()} wall together`)
|
||||||
|
})
|
||||||
|
// People aiming for the same grade
|
||||||
|
const byGrade = {}
|
||||||
|
gradeGoals.forEach(({ p, g }) => { (byGrade[g.grade] ||= new Set()).add(p.name) })
|
||||||
|
Object.entries(byGrade).forEach(([grade, names]) => {
|
||||||
|
if (names.size > 1) out.push(`${listNames([...names])} are aiming for ${GRADES[grade]}: try the same problems and swap tips`)
|
||||||
|
})
|
||||||
|
// Someone who has already climbed what another person is aiming for
|
||||||
|
const helped = new Set()
|
||||||
|
gradeGoals.forEach(({ p, g }) => {
|
||||||
|
const helper = people.find((h) => h.id !== p.id && hardestSend(h) !== null && hardestSend(h) >= g.grade)
|
||||||
|
if (helper && !helped.has(p.id)) { helped.add(p.id); out.push(`${helper.name} has sent ${GRADES[hardestSend(helper)]}: ask them for tips on ${p.name}'s goal (${goalText(g)})`) }
|
||||||
|
})
|
||||||
|
// Unfinished projects at this gym
|
||||||
|
people.forEach((p) => {
|
||||||
|
const project = p.climbs.find((c) => !c.sent && session.gym && sameText(c.gym, session.gym))
|
||||||
|
if (project) out.push(`${p.name} has an unfinished ${describeClimb(project)}${project.wall ? ` on ${project.wall}` : ''}: have a go together and cheer them on`)
|
||||||
|
})
|
||||||
|
out.push('Finish together: everyone picks one climb for the whole group to try')
|
||||||
|
return out.slice(0, 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sessionWhen = (s) => `${niceDate(s.date)}${s.date === today() ? ' (today)' : ''}${s.time ? ` at ${s.time}` : ''}`
|
||||||
|
|
||||||
|
function Sessions({ all, me, data, update, fresh }) {
|
||||||
|
const blank = () => ({ date: today(), time: '', gym: data.climbs[0]?.gym ?? '', note: '' })
|
||||||
|
const [form, setForm] = useState(blank)
|
||||||
|
const [formKey, setFormKey] = useState(0)
|
||||||
|
const [ideas, setIdeas] = useState({}) // text being typed, by session id
|
||||||
|
const set = (k, v) => setForm((f) => ({ ...f, [k]: v }))
|
||||||
|
|
||||||
|
const sessions = allSessions(all)
|
||||||
|
const upcoming = sessions.filter((s) => s.date >= today())
|
||||||
|
const past = sessions.filter((s) => s.date < today()).reverse().slice(0, 5)
|
||||||
|
const gyms = sharedList(all, 'gym')
|
||||||
|
sessions.forEach((s) => { if (s.gym && !gyms.some((g) => sameText(g, s.gym))) gyms.push(s.gym) })
|
||||||
|
const myUpcoming = upcoming.filter((s) => data.rsvps[s.id] === 'in')
|
||||||
|
|
||||||
|
const create = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const session = { id: newId(), date: form.date, time: form.time, gym: tidy(gyms, form.gym), note: form.note.trim() }
|
||||||
|
update({ sessions: [...data.sessions, session], rsvps: { ...data.rsvps, [session.id]: 'in' } })
|
||||||
|
setForm(blank()); setFormKey((k) => k + 1)
|
||||||
|
}
|
||||||
|
const cancel = (s) => {
|
||||||
|
if (confirm('Cancel this session for everyone?')) update({ sessions: data.sessions.filter((x) => x.id !== s.id) })
|
||||||
|
}
|
||||||
|
const answer = (s, value) => update({ rsvps: { ...data.rsvps, [s.id]: data.rsvps[s.id] === value ? undefined : value } })
|
||||||
|
const toggleCheck = (key) => update({ planChecks: { ...data.planChecks, [key]: !data.planChecks[key] } })
|
||||||
|
const addIdea = (e, s) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const text = (ideas[s.id] || '').trim()
|
||||||
|
if (!text) return
|
||||||
|
update({ groupItems: [...data.groupItems, { id: newId(), sessionId: s.id, text }] })
|
||||||
|
setIdeas({ ...ideas, [s.id]: '' })
|
||||||
|
}
|
||||||
|
const removeIdea = (id) => update({ groupItems: data.groupItems.filter((i) => i.id !== id) })
|
||||||
|
const groupItems = (s) => Object.entries(all).flatMap(([pid, p]) => (p.groupItems || []).filter((i) => i.sessionId === s.id).map((i) => ({ ...i, pid, by: p.name || 'Unnamed' })))
|
||||||
|
const when = sessionWhen
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<form className="card form" onSubmit={create}>
|
||||||
|
<h2>Schedule a session</h2>
|
||||||
|
<div className="grid">
|
||||||
|
<label>Date<input type="date" required min={today()} value={form.date} onChange={(e) => set('date', e.target.value)} /></label>
|
||||||
|
<label>Time (optional)<input type="time" value={form.time} onChange={(e) => set('time', e.target.value)} /></label>
|
||||||
|
<label>Gym<ListPicker key={`sgym${formKey}`} noun="gym" value={form.gym} options={gyms} onChange={(v) => set('gym', v)} /></label>
|
||||||
|
</div>
|
||||||
|
<label className="spaced">Note (optional)<input value={form.note} maxLength={120} placeholder="e.g. Meet at the front desk" onChange={(e) => set('note', e.target.value)} /></label>
|
||||||
|
<button className="primary">Add session</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{upcoming.length === 0 && <div className="card"><p className="muted">No sessions planned yet. Add one above and your friends will see it here.</p></div>}
|
||||||
|
|
||||||
|
{upcoming.map((s) => {
|
||||||
|
const going = peopleWho(all, s.id, 'in')
|
||||||
|
const notGoing = peopleWho(all, s.id, 'out')
|
||||||
|
const mine = data.rsvps[s.id]
|
||||||
|
const plan = mine === 'in' ? personalPlan(data, myUpcoming.findIndex((x) => x.id === s.id)) : null
|
||||||
|
const suggestions = groupSuggestions(going, s)
|
||||||
|
const items = groupItems(s)
|
||||||
|
return (
|
||||||
|
<div className="card" key={s.id}>
|
||||||
|
<h2>{fresh.includes(s.id) && <span className="badge new">New</span>}{when(s)}{s.gym && ` · ${s.gym}`}</h2>
|
||||||
|
<p className="muted small">Added by {s.owner === me ? 'you' : s.ownerName}{s.note && ` · ${s.note}`} {s.owner === me && <button className="link" onClick={() => cancel(s)}>Cancel session</button>}</p>
|
||||||
|
<div className="toggle">
|
||||||
|
<button className={mine === 'in' ? 'pill on' : 'pill'} onClick={() => answer(s, 'in')}>👍 I'm in</button>
|
||||||
|
<button className={mine === 'out' ? 'pill on' : 'pill'} onClick={() => answer(s, 'out')}>Can't make it</button>
|
||||||
|
</div>
|
||||||
|
<p className="line"><strong>Going:</strong> {going.length ? listNames(going.map((p) => (p.id === me ? 'you' : p.name))) : 'nobody yet'}</p>
|
||||||
|
{notGoing.length > 0 && <p className="line muted">Can't make it: {listNames(notGoing.map((p) => (p.id === me ? 'you' : p.name)))}</p>}
|
||||||
|
|
||||||
|
{plan && (
|
||||||
|
<div className="session today">
|
||||||
|
<h3>Your plan <span className="muted">· {plan.focus}</span></h3>
|
||||||
|
{plan.items.map((item, i) => {
|
||||||
|
const key = `${s.id}|${i}`
|
||||||
|
return (
|
||||||
|
<label className="check" key={key}>
|
||||||
|
<input type="checkbox" checked={!!data.planChecks[key]} onChange={() => toggleCheck(key)} />
|
||||||
|
<span>{item}</span>
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!mine && <p className="muted small">Tap "I'm in" to get your personal plan for this session.</p>}
|
||||||
|
|
||||||
|
<div className="session">
|
||||||
|
<h3>Group plan</h3>
|
||||||
|
{suggestions.length === 0 && items.length === 0 && <p className="muted">Suggestions appear once two or more people are in.</p>}
|
||||||
|
{suggestions.map((t) => <p className="line" key={t}>💡 {t}</p>)}
|
||||||
|
{items.map((i) => (
|
||||||
|
<p className="line" key={i.id}>📝 {i.text} <span className="muted">· {i.pid === me ? 'you' : i.by}</span> {i.pid === me && <button className="link" onClick={() => removeIdea(i.id)}>Remove</button>}</p>
|
||||||
|
))}
|
||||||
|
<form className="idea-form" onSubmit={(e) => addIdea(e, s)}>
|
||||||
|
<input value={ideas[s.id] || ''} maxLength={140} placeholder="Add an idea for the group…" onChange={(e) => setIdeas({ ...ideas, [s.id]: e.target.value })} />
|
||||||
|
<button className="primary">Add</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
|
||||||
|
{past.length > 0 && (
|
||||||
|
<div className="card">
|
||||||
|
<h2>Recent sessions</h2>
|
||||||
|
{past.map((s) => {
|
||||||
|
const went = peopleWho(all, s.id, 'in')
|
||||||
|
return (
|
||||||
|
<div className="session" key={s.id}>
|
||||||
|
<h3>{niceDate(s.date)}{s.gym && ` · ${s.gym}`}</h3>
|
||||||
|
{went.length === 0 && <p className="muted">Nobody signed up.</p>}
|
||||||
|
{went.map((p) => {
|
||||||
|
const sent = p.climbs.filter((c) => c.date === s.date && c.sent)
|
||||||
|
const tried = p.climbs.filter((c) => c.date === s.date && !c.sent)
|
||||||
|
return (
|
||||||
|
<p className="line" key={p.id}><strong>{p.id === me ? 'You' : p.name}:</strong> {sent.length || tried.length
|
||||||
|
? [sent.length && `sent ${sent.map(describeClimb).join(', ')}`, tried.length && `worked on ${tried.map(describeClimb).join(', ')}`].filter(Boolean).join('; ')
|
||||||
|
: <span className="muted">no climbs logged</span>}</p>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Friends tab ----------
|
||||||
|
function personStats(p) {
|
||||||
|
const sends = p.climbs.filter((c) => c.sent)
|
||||||
|
const wk = weekStart(today())
|
||||||
|
return {
|
||||||
|
hardest: sends.length ? Math.max(...sends.map((c) => c.grade)) : null,
|
||||||
|
sends: sends.length,
|
||||||
|
rate: p.climbs.length ? Math.round((sends.length / p.climbs.length) * 100) : null,
|
||||||
|
sessions: new Set(p.climbs.map((c) => c.date)).size,
|
||||||
|
thisWeek: new Set(p.climbs.filter((c) => weekStart(c.date) === wk).map((c) => c.date)).size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Friends({ all, me }) {
|
||||||
|
const [viewId, setViewId] = useState(null)
|
||||||
|
const people = Object.entries(all).map(([id, p]) => ({ id, ...withDefaults(p), stats: personStats(withDefaults(p)) }))
|
||||||
|
.sort((a, b) => (b.id === me) - (a.id === me) || a.name.localeCompare(b.name))
|
||||||
|
const label = (p) => (p.id === me ? `${p.name} (you)` : p.name)
|
||||||
|
const viewing = people.find((p) => p.id === viewId)
|
||||||
|
const link = window.location.href.split(/[?#]/)[0]
|
||||||
|
|
||||||
|
const hardestRows = people.filter((p) => p.stats.hardest !== null)
|
||||||
|
.map((p) => ({ label: label(p), value: p.stats.hardest + 1, text: GRADES[p.stats.hardest] }))
|
||||||
|
const sendRows = people.map((p) => ({ label: label(p), value: p.stats.sends }))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{people.length < 2 && (
|
||||||
|
<div className="card">
|
||||||
|
<h2>Invite your friends</h2>
|
||||||
|
<p>Send them this link. When they open it they enter their name and get their own tracker, and you'll see each other here.</p>
|
||||||
|
<p className="share-link">{link}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="card">
|
||||||
|
<h2>How everyone is doing</h2>
|
||||||
|
<div className="table-wrap">
|
||||||
|
<table>
|
||||||
|
<thead><tr><th>Climber</th><th>Hardest send</th><th>Sends</th><th>Send rate</th><th>Sessions</th><th>This week</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
{people.map((p) => (
|
||||||
|
<tr key={p.id} className={p.id === me ? 'me' : ''}>
|
||||||
|
<td><button className="link name" onClick={() => setViewId(p.id)}>{label(p)}</button></td>
|
||||||
|
<td>{p.stats.hardest === null ? '–' : GRADES[p.stats.hardest]}</td>
|
||||||
|
<td>{p.stats.sends}</td>
|
||||||
|
<td>{p.stats.rate === null ? '–' : `${p.stats.rate}%`}</td>
|
||||||
|
<td>{p.stats.sessions}</td>
|
||||||
|
<td>{p.stats.thisWeek}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p className="muted small">Tap a name to see that person's climbs and progress.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{hardestRows.length > 0 && <div className="card wide-labels"><h2>Hardest send</h2><Bars rows={hardestRows} max={Math.max(...hardestRows.map((r) => r.value))} /></div>}
|
||||||
|
{sendRows.some((r) => r.value > 0) && <div className="card wide-labels"><h2>Total sends</h2><Bars rows={sendRows} max={Math.max(...sendRows.map((r) => r.value))} /></div>}
|
||||||
|
|
||||||
|
<div className="card">
|
||||||
|
<h2>What everyone is working on</h2>
|
||||||
|
{people.map((p) => {
|
||||||
|
const goals = p.goals.map((g) => ({ g, prog: goalProgress(g, p) }))
|
||||||
|
const projects = p.climbs.filter((c) => !c.sent).slice(0, 3)
|
||||||
|
return (
|
||||||
|
<div className="session" key={p.id}>
|
||||||
|
<h3>{label(p)}</h3>
|
||||||
|
{goals.length === 0 && projects.length === 0 && <p className="muted">Nothing set yet.</p>}
|
||||||
|
{goals.map(({ g, prog }) => (
|
||||||
|
<p key={g.id} className="line">🎯 {goalText(g)} <span className="muted">· {prog.text}</span></p>
|
||||||
|
))}
|
||||||
|
{projects.map((c) => (
|
||||||
|
<p key={c.id} className="line">🔁 Projecting a {c.colour && `${c.colour.toLowerCase()} `}{GRADES[c.grade]} {c.style.toLowerCase()} <span className="muted">· {niceDate(c.date)}{c.gym && ` · ${c.gym}`}{c.wall && ` · ${c.wall}`}</span></p>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{viewing && (
|
||||||
|
<>
|
||||||
|
<div className="card">
|
||||||
|
<h2>{label(viewing)}: progress and climbs <button className="link" onClick={() => setViewId(null)}>close</button></h2>
|
||||||
|
{viewing.climbs.length === 0 ? <p className="muted">No climbs logged yet.</p> : (
|
||||||
|
<ul className="climbs">
|
||||||
|
{viewing.climbs.slice(0, 20).map((c) => (
|
||||||
|
<li key={c.id}>
|
||||||
|
<span className="grade">{GRADES[c.grade]}</span>
|
||||||
|
<ClimbInfo c={c} />
|
||||||
|
<Photo owner={viewing.id} c={c} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
{viewing.climbs.length > 20 && <p className="muted small">Showing the latest 20 climbs.</p>}
|
||||||
|
</div>
|
||||||
|
{viewing.climbs.length > 0 && <Progress data={viewing} />}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
11
src/main.jsx
Normal file
11
src/main.jsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { createRoot } from 'react-dom/client'
|
||||||
|
import App from './App.jsx'
|
||||||
|
// The styles are placed inside the page itself so the hosted version doesn't
|
||||||
|
// depend on the server guessing the right file type for a stylesheet
|
||||||
|
import css from './styles.css?inline'
|
||||||
|
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.textContent = css
|
||||||
|
document.head.appendChild(style)
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')).render(<App />)
|
||||||
157
src/styles.css
Normal file
157
src/styles.css
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
:root {
|
||||||
|
--bg: #f6f4ef;
|
||||||
|
--card: #ffffff;
|
||||||
|
--text: #22252a;
|
||||||
|
--muted: #6b7078;
|
||||||
|
--line: #e3dfd6;
|
||||||
|
--accent: #2f6f5e;
|
||||||
|
--accent-soft: #e2efeb;
|
||||||
|
color-scheme: light dark;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #17191c;
|
||||||
|
--card: #212428;
|
||||||
|
--text: #eceae5;
|
||||||
|
--muted: #a0a4ab;
|
||||||
|
--line: #34383e;
|
||||||
|
--accent: #5fb39c;
|
||||||
|
--accent-soft: #24362f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
font: 16px/1.5 system-ui, sans-serif;
|
||||||
|
}
|
||||||
|
.app { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
|
||||||
|
h1 { margin: 0 0 16px; font-size: 1.7rem; }
|
||||||
|
h2 { margin: 0 0 12px; font-size: 1.15rem; }
|
||||||
|
h3 { margin: 0 0 6px; font-size: 1rem; }
|
||||||
|
.muted { color: var(--muted); font-weight: normal; }
|
||||||
|
.error { background: #fbe4e1; color: #8a1f14; padding: 10px 14px; border-radius: 8px; }
|
||||||
|
|
||||||
|
nav { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
|
||||||
|
.tab, .pill {
|
||||||
|
border: 1px solid var(--line); background: var(--card); color: var(--text);
|
||||||
|
padding: 8px 16px; border-radius: 999px; font: inherit; cursor: pointer;
|
||||||
|
}
|
||||||
|
.tab.active, .pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
|
||||||
|
@media (prefers-color-scheme: dark) { .tab.active, .pill.on { color: #10201b; } }
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: var(--card); border: 1px solid var(--line);
|
||||||
|
border-radius: 14px; padding: 20px; margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
|
||||||
|
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
|
||||||
|
input, select, textarea {
|
||||||
|
font: inherit; color: var(--text); background: var(--bg);
|
||||||
|
border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
|
||||||
|
}
|
||||||
|
.toggle { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
|
||||||
|
.primary {
|
||||||
|
margin-top: 14px; background: var(--accent); color: #fff; border: 0;
|
||||||
|
padding: 10px 20px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) { .primary { color: #10201b; } }
|
||||||
|
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
|
||||||
|
|
||||||
|
ul { list-style: none; margin: 0; padding: 0; }
|
||||||
|
.climbs li, .goals li {
|
||||||
|
display: flex; align-items: center; gap: 14px;
|
||||||
|
padding: 12px 0; border-top: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
.climbs li:first-child, .goals li:first-child { border-top: 0; }
|
||||||
|
.grade {
|
||||||
|
flex: none; width: 48px; height: 48px; border-radius: 12px;
|
||||||
|
background: var(--accent-soft); color: var(--text);
|
||||||
|
display: grid; place-items: center; font-weight: 700;
|
||||||
|
}
|
||||||
|
.info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
|
||||||
|
.notes { font-size: 0.9rem; margin-top: 2px; overflow-wrap: anywhere; }
|
||||||
|
.goals li.done strong { text-decoration: line-through; }
|
||||||
|
.goal-form {
|
||||||
|
display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
|
||||||
|
border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px;
|
||||||
|
}
|
||||||
|
.goal-form label { flex: 1 1 150px; }
|
||||||
|
.goal-form .wide { flex-basis: 100%; }
|
||||||
|
.goal-form .primary { margin-top: 0; }
|
||||||
|
|
||||||
|
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
|
||||||
|
.tile {
|
||||||
|
background: var(--card); border: 1px solid var(--line); border-radius: 14px;
|
||||||
|
padding: 16px; display: flex; flex-direction: column;
|
||||||
|
}
|
||||||
|
.tile strong { font-size: 1.8rem; }
|
||||||
|
|
||||||
|
.bar-row { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: 10px; padding: 5px 0; }
|
||||||
|
.bar-row:hover { background: var(--accent-soft); border-radius: 6px; }
|
||||||
|
.bar-label { font-size: 0.9rem; color: var(--muted); }
|
||||||
|
.bar-track { height: 14px; }
|
||||||
|
.bar { height: 100%; min-width: 4px; background: var(--accent); border-radius: 0 4px 4px 0; }
|
||||||
|
.bar-value { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
|
.session { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
|
||||||
|
.session.today { border-color: var(--accent); background: var(--accent-soft); }
|
||||||
|
.check { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
|
||||||
|
.check input { width: auto; margin-top: 5px; }
|
||||||
|
.check input:checked + span { text-decoration: line-through; color: var(--muted); }
|
||||||
|
|
||||||
|
.whoami { margin: -8px 0 14px; font-size: 0.9rem; }
|
||||||
|
.small { font-size: 0.85rem; }
|
||||||
|
.primary:disabled { opacity: 0.5; cursor: default; }
|
||||||
|
.share-link {
|
||||||
|
background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
|
||||||
|
padding: 10px 12px; overflow-wrap: anywhere; user-select: all;
|
||||||
|
}
|
||||||
|
.table-wrap { overflow-x: auto; }
|
||||||
|
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
|
||||||
|
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
||||||
|
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
|
||||||
|
tr.me td { background: var(--accent-soft); }
|
||||||
|
.link.name { color: var(--text); font-size: 1rem; font-weight: 600; padding: 0; }
|
||||||
|
.wide-labels .bar-row { grid-template-columns: 120px 1fr auto; }
|
||||||
|
.wide-labels .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.line { margin: 4px 0; }
|
||||||
|
h2 .link { float: right; font-weight: normal; }
|
||||||
|
.cancel { margin-left: 14px; }
|
||||||
|
.climbs li.editing { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
|
||||||
|
.form-error { flex-basis: 100%; margin: 0; color: #a12a1c; }
|
||||||
|
@media (prefers-color-scheme: dark) { .form-error { color: #f0a59b; } }
|
||||||
|
.goal-form .wide, .goal-form p { flex-basis: 100%; margin: 0; }
|
||||||
|
.back-to-list { align-self: flex-start; padding: 0; }
|
||||||
|
.dot {
|
||||||
|
display: inline-block; width: 0.75em; height: 0.75em; border-radius: 50%;
|
||||||
|
border: 1px solid var(--muted); margin-right: 6px; vertical-align: baseline;
|
||||||
|
}
|
||||||
|
.form label .dot { margin: 0 0 0 4px; }
|
||||||
|
.spaced { margin-top: 12px; }
|
||||||
|
.idea-form { display: flex; gap: 8px; margin-top: 10px; }
|
||||||
|
.idea-form .primary { margin-top: 0; }
|
||||||
|
.card > .session { margin-bottom: 4px; }
|
||||||
|
.photo-field { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
|
||||||
|
.form label.photo-button { flex-direction: row; color: var(--text); font-size: 1rem; }
|
||||||
|
.photo-preview { display: flex; align-items: center; gap: 12px; }
|
||||||
|
.photo-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
|
||||||
|
.thumb { flex: none; width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
|
||||||
|
.lightbox {
|
||||||
|
position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.85);
|
||||||
|
display: grid; place-items: center; padding: 16px; cursor: zoom-out;
|
||||||
|
}
|
||||||
|
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
|
||||||
|
.badge {
|
||||||
|
display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px;
|
||||||
|
background: #c8372d; color: #fff; font-size: 0.75rem; font-weight: 700; line-height: 1.5;
|
||||||
|
}
|
||||||
|
.badge.new { margin: 0 8px 0 0; vertical-align: middle; }
|
||||||
|
.notice {
|
||||||
|
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
||||||
|
background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px;
|
||||||
|
padding: 14px 18px; margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.notice .primary { margin-top: 0; flex: none; }
|
||||||
110
vite.config.js
Normal file
110
vite.config.js
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
import fs from 'node:fs'
|
||||||
|
import path from 'node:path'
|
||||||
|
import crypto from 'node:crypto'
|
||||||
|
|
||||||
|
// When running on this laptop, this saves the app's data to files inside the
|
||||||
|
// project (data/users/<id>.json). It answers at the same addresses as the
|
||||||
|
// hosted version, where cgi/api.sh does this job.
|
||||||
|
const dataDir = path.resolve(import.meta.dirname, 'data')
|
||||||
|
const usersDir = path.join(dataDir, 'users')
|
||||||
|
const legacyFile = path.join(dataDir, 'climbing-data.json')
|
||||||
|
const authDir = path.join(dataDir, '.auth')
|
||||||
|
const photosDir = path.join(dataDir, 'photos')
|
||||||
|
|
||||||
|
// Passwords work the same way as in cgi/api.sh: the browser sends a token in
|
||||||
|
// the X-Auth header and a SHA-256 of that token is kept in data/.auth/<id>
|
||||||
|
const validToken = (t) => /^[a-f0-9]{64}$/.test(t || '')
|
||||||
|
const tokenHash = (t) => crypto.createHash('sha256').update(t).digest('hex')
|
||||||
|
const authFile = (id) => path.join(authDir, id)
|
||||||
|
const hasPassword = (id) => fs.existsSync(authFile(id))
|
||||||
|
const passwordCorrect = (id, t) => validToken(t) && hasPassword(id) &&
|
||||||
|
fs.readFileSync(authFile(id), 'utf8').trim() === tokenHash(t)
|
||||||
|
|
||||||
|
function readAll() {
|
||||||
|
fs.mkdirSync(usersDir, { recursive: true })
|
||||||
|
// One-off move of the original single-person data into a profile
|
||||||
|
const first = path.join(usersDir, 'alysia.json')
|
||||||
|
if (fs.existsSync(legacyFile) && !fs.existsSync(first)) {
|
||||||
|
const old = JSON.parse(fs.readFileSync(legacyFile, 'utf8'))
|
||||||
|
fs.writeFileSync(first, JSON.stringify({ name: 'Alysia', ...old }))
|
||||||
|
fs.renameSync(legacyFile, legacyFile + '.old')
|
||||||
|
}
|
||||||
|
const all = {}
|
||||||
|
for (const file of fs.readdirSync(usersDir)) {
|
||||||
|
const id = file.replace(/\.json$/, '')
|
||||||
|
if (file.endsWith('.json') && /^[a-z0-9]+$/.test(id)) {
|
||||||
|
all[id] = JSON.parse(fs.readFileSync(path.join(usersDir, file), 'utf8'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return all
|
||||||
|
}
|
||||||
|
|
||||||
|
function dataApi() {
|
||||||
|
return {
|
||||||
|
name: 'climbing-data-api',
|
||||||
|
configureServer(server) {
|
||||||
|
server.middlewares.use('/api.sh', (req, res) => {
|
||||||
|
const send = (code, obj) => {
|
||||||
|
res.statusCode = code
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
res.end(JSON.stringify(obj))
|
||||||
|
}
|
||||||
|
const { pathname, searchParams } = new URL(req.url, 'http://localhost')
|
||||||
|
const user = pathname === '/' && (searchParams.get('user') || '').match(/^([a-z0-9]{4,24})$/)
|
||||||
|
const token = req.headers['x-auth']
|
||||||
|
const check = searchParams.get('check')
|
||||||
|
if (req.method === 'GET' && pathname === '/' && check !== null) {
|
||||||
|
const valid = /^[a-z0-9]{4,24}$/.test(check)
|
||||||
|
send(200, { ok: valid && passwordCorrect(check, token), hasPassword: valid && hasPassword(check) })
|
||||||
|
} else if (req.method === 'GET' && pathname === '/') {
|
||||||
|
send(200, readAll())
|
||||||
|
} else if (req.method === 'PUT' && user) {
|
||||||
|
let body = ''
|
||||||
|
req.on('data', (c) => (body += c))
|
||||||
|
req.on('end', () => {
|
||||||
|
try {
|
||||||
|
JSON.parse(body)
|
||||||
|
const id = user[1]
|
||||||
|
const photoId = searchParams.get('photo')
|
||||||
|
if (photoId !== null) {
|
||||||
|
// Photo for a climb: { photo: "<base64 JPEG>" }, or "" to delete it
|
||||||
|
if (!/^[a-z0-9]{4,24}$/.test(photoId)) return send(400, { ok: false })
|
||||||
|
if (!passwordCorrect(id, token)) return send(403, { ok: false, auth: false })
|
||||||
|
const file = path.join(photosDir, `${id}-${photoId}.jpg`)
|
||||||
|
const bytes = Buffer.from(JSON.parse(body).photo || '', 'base64')
|
||||||
|
fs.mkdirSync(photosDir, { recursive: true })
|
||||||
|
if (bytes.length === 0) fs.rmSync(file, { force: true })
|
||||||
|
else if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes.length <= 72000) fs.writeFileSync(file, bytes)
|
||||||
|
else return send(400, { ok: false })
|
||||||
|
return send(200, { ok: true })
|
||||||
|
}
|
||||||
|
if (!validToken(token) || (hasPassword(id) && !passwordCorrect(id, token))) {
|
||||||
|
return send(403, { ok: false, auth: false })
|
||||||
|
}
|
||||||
|
// A profile without a password yet is claimed by the first save
|
||||||
|
fs.mkdirSync(authDir, { recursive: true })
|
||||||
|
if (!hasPassword(id)) fs.writeFileSync(authFile(id), tokenHash(token))
|
||||||
|
fs.mkdirSync(usersDir, { recursive: true })
|
||||||
|
const file = path.join(usersDir, user[1] + '.json')
|
||||||
|
fs.writeFileSync(file + '.tmp', body)
|
||||||
|
fs.renameSync(file + '.tmp', file)
|
||||||
|
send(200, { ok: true })
|
||||||
|
} catch (e) {
|
||||||
|
send(400, { ok: false })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
send(404, { ok: false })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
base: './',
|
||||||
|
plugins: [react(), dataApi()],
|
||||||
|
server: { port: 5173, strictPort: true, host: 'localhost' },
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue
Block a user