Files
headroom/frontend/node_modules/happy-dom/lib/xml-http-request/XMLHttpRequestResponseDataParser.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

62 lines
2.1 KiB
JavaScript

import XMLHttpResponseTypeEnum from './XMLHttpResponseTypeEnum.js';
/**
*
*/
export default class XMLHttpRequestResponseDataParser {
/**
* Parses response.
*
* @param options Options.
* @param options.window Window.
* @param [options.responseType] Response type.
* @param [options.data] Data.
* @param [options.contentType] Content type.
* @returns Parsed response.
**/
static parse(options) {
if (!options.data) {
return '';
}
switch (options.responseType) {
case XMLHttpResponseTypeEnum.arraybuffer:
// See: https://github.com/jsdom/jsdom/blob/c3c421c364510e053478520500bccafd97f5fa39/lib/jsdom/living/helpers/binary-data.js
const newAB = new ArrayBuffer(options.data.length);
const view = new Uint8Array(newAB);
view.set(options.data);
return view;
case XMLHttpResponseTypeEnum.blob:
try {
return new options.window.Blob([new Uint8Array(options.data)], {
type: options.contentType || ''
});
}
catch (e) {
// Ignore error.
}
return null;
case XMLHttpResponseTypeEnum.document:
const window = options.window;
const domParser = new window.DOMParser();
try {
return domParser.parseFromString(options.data.toString(), 'application/xml');
}
catch (e) {
// Ignore error.
}
return null;
case XMLHttpResponseTypeEnum.json:
try {
return JSON.parse(options.data.toString());
}
catch (e) {
// Ignore error.
}
return null;
case XMLHttpResponseTypeEnum.text:
case '':
default:
return options.data.toString();
}
}
}
//# sourceMappingURL=XMLHttpRequestResponseDataParser.js.map