- 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
50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
import { domainOf } from "./domain.js";
|
|
import { throwInternalError } from "./errors.js";
|
|
import { isomorphic } from "./isomorphic.js";
|
|
import { FileConstructor, objectKindOf } from "./objectKinds.js";
|
|
// Eventually we can just import from package.json in the source itself
|
|
// but for now, import assertions are too unstable and it wouldn't support
|
|
// recent node versions (https://nodejs.org/api/esm.html#json-modules).
|
|
// For now, we assert this matches the package.json version via a unit test.
|
|
export const arkUtilVersion = "0.56.0";
|
|
export const initialRegistryContents = {
|
|
version: arkUtilVersion,
|
|
filename: isomorphic.fileName(),
|
|
FileConstructor
|
|
};
|
|
export const registry = initialRegistryContents;
|
|
const namesByResolution = new Map();
|
|
const nameCounts = Object.create(null);
|
|
export const register = (value) => {
|
|
const existingName = namesByResolution.get(value);
|
|
if (existingName)
|
|
return existingName;
|
|
let name = baseNameFor(value);
|
|
if (nameCounts[name])
|
|
name = `${name}${nameCounts[name]++}`;
|
|
else
|
|
nameCounts[name] = 1;
|
|
registry[name] = value;
|
|
namesByResolution.set(value, name);
|
|
return name;
|
|
};
|
|
export const isDotAccessible = (keyName) => /^[$A-Z_a-z][\w$]*$/.test(keyName);
|
|
const baseNameFor = (value) => {
|
|
switch (typeof value) {
|
|
case "object": {
|
|
if (value === null)
|
|
break;
|
|
const prefix = objectKindOf(value) ?? "object";
|
|
// convert to camelCase
|
|
return prefix[0].toLowerCase() + prefix.slice(1);
|
|
}
|
|
case "function":
|
|
return isDotAccessible(value.name) ? value.name : "fn";
|
|
case "symbol":
|
|
return value.description && isDotAccessible(value.description) ?
|
|
value.description
|
|
: "symbol";
|
|
}
|
|
return throwInternalError(`Unexpected attempt to register serializable value of type ${domainOf(value)}`);
|
|
};
|