mapped_code.js — svelte Source File
Architecture documentation for mapped_code.js, a javascript file in the svelte codebase. 3 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR d383a41d_5383_ee86_cab6_03bf1a2daf93["mapped_code.js"] 2067be31_d6f4_6cb7_7cca_305fa17770b0["push_array.js"] d383a41d_5383_ee86_cab6_03bf1a2daf93 --> 2067be31_d6f4_6cb7_7cca_305fa17770b0 6604fbb1_f99a_248a_dfc6_b9e14a5f0a36["push_array"] d383a41d_5383_ee86_cab6_03bf1a2daf93 --> 6604fbb1_f99a_248a_dfc6_b9e14a5f0a36 117159f4_cbb2_daf5_f169_9ec9d696a13a["remapping"] d383a41d_5383_ee86_cab6_03bf1a2daf93 --> 117159f4_cbb2_daf5_f169_9ec9d696a13a 194b07ed_c18e_6587_618d_b4b4d02442e0["index.js"] 194b07ed_c18e_6587_618d_b4b4d02442e0 --> d383a41d_5383_ee86_cab6_03bf1a2daf93 f1cb032f_d7a0_6877_cebc_2e5f4505e958["index.js"] f1cb032f_d7a0_6877_cebc_2e5f4505e958 --> d383a41d_5383_ee86_cab6_03bf1a2daf93 ccf6927a_1f1b_1dda_8616_80903a72ba16["index.js"] ccf6927a_1f1b_1dda_8616_80903a72ba16 --> d383a41d_5383_ee86_cab6_03bf1a2daf93 7c2d202c_a1cf_5f41_27b4_e23d2a4c21a4["private.d.ts"] 7c2d202c_a1cf_5f41_27b4_e23d2a4c21a4 --> d383a41d_5383_ee86_cab6_03bf1a2daf93 76cde72f_b08b_6c0b_1e04_dda16a7ac104["replace_in_code.js"] 76cde72f_b08b_6c0b_1e04_dda16a7ac104 --> d383a41d_5383_ee86_cab6_03bf1a2daf93 style d383a41d_5383_ee86_cab6_03bf1a2daf93 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { ValidatedCompileOptions } from '#compiler' */
/** @import { Processed } from '../preprocess/public.js' */
/** @import { SourceMap } from 'magic-string' */
/** @import { Source } from '../preprocess/private.js' */
/** @import { DecodedSourceMap, SourceMapSegment, RawSourceMap } from '@jridgewell/remapping' */
import remapping from '@jridgewell/remapping';
import { push_array } from './push_array.js';
/**
* @param {string} s
*/
function last_line_length(s) {
return s.length - s.lastIndexOf('\n') - 1;
}
// mutate map in-place
/**
* @param {DecodedSourceMap} map
* @param {{ line: number; column: number; }} offset
* @param {number} source_index
*/
export function sourcemap_add_offset(map, offset, source_index) {
if (map.mappings.length == 0) return;
for (let line = 0; line < map.mappings.length; line++) {
const segment_list = map.mappings[line];
for (let segment = 0; segment < segment_list.length; segment++) {
const seg = segment_list[segment];
// shift only segments that belong to component source file
if (seg[1] === source_index) {
// also ensures that seg.length >= 4
// shift column if it points at the first line
if (seg[2] === 0) {
/** @type {any} */ (seg[3]) += offset.column;
}
// shift line
/** @type {any} */ (seg[2]) += offset.line;
}
}
}
}
/**
* @template T
* @param {T[]} this_table
* @param {T[]} other_table
* @returns {[T[], number[], boolean, boolean]}
*/
function merge_tables(this_table, other_table) {
const new_table = this_table.slice();
const idx_map = [];
other_table = other_table || [];
let val_changed = false;
for (const [other_idx, other_val] of other_table.entries()) {
const this_idx = this_table.indexOf(other_val);
if (this_idx >= 0) {
idx_map[other_idx] = this_idx;
} else {
const new_idx = new_table.length;
new_table[new_idx] = other_val;
idx_map[other_idx] = new_idx;
// ... (395 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- push_array
- push_array.js
- remapping
Imported By
Source
Frequently Asked Questions
What does mapped_code.js do?
mapped_code.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Migrator subdomain.
What functions are defined in mapped_code.js?
mapped_code.js defines 12 function(s): apply_preprocessor_sourcemap, b64dec, b64enc, combine_sourcemaps, get_basename, get_relative_path, get_source_name, last_line_length, merge_tables, merge_with_preprocessor_map, and 2 more.
What does mapped_code.js depend on?
mapped_code.js imports 3 module(s): push_array, push_array.js, remapping.
What files import mapped_code.js?
mapped_code.js is imported by 5 file(s): index.js, index.js, index.js, private.d.ts, replace_in_code.js.
Where is mapped_code.js in the architecture?
mapped_code.js is located at packages/svelte/src/compiler/utils/mapped_code.js (domain: Compiler, subdomain: Migrator, directory: packages/svelte/src/compiler/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free