Files
headroom/frontend/node_modules/@ark/util/out/path.js
Santhosh Janardhanan de2d83092e 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
2026-02-17 16:19:59 -05:00

66 lines
2.3 KiB
JavaScript

import { ReadonlyArray } from "./arrays.js";
import { throwParseError } from "./errors.js";
import { isDotAccessible } from "./registry.js";
import { printable } from "./serialize.js";
export const appendStringifiedKey = (path, prop, ...[opts]) => {
const stringifySymbol = opts?.stringifySymbol ?? printable;
let propAccessChain = path;
switch (typeof prop) {
case "string":
propAccessChain =
isDotAccessible(prop) ?
path === "" ?
prop
: `${path}.${prop}`
: `${path}[${JSON.stringify(prop)}]`;
break;
case "number":
propAccessChain = `${path}[${prop}]`;
break;
case "symbol":
propAccessChain = `${path}[${stringifySymbol(prop)}]`;
break;
default:
if (opts?.stringifyNonKey)
propAccessChain = `${path}[${opts.stringifyNonKey(prop)}]`;
else {
throwParseError(`${printable(prop)} must be a PropertyKey or stringifyNonKey must be passed to options`);
}
}
return propAccessChain;
};
export const stringifyPath = (path, ...opts) => path.reduce((s, k) => appendStringifiedKey(s, k, ...opts), "");
export class ReadonlyPath extends ReadonlyArray {
// alternate strategy for caching since the base object is frozen
cache = {};
constructor(...items) {
super();
this.push(...items);
}
toJSON() {
if (this.cache.json)
return this.cache.json;
this.cache.json = [];
for (let i = 0; i < this.length; i++) {
this.cache.json.push(typeof this[i] === "symbol" ? printable(this[i]) : this[i]);
}
return this.cache.json;
}
stringify() {
if (this.cache.stringify)
return this.cache.stringify;
return (this.cache.stringify = stringifyPath(this));
}
stringifyAncestors() {
if (this.cache.stringifyAncestors)
return this.cache.stringifyAncestors;
let propString = "";
const result = [propString];
for (const path of this) {
propString = appendStringifiedKey(propString, path);
result.push(propString);
}
return (this.cache.stringifyAncestors = result);
}
}