feat: Reinitialize frontend with SvelteKit and TypeScript

- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
This commit is contained in:
2026-02-17 16:19:59 -05:00
parent 54df6018f5
commit de2d83092e
28274 changed files with 3816354 additions and 90 deletions

View File

@@ -0,0 +1,16 @@
/**
* CSS escaper.
*/
export default class CSSEscaper {
/**
* Escapes CSS.
*
* Based on:
* https://github.com/mathiasbynens/CSS.escape
*
* @param cssText CSS.
* @returns Escaped CSS.
*/
static escape(cssText: string): string;
}
//# sourceMappingURL=CSSEscaper.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSEscaper.d.ts","sourceRoot":"","sources":["../../../src/css/utilities/CSSEscaper.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC9B;;;;;;;;OAQG;WACW,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAyE7C"}

View File

@@ -0,0 +1,77 @@
/**
* CSS escaper.
*/
export default class CSSEscaper {
/**
* Escapes CSS.
*
* Based on:
* https://github.com/mathiasbynens/CSS.escape
*
* @param cssText CSS.
* @returns Escaped CSS.
*/
static escape(cssText) {
if (arguments.length == 0) {
throw new TypeError('`CSS.escape` requires an argument.');
}
const returnValue = String(cssText);
const length = returnValue.length;
let index = -1;
let codeUnit;
let result = '';
const firstCodeUnit = returnValue.charCodeAt(0);
if (
// If the character is the first character and is a `-` (U+002D), and
// There is no second character, […]
length == 1 &&
firstCodeUnit == 0x002d) {
return '\\' + returnValue;
}
while (++index < length) {
codeUnit = returnValue.charCodeAt(index);
// Note: theres no need to special-case astral symbols, surrogate
// Pairs, or lone surrogates.
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
// (U+FFFD).
if (codeUnit == 0x0000) {
result += '\uFFFD';
continue;
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001f) ||
codeUnit == 0x007f ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002d)) {
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
// If the character is not handled by one of the above rules and is
// Greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// Is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (codeUnit >= 0x0080 ||
codeUnit == 0x002d ||
codeUnit == 0x005f ||
(codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
(codeUnit >= 0x0041 && codeUnit <= 0x005a) ||
(codeUnit >= 0x0061 && codeUnit <= 0x007a)) {
// The character itself
result += returnValue.charAt(index);
continue;
}
// Otherwise, the escaped character.
// https://drafts.csswg.org/cssom/#escape-a-character
result += '\\' + returnValue.charAt(index);
}
return result;
}
}
//# sourceMappingURL=CSSEscaper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSEscaper.js","sourceRoot":"","sources":["../../../src/css/utilities/CSSEscaper.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC9B;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAAC,OAAe;QACnC,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,SAA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,CAAC;YAED,mEAAmE;YACnE,uEAAuE;YACvE,qEAAqE;YACrE,4CAA4C;YAC5C,IACC,QAAQ,IAAI,MAAM;gBAClB,QAAQ,IAAI,MAAM;gBAClB,QAAQ,IAAI,MAAM;gBAClB,CAAC,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC;gBAC1C,CAAC,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC;gBAC1C,CAAC,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC,EACzC,CAAC;gBACF,uBAAuB;gBACvB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACpC,SAAS;YACV,CAAC;YAED,oCAAoC;YACpC,qDAAqD;YACrD,MAAM,IAAI,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD"}

View File

@@ -0,0 +1,24 @@
import CSSRule from '../CSSRule.js';
import CSSStyleSheet from '../CSSStyleSheet.js';
/**
* CSS parser.
*/
export default class CSSParser {
/**
* Parses HTML and returns a root element.
*
* @param parentStyleSheet Parent style sheet.
* @param cssText CSS code.
* @returns Root element.
*/
static parseFromString(parentStyleSheet: CSSStyleSheet, cssText: string): CSSRule[];
/**
* Validates a selector text.
*
* @see https://www.w3.org/TR/CSS21/syndata.html#rule-sets
* @param selectorText Selector text.
* @returns True if valid, false otherwise.
*/
private static validateSelectorText;
}
//# sourceMappingURL=CSSParser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSParser.d.ts","sourceRoot":"","sources":["../../../src/css/utilities/CSSParser.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAahD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC7B;;;;;;OAMG;WACW,eAAe,CAAC,gBAAgB,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE;IA8L1F;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAQnC"}

View File

@@ -0,0 +1,209 @@
import CSSRule from '../CSSRule.js';
import * as PropertySymbol from '../../PropertySymbol.js';
import CSSStyleRule from '../rules/CSSStyleRule.js';
import CSSKeyframeRule from '../rules/CSSKeyframeRule.js';
import CSSKeyframesRule from '../rules/CSSKeyframesRule.js';
import CSSMediaRule from '../rules/CSSMediaRule.js';
import CSSContainerRule from '../rules/CSSContainerRule.js';
import CSSSupportsRule from '../rules/CSSSupportsRule.js';
import CSSFontFaceRule from '../rules/CSSFontFaceRule.js';
import SelectorParser from '../../query-selector/SelectorParser.js';
import CSSRuleTypeEnum from '../CSSRuleTypeEnum.js';
const COMMENT_REGEXP = /\/\*[\s\S]*?\*\//gm;
/**
* CSS parser.
*/
export default class CSSParser {
/**
* Parses HTML and returns a root element.
*
* @param parentStyleSheet Parent style sheet.
* @param cssText CSS code.
* @returns Root element.
*/
static parseFromString(parentStyleSheet, cssText) {
const window = parentStyleSheet[PropertySymbol.window];
const css = cssText.replace(COMMENT_REGEXP, '');
const cssRules = [];
const regExp = /{|}/gm;
const stack = [];
let parentRule = null;
let lastIndex = 0;
let match;
while ((match = regExp.exec(css))) {
if (match[0] === '{') {
const selectorText = css.substring(lastIndex, match.index).trim();
if (selectorText[0] === '@') {
const ruleParts = selectorText.split(' ');
const ruleType = ruleParts[0];
const ruleParameters = ruleParts.slice(1).join(' ').trim();
switch (ruleType) {
case '@keyframes':
case '@-webkit-keyframes':
const keyframesRule = new CSSKeyframesRule(PropertySymbol.illegalConstructor, window);
keyframesRule.name = ruleParameters;
keyframesRule.parentStyleSheet = parentStyleSheet;
if (parentRule) {
if (parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule) {
parentRule.cssRules.push(keyframesRule);
}
}
else {
cssRules.push(keyframesRule);
}
parentRule = keyframesRule;
break;
case '@media':
const mediums = ruleParameters.split(',');
const mediaRule = new CSSMediaRule(PropertySymbol.illegalConstructor, window);
for (const medium of mediums) {
mediaRule.media.appendMedium(medium.trim());
}
mediaRule.parentStyleSheet = parentStyleSheet;
if (parentRule) {
if (parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule) {
parentRule.cssRules.push(mediaRule);
}
}
else {
cssRules.push(mediaRule);
}
parentRule = mediaRule;
break;
case '@container':
case '@-webkit-container':
const containerRule = new CSSContainerRule(PropertySymbol.illegalConstructor, window);
containerRule.conditionText = ruleParameters;
containerRule.parentStyleSheet = parentStyleSheet;
if (parentRule) {
if (parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule) {
parentRule.cssRules.push(containerRule);
}
}
else {
cssRules.push(containerRule);
}
parentRule = containerRule;
break;
case '@supports':
case '@-webkit-supports':
const supportsRule = new CSSSupportsRule(PropertySymbol.illegalConstructor, window);
supportsRule.conditionText = ruleParameters;
supportsRule.parentStyleSheet = parentStyleSheet;
if (parentRule) {
if (parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule) {
parentRule.cssRules.push(supportsRule);
}
}
else {
cssRules.push(supportsRule);
}
parentRule = supportsRule;
break;
case '@font-face':
const fontFaceRule = new CSSFontFaceRule(PropertySymbol.illegalConstructor, window);
fontFaceRule[PropertySymbol.cssText] = ruleParameters;
fontFaceRule.parentStyleSheet = parentStyleSheet;
if (parentRule) {
if (parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule) {
parentRule.cssRules.push(fontFaceRule);
}
}
else {
cssRules.push(fontFaceRule);
}
parentRule = fontFaceRule;
break;
default:
// Unknown rule.
// We will create a new rule to let it grab its content, but we will not add it to the cssRules array.
const newRule = new CSSRule(PropertySymbol.illegalConstructor, window);
newRule.parentStyleSheet = parentStyleSheet;
parentRule = newRule;
break;
}
}
else if (parentRule && parentRule.type === CSSRuleTypeEnum.keyframesRule) {
const newRule = new CSSKeyframeRule(PropertySymbol.illegalConstructor, window);
newRule.keyText = selectorText.trim();
newRule.parentStyleSheet = parentStyleSheet;
newRule.parentRule = parentRule;
parentRule.cssRules.push(newRule);
parentRule = newRule;
}
else if (parentRule &&
(parentRule.type === CSSRuleTypeEnum.mediaRule ||
parentRule.type === CSSRuleTypeEnum.containerRule ||
parentRule.type === CSSRuleTypeEnum.supportsRule)) {
if (this.validateSelectorText(selectorText)) {
const newRule = new CSSStyleRule(PropertySymbol.illegalConstructor, window);
newRule.selectorText = selectorText;
newRule.parentStyleSheet = parentStyleSheet;
newRule.parentRule = parentRule;
parentRule.cssRules.push(newRule);
parentRule = newRule;
}
}
else {
if (this.validateSelectorText(selectorText)) {
const newRule = new CSSStyleRule(PropertySymbol.illegalConstructor, window);
newRule.selectorText = selectorText;
newRule.parentStyleSheet = parentStyleSheet;
newRule.parentRule = parentRule;
if (!parentRule) {
cssRules.push(newRule);
}
parentRule = newRule;
}
}
stack.push(parentRule);
}
else {
if (parentRule) {
const cssText = css
.substring(lastIndex, match.index)
.trim()
.replace(/([^;])$/, '$1;'); // Ensure last semicolon
switch (parentRule.type) {
case CSSRuleTypeEnum.fontFaceRule:
case CSSRuleTypeEnum.keyframeRule:
case CSSRuleTypeEnum.styleRule:
parentRule[PropertySymbol.cssText] = cssText;
break;
}
}
stack.pop();
parentRule = stack[stack.length - 1] || null;
}
lastIndex = match.index + 1;
}
return cssRules;
}
/**
* Validates a selector text.
*
* @see https://www.w3.org/TR/CSS21/syndata.html#rule-sets
* @param selectorText Selector text.
* @returns True if valid, false otherwise.
*/
static validateSelectorText(selectorText) {
try {
SelectorParser.getSelectorGroups(selectorText);
}
catch (e) {
return false;
}
return true;
}
}
//# sourceMappingURL=CSSParser.js.map

File diff suppressed because one or more lines are too long