From 198591b80bd2fefd033def9a4938d11d441d781c Mon Sep 17 00:00:00 2001 From: Igor Date: Sat, 4 Apr 2026 08:28:50 +0200 Subject: [PATCH] Modern Frontend Complexity Alternative --- .../.mvn/wrapper/maven-wrapper.properties | 3 + .../Dockerfile | 14 + .../README.md | 43 + modern-frontend-complexity-alternative/mvnw | 295 ++++++ .../mvnw.cmd | 189 ++++ .../ops/build_and_package.bash | 72 ++ .../ops/live-css-gen.sh | 2 + .../ops/package_components.py | 21 + .../ops/template_load_and_run_app.bash | 8 + .../ops/template_run_app.bash | 16 + .../package-lock.json | 991 ++++++++++++++++++ .../package.json | 6 + .../pom.xml | 73 ++ .../AppDataInitializer.java | 91 ++ ...odernFrontendComplexityAlternativeApp.java | 22 + .../app/DeviceController.java | 181 ++++ .../app/ErrorsHandler.java | 102 ++ .../complexity_alternative/app/HTMX.java | 17 + .../app/HomeController.java | 14 + .../app/TemplatesResolver.java | 50 + .../app/TranslatedAvailableAttribute.java | 13 + .../app/Translations.java | 58 + .../app/WebProperties.java | 9 + .../complexity_alternative/app/WebTools.java | 18 + .../domain/AvailableAttribute.java | 6 + .../complexity_alternative/domain/Device.java | 6 + .../domain/DeviceNotFoundException.java | 10 + .../domain/DeviceOffer.java | 18 + .../domain/DevicesException.java | 8 + .../complexity_alternative/domain/Money.java | 14 + .../infra/DeviceOfferRepository.java | 85 ++ .../infra/DeviceRepository.java | 42 + .../src/main/resources/application-prod.yaml | 10 + .../src/main/resources/application.yaml | 20 + .../src/main/resources/messages.properties | 37 + .../src/main/resources/static/drop-down.js | 27 + .../src/main/resources/static/error-modal.js | 31 + .../src/main/resources/static/input.css | 10 + .../resources/static/lib/htmx.min.2.0.8.js | 2 + .../src/main/resources/static/output.css | 551 ++++++++++ .../resources/static/selectables-container.js | 40 + .../resources/static/selected-container.js | 66 ++ .../resources/static/sortables-container.js | 54 + .../resources/static/validateable-input.js | 26 + .../templates/buy-device-offer-page.mustache | 20 + .../templates/buy-device-page.mustache | 129 +++ .../templates/content-router.mustache | 15 + .../templates/device-offers.mustache | 9 + .../resources/templates/device-page.mustache | 1 + .../resources/templates/devices-page.mustache | 11 + .../templates/devices-search-results.mustache | 17 + .../resources/templates/error-info.mustache | 1 + .../resources/templates/error-page.mustache | 2 + .../resources/templates/page-wrapper.mustache | 57 + .../BaseIntegrationTest.java | 25 + .../DeviceControllerTest.java | 40 + 56 files changed, 3698 insertions(+) create mode 100644 modern-frontend-complexity-alternative/.mvn/wrapper/maven-wrapper.properties create mode 100644 modern-frontend-complexity-alternative/Dockerfile create mode 100644 modern-frontend-complexity-alternative/README.md create mode 100755 modern-frontend-complexity-alternative/mvnw create mode 100644 modern-frontend-complexity-alternative/mvnw.cmd create mode 100755 modern-frontend-complexity-alternative/ops/build_and_package.bash create mode 100755 modern-frontend-complexity-alternative/ops/live-css-gen.sh create mode 100644 modern-frontend-complexity-alternative/ops/package_components.py create mode 100644 modern-frontend-complexity-alternative/ops/template_load_and_run_app.bash create mode 100644 modern-frontend-complexity-alternative/ops/template_run_app.bash create mode 100644 modern-frontend-complexity-alternative/package-lock.json create mode 100644 modern-frontend-complexity-alternative/package.json create mode 100644 modern-frontend-complexity-alternative/pom.xml create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/AppDataInitializer.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/ModernFrontendComplexityAlternativeApp.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/DeviceController.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/ErrorsHandler.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HTMX.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HomeController.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TemplatesResolver.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TranslatedAvailableAttribute.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/Translations.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebProperties.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebTools.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/AvailableAttribute.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Device.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceNotFoundException.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceOffer.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DevicesException.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Money.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceOfferRepository.java create mode 100644 modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceRepository.java create mode 100644 modern-frontend-complexity-alternative/src/main/resources/application-prod.yaml create mode 100644 modern-frontend-complexity-alternative/src/main/resources/application.yaml create mode 100644 modern-frontend-complexity-alternative/src/main/resources/messages.properties create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/drop-down.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/error-modal.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/input.css create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/lib/htmx.min.2.0.8.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/output.css create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/selectables-container.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/selected-container.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/sortables-container.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/static/validateable-input.js create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-offer-page.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-page.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/content-router.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/device-offers.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/device-page.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/devices-page.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/devices-search-results.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/error-info.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/error-page.mustache create mode 100644 modern-frontend-complexity-alternative/src/main/resources/templates/page-wrapper.mustache create mode 100644 modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/BaseIntegrationTest.java create mode 100644 modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/DeviceControllerTest.java diff --git a/modern-frontend-complexity-alternative/.mvn/wrapper/maven-wrapper.properties b/modern-frontend-complexity-alternative/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..8dea6c22 --- /dev/null +++ b/modern-frontend-complexity-alternative/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip diff --git a/modern-frontend-complexity-alternative/Dockerfile b/modern-frontend-complexity-alternative/Dockerfile new file mode 100644 index 00000000..317c0281 --- /dev/null +++ b/modern-frontend-complexity-alternative/Dockerfile @@ -0,0 +1,14 @@ +FROM maven:3.9-eclipse-temurin-25-alpine AS build + +WORKDIR /build + +COPY pom.xml . +COPY src/main/java ./src/main/java +COPY dist/src/main/resources ./src/main/resources + +# reuse deps across builds +RUN --mount=type=cache,target=/root/.m2 mvn clean package + +FROM eclipse-temurin:25-jre-alpine +COPY --from=build /build/target/modern-frontend-complexity-alternative.jar modern-frontend-complexity-alternative.jar +ENTRYPOINT ["java", "-jar", "modern-frontend-complexity-alternative.jar"] \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/README.md b/modern-frontend-complexity-alternative/README.md new file mode 100644 index 00000000..d946ea0b --- /dev/null +++ b/modern-frontend-complexity-alternative/README.md @@ -0,0 +1,43 @@ +# Modern Frontend Complexity Alternative + +A simpler approach to build web apps with all the expected features: +* fast load times +* native-like, smooth transitions between pages +* high degree of interactivity; most user actions should feel fast +* real-time validation, especially for complex forms and processes +* great development experience - ability to quickly see and validate UI changes +* ability to create, share and use UI components +* testability - does it work? +* translations, internationalization +* ?? + +For local development we need: +* Java 25 +* node (TailwindCSS management) + +For building & packing, Java is not required but Docker must be present. + +For local development, run: +``` +./mvnw spring-boot:run +``` +To have reloadable backend; in other terminal run +``` +npm ci + +cd ops +./live-css-gen.sh + +≈ tailwindcss v4.2.2 + +Done in 93ms +Done in 169µs +Done in 4ms +``` +To have CSS classes (thanks to the use of Tailwind) to be live-generated. + +TODO: +* recheck dev instructions +* input live validation? +* some tests + diff --git a/modern-frontend-complexity-alternative/mvnw b/modern-frontend-complexity-alternative/mvnw new file mode 100755 index 00000000..bd8896bf --- /dev/null +++ b/modern-frontend-complexity-alternative/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/modern-frontend-complexity-alternative/mvnw.cmd b/modern-frontend-complexity-alternative/mvnw.cmd new file mode 100644 index 00000000..92450f93 --- /dev/null +++ b/modern-frontend-complexity-alternative/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/modern-frontend-complexity-alternative/ops/build_and_package.bash b/modern-frontend-complexity-alternative/ops/build_and_package.bash new file mode 100755 index 00000000..104ec19d --- /dev/null +++ b/modern-frontend-complexity-alternative/ops/build_and_package.bash @@ -0,0 +1,72 @@ +#!/bin/bash +set -euo pipefail + +app="simpler-web" +tag="${TAG:-latest}" +tagged_image="${app}:${tag}" + +echo "Creating package directory in dist directory for ${tagged_image}" +echo "Preparing dist dir" + +cd .. + +rm -r -f dist +mkdir dist + +echo "Building static resources" + +dev_resources=src/main/resources +dev_static_resources="$dev_resources/static" +package_resources=dist/src/main/resources +package_static_resources="$package_resources/static" + +mkdir -p "$package_static_resources" + +bundle_hash=$(openssl rand -hex 8) + +input_css_path="$dev_static_resources/input.css" +hashed_css_file="styles_$bundle_hash.css" +output_css_path="$package_static_resources/$hashed_css_file" +export stylesPath=$output_css_path + +npx @tailwindcss/cli --minify -i "${input_css_path}" -o "${output_css_path}" + +cp -r "$dev_static_resources/lib" "$package_static_resources/lib" +cp -r "$dev_resources/templates" "$package_resources/templates" +cp -r "$dev_resources/application.yaml" "$package_resources/application.yaml" + +components_file="components_${bundle_hash}.js" +export CSS_PATH="/${hashed_css_file}" +export COMPONENTS_PATH="/${components_file}" +envsubst '${CSS_PATH} ${COMPONENTS_PATH}' < "$dev_resources/application-prod.yaml" > "$package_resources/application.yaml" + +cp "$dev_resources/messages.properties" "$package_resources/messages.properties" + +export COMPONENTS_INPUT_DIR="${dev_static_resources}" +export COMPONENTS_OUTPUT_PATH="${package_static_resources}/${components_file}" + +python3 ops/package_components.py + +echo +echo "Static resources prepared, building Docker image" + +docker build -t "$tagged_image" . + +gzipped_image_path="dist/$app.tar.gz" + +echo +echo "Image built, exporting it to $gzipped_image_path, this can take a while" + +docker save "$tagged_image" | gzip > ${gzipped_image_path} + +echo "Image exported, preparing scripts..." + +export app=$app +export tag=$tag +export run_cmd="docker run -d --network host \\ +--restart unless-stopped --name $app $tagged_image" + +envsubst '${app} ${tag}' < ops/template_load_and_run_app.bash > dist/load_and_run_app.bash +envsubst '${app} ${run_cmd}' < ops/template_run_app.bash > dist/run_app.bash + +echo "Package prepared." \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/ops/live-css-gen.sh b/modern-frontend-complexity-alternative/ops/live-css-gen.sh new file mode 100755 index 00000000..1583c559 --- /dev/null +++ b/modern-frontend-complexity-alternative/ops/live-css-gen.sh @@ -0,0 +1,2 @@ +cd .. +npx @tailwindcss/cli -i src/main/resources/static/input.css -o src/main/resources/static/output.css --watch \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/ops/package_components.py b/modern-frontend-complexity-alternative/ops/package_components.py new file mode 100644 index 00000000..0ee2eb9d --- /dev/null +++ b/modern-frontend-complexity-alternative/ops/package_components.py @@ -0,0 +1,21 @@ +import json +import subprocess +from os import path, listdir, environ + +components_input_dir=environ["COMPONENTS_INPUT_DIR"] +components_output_path=environ["COMPONENTS_OUTPUT_PATH"] + +content_to_write = "" + +for c in listdir(components_input_dir): + if not c.endswith(".js"): + continue + + with open(path.join(components_input_dir, c)) as c: + content_to_write += (c.read() + "\n\n") + + +with open(components_output_path, "w") as f: + f.write(content_to_write.strip()) + + diff --git a/modern-frontend-complexity-alternative/ops/template_load_and_run_app.bash b/modern-frontend-complexity-alternative/ops/template_load_and_run_app.bash new file mode 100644 index 00000000..59528028 --- /dev/null +++ b/modern-frontend-complexity-alternative/ops/template_load_and_run_app.bash @@ -0,0 +1,8 @@ +#!/bin/bash +tagged_image="${app}:${tag}" +gzipped_image_path="${app}.tar.gz" + +echo "Loading ${tagged_image} image, this can take a while..." +docker load < "$gzipped_image_path" +echo "Image loaded, running it..." +exec bash run_app.bash \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/ops/template_run_app.bash b/modern-frontend-complexity-alternative/ops/template_run_app.bash new file mode 100644 index 00000000..3d1e8570 --- /dev/null +++ b/modern-frontend-complexity-alternative/ops/template_run_app.bash @@ -0,0 +1,16 @@ +#!/bin/bash +found_container=$(docker ps -q -f name="${app}") + +if [ "$found_container" ]; then + echo "Stopping previous ${app} version..." + docker stop "${app}" +fi + +echo "Removing previous container...." +docker rm "${app}" + +echo +echo "Starting new ${app} version..." +echo + +${run_cmd} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/package-lock.json b/modern-frontend-complexity-alternative/package-lock.json new file mode 100644 index 00000000..2ea90880 --- /dev/null +++ b/modern-frontend-complexity-alternative/package-lock.json @@ -0,0 +1,991 @@ +{ + "name": "modern-frontend-complexity-alternative", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@tailwindcss/cli": "^4.2.2", + "tailwindcss": "^4.2.2" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@parcel/watcher": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", + "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.3", + "is-glob": "^4.0.3", + "node-addon-api": "^7.0.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.6", + "@parcel/watcher-darwin-arm64": "2.5.6", + "@parcel/watcher-darwin-x64": "2.5.6", + "@parcel/watcher-freebsd-x64": "2.5.6", + "@parcel/watcher-linux-arm-glibc": "2.5.6", + "@parcel/watcher-linux-arm-musl": "2.5.6", + "@parcel/watcher-linux-arm64-glibc": "2.5.6", + "@parcel/watcher-linux-arm64-musl": "2.5.6", + "@parcel/watcher-linux-x64-glibc": "2.5.6", + "@parcel/watcher-linux-x64-musl": "2.5.6", + "@parcel/watcher-win32-arm64": "2.5.6", + "@parcel/watcher-win32-ia32": "2.5.6", + "@parcel/watcher-win32-x64": "2.5.6" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.6.tgz", + "integrity": "sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.6.tgz", + "integrity": "sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.6.tgz", + "integrity": "sha512-HgvOf3W9dhithcwOWX9uDZyn1lW9R+7tPZ4sug+NGrGIo4Rk1hAXLEbcH1TQSqxts0NYXXlOWqVpvS1SFS4fRg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.6.tgz", + "integrity": "sha512-vJVi8yd/qzJxEKHkeemh7w3YAn6RJCtYlE4HPMoVnCpIXEzSrxErBW5SJBgKLbXU3WdIpkjBTeUNtyBVn8TRng==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.6.tgz", + "integrity": "sha512-9JiYfB6h6BgV50CCfasfLf/uvOcJskMSwcdH1PHH9rvS1IrNy8zad6IUVPVUfmXr+u+Km9IxcfMLzgdOudz9EQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.6.tgz", + "integrity": "sha512-Ve3gUCG57nuUUSyjBq/MAM0CzArtuIOxsBdQ+ftz6ho8n7s1i9E1Nmk/xmP323r2YL0SONs1EuwqBp2u1k5fxg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.6.tgz", + "integrity": "sha512-f2g/DT3NhGPdBmMWYoxixqYr3v/UXcmLOYy16Bx0TM20Tchduwr4EaCbmxh1321TABqPGDpS8D/ggOTaljijOA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.6.tgz", + "integrity": "sha512-qb6naMDGlbCwdhLj6hgoVKJl2odL34z2sqkC7Z6kzir8b5W65WYDpLB6R06KabvZdgoHI/zxke4b3zR0wAbDTA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.6.tgz", + "integrity": "sha512-kbT5wvNQlx7NaGjzPFu8nVIW1rWqV780O7ZtkjuWaPUgpv2NMFpjYERVi0UYj1msZNyCzGlaCWEtzc+exjMGbQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.6.tgz", + "integrity": "sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.6.tgz", + "integrity": "sha512-3ukyebjc6eGlw9yRt678DxVF7rjXatWiHvTXqphZLvo7aC5NdEgFufVwjFfY51ijYEWpXbqF5jtrK275z52D4Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.6.tgz", + "integrity": "sha512-k35yLp1ZMwwee3Ez/pxBi5cf4AoBKYXj00CZ80jUz5h8prpiaQsiRPKQMxoLstNuqe2vR4RNPEAEcjEFzhEz/g==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.6.tgz", + "integrity": "sha512-hbQlYcCq5dlAX9Qx+kFb0FHue6vbjlf0FrNzSKdYK2APUf7tGfGxQCk2ihEREmbR6ZMc0MVAD5RIX/41gpUzTw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@tailwindcss/cli": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/cli/-/cli-4.2.2.tgz", + "integrity": "sha512-iJS+8kAFZ8HPqnh0O5DHCLjo4L6dD97DBQEkrhfSO4V96xeefUus2jqsBs1dUMt3OU9Ks4qIkiY0mpL5UW+4LQ==", + "license": "MIT", + "dependencies": { + "@parcel/watcher": "^2.5.1", + "@tailwindcss/node": "4.2.2", + "@tailwindcss/oxide": "4.2.2", + "enhanced-resolve": "^5.19.0", + "mri": "^1.2.0", + "picocolors": "^1.1.1", + "tailwindcss": "4.2.2" + }, + "bin": { + "tailwindcss": "dist/index.mjs" + } + }, + "node_modules/@tailwindcss/node": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.2.tgz", + "integrity": "sha512-pXS+wJ2gZpVXqFaUEjojq7jzMpTGf8rU6ipJz5ovJV6PUGmlJ+jvIwGrzdHdQ80Sg+wmQxUFuoW1UAAwHNEdFA==", + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "enhanced-resolve": "^5.19.0", + "jiti": "^2.6.1", + "lightningcss": "1.32.0", + "magic-string": "^0.30.21", + "source-map-js": "^1.2.1", + "tailwindcss": "4.2.2" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.2.2.tgz", + "integrity": "sha512-qEUA07+E5kehxYp9BVMpq9E8vnJuBHfJEC0vPC5e7iL/hw7HR61aDKoVoKzrG+QKp56vhNZe4qwkRmMC0zDLvg==", + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.2.2", + "@tailwindcss/oxide-darwin-arm64": "4.2.2", + "@tailwindcss/oxide-darwin-x64": "4.2.2", + "@tailwindcss/oxide-freebsd-x64": "4.2.2", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.2.2", + "@tailwindcss/oxide-linux-arm64-gnu": "4.2.2", + "@tailwindcss/oxide-linux-arm64-musl": "4.2.2", + "@tailwindcss/oxide-linux-x64-gnu": "4.2.2", + "@tailwindcss/oxide-linux-x64-musl": "4.2.2", + "@tailwindcss/oxide-wasm32-wasi": "4.2.2", + "@tailwindcss/oxide-win32-arm64-msvc": "4.2.2", + "@tailwindcss/oxide-win32-x64-msvc": "4.2.2" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.2.2.tgz", + "integrity": "sha512-dXGR1n+P3B6748jZO/SvHZq7qBOqqzQ+yFrXpoOWWALWndF9MoSKAT3Q0fYgAzYzGhxNYOoysRvYlpixRBBoDg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.2.2.tgz", + "integrity": "sha512-iq9Qjr6knfMpZHj55/37ouZeykwbDqF21gPFtfnhCCKGDcPI/21FKC9XdMO/XyBM7qKORx6UIhGgg6jLl7BZlg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.2.2.tgz", + "integrity": "sha512-BlR+2c3nzc8f2G639LpL89YY4bdcIdUmiOOkv2GQv4/4M0vJlpXEa0JXNHhCHU7VWOKWT/CjqHdTP8aUuDJkuw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.2.2.tgz", + "integrity": "sha512-YUqUgrGMSu2CDO82hzlQ5qSb5xmx3RUrke/QgnoEx7KvmRJHQuZHZmZTLSuuHwFf0DJPybFMXMYf+WJdxHy/nQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.2.2.tgz", + "integrity": "sha512-FPdhvsW6g06T9BWT0qTwiVZYE2WIFo2dY5aCSpjG/S/u1tby+wXoslXS0kl3/KXnULlLr1E3NPRRw0g7t2kgaQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.2.2.tgz", + "integrity": "sha512-4og1V+ftEPXGttOO7eCmW7VICmzzJWgMx+QXAJRAhjrSjumCwWqMfkDrNu1LXEQzNAwz28NCUpucgQPrR4S2yw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.2.2.tgz", + "integrity": "sha512-oCfG/mS+/+XRlwNjnsNLVwnMWYH7tn/kYPsNPh+JSOMlnt93mYNCKHYzylRhI51X+TbR+ufNhhKKzm6QkqX8ag==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.2.2.tgz", + "integrity": "sha512-rTAGAkDgqbXHNp/xW0iugLVmX62wOp2PoE39BTCGKjv3Iocf6AFbRP/wZT/kuCxC9QBh9Pu8XPkv/zCZB2mcMg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.2.2.tgz", + "integrity": "sha512-XW3t3qwbIwiSyRCggeO2zxe3KWaEbM0/kW9e8+0XpBgyKU4ATYzcVSMKteZJ1iukJ3HgHBjbg9P5YPRCVUxlnQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.2.2.tgz", + "integrity": "sha512-eKSztKsmEsn1O5lJ4ZAfyn41NfG7vzCg496YiGtMDV86jz1q/irhms5O0VrY6ZwTUkFy/EKG3RfWgxSI3VbZ8Q==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.8.1", + "@emnapi/runtime": "^1.8.1", + "@emnapi/wasi-threads": "^1.1.0", + "@napi-rs/wasm-runtime": "^1.1.1", + "@tybys/wasm-util": "^0.10.1", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.2.2.tgz", + "integrity": "sha512-qPmaQM4iKu5mxpsrWZMOZRgZv1tOZpUm+zdhhQP0VhJfyGGO3aUKdbh3gDZc/dPLQwW4eSqWGrrcWNBZWUWaXQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.2.2.tgz", + "integrity": "sha512-1T/37VvI7WyH66b+vqHj/cLwnCxt7Qt3WFu5Q8hk65aOvlwAhs7rAp1VkulBJw/N4tMirXjVnylTR72uI0HGcA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "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/enhanced-resolve": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.20.1.tgz", + "integrity": "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "license": "ISC" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/jiti": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz", + "integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==", + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "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.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "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.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "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/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "license": "MIT" + }, + "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.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tailwindcss": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.2.tgz", + "integrity": "sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q==", + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.2.tgz", + "integrity": "sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + } + } +} diff --git a/modern-frontend-complexity-alternative/package.json b/modern-frontend-complexity-alternative/package.json new file mode 100644 index 00000000..2c47ac4f --- /dev/null +++ b/modern-frontend-complexity-alternative/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@tailwindcss/cli": "^4.2.2", + "tailwindcss": "^4.2.2" + } +} diff --git a/modern-frontend-complexity-alternative/pom.xml b/modern-frontend-complexity-alternative/pom.xml new file mode 100644 index 00000000..bf43ed49 --- /dev/null +++ b/modern-frontend-complexity-alternative/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 4.0.3 + + + com.binaryigor + modern-frontend-complexity-alternative + 0.0.1-SNAPSHOT + Modern Frontend Complexity Alternative + + + + + + + + + + + + + + + 25 + + + + org.springframework.boot + spring-boot-starter-webmvc + + + org.springframework.boot + spring-boot-starter-mustache + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-webmvc-test + test + + + + org.jsoup + jsoup + 1.22.1 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + modern-frontend-complexity-alternative + + + + + + \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/AppDataInitializer.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/AppDataInitializer.java new file mode 100644 index 00000000..0d46b646 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/AppDataInitializer.java @@ -0,0 +1,91 @@ +package com.binaryigor.complexity_alternative; + +import com.binaryigor.complexity_alternative.domain.Device; +import com.binaryigor.complexity_alternative.domain.DeviceOffer; +import com.binaryigor.complexity_alternative.domain.Money; +import com.binaryigor.complexity_alternative.infra.DeviceOfferRepository; +import com.binaryigor.complexity_alternative.infra.DeviceRepository; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; + +import java.time.Clock; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.Map; +import java.util.UUID; + +@Component +public class AppDataInitializer implements InitializingBean { + + private final DeviceRepository deviceRepository; + private final DeviceOfferRepository deviceOfferRepository; + private final Clock clock; + + public AppDataInitializer(DeviceRepository deviceRepository, DeviceOfferRepository deviceOfferRepository, + Clock clock) { + this.deviceRepository = deviceRepository; + this.deviceOfferRepository = deviceOfferRepository; + this.clock = clock; + } + + // TODO: more data + @Override + public void afterPropertiesSet() throws Exception { + var merchant1Id = UUID.randomUUID(); + var merchant2Id = UUID.randomUUID(); + var merchant3Id = UUID.randomUUID(); + + var now = clock.instant().truncatedTo(ChronoUnit.SECONDS); + + var iphone13 = new Device(UUID.fromString("9b0d5f33-6f9e-4aef-bb81-a57a045fb1aa"), "iPhone 13"); + deviceRepository.save(iphone13); + deviceOfferRepository.save(new DeviceOffer( + UUID.fromString("1b70aa73-29fd-41a1-b220-34ebba7a9c40"), + iphone13.id(), + Map.of("color", "black", + "memory", "8 GB", + "storage", "256 GB"), + Money.euro("1000.00"), + merchant1Id, + now.plus(Duration.ofDays(7)))); + deviceOfferRepository.save(new DeviceOffer( + UUID.fromString("4339e313-4391-48f3-bd7c-472b377aa19c"), + iphone13.id(), + Map.of("color", "black", + "memory", "12 GB", + "storage", "256 GB"), + Money.euro("1500.00"), + merchant1Id, + now.plus(Duration.ofDays(6)))); + deviceOfferRepository.save(new DeviceOffer( + UUID.fromString("0b14a01e-bfb4-4d91-bc57-b812114f75c8"), + iphone13.id(), + Map.of("color", "blue", + "memory", "8 GB", + "storage", "256 GB"), + Money.euro("900.00"), + merchant2Id, + now.plus(Duration.ofDays(3)))); + deviceOfferRepository.save(new DeviceOffer( + UUID.fromString("0b14a01e-bfb4-4d91-bc57-b812114f75c8"), + iphone13.id(), + Map.of("color", "midnight", + "memory", "8 GB", + "storage", "256 GB"), + Money.euro("1000.00"), + merchant2Id, + now.plus(Duration.ofDays(4)))); + + var iphone15 = new Device(UUID.fromString("11bdd7e6-a5e8-4d0f-a7cd-5f8074483e37"), "iPhone 15"); + deviceRepository.save(iphone15); + + var iphone17 = new Device(UUID.fromString("0cd8d327-604b-4ffd-9e43-08497ed99d2c"), "iPhone 17"); + deviceRepository.save(iphone17); + + var thinkPadT16 = new Device(UUID.fromString("73aad6b7-8bf1-4346-b833-3767997205db"), "Lenovo ThinkPad T16"); + deviceRepository.save(thinkPadT16); + + var thinkPadT14 = new Device(UUID.fromString("94a0d28e-3e7e-47ac-ac81-3cf38bff18a8"), "Lenovo ThinkPad T14"); + deviceRepository.save(thinkPadT14); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/ModernFrontendComplexityAlternativeApp.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/ModernFrontendComplexityAlternativeApp.java new file mode 100644 index 00000000..52c3557d --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/ModernFrontendComplexityAlternativeApp.java @@ -0,0 +1,22 @@ +package com.binaryigor.complexity_alternative; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.Bean; + +import java.time.Clock; + +@ConfigurationPropertiesScan +@SpringBootApplication +public class ModernFrontendComplexityAlternativeApp { + + static void main(String[] args) { + SpringApplication.run(ModernFrontendComplexityAlternativeApp.class, args); + } + + @Bean + Clock clock() { + return Clock.systemUTC(); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/DeviceController.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/DeviceController.java new file mode 100644 index 00000000..debf5f1a --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/DeviceController.java @@ -0,0 +1,181 @@ +package com.binaryigor.complexity_alternative.app; + +import com.binaryigor.complexity_alternative.domain.AvailableAttribute; +import com.binaryigor.complexity_alternative.domain.Device; +import com.binaryigor.complexity_alternative.domain.DeviceNotFoundException; +import com.binaryigor.complexity_alternative.domain.DevicesException; +import com.binaryigor.complexity_alternative.infra.DeviceOfferRepository; +import com.binaryigor.complexity_alternative.infra.DeviceRepository; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.*; +import java.util.stream.Collectors; + +@Controller +public class DeviceController { + + private final DeviceRepository deviceRepository; + private final DeviceOfferRepository deviceOfferRepository; + private final TemplatesResolver templatesResolver; + private final Translations translations; + + public DeviceController(DeviceRepository deviceRepository, DeviceOfferRepository deviceOfferRepository, + TemplatesResolver templatesResolver, Translations translations) { + this.deviceRepository = deviceRepository; + this.deviceOfferRepository = deviceOfferRepository; + this.templatesResolver = templatesResolver; + this.translations = translations; + } + + @GetMapping("/devices") + public String devices(Model model, Locale locale, + @RequestParam(required = false) String search) { + translations.enrich(model, locale, Map.of("devices-page.title", "title"), + "devices-page.title", + "devices-page.search-input-placeholder", + "devices-page.search-indicator", + "devices-page.trigger-error-button"); + + enrichWithDevicesSearchResultsTranslations(model, locale); + + var devices = deviceRepository.devices(search); + + return templatesResolver.resolve("devices-page", + devicesModel(model, devices)); + } + + private void enrichWithDevicesSearchResultsTranslations(Model model, Locale locale) { + translations.enrich(model, locale, + "devices-search-results.no-results", + "devices-search-results.details-option", + "devices-search-results.buy-option"); + } + + private Model devicesModel(Model model, List devices) { + return model.addAttribute("devices", devices) + .addAttribute("no-results", devices.isEmpty()); + } + + @GetMapping("/search-devices") + public String searchDevices(Model model, Locale locale, @RequestParam(required = false) String search) { + var devices = deviceRepository.devices(search); + enrichWithDevicesSearchResultsTranslations(model, locale); + // simulate slower search for UI experiments + try { + Thread.sleep(1000); + } catch (Exception e) { + throw new RuntimeException(e); + } + return templatesResolver.resolve("devices-search-results", devicesModel(model, devices)); + } + + @GetMapping("/devices/{id}/offers") + public String deviceOffers(@PathVariable UUID id, + @RequestParam MultiValueMap params, + Model model) { + var availableAttributes = deviceOfferRepository.availableAttributes(id).stream() + .map(AvailableAttribute::key) + .collect(Collectors.toSet()); + + var searchRequestAttributes = params.entrySet().stream() + .filter(e -> availableAttributes.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + var sortingColumn = Optional.ofNullable(params.getFirst("sortingColumn")) + .map(v -> DeviceOfferRepository.SortingColumn.valueOf(v.toUpperCase())) + .orElse(DeviceOfferRepository.SortingColumn.PRICE); + + var ascendingSortingDirection = Optional.ofNullable(params.getFirst("sortingDirection")) + .map(d -> d.equalsIgnoreCase("ascending")) + .orElse(true); + + var deviceOffers = deviceOfferRepository.offers(new DeviceOfferRepository.SearchRequest(id, searchRequestAttributes, + sortingColumn, ascendingSortingDirection)); + return templatesResolver.resolve("device-offers", + model.addAttribute("offers", deviceOffers) + .addAttribute("hasOffers", !deviceOffers.isEmpty())); + } + + @PostMapping("/devices/trigger-error") + void triggerError() { + throw new DevicesException("Triggered devices error"); + } + + @GetMapping("/devices/{id}") + public String device(@PathVariable UUID id, Model model, Locale locale) { + var device = deviceRepository.ofId(id) + .orElseThrow(() -> new DeviceNotFoundException(id)); + + translations.enrich(model, locale, Map.of("device-page.title", "title"), + "device-page.title", "device-page.page-description"); + + return templatesResolver.resolve("device-page", + model.addAttribute("id", device.id()) + .addAttribute("name", device.name())); + } + + @GetMapping("/buy-device/{id}") + public String buyDevice(@PathVariable UUID id, Locale locale, Model model) { + translations.enrich(model, locale, Map.of("buy-device-page.title", "title"), + "buy-device-page.title", + "buy-device-page.no-offers", + "buy-device-page.attributes-column", + "buy-device-page.price-column", + "buy-device-page.merchant-column", + "buy-device-page.expires-at-column", + "buy-device-page.actions-column", + "buy-device-page.actions.buy"); + + var device = deviceRepository.ofId(id) + .orElseThrow(() -> new DeviceNotFoundException(id)); + var availableAttributes = deviceOfferRepository.availableAttributes(id).stream() + .map(a -> toTranslatedAvailableAttribute(a, locale)) + .toList(); + var deviceOffers = deviceOfferRepository.offers(new DeviceOfferRepository.SearchRequest(id)); + + var attributeNames = availableAttributes.stream() + .map(TranslatedAvailableAttribute::name) + .toList(); + + return templatesResolver.resolve("buy-device-page", + model.addAttribute("id", device.id()) + .addAttribute("name", device.name()) + .addAttribute("availableAttributes", availableAttributes) + .addAttribute("offers", deviceOffers) + .addAttribute("hasOffers", !deviceOffers.isEmpty()) + .addAttribute("attributeNames", attributeNames)); + } + + private TranslatedAvailableAttribute toTranslatedAvailableAttribute(AvailableAttribute attribute, Locale locale) { + var name = translations.translate("device-attributes." + attribute.key(), attribute.key(), locale); + return TranslatedAvailableAttribute.translated(attribute, name); + } + + @GetMapping("/buy-device/{deviceId}/offers/{offerId}") + public String buyDeviceOffer(@PathVariable UUID deviceId, @PathVariable UUID offerId, + Locale locale, Model model) { + // TODO: better exception & check deviceId with offerId alignment + var deviceOffer = deviceOfferRepository.ofId(offerId).orElseThrow(); + var device = deviceRepository.ofId(deviceOffer.deviceId()).orElseThrow(); + + translations.enrich(model, locale, + Map.of("buy-device-offer-page.title", "title"), + Map.of("buy-device-offer-page.merchant-offer", + Map.of("__merchant__", deviceOffer.merchantId().toString())), + "buy-device-offer-page.title", + "buy-device-offer-page.merchant-offer", + "buy-device-offer-page.user-offer", + "buy-device-offer-page.user-offer-validation-error", + "buy-device-offer-page.send-button"); + + return templatesResolver.resolve("buy-device-offer-page", + model.addAttribute("deviceName", device.name()) + .addAttribute("offerPrice", deviceOffer.price())); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/ErrorsHandler.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/ErrorsHandler.java new file mode 100644 index 00000000..7356b2df --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/ErrorsHandler.java @@ -0,0 +1,102 @@ +package com.binaryigor.complexity_alternative.app; + +import com.binaryigor.complexity_alternative.domain.DeviceNotFoundException; +import com.binaryigor.complexity_alternative.domain.DevicesException; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.boot.webmvc.error.ErrorAttributes; +import org.springframework.boot.webmvc.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.request.ServletWebRequest; + +import java.util.Locale; +import java.util.Map; +import java.util.Optional; + +@Controller +@ControllerAdvice +public class ErrorsHandler implements ErrorController { + + private static final Map EXCEPTIONS_TO_TRANSLATION_KEYS = Map.of( + DevicesException.class.getSimpleName(), "errors.devices-exception", + DeviceNotFoundException.class.getSimpleName(), "errors.device-not-found-exception" + ); + private static final String DEFAULT_EXCEPTION_TRANSLATION_KEY = "errors.unhandled-exception"; + private final TemplatesResolver templatesResolver; + private final Translations translations; + private final ErrorAttributes errorAttributes; + + public ErrorsHandler(TemplatesResolver templatesResolver, Translations translations, ErrorAttributes errorAttributes) { + this.templatesResolver = templatesResolver; + this.translations = translations; + this.errorAttributes = errorAttributes; + } + + @RequestMapping("/error") + public String returnErrorPage(HttpServletRequest request, Model model, Locale locale) { + var webRequest = new ServletWebRequest(request); + var errorTranslationKey = Optional.ofNullable(errorAttributes.getError(webRequest)) + .map(e -> e.getClass().getSimpleName()) + .map(EXCEPTIONS_TO_TRANSLATION_KEYS::get) + .orElse(DEFAULT_EXCEPTION_TRANSLATION_KEY); + + + if (HTMX.isHTMXRequest()) { + return resolveErrorInfo(model, locale, errorTranslationKey); + } + + return resolveErrorPage(model, locale, errorTranslationKey); + } + + @ExceptionHandler + ResponseEntity handle(DevicesException exception, Locale locale, Model model) { + return handleTranslatableException(exception, locale, model, HttpStatus.UNPROCESSABLE_CONTENT); + } + + @ExceptionHandler + ResponseEntity handle(DeviceNotFoundException exception, Locale locale, Model model) { + return handleTranslatableException(exception, locale, model, HttpStatus.NOT_FOUND); + } + + private ResponseEntity handleTranslatableException(Exception exception, Locale locale, Model model, HttpStatus status) { + var translationKey = EXCEPTIONS_TO_TRANSLATION_KEYS.get(exception.getClass().getSimpleName()); + if (HTMX.isHTMXRequest()) { + return ResponseEntity.status(status) + .body(renderErrorInfo(model, locale, translationKey)); + } + return ResponseEntity.status(status) + .body(renderErrorPage(model, locale, translationKey)); + } + + private String resolveErrorInfo(Model model, Locale locale, String errorTranslationKey) { + translations.enrich(model, locale, Map.of(errorTranslationKey, "error-info.message"), + "error-info.title", errorTranslationKey); + return "error-info"; + } + private String renderErrorInfo(Model model, Locale locale, String errorTranslationKey) { + translations.enrich(model, locale, Map.of(errorTranslationKey, "error-info.message"), + "error-info.title", errorTranslationKey); + return templatesResolver.render("error-info", model, true); + } + + private String resolveErrorPage(Model model, Locale locale, String errorTranslationKey) { + translations.enrich(model, locale, + Map.of("error-page.title", "title", + errorTranslationKey, "error-page.message"), + "error-page.title", errorTranslationKey); + return templatesResolver.resolve("error-page", model); + } + + private String renderErrorPage(Model model, Locale locale, String errorTranslationKey) { + translations.enrich(model, locale, + Map.of("error-page.title", "title", + errorTranslationKey, "error-page.message"), + "error-page.title", errorTranslationKey); + return templatesResolver.render("error-page", model, false); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HTMX.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HTMX.java new file mode 100644 index 00000000..a0b03454 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HTMX.java @@ -0,0 +1,17 @@ +package com.binaryigor.complexity_alternative.app; + +import jakarta.servlet.http.HttpServletRequest; + +public class HTMX { + + public static String REQUEST_HEADER = "hx-request"; + + public static boolean isHTMXRequest() { + var currentRequest = WebTools.currentRequest(); + return currentRequest.isPresent() && isHTMXRequest(currentRequest.get()); + } + + public static boolean isHTMXRequest(HttpServletRequest request) { + return request.getHeader(REQUEST_HEADER) != null; + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HomeController.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HomeController.java new file mode 100644 index 00000000..203b1b08 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/HomeController.java @@ -0,0 +1,14 @@ +package com.binaryigor.complexity_alternative.app; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class HomeController { + + @GetMapping + String home(Model model) { + return "forward:/devices"; + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TemplatesResolver.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TemplatesResolver.java new file mode 100644 index 00000000..e6c66a9f --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TemplatesResolver.java @@ -0,0 +1,50 @@ +package com.binaryigor.complexity_alternative.app; + +import com.samskivert.mustache.Mustache; +import org.springframework.stereotype.Component; +import org.springframework.ui.Model; + +import java.util.List; + +@Component +public class TemplatesResolver { + + private final Mustache.Compiler compiler; + private final String cssPath; + private final String htmxPath; + private final List componentPaths; + + public TemplatesResolver(Mustache.Compiler compiler, WebProperties properties) { + this.compiler = compiler; + this.cssPath = properties.cssPath(); + this.htmxPath = properties.htmxPath(); + this.componentPaths = properties.componentPaths(); + } + + public String resolve(String template, Model model) { + if (HTMX.isHTMXRequest()) { + return template; + } + + model.addAttribute("cssPath", cssPath) + .addAttribute("htmxPath", htmxPath) + .addAttribute("componentPaths", componentPaths) + .addAttribute(template, true); + + return "page-wrapper"; + } + + public String render(String template, Model model, boolean fragment) { + model.addAttribute("cssPath", cssPath) + .addAttribute("htmxPath", htmxPath) + .addAttribute("componentPaths", componentPaths); + + if (fragment) { + return compiler.loadTemplate(template).execute(model); + } + + model.addAttribute(template, true); + + return compiler.loadTemplate("page-wrapper").execute(model); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TranslatedAvailableAttribute.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TranslatedAvailableAttribute.java new file mode 100644 index 00000000..62aa650b --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/TranslatedAvailableAttribute.java @@ -0,0 +1,13 @@ +package com.binaryigor.complexity_alternative.app; + + +import com.binaryigor.complexity_alternative.domain.AvailableAttribute; + +import java.util.Collection; + +public record TranslatedAvailableAttribute(String name, String key, Collection values) { + + public static TranslatedAvailableAttribute translated(AvailableAttribute attribute, String name) { + return new TranslatedAvailableAttribute(name, attribute.key(), attribute.values()); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/Translations.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/Translations.java new file mode 100644 index 00000000..a5af9e99 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/Translations.java @@ -0,0 +1,58 @@ +package com.binaryigor.complexity_alternative.app; + +import org.jspecify.annotations.Nullable; +import org.springframework.context.MessageSource; +import org.springframework.stereotype.Component; +import org.springframework.ui.Model; + +import java.util.Locale; +import java.util.Map; + +@Component +public class Translations { + + private final MessageSource messageSource; + + public Translations(MessageSource messageSource) { + this.messageSource = messageSource; + } + + public void enrich(Model model, Locale locale, String... keys) { + enrich(model, locale, Map.of(), Map.of(), keys); + } + + public void enrich(Model model, Locale locale, Map mapping, String... keys) { + enrich(model, locale, mapping, Map.of(), keys); + } + + public void enrich(Model model, Locale locale, + Map mapping, + Map> keysToVariables, + String... keys) { + for (var k : keys) { + var t = messageSource.getMessage(k, null, locale); + var tVars = keysToVariables.getOrDefault(k, Map.of()); + if (!tVars.isEmpty()) { + t = replaceTranslationVars(t, tVars); + } + + var attribute = mapping.getOrDefault(k, k); + model.addAttribute(attribute, t); + if (!attribute.equals(k)) { + model.addAttribute(k, t); + } + } + } + + private String replaceTranslationVars(String template, Map vars) { + var t = template; + for (var e : vars.entrySet()) { + t = t.replace(e.getKey(), e.getValue()); + } + return t; + } + + public String translate(String key, @Nullable String defaultMessage, Locale locale) { + return messageSource.getMessage(key, null, defaultMessage, locale); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebProperties.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebProperties.java new file mode 100644 index 00000000..1b01905f --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebProperties.java @@ -0,0 +1,9 @@ +package com.binaryigor.complexity_alternative.app; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +@ConfigurationProperties(prefix = "web") +public record WebProperties(String cssPath, String htmxPath, List componentPaths) { +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebTools.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebTools.java new file mode 100644 index 00000000..080e3b24 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/app/WebTools.java @@ -0,0 +1,18 @@ +package com.binaryigor.complexity_alternative.app; + +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Optional; + +public class WebTools { + + public static Optional currentRequest() { + var ra = RequestContextHolder.getRequestAttributes(); + if (ra instanceof ServletRequestAttributes sra) { + return Optional.of(sra.getRequest()); + } + return Optional.empty(); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/AvailableAttribute.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/AvailableAttribute.java new file mode 100644 index 00000000..c6b538dc --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/AvailableAttribute.java @@ -0,0 +1,6 @@ +package com.binaryigor.complexity_alternative.domain; + +import java.util.Collection; + +public record AvailableAttribute(String key, Collection values) { +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Device.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Device.java new file mode 100644 index 00000000..39f62506 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Device.java @@ -0,0 +1,6 @@ +package com.binaryigor.complexity_alternative.domain; + +import java.util.UUID; + +public record Device(UUID id, String name) { +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceNotFoundException.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceNotFoundException.java new file mode 100644 index 00000000..6ffd1d32 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceNotFoundException.java @@ -0,0 +1,10 @@ +package com.binaryigor.complexity_alternative.domain; + +import java.util.UUID; + +public class DeviceNotFoundException extends RuntimeException { + + public DeviceNotFoundException(UUID id) { + super("Device of %s id doesn't exist".formatted(id)); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceOffer.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceOffer.java new file mode 100644 index 00000000..919e6e8f --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DeviceOffer.java @@ -0,0 +1,18 @@ +package com.binaryigor.complexity_alternative.domain; + +import java.time.Instant; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +public record DeviceOffer(UUID id, + UUID deviceId, + Map attributes, + Money price, + UUID merchantId, + Instant expiresAt) { + + public Collection attributeValues() { + return attributes.values(); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DevicesException.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DevicesException.java new file mode 100644 index 00000000..eeaf20cc --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/DevicesException.java @@ -0,0 +1,8 @@ +package com.binaryigor.complexity_alternative.domain; + +public class DevicesException extends RuntimeException { + + public DevicesException(String message) { + super(message); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Money.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Money.java new file mode 100644 index 00000000..c66082dd --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/domain/Money.java @@ -0,0 +1,14 @@ +package com.binaryigor.complexity_alternative.domain; + +import java.math.BigDecimal; + +public record Money(BigDecimal value, Currency currency) { + + public static Money euro(String value) { + return new Money(new BigDecimal(value), Currency.EUR); + } + + public enum Currency { + EUR + } +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceOfferRepository.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceOfferRepository.java new file mode 100644 index 00000000..3483cb44 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceOfferRepository.java @@ -0,0 +1,85 @@ +package com.binaryigor.complexity_alternative.infra; + +import com.binaryigor.complexity_alternative.domain.AvailableAttribute; +import com.binaryigor.complexity_alternative.domain.DeviceOffer; +import org.springframework.stereotype.Repository; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +@Repository +public class DeviceOfferRepository { + + private final Map> deviceIdToOfferDb = new ConcurrentHashMap<>(); + private final Map offerIdToOfferDb = new ConcurrentHashMap<>(); + + public void save(DeviceOffer offer) { + deviceIdToOfferDb.computeIfAbsent(offer.deviceId(), $ -> new ArrayList<>()).add(offer); + offerIdToOfferDb.put(offer.id(), offer); + } + + public List availableAttributes(UUID deviceId) { + var attributes = new HashMap>(); + deviceIdToOfferDb.getOrDefault(deviceId, List.of()) + .forEach(o -> { + o.attributes().forEach((attrK, attrV) -> { + attributes.computeIfAbsent(attrK, $ -> new HashSet<>()).add(attrV); + }); + }); + return attributes.entrySet().stream() + .map(e -> new AvailableAttribute(e.getKey(), e.getValue())) + .toList(); + } + + public List offers(SearchRequest request) { + return deviceIdToOfferDb.getOrDefault(request.deviceId, List.of()).stream() + .filter(d -> { + for (var e : request.attributes().entrySet()) { + var key = e.getKey(); + var values = e.getValue(); + var deviceValue = d.attributes().get(key); + if (deviceValue == null || !values.contains(deviceValue)) { + return false; + } + } + return true; + }) + .sorted((a, b) -> { + Comparator comparator = switch (request.sortingColumn) { + case PRICE -> Comparator.comparing(o -> o.price().value()); + case MERCHANT -> Comparator.comparing(DeviceOffer::merchantId); + case EXPIRES_AT -> Comparator.comparing(DeviceOffer::expiresAt); + }; + return request.sortingAscending ? comparator.compare(a, b) : -comparator.compare(a, b); + }) + .toList(); + } + + public Optional ofId(UUID id) { + return Optional.ofNullable(offerIdToOfferDb.get(id)); + } + + public record SearchRequest(UUID deviceId, + Map> attributes, + SortingColumn sortingColumn, + boolean sortingAscending) { + + public SearchRequest(UUID deviceId) { + this(deviceId, null, null, true); + } + + public SearchRequest { + if (attributes == null) { + attributes = Map.of(); + } + if (sortingColumn == null) { + sortingColumn = SortingColumn.PRICE; + } + } + } + + public enum SortingColumn { + PRICE, MERCHANT, EXPIRES_AT + } + +} diff --git a/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceRepository.java b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceRepository.java new file mode 100644 index 00000000..5f719095 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/java/com/binaryigor/complexity_alternative/infra/DeviceRepository.java @@ -0,0 +1,42 @@ +package com.binaryigor.complexity_alternative.infra; + +import com.binaryigor.complexity_alternative.domain.Device; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +@Repository +public class DeviceRepository { + + private final Map db = new ConcurrentHashMap<>(); + + public void save(Device device) { + db.put(device.id(), device); + } + + public List all() { + return db.values().stream().toList(); + } + + public List devices(String search) { + if (search == null || search.isBlank()) { + return db.values().stream().toList(); + } + var loweredSearch = search.toLowerCase(); + return db.values().stream() + .filter(d -> d.name().toLowerCase().contains(loweredSearch)) + .toList(); + } + + public List allDevices() { + return devices(null); + } + + public Optional ofId(UUID id) { + return Optional.ofNullable(db.get(id)); + } +} diff --git a/modern-frontend-complexity-alternative/src/main/resources/application-prod.yaml b/modern-frontend-complexity-alternative/src/main/resources/application-prod.yaml new file mode 100644 index 00000000..26ebce3c --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/application-prod.yaml @@ -0,0 +1,10 @@ +spring: + devtools: + restart: + enabled: false + +web: + cssPath: ${CSS_PATH} + htmxPath: "/lib/htmx.min.2.0.8.js" + component-paths: + - ${COMPONENTS_PATH} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/application.yaml b/modern-frontend-complexity-alternative/src/main/resources/application.yaml new file mode 100644 index 00000000..a6639eae --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/application.yaml @@ -0,0 +1,20 @@ +spring: + application: + name: modern-frontend-complexity-alternative + devtools: + restart: + enabled: true + poll-interval: 500ms + quiet-period: 250ms + +web: + cssPath: "/output.css" + htmxPath: "/lib/htmx.min.2.0.8.js" + component-paths: + - "/drop-down.js" + - "/error-modal.js" + - "/selectables-container.js" + - "/selected-container.js" + - "/sortables-container.js" + - "/validateable-input.js" + diff --git a/modern-frontend-complexity-alternative/src/main/resources/messages.properties b/modern-frontend-complexity-alternative/src/main/resources/messages.properties new file mode 100644 index 00000000..81ab8e17 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/messages.properties @@ -0,0 +1,37 @@ +devices-page.title=Devices +devices-page.search-input-placeholder=Search devices... +devices-page.search-indicator=Searching devices... +devices-page.trigger-error-button=Trigger some error + +devices-search-results.no-results=No devices for a given query. Try another one +devices-search-results.details-option=Details +devices-search-results.buy-option=Buy + +device-page.title=Device Page +device-page.page-description=device page + +buy-device-page.title=Offers +buy-device-page.no-offers=0 offers for this device. +buy-device-page.attributes-column=Attributes +buy-device-page.price-column=Price +buy-device-page.merchant-column=Merchant +buy-device-page.expires-at-column=Expires at +buy-device-page.actions-column=Actions +buy-device-page.actions.buy=Buy + +device-attributes.color=Color +device-attributes.memory=Memory +device-attributes.storage=Storage + + +buy-device-offer-page.title=Device Offer +buy-device-offer-page.merchant-offer=offer from __merchant__ merchant. +buy-device-offer-page.user-offer=Your offer: +buy-device-offer-page.user-offer-validation-error=Invalid money format. Positive number with up to 2 decimal places is required +buy-device-offer-page.send-button=Send + +error-info.title=Something went wrong... +error-page.title=Something went wrong... +errors.devices-exception=Just some triggered exception. +errors.device-not-found-exception=This device doesn't exist. +errors.unhandled-exception=Unknown exception. \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/drop-down.js b/modern-frontend-complexity-alternative/src/main/resources/static/drop-down.js new file mode 100644 index 00000000..360af21f --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/drop-down.js @@ -0,0 +1,27 @@ +class DropDown extends HTMLElement { + + #hideOnOutsideClick = undefined; + + connectedCallback() { + const anchor = this.querySelector("[data-drop-down-anchor]"); + const options = this.querySelector("[data-drop-down-options]"); + + anchor.onclick = () => options.classList.toggle("hidden"); + + this.#hideOnOutsideClick = (e) => { + if (e.target != anchor) { + options.classList.add("hidden"); + } + }; + + window.addEventListener("click", this.#hideOnOutsideClick); + } + + disconnectedCallback() { + window.removeEventListener("click", this.#hideOnOutsideClick); + } +} + +if (customElements.get("drop-down") === undefined) { + customElements.define("drop-down", DropDown); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/error-modal.js b/modern-frontend-complexity-alternative/src/main/resources/static/error-modal.js new file mode 100644 index 00000000..01def0cd --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/error-modal.js @@ -0,0 +1,31 @@ +class ErorrModal extends HTMLElement { + + #container = undefined; + #titleElement = undefined; + #contentElement = undefined; + + connectedCallback() { + this.#container = this.querySelector("[data-container]"); + this.#titleElement = this.querySelector("[data-title]"); + this.#contentElement = this.querySelector("[data-content]"); + + this.querySelector("[data-close-button]").onclick = () => { + this.#container.classList.add("hidden"); + }; + + this.addEventListener("error-modal-show", e => { + const { title, content } = e.detail; + if (title) { + this.#titleElement.innerHTML = title; + } + if (content) { + this.#contentElement.innerHTML = content; + } + this.#container.classList.remove("hidden"); + }); + } +} + +if (customElements.get("error-modal") === undefined) { + customElements.define("error-modal", ErorrModal); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/input.css b/modern-frontend-complexity-alternative/src/main/resources/static/input.css new file mode 100644 index 00000000..01183960 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/input.css @@ -0,0 +1,10 @@ +@import "tailwindcss"; + +.search-indicator { + display: none; +} + +.htmx-request .search-indicator, +.htmx-request.search-indicator { + display: block; +} diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/lib/htmx.min.2.0.8.js b/modern-frontend-complexity-alternative/src/main/resources/static/lib/htmx.min.2.0.8.js new file mode 100644 index 00000000..6c70defa --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/lib/htmx.min.2.0.8.js @@ -0,0 +1,2 @@ +var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=dn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.8"};Q.onLoad=V;Q.process=Ft;Q.on=xe;Q.off=be;Q.trigger=ae;Q.ajax=Ln;Q.find=f;Q.findAll=x;Q.closest=g;Q.remove=_;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=ze;Q.defineExtension=_n;Q.removeExtension=zn;Q.logAll=j;Q.logNone=$;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:se,canAccessLocalStorage:X,findThisElement:Se,filterValues:yn,swap:ze,hasAttribute:s,getAttributeValue:a,getClosestAttributeValue:ne,getClosestMatch:q,getExpressionVars:Rn,getHeaders:mn,getInputValues:dn,getInternalData:oe,getSwapSpecification:bn,getTriggerSpecs:st,getTarget:Ee,makeFragment:D,mergeObjects:le,makeSettleInfo:Sn,oobSwap:Te,querySelectorExt:ue,settleImmediately:Yt,shouldCancel:ht,triggerEvent:ae,triggerErrorEvent:fe,withExtensions:Vt};const de=["get","post","put","delete","patch"];const R=de.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function a(e,t){return ee(e,t)||ee(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function te(){return document}function y(e,t){return e.getRootNode?e.getRootNode({composed:t}):te()}function q(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=a(t,n);const o=a(t,"hx-disinherit");var i=a(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function ne(t,n){let r=null;q(t,function(e){return!!(r=o(t,ce(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function A(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function L(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function N(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=te().createElement("script");ie(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){H(e)}finally{e.remove()}}})}function D(e){const t=e.replace(/]*)?>[\s\S]*?<\/head>/i,"");const n=A(t);let r;if(n==="html"){r=new DocumentFragment;const i=L(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=L(t);N(r,i.body);r.title=i.title}else{const i=L('");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function re(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function P(e){return typeof e==="function"}function k(e){return t(e,"Object")}function oe(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e=0}function se(e){return e.getRootNode({composed:true})===document}function B(e){return e.trim().split(/\s+/)}function le(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function v(e){try{return JSON.parse(e)}catch(e){H(e);return null}}function X(){const e="htmx:sessionStorageTest";try{sessionStorage.setItem(e,e);sessionStorage.removeItem(e);return true}catch(e){return false}}function U(e){const t=new URL(e,"http://x");if(t){e=t.pathname+t.search}if(e!="/"){e=e.replace(/\/+$/,"")}return e}function e(e){return On(te().body,function(){return eval(e)})}function V(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function j(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function $(){Q.logger=null}function f(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return f(te(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(te(),e)}}function b(){return window}function _(e,t){e=w(e);if(t){b().setTimeout(function(){_(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function z(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function p(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ce(w(e));if(!e){return}if(n){b().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ce(w(e));if(!r){return}if(n){b().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=w(e);e.classList.toggle(t)}function Z(e,t){e=w(e);ie(e.parentElement.children,function(e){G(e,t)});K(ce(e),t)}function g(e,t){e=ce(w(e));if(e){return e.closest(t)}return null}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function pe(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(t,r,n){if(r.indexOf("global ")===0){return m(t,r.slice(7),true)}t=w(t);const o=[];{let t=0;let n=0;for(let e=0;e"){t--}}if(n0){const r=pe(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ce(t),pe(r.slice(8)))}else if(r.indexOf("find ")===0){e=f(p(t),pe(r.slice(5)))}else if(r==="next"||r==="nextElementSibling"){e=ce(t).nextElementSibling}else if(r.indexOf("next ")===0){e=ge(t,pe(r.slice(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ce(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,pe(r.slice(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=y(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=p(y(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var ge=function(t,e,n){const r=p(y(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ue(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(te().body,e)[0]}}function w(e,t){if(typeof e==="string"){return f(p(t)||document,e)}else{return e}}function ye(e,t,n,r){if(P(t)){return{target:te().body,event:J(e),listener:t,options:n}}else{return{target:w(e),event:J(t),listener:n,options:r}}}function xe(t,n,r,o){Gn(function(){const e=ye(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=P(n);return e?n:r}function be(t,n,r){Gn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return P(n)?n:r}const ve=te().createElement("output");function we(t,n){const e=ne(t,n);if(e){if(e==="this"){return[Se(t,n)]}else{const r=m(t,e);const o=/(^|,)(\s*)inherit(\s*)($|,)/.test(e);if(o){const i=ce(q(t,function(e){return e!==t&&s(ce(e),n)}));if(i){r.push(...we(i,n))}}if(r.length===0){H('The selector "'+e+'" on '+n+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ce(q(e,function(e){return a(ce(e),t)!=null}))}function Ee(e){const t=ne(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ue(e,t)}}else{const n=oe(e);if(n.boosted){return te().body}else{return e}}}function Ce(e){return Q.config.attributesToSettle.includes(e)}function Oe(t,n){ie(Array.from(t.attributes),function(e){if(!n.hasAttribute(e.name)&&Ce(e.name)){t.removeAttribute(e.name)}});ie(n.attributes,function(e){if(Ce(e.name)){t.setAttribute(e.name,e.value)}})}function He(t,e){const n=Jn(e);for(let e=0;e0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=m(t,n,false);if(r.length){ie(r,function(e){let t;const n=o.cloneNode(true);t=te().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=p(n)}const r={shouldSwap:true,target:e,fragment:t};if(!ae(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);$e(s,e,e,t,i);Re()}ie(i.elts,function(e){ae(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(te().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Re(){const e=f("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=f("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){ie(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=a(e,"id");const n=te().getElementById(t);if(n!=null){if(e.moveBefore){let e=f("#--htmx-preserve-pantry--");if(e==null){te().body.insertAdjacentHTML("afterend","
");e=f("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Ae(l,e,c){ie(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=p(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Le(e){return function(){G(e,Q.config.addedClass);Ft(ce(e));Ne(p(e));ae(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=z(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Ae(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Le(o))}}}function Ie(e,t){let n=0;while(n0}function ze(h,d,p,g){if(!g){g={}}let m=null;let n=null;let e=function(){re(g.beforeSwapCallback);h=w(h);const r=g.contextElement?y(g.contextElement,false):te();const e=document.activeElement;let t={};t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null};const o=Sn(h);if(p.swapStyle==="textContent"){h.textContent=d}else{let n=D(d);o.title=g.title||n.title;if(g.historyRequest){n=n.querySelector("[hx-history-elt],[data-hx-history-elt]")||n}if(g.selectOOB){const i=g.selectOOB.split(",");for(let t=0;t0){b().setTimeout(n,p.settleDelay)}else{n()}};let t=Q.config.globalViewTransitions;if(p.hasOwnProperty("transition")){t=p.transition}const r=g.contextElement||te();if(t&&ae(r,"htmx:beforeTransition",g.eventInfo)&&typeof Promise!=="undefined"&&document.startViewTransition){const o=new Promise(function(e,t){m=e;n=t});const i=e;e=function(){document.startViewTransition(function(){i();return o})}}try{if(p?.swapDelay&&p.swapDelay>0){b().setTimeout(e,p.swapDelay)}else{e()}}catch(e){fe(r,"htmx:swapError",g.eventInfo);re(n);throw e}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=v(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(k(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}ae(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=On(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(te().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function O(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=O(e,Qe).trim();e.shift()}else{t=O(e,E)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{O(o,C);const l=o.length;const c=O(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};O(o,C);u.pollInterval=d(O(o,/[,\[\s]/));O(o,C);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const f={trigger:c};var i=nt(e,o,"event");if(i){f.eventFilter=i}O(o,C);while(o.length>0&&o[0]!==","){const a=o.shift();if(a==="changed"){f.changed=true}else if(a==="once"){f.once=true}else if(a==="consume"){f.consume=true}else if(a==="delay"&&o[0]===":"){o.shift();f.delay=d(O(o,E))}else if(a==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=O(o,E);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=rt(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(O(o,E))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=O(o,E)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=rt(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=O(o,E)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}r.push(f)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=a(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){oe(e).cancelled=true}function ct(e,t,n){const r=oe(e);r.timeout=b().setTimeout(function(){if(se(e)&&r.cancelled!==true){if(!pt(n,e,Xt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function ft(e){return g(e,Q.config.disableSelector)}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){gt(t,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)},n,e,true)})}}function ht(e,t){if(e.type==="submit"&&t.tagName==="FORM"){return true}else if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit"){return true}const r=t.closest("a");const o=/^#.+/;if(r&&r.href&&!o.test(r.getAttribute("href"))){return true}}return false}function dt(e,t){return oe(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function pt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(te().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function gt(l,c,e,u,f){const a=oe(l);let t;if(u.from){t=m(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in a)){a.lastValue=new WeakMap}t.forEach(function(e){if(!a.lastValue.has(u)){a.lastValue.set(u,new WeakMap)}a.lastValue.get(u).set(e,e.value)})}ie(t,function(i){const s=function(e){if(!se(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(f||ht(e,i)){e.preventDefault()}if(pt(u,l,e)){return}const t=oe(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ce(e.target),u.target)){return}}if(u.once){if(a.triggeredOnce){return}else{a.triggeredOnce=true}}if(u.changed){const n=e.target;const r=n.value;const o=a.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(a.delayed){clearTimeout(a.delayed)}if(a.throttle){return}if(u.throttle>0){if(!a.throttle){ae(l,"htmx:trigger");c(l,e);a.throttle=b().setTimeout(function(){a.throttle=null},u.throttle)}}else if(u.delay>0){a.delayed=b().setTimeout(function(){ae(l,"htmx:trigger");c(l,e)},u.delay)}else{ae(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let yt=null;function xt(){if(!yt){yt=function(){mt=true};window.addEventListener("scroll",yt);window.addEventListener("resize",yt);setInterval(function(){if(mt){mt=false;ie(te().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&F(e)){e.setAttribute("data-hx-revealed","true");const t=oe(e);if(t.initHash){ae(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){ae(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;ae(e,"htmx:trigger");t(e)}};if(r>0){b().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;ie(de,function(r){if(s(t,"hx-"+r)){const o=a(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){xt();gt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ue(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ce(r),n,e)}else{gt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;e", "+e).join(""));return o}else{return[]}}function Rt(e){const t=At(e.target);const n=Nt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Nt(e);if(t){t.lastButtonClicked=null}}function At(e){return g(ce(e),"button, input[type='submit']")}function Lt(e){return e.form||g(e,"form")}function Nt(e){const t=At(e.target);if(!t){return}const n=Lt(t);if(!n){return}return oe(n)}function It(e){e.addEventListener("click",Rt);e.addEventListener("focusin",Rt);e.addEventListener("focusout",qt)}function Dt(t,e,n){const r=oe(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){On(t,function(){if(ft(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function Pt(t){Pe(t);for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(te().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Jt(t){if(!X()){return null}t=U(t);const n=v(sessionStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){r.response=this.response;ae(te().body,"htmx:historyCacheMissLoad",r);ze(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:true});$t(r.path);ae(te().body,"htmx:historyRestore",{path:e,cacheMiss:true,serverResponse:r.response})}else{fe(te().body,"htmx:historyCacheMissLoadError",r)}};if(ae(te().body,"htmx:historyCacheMiss",r)){t.send()}}function en(e){Gt();e=e||location.pathname+location.search;const t=Jt(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll};const r={path:e,item:t,historyElt:_t(),swapSpec:n};if(ae(te().body,"htmx:historyCacheHit",r)){ze(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title});$t(r.path);ae(te().body,"htmx:historyRestore",r)}}else{if(Q.config.refreshOnHistoryMiss){Q.location.reload(true)}else{Qt(e)}}}function tn(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function nn(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function rn(e,t){ie(e.concat(t),function(e){const t=oe(e);t.requestCount=(t.requestCount||1)-1});ie(e,function(e){const t=oe(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});ie(t,function(e){const t=oe(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function on(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);ie(e,e=>r.append(t,e))}}function un(e){if(e instanceof HTMLSelectElement&&e.multiple){return M(e.querySelectorAll("option:checked")).map(function(e){return e.value})}if(e instanceof HTMLInputElement&&e.files){return M(e.files)}return e.value}function fn(t,n,r,e,o){if(e==null||on(t,e)){return}else{t.push(e)}if(sn(e)){const i=ee(e,"name");ln(i,un(e),n);if(o){an(e,r)}}if(e instanceof HTMLFormElement){ie(e.elements,function(e){if(t.indexOf(e)>=0){cn(e.name,un(e),n)}else{t.push(e)}if(o){an(e,r)}});new FormData(e).forEach(function(e,t){if(e instanceof File&&e.name===""){return}ln(t,e,n)})}}function an(e,t){const n=e;if(n.willValidate){ae(n,"htmx:validation:validate");if(!n.checkValidity()){if(ae(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&Q.config.reportValidityOfForms){n.reportValidity()}t.push({elt:n,message:n.validationMessage,validity:n.validity})}}}function hn(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function dn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=oe(e);if(s.lastButtonClicked&&!se(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||a(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){fn(n,o,i,Lt(e),l)}fn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const f=ee(u,"name");ln(f,u.value,o)}const c=we(e,"hx-include");ie(c,function(e){fn(n,r,i,ce(e),l);if(!h(e,"form")){ie(p(e).querySelectorAll(ot),function(e){fn(n,r,i,e,l)})}});hn(r,o);return{errors:i,formData:r,values:kn(r)}}function pn(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function gn(e){e=Dn(e);let n="";e.forEach(function(e,t){n=pn(n,t,e)});return n}function mn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":a(t,"id"),"HX-Current-URL":location.href};Cn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(oe(e).boosted){r["HX-Boosted"]="true"}return r}function yn(n,e){const t=ne(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){ie(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;ie(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function xn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function bn(e,t){const n=t||ne(e,"hx-swap");const r={swapStyle:oe(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&oe(e).boosted&&!xn(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.slice(5);var o=f.split(":");const a=o.pop();var i=o.length>0?o.join(":"):null;r.show=a;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{H("Unknown modifier in hx-swap: "+l)}}}}return r}function vn(e){return ne(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function wn(t,n,r){let o=null;Vt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(vn(n)){return hn(new FormData,Dn(r))}else{return gn(r)}}}function Sn(e){return{tasks:[],elts:[e]}}function En(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(ue(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}if(typeof t.scroll==="number"){b().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(ue(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function Cn(r,e,o,i,s){if(i==null){i={}}if(r==null){return i}const l=a(r,e);if(l){let e=l.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=On(r,function(){if(s){return Function("event","return ("+e+")").call(r,s)}else{return Function("return ("+e+")").call(r)}},{})}else{n=v(e)}for(const c in n){if(n.hasOwnProperty(c)){if(i[c]==null){i[c]=n[c]}}}}return Cn(ce(u(r)),e,o,i,s)}function On(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function Hn(e,t,n){return Cn(e,"hx-vars",true,n,t)}function Tn(e,t,n){return Cn(e,"hx-vals",false,n,t)}function Rn(e,t){return le(Hn(e,t),Tn(e,t))}function qn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function An(t){if(t.responseURL){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(te().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function T(e,t){return t.test(e.getAllResponseHeaders())}function Ln(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return he(t,n,null,null,{targetOverride:w(r)||ve,returnPromise:true})}else{let e=w(r.target);if(r.target&&!e||r.source&&!e&&!w(r.source)){e=ve}return he(t,n,w(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true,push:r.push,replace:r.replace,selectOOB:r.selectOOB})}}else{return he(t,n,null,null,{returnPromise:true})}}function Nn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function In(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin);const o=location.protocol!=="about:"?location.origin:window.origin;const i=o===r.origin;if(Q.config.selfRequestsOnly){if(!i){return false}}return ae(e,"htmx:validateUrl",le({url:r,sameHost:i},n))}function Dn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Pn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function kn(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Pn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function he(t,n,r,o,i,k){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=te().body}const M=i.handler||Vn;const F=i.select||null;if(!se(r)){re(s);return e}const c=i.targetOverride||ce(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:ne(r,"hx-target")});re(l);return e}let u=oe(r);const f=u.lastButtonClicked;if(f){const A=ee(f,"formaction");if(A!=null){n=A}const L=ee(f,"formmethod");if(L!=null){if(de.includes(L.toLowerCase())){t=L}else{re(s);return e}}}const a=ne(r,"hx-confirm");if(k===undefined){const K=function(e){return he(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(ae(r,"htmx:confirm",G)===false){re(s);return e}}let h=r;let d=ne(r,"hx-sync");let p=null;let B=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ce(ue(r,I))}d=(N[1]||"drop").trim();u=oe(h);if(d==="drop"&&u.xhr&&u.abortable!==true){re(s);return e}else if(d==="abort"){if(u.xhr){re(s);return e}else{B=true}}else if(d==="replace"){ae(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");p=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){ae(h,"htmx:abort")}else{if(p==null){if(o){const D=oe(o);if(D&&D.triggerSpec&&D.triggerSpec.queue){p=D.triggerSpec.queue}}if(p==null){p="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(p==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="all"){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){he(t,n,r,o,i)})}re(s);return e}}const g=new XMLHttpRequest;u.xhr=g;u.abortable=B;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const X=ne(r,"hx-prompt");if(X){var y=prompt(X);if(y===null||!ae(r,"htmx:prompt",{prompt:y,target:c})){re(s);m();return e}}if(a&&!k){if(!confirm(a)){re(s);m();return e}}let x=mn(r,c,y);if(t!=="get"&&!vn(r)){x["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){x=le(x,i.headers)}const U=dn(r,t);let b=U.errors;const V=U.formData;if(i.values){hn(V,Dn(i.values))}const j=Dn(Rn(r,o));const v=hn(V,j);let w=yn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=location.href}const S=Cn(r,"hx-request");const $=oe(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:$,useUrlParams:E,formData:w,parameters:kn(w),unfilteredFormData:v,unfilteredParameters:kn(v),headers:x,elt:r,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!ae(r,"htmx:configRequest",C)){re(s);m();return e}n=C.path;t=C.verb;x=C.headers;w=Dn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){ae(r,"htmx:validation:halted",C);re(s);m();return e}const _=n.split("#");const z=_[0];const O=_[1];let H=n;if(E){H=z;const Z=!w.keys().next().done;if(Z){if(H.indexOf("?")<0){H+="?"}else{H+="&"}H+=gn(w);if(O){H+="#"+O}}}if(!In(r,H,C)){fe(r,"htmx:invalidPath",C);re(l);m();return e}g.open(t.toUpperCase(),H,true);g.overrideMimeType("text/html");g.withCredentials=C.withCredentials;g.timeout=C.timeout;if(S.noHeaders){}else{for(const P in x){if(x.hasOwnProperty(P)){const Y=x[P];qn(g,P,Y)}}}const T={xhr:g,target:c,requestConfig:C,etc:i,boosted:$,select:F,pathInfo:{requestPath:n,finalRequestPath:H,responsePath:null,anchor:O}};g.onload=function(){try{const t=Nn(r);T.pathInfo.responsePath=An(g);M(r,T);if(T.keepIndicators!==true){rn(R,q)}ae(r,"htmx:afterRequest",T);ae(r,"htmx:afterOnLoad",T);if(!se(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(se(n)){e=n}}if(e){ae(e,"htmx:afterRequest",T);ae(e,"htmx:afterOnLoad",T)}}re(s)}catch(e){fe(r,"htmx:onLoadError",le({error:e},T));throw e}finally{m()}};g.onerror=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendError",T);re(l);m()};g.onabort=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendAbort",T);re(l);m()};g.ontimeout=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:timeout",T);re(l);m()};if(!ae(r,"htmx:beforeRequest",T)){re(s);m();return e}var R=tn(r);var q=nn(r);ie(["loadstart","loadend","progress","abort"],function(t){ie([g,g.upload],function(e){e.addEventListener(t,function(e){ae(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});ae(r,"htmx:beforeSend",T);const J=E?null:wn(g,r,w);g.send(J);return e}function Mn(e,t){const n=t.xhr;let r=null;let o=null;if(T(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(T(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(T(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=t.etc.push||ne(e,"hx-push-url");const c=t.etc.replace||ne(e,"hx-replace-url");const u=oe(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(c){f="replace";a=c}else if(u){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function Fn(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Bn(e){for(var t=0;t`+`.${t}{opacity:0;visibility: hidden} `+`.${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`+"")}}function Zn(){const e=te().querySelector('meta[name="htmx-config"]');if(e){return v(e.content)}else{return null}}function Yn(){const e=Zn();if(e){Q.config=le(Q.config,e)}}Gn(function(){Yn();Wn();let e=te().body;Ft(e);const t=te().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.detail.elt||e.target;const n=oe(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){en();ie(t,function(e){ae(e,"htmx:restored",{document:te(),triggerEvent:ae})})}else{if(n){n(e)}}};b().setTimeout(function(){ae(e,"htmx:load",{});e=null},0)});return Q}(); + diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/output.css b/modern-frontend-complexity-alternative/src/main/resources/static/output.css new file mode 100644 index 00000000..850a4674 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/output.css @@ -0,0 +1,551 @@ +/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */ +@layer properties; +@layer theme, base, components, utilities; +@layer theme { + :root, :host { + --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", + "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", + "Courier New", monospace; + --color-red-700: oklch(50.5% 0.213 27.518); + --color-slate-200: oklch(92.9% 0.013 255.508); + --color-zinc-400: oklch(70.5% 0.015 286.067); + --color-black: #000; + --color-white: #fff; + --spacing: 0.25rem; + --text-lg: 1.125rem; + --text-lg--line-height: calc(1.75 / 1.125); + --text-xl: 1.25rem; + --text-xl--line-height: calc(1.75 / 1.25); + --text-2xl: 1.5rem; + --text-2xl--line-height: calc(2 / 1.5); + --text-3xl: 1.875rem; + --text-3xl--line-height: calc(2.25 / 1.875); + --text-4xl: 2.25rem; + --text-4xl--line-height: calc(2.5 / 2.25); + --font-weight-medium: 500; + --font-weight-bold: 700; + --default-transition-duration: 150ms; + --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + --default-font-family: var(--font-sans); + --default-mono-font-family: var(--font-mono); + } +} +@layer base { + *, ::after, ::before, ::backdrop, ::file-selector-button { + box-sizing: border-box; + margin: 0; + padding: 0; + border: 0 solid; + } + html, :host { + line-height: 1.5; + -webkit-text-size-adjust: 100%; + tab-size: 4; + font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); + font-feature-settings: var(--default-font-feature-settings, normal); + font-variation-settings: var(--default-font-variation-settings, normal); + -webkit-tap-highlight-color: transparent; + } + hr { + height: 0; + color: inherit; + border-top-width: 1px; + } + abbr:where([title]) { + -webkit-text-decoration: underline dotted; + text-decoration: underline dotted; + } + h1, h2, h3, h4, h5, h6 { + font-size: inherit; + font-weight: inherit; + } + a { + color: inherit; + -webkit-text-decoration: inherit; + text-decoration: inherit; + } + b, strong { + font-weight: bolder; + } + code, kbd, samp, pre { + font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); + font-feature-settings: var(--default-mono-font-feature-settings, normal); + font-variation-settings: var(--default-mono-font-variation-settings, normal); + font-size: 1em; + } + small { + font-size: 80%; + } + sub, sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; + } + sub { + bottom: -0.25em; + } + sup { + top: -0.5em; + } + table { + text-indent: 0; + border-color: inherit; + border-collapse: collapse; + } + :-moz-focusring { + outline: auto; + } + progress { + vertical-align: baseline; + } + summary { + display: list-item; + } + ol, ul, menu { + list-style: none; + } + img, svg, video, canvas, audio, iframe, embed, object { + display: block; + vertical-align: middle; + } + img, video { + max-width: 100%; + height: auto; + } + button, input, select, optgroup, textarea, ::file-selector-button { + font: inherit; + font-feature-settings: inherit; + font-variation-settings: inherit; + letter-spacing: inherit; + color: inherit; + border-radius: 0; + background-color: transparent; + opacity: 1; + } + :where(select:is([multiple], [size])) optgroup { + font-weight: bolder; + } + :where(select:is([multiple], [size])) optgroup option { + padding-inline-start: 20px; + } + ::file-selector-button { + margin-inline-end: 4px; + } + ::placeholder { + opacity: 1; + } + @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) { + ::placeholder { + color: currentcolor; + @supports (color: color-mix(in lab, red, red)) { + color: color-mix(in oklab, currentcolor 50%, transparent); + } + } + } + textarea { + resize: vertical; + } + ::-webkit-search-decoration { + -webkit-appearance: none; + } + ::-webkit-date-and-time-value { + min-height: 1lh; + text-align: inherit; + } + ::-webkit-datetime-edit { + display: inline-flex; + } + ::-webkit-datetime-edit-fields-wrapper { + padding: 0; + } + ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field { + padding-block: 0; + } + ::-webkit-calendar-picker-indicator { + line-height: 1; + } + :-moz-ui-invalid { + box-shadow: none; + } + button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button { + appearance: button; + } + ::-webkit-inner-spin-button, ::-webkit-outer-spin-button { + height: auto; + } + [hidden]:where(:not([hidden="until-found"])) { + display: none !important; + } +} +@layer utilities { + .absolute { + position: absolute; + } + .fixed { + position: fixed; + } + .relative { + position: relative; + } + .static { + position: static; + } + .start { + inset-inline-start: var(--spacing); + } + .end { + inset-inline-end: var(--spacing); + } + .top-0 { + top: calc(var(--spacing) * 0); + } + .top-5 { + top: calc(var(--spacing) * 5); + } + .top-6 { + top: calc(var(--spacing) * 6); + } + .right-0 { + right: calc(var(--spacing) * 0); + } + .right-2 { + right: calc(var(--spacing) * 2); + } + .left-0 { + left: calc(var(--spacing) * 0); + } + .z-50 { + z-index: 50; + } + .z-99 { + z-index: 99; + } + .m-auto { + margin: auto; + } + .my-2 { + margin-block: calc(var(--spacing) * 2); + } + .my-4 { + margin-block: calc(var(--spacing) * 4); + } + .my-8 { + margin-block: calc(var(--spacing) * 8); + } + .mt-2 { + margin-top: calc(var(--spacing) * 2); + } + .mt-8 { + margin-top: calc(var(--spacing) * 8); + } + .mb-2 { + margin-bottom: calc(var(--spacing) * 2); + } + .mb-4 { + margin-bottom: calc(var(--spacing) * 4); + } + .block { + display: block; + } + .flex { + display: flex; + } + .grid { + display: grid; + } + .hidden { + display: none; + } + .h-screen { + height: 100vh; + } + .w-11\/12 { + width: calc(11 / 12 * 100%); + } + .w-full { + width: 100%; + } + .max-w-\[200px\] { + max-width: 200px; + } + .max-w-\[225px\] { + max-width: 225px; + } + .max-w-\[250px\] { + max-width: 250px; + } + .max-w-\[275px\] { + max-width: 275px; + } + .max-w-\[300px\] { + max-width: 300px; + } + .max-w-\[350px\] { + max-width: 350px; + } + .flex-1 { + flex: 1; + } + .cursor-pointer { + cursor: pointer; + } + .resize { + resize: both; + } + .grid-cols-\[4fr_2fr_2fr_4fr_1fr\] { + grid-template-columns: 4fr 2fr 2fr 4fr 1fr; + } + .grid-cols-\[4fr_2fr_4fr_4fr_1fr\] { + grid-template-columns: 4fr 2fr 4fr 4fr 1fr; + } + .grid-cols-\[4fr_2fr_4fr_4fr_2fr\] { + grid-template-columns: 4fr 2fr 4fr 4fr 2fr; + } + .flex-col { + flex-direction: column; + } + .gap-2 { + gap: calc(var(--spacing) * 2); + } + .space-y-2 { + :where(& > :not(:last-child)) { + --tw-space-y-reverse: 0; + margin-block-start: calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse)); + margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse))); + } + } + .space-x-4 { + :where(& > :not(:last-child)) { + --tw-space-x-reverse: 0; + margin-inline-start: calc(calc(var(--spacing) * 4) * var(--tw-space-x-reverse)); + margin-inline-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse))); + } + } + .rounded { + border-radius: 0.25rem; + } + .border { + border-style: var(--tw-border-style); + border-width: 1px; + } + .border-2 { + border-style: var(--tw-border-style); + border-width: 2px; + } + .bg-black\/70 { + background-color: color-mix(in srgb, #000 70%, transparent); + @supports (color: color-mix(in lab, red, red)) { + background-color: color-mix(in oklab, var(--color-black) 70%, transparent); + } + } + .bg-slate-200 { + background-color: var(--color-slate-200); + } + .bg-white { + background-color: var(--color-white); + } + .p-0 { + padding: calc(var(--spacing) * 0); + } + .p-2 { + padding: calc(var(--spacing) * 2); + } + .p-4 { + padding: calc(var(--spacing) * 4); + } + .px-4 { + padding-inline: calc(var(--spacing) * 4); + } + .px-8 { + padding-inline: calc(var(--spacing) * 8); + } + .py-1 { + padding-block: calc(var(--spacing) * 1); + } + .py-2 { + padding-block: calc(var(--spacing) * 2); + } + .pt-4 { + padding-top: calc(var(--spacing) * 4); + } + .pt-8 { + padding-top: calc(var(--spacing) * 8); + } + .pt-32 { + padding-top: calc(var(--spacing) * 32); + } + .pb-12 { + padding-bottom: calc(var(--spacing) * 12); + } + .text-2xl { + font-size: var(--text-2xl); + line-height: var(--tw-leading, var(--text-2xl--line-height)); + } + .text-3xl { + font-size: var(--text-3xl); + line-height: var(--tw-leading, var(--text-3xl--line-height)); + } + .text-4xl { + font-size: var(--text-4xl); + line-height: var(--tw-leading, var(--text-4xl--line-height)); + } + .text-lg { + font-size: var(--text-lg); + line-height: var(--tw-leading, var(--text-lg--line-height)); + } + .text-xl { + font-size: var(--text-xl); + line-height: var(--tw-leading, var(--text-xl--line-height)); + } + .font-bold { + --tw-font-weight: var(--font-weight-bold); + font-weight: var(--font-weight-bold); + } + .font-medium { + --tw-font-weight: var(--font-weight-medium); + font-weight: var(--font-weight-medium); + } + .wrap-normal { + overflow-wrap: normal; + } + .whitespace-nowrap { + white-space: nowrap; + } + .text-red-700 { + color: var(--color-red-700); + } + .italic { + font-style: italic; + } + .underline { + text-decoration-line: underline; + } + .filter { + filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,); + } + .transition { + transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events; + transition-timing-function: var(--tw-ease, var(--default-transition-timing-function)); + transition-duration: var(--tw-duration, var(--default-transition-duration)); + } + .hover\:text-zinc-400 { + &:hover { + @media (hover: hover) { + color: var(--color-zinc-400); + } + } + } + .md\:w-8\/12 { + @media (width >= 48rem) { + width: calc(8 / 12 * 100%); + } + } + .xl\:w-2\/5 { + @media (width >= 80rem) { + width: calc(2 / 5 * 100%); + } + } +} +.search-indicator { + display: none; +} +.htmx-request .search-indicator, .htmx-request.search-indicator { + display: block; +} +@property --tw-space-y-reverse { + syntax: "*"; + inherits: false; + initial-value: 0; +} +@property --tw-space-x-reverse { + syntax: "*"; + inherits: false; + initial-value: 0; +} +@property --tw-border-style { + syntax: "*"; + inherits: false; + initial-value: solid; +} +@property --tw-font-weight { + syntax: "*"; + inherits: false; +} +@property --tw-blur { + syntax: "*"; + inherits: false; +} +@property --tw-brightness { + syntax: "*"; + inherits: false; +} +@property --tw-contrast { + syntax: "*"; + inherits: false; +} +@property --tw-grayscale { + syntax: "*"; + inherits: false; +} +@property --tw-hue-rotate { + syntax: "*"; + inherits: false; +} +@property --tw-invert { + syntax: "*"; + inherits: false; +} +@property --tw-opacity { + syntax: "*"; + inherits: false; +} +@property --tw-saturate { + syntax: "*"; + inherits: false; +} +@property --tw-sepia { + syntax: "*"; + inherits: false; +} +@property --tw-drop-shadow { + syntax: "*"; + inherits: false; +} +@property --tw-drop-shadow-color { + syntax: "*"; + inherits: false; +} +@property --tw-drop-shadow-alpha { + syntax: ""; + inherits: false; + initial-value: 100%; +} +@property --tw-drop-shadow-size { + syntax: "*"; + inherits: false; +} +@layer properties { + @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) { + *, ::before, ::after, ::backdrop { + --tw-space-y-reverse: 0; + --tw-space-x-reverse: 0; + --tw-border-style: solid; + --tw-font-weight: initial; + --tw-blur: initial; + --tw-brightness: initial; + --tw-contrast: initial; + --tw-grayscale: initial; + --tw-hue-rotate: initial; + --tw-invert: initial; + --tw-opacity: initial; + --tw-saturate: initial; + --tw-sepia: initial; + --tw-drop-shadow: initial; + --tw-drop-shadow-color: initial; + --tw-drop-shadow-alpha: 100%; + --tw-drop-shadow-size: initial; + } + } +} diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/selectables-container.js b/modern-frontend-complexity-alternative/src/main/resources/static/selectables-container.js new file mode 100644 index 00000000..3f8f8566 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/selectables-container.js @@ -0,0 +1,40 @@ +class SelectablesContainer extends HTMLElement { + + connectedCallback() { + let selectedClass = this.getAttribute("data-selected-class"); + if (!selectedClass) { + selectedClass = "underline"; + } + + const selectables = this.querySelectorAll("[data-selectable]"); + for (let s of selectables) { + const key = s.getAttribute("data-selectable-key"); + const value = s.getAttribute("data-selectable-value"); + + s.addEventListener("click", e => { + e.stopPropagation(); + const selected = s.classList.toggle(selectedClass); + this.dispatchEvent(new CustomEvent("selectables-container-selection-changed", { + detail: { key, value, selected } + })); + }); + } + + this.addEventListener("selectables-container-change-selection", e => { + const { selected, value } = e.detail; + const selectableElement = this.querySelector(`[data-selectable-value="${value}"]`); + if (!selectableElement) { + return; + } + if (selected) { + selectableElement.classList.add(selectedClass); + } else { + selectableElement.classList.remove(selectedClass); + } + }); + } +} + +if (customElements.get("selectables-container") === undefined) { + customElements.define("selectables-container", SelectablesContainer); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/selected-container.js b/modern-frontend-complexity-alternative/src/main/resources/static/selected-container.js new file mode 100644 index 00000000..a45b82e2 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/selected-container.js @@ -0,0 +1,66 @@ +class SelectedContainer extends HTMLElement { + + #selectedValues = []; + #selectedValuesToKeys = new Map(); + + get selectedValues() { + return this.#selectedValues; + } + + connectedCallback() { + this.#render(); + + this.addEventListener("selected-container-change-selection", e => { + const { key, value, selected } = e.detail; + const beforeLength = this.#selectedValues.length; + if (selected && !this.#selectedValues.includes(value)) { + this.#selectedValues = [...this.#selectedValues, value]; + this.#selectedValuesToKeys.set(value, key); + } else { + this.#selectedValues = this.#selectedValues.filter(v => v != value); + this.#selectedValuesToKeys.delete(value); + } + + if (this.#selectedValues.length != beforeLength) { + this.#render(); + } + }); + } + + #render() { + if (!this.#selectedValues) { + this.innerHTML = null; + return; + } + + const selectedTemplateId = this.getAttribute("data-selected-template-id") ?? "selected-template-id"; + const selectedTemplate = document.getElementById(selectedTemplateId); + + this.innerHTML = this.#selectedValues.map(v => selectedTemplate.innerHTML.replaceAll("__value__", v)).join("\n"); + + [...this.querySelectorAll("[data-selected]")].forEach(e => { + const selectedValueElement = e.querySelector("[data-selected-value]"); + let selectedValue; + if (selectedValueElement) { + selectedValue = selectedValueElement.getAttribute("data-selected-value"); + } else { + selectedValue = null; + } + const unselectButton = e.querySelector("[data-unselect-button]"); + if (unselectButton) { + unselectButton.onclick = () => { + this.#selectedValues = this.#selectedValues.filter(v => v != selectedValue); + const key = this.#selectedValuesToKeys.get(selectedValue); + this.#render(); + this.dispatchEvent(new CustomEvent("selected-container-selection-changed", + { detail: { key, value: selectedValue, selected: false } } + )); + }; + } + }); + } +} + +if (customElements.get("selected-container") == undefined) { + customElements.define("selected-container", SelectedContainer); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/sortables-container.js b/modern-frontend-complexity-alternative/src/main/resources/static/sortables-container.js new file mode 100644 index 00000000..c62ab41e --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/sortables-container.js @@ -0,0 +1,54 @@ +class SortablesContainer extends HTMLElement { + + connectedCallback() { + const sortableColumnAscTemplateId = this.getAttribute("data-sortable-column-asc-template-id") ?? "sortable-column-asc-template"; + const sortableColumnDescTemplateId = this.getAttribute("data-sortable-column-desc-template-id") ?? "sortable-column-desc-template"; + + // TODO: validate + const sortableColumnAscTemplate = document.getElementById(sortableColumnAscTemplateId)?.innerHTML; + const sortableColumnDescTemplate = document.getElementById(sortableColumnDescTemplateId)?.innerHTML; + + const sortableColumns = this.querySelectorAll("[data-sortable-column-key]"); + + for (let c of sortableColumns) { + c.onclick = () => this.#handleSortableColumnClick(c, sortableColumns, + sortableColumnAscTemplate, sortableColumnDescTemplate + ); + } + } + + #handleSortableColumnClick(column, columns, ascTemplate, descTemplate) { + const columnKey = column.getAttribute("data-sortable-column-key"); + const indicator = column.querySelector("[data-sortable-column-indicator]"); + let ascDirection = true; + if (indicator && indicator.innerHTML) { + if (indicator.innerHTML == ascTemplate) { + indicator.innerHTML = descTemplate; + ascDirection = false; + } else { + indicator.innerHTML = ascTemplate; + } + } else if (indicator) { + indicator.innerHTML = ascTemplate; + } + + for (let c of columns) { + if (c == column) { + continue; + } + const indicator = c.querySelector("[data-sortable-column-indicator]"); + if (indicator) { + indicator.innerHTML = null; + } + } + + if (columnKey && indicator) { + this.dispatchEvent(new CustomEvent("sortables-container-sorting-changed", + { detail: { key: columnKey, asc: ascDirection } })); + } + } +} + +if (customElements.get("sortables-container") == undefined) { + customElements.define("sortables-container", SortablesContainer); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/static/validateable-input.js b/modern-frontend-complexity-alternative/src/main/resources/static/validateable-input.js new file mode 100644 index 00000000..b21143d3 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/static/validateable-input.js @@ -0,0 +1,26 @@ +class ValidateableInput extends HTMLElement { + + #validator = (input) => true; + + set validator(v) { + this.#validator = v; + } + + connectedCallback() { + const inputElement = this.querySelector("[data-input]") + const inputErrorElement = this.querySelector("[data-input-error]"); + + inputElement.addEventListener("input", () => { + if (this.#validator(inputElement.value)) { + inputErrorElement.classList.add("hidden"); + } else { + inputErrorElement.classList.remove("hidden"); + } + }); + } + +} + +if (customElements.get("validateable-input") == undefined) { + customElements.define("validateable-input", ValidateableInput); +} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-offer-page.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-offer-page.mustache new file mode 100644 index 00000000..83752b26 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-offer-page.mustache @@ -0,0 +1,20 @@ +

{{deviceName}}

+ +
{{offerPrice.value}} {{offerPrice.currency}} {{buy-device-offer-page.merchant-offer}}
+ +
{{buy-device-offer-page.user-offer}}
+ + + + + + + + \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-page.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-page.mustache new file mode 100644 index 00000000..3ff1cc93 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/buy-device-page.mustache @@ -0,0 +1,129 @@ +

{{name}}

+ +
+

{{buy-device-page.title}}

+
+ {{#availableAttributes}} + +
{{name}}
+ +
+ {{/availableAttributes}} +
+ + + + {{^hasOffers}} + {{buy-device-page.no-offers}} + {{/hasOffers}} + {{#hasOffers}} + + + +
+
+ {{buy-device-page.attributes-column}} +
+
+ {{buy-device-page.price-column}} +
+
+ {{buy-device-page.merchant-column}} +
+
+ {{buy-device-page.expires-at-column}} +
+
+
+ {{>device-offers}} +
+
+ {{/hasOffers}} +
+ + + diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/content-router.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/content-router.mustache new file mode 100644 index 00000000..6cf55049 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/content-router.mustache @@ -0,0 +1,15 @@ +{{#error-page}} + {{>error-page}} +{{/error-page}} +{{#devices-page}} + {{>devices-page}} +{{/devices-page}} +{{#device-page}} + {{>device-page}} +{{/device-page}} +{{#buy-device-page}} + {{>buy-device-page}} +{{/buy-device-page}} +{{#buy-device-offer-page}} + {{>buy-device-offer-page}} +{{/buy-device-offer-page}} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/device-offers.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/device-offers.mustache new file mode 100644 index 00000000..869942b6 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/device-offers.mustache @@ -0,0 +1,9 @@ +{{#offers}} +
{{attributeValues}}
+
{{price.value}} {{price.currency}}
+
{{merchantId}}
+
{{expiresAt}}
+ +{{/offers}} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/device-page.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/device-page.mustache new file mode 100644 index 00000000..81fc2f79 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/device-page.mustache @@ -0,0 +1 @@ +
{{name}}:{{id}} {{device-page.page-description}}
\ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/devices-page.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/devices-page.mustache new file mode 100644 index 00000000..47e20ef3 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/devices-page.mustache @@ -0,0 +1,11 @@ +

{{devices-page.title}}

+ + +

{{devices-page.search-indicator}}

+
+ {{>devices-search-results}} +
+ + \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/devices-search-results.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/devices-search-results.mustache new file mode 100644 index 00000000..fb51a997 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/devices-search-results.mustache @@ -0,0 +1,17 @@ +{{#no-results}} +

{{devices-search-results.no-results}}

+{{/no-results}} +
+{{#devices}} +
+ {{id}}: {{name}} + +
...
+ +
+
+{{/devices}} +
\ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/error-info.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/error-info.mustache new file mode 100644 index 00000000..83979aa4 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/error-info.mustache @@ -0,0 +1 @@ +{{error-info.title}}#{{error-info.message}} \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/error-page.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/error-page.mustache new file mode 100644 index 00000000..8f56de24 --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/error-page.mustache @@ -0,0 +1,2 @@ +

{{error-page.title}}

+
{{error-page.message}}
\ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/main/resources/templates/page-wrapper.mustache b/modern-frontend-complexity-alternative/src/main/resources/templates/page-wrapper.mustache new file mode 100644 index 00000000..4627d27a --- /dev/null +++ b/modern-frontend-complexity-alternative/src/main/resources/templates/page-wrapper.mustache @@ -0,0 +1,57 @@ + + + + {{title}} + + + + + {{#componentPaths}} + + {{/componentPaths}} + + + + + + +
+
+ {{>content-router}} +
+
+ + + + + \ No newline at end of file diff --git a/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/BaseIntegrationTest.java b/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/BaseIntegrationTest.java new file mode 100644 index 00000000..8cfe9c2e --- /dev/null +++ b/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/BaseIntegrationTest.java @@ -0,0 +1,25 @@ +package com.binaryigor.complexity_alternative; + +import org.junit.jupiter.api.BeforeEach; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.web.client.RestClient; + +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; + +// TODO: https://mvnrepository.com/artifact/org.jsoup/jsoup +@SpringBootTest(webEnvironment = RANDOM_PORT) +public abstract class BaseIntegrationTest { + + @LocalServerPort + protected int port; + + protected RestClient testRestClient; + + @BeforeEach + void setup() { + testRestClient = RestClient.builder() + .baseUrl("http://localhost:" + port) + .build(); + } +} diff --git a/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/DeviceControllerTest.java b/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/DeviceControllerTest.java new file mode 100644 index 00000000..12a04fce --- /dev/null +++ b/modern-frontend-complexity-alternative/src/test/java/com/binaryigor/complexity_alternative/DeviceControllerTest.java @@ -0,0 +1,40 @@ +package com.binaryigor.complexity_alternative; + +import com.binaryigor.complexity_alternative.infra.DeviceRepository; +import org.jsoup.Jsoup; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DeviceControllerTest extends BaseIntegrationTest { + + @Autowired + private DeviceRepository deviceRepository; + + @Test + void rendersFullDevicesPage() { + var allDevices = deviceRepository.allDevices(); + + var response = testRestClient.get() + .uri("/devices") + .retrieve() + .toEntity(String.class); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + var document = Jsoup.parse(response.getBody()); + assertThat(document.select("html")) + .isNotEmpty(); + + var devicesElement = document.select("#devices"); + allDevices.forEach(d -> { + assertThat(devicesElement.text()).contains(d.name()); + assertThat(devicesElement.select("[hx-get=/devices/%s]".formatted(d.id()))) + .isNotEmpty(); + assertThat(devicesElement.select("[hx-get=/buy-device/%s]".formatted(d.id()))) + .isNotEmpty(); + }); + } +}