- 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
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
import { analyzeScope } from "./analyze-scope.js";
|
|
import { traverseNodes } from "../traverse.js";
|
|
import { getParser } from "./resolve-parser.js";
|
|
import { isEnhancedParserObject } from "./parser-object.js";
|
|
/**
|
|
* Parse for <script>
|
|
*/
|
|
export function parseScriptInSvelte(code, attrs, parserOptions) {
|
|
const result = parseScript(code, attrs, parserOptions);
|
|
traverseNodes(result.ast, {
|
|
visitorKeys: result.visitorKeys,
|
|
enterNode(node, parent) {
|
|
node.parent = parent;
|
|
if (node.type === "LabeledStatement" && node.label.name === "$") {
|
|
if (parent?.type === "Program") {
|
|
// Transform node type
|
|
node.type = "SvelteReactiveStatement";
|
|
}
|
|
}
|
|
},
|
|
leaveNode() {
|
|
//
|
|
},
|
|
});
|
|
return result;
|
|
}
|
|
/**
|
|
* Parse for script
|
|
*/
|
|
export function parseScript(code, attrs, parserOptions) {
|
|
const result = parseScriptWithoutAnalyzeScopeFromVCode(code, attrs, parserOptions);
|
|
if (!result.scopeManager) {
|
|
const scopeManager = analyzeScope(result.ast, parserOptions);
|
|
result.scopeManager = scopeManager;
|
|
}
|
|
return result;
|
|
}
|
|
/**
|
|
* Parse for script without analyze scope
|
|
*/
|
|
export function parseScriptWithoutAnalyzeScope(code, attrs, options) {
|
|
const parser = getParser(attrs, options.parser);
|
|
const result = isEnhancedParserObject(parser)
|
|
? parser.parseForESLint(code, options)
|
|
: parser.parse(code, options);
|
|
if ("ast" in result && result.ast != null) {
|
|
return result;
|
|
}
|
|
return { ast: result };
|
|
}
|
|
/**
|
|
* Parse for script without analyze scope
|
|
*/
|
|
function parseScriptWithoutAnalyzeScopeFromVCode(code, attrs, options) {
|
|
const result = parseScriptWithoutAnalyzeScope(code, attrs, options);
|
|
result._virtualScriptCode = code;
|
|
return result;
|
|
}
|