mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
fix sourcemap cursor
This commit is contained in:
parent
647883b977
commit
9815e7fe6c
1 changed files with 4 additions and 7 deletions
|
@ -6,7 +6,6 @@ const sourcemaps: Record<string, Mapping[]> = {};
|
|||
|
||||
export const enabled = () => self.$scramjet.config.flags.sourcemaps;
|
||||
|
||||
let t = 0;
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
// every script will push a sourcemap
|
||||
Object.defineProperty(self, "$scramjet$pushsourcemap", {
|
||||
|
@ -53,14 +52,12 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
|
||||
const maps = sourcemaps[tag];
|
||||
|
||||
const relevantRewrites = maps.filter(
|
||||
([str, start, end]) =>
|
||||
start >= absindex && end <= absindex + stringified.length
|
||||
);
|
||||
|
||||
let i = 0;
|
||||
let offset = 0;
|
||||
for (const [str, start, end] of relevantRewrites) {
|
||||
for (const [str, start, end] of maps) {
|
||||
if (start < absindex) continue;
|
||||
if (start - absindex + offset > stringified.length) break;
|
||||
|
||||
// ooh i should really document this before i forget how it works
|
||||
newString += stringified.slice(i, start - absindex + offset);
|
||||
newString += str;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue