convert_sveltekit_project() — svelte Function Reference
Architecture documentation for the convert_sveltekit_project() function in download.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 04de3495_cffc_dc6d_e930_d1c6d03a3a34["convert_sveltekit_project()"] 65d20932_41e6_eeee_7338_5dd0682e5e42["download.js"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|defined in| 65d20932_41e6_eeee_7338_5dd0682e5e42 2e34f7ff_3d9b_3d31_75ac_8a472947d75a["process_directory()"] 2e34f7ff_3d9b_3d31_75ac_8a472947d75a -->|calls| 04de3495_cffc_dc6d_e930_d1c6d03a3a34 7f0ea1c2_2714_c186_16e3_baa473ab323e["get_all_files()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| 7f0ea1c2_2714_c186_16e3_baa473ab323e 169d027f_570a_0058_99af_8bec7c7047b4["build_route_tree()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| 169d027f_570a_0058_99af_8bec7c7047b4 f6896a7b_31a4_88bc_570a_10ebde3f1327["transform_lib_imports()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| f6896a7b_31a4_88bc_570a_10ebde3f1327 0efd95ef_9e84_6196_a77a_9e9137671f3d["route_to_component_name()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| 0efd95ef_9e84_6196_a77a_9e9137671f3d 49fcbc38_304d_ca78_d0ee_358275ad2d49["get_child_routes()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| 49fcbc38_304d_ca78_d0ee_358275ad2d49 0499fbdd_15ce_f4d2_c38f_990a15ec7429["transform_layout_content()"] 04de3495_cffc_dc6d_e930_d1c6d03a3a34 -->|calls| 0499fbdd_15ce_f4d2_c38f_990a15ec7429 style 04de3495_cffc_dc6d_e930_d1c6d03a3a34 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
playgrounds/sandbox/scripts/download.js lines 379–511
function convert_sveltekit_project(repo_dir) {
const all_files = get_all_files(repo_dir);
/** @type {Array<{name: string, contents: string}>} */
const output_files = [];
// Find the routes directory
let routes_prefix = '';
for (const file of all_files) {
if (file.path.includes('src/routes/')) {
routes_prefix = 'src/routes';
break;
}
}
if (!routes_prefix) {
console.error('Could not find src/routes directory');
process.exit(1);
}
// Build route tree
const routes = build_route_tree(all_files, routes_prefix);
// Process lib files - flatten them to root level
const lib_files = all_files.filter((f) => f.path.startsWith('src/lib/'));
for (const file of lib_files) {
// Flatten to just the filename
const new_path = path.basename(file.path);
let contents = file.contents;
contents = transform_lib_imports(contents);
output_files.push({
name: new_path,
contents
});
}
// Sort routes by depth (deepest first) so we can process children before parents
const sorted_routes = [...routes.keys()].sort((a, b) => {
const depth_a = a === '' ? 0 : a.split('/').length;
const depth_b = b === '' ? 0 : b.split('/').length;
return depth_b - depth_a;
});
// Map to store what component each route renders
/** @type {Map<string, string>} */
const route_component_map = new Map();
// First pass: convert all pages
for (const route_key of sorted_routes) {
const route = routes.get(route_key);
if (route?.page) {
const component_name = route_to_component_name(route_key);
let contents = route.page.contents;
contents = transform_lib_imports(contents);
output_files.push({
name: `${component_name}.svelte`,
contents
});
// If no layout, this is what the route renders
if (!route.layout) {
route_component_map.set(route_key, component_name);
}
}
}
// Second pass: convert layouts (from deepest to root)
for (const route_key of sorted_routes) {
const route = routes.get(route_key);
if (route?.layout) {
const is_root = route_key === '';
const component_name = is_root ? 'App' : route_to_component_name(route_key) + 'Layout';
// Determine what child component this layout should render
let child_component = '';
// Check if there's a page at this route level
if (route.page) {
child_component = route_to_component_name(route_key);
} else {
// Find child routes that have content
const children = get_child_routes(routes, route_key);
if (children.length > 0) {
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does convert_sveltekit_project() do?
convert_sveltekit_project() is a function in the svelte codebase, defined in playgrounds/sandbox/scripts/download.js.
Where is convert_sveltekit_project() defined?
convert_sveltekit_project() is defined in playgrounds/sandbox/scripts/download.js at line 379.
What does convert_sveltekit_project() call?
convert_sveltekit_project() calls 6 function(s): build_route_tree, get_all_files, get_child_routes, route_to_component_name, transform_layout_content, transform_lib_imports.
What calls convert_sveltekit_project()?
convert_sveltekit_project() is called by 1 function(s): process_directory.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free