Node-Red configuration
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

magic-string.cjs.js 37KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. 'use strict';
  2. var sourcemapCodec = require('@jridgewell/sourcemap-codec');
  3. class BitSet {
  4. constructor(arg) {
  5. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  6. }
  7. add(n) {
  8. this.bits[n >> 5] |= 1 << (n & 31);
  9. }
  10. has(n) {
  11. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  12. }
  13. }
  14. class Chunk {
  15. constructor(start, end, content) {
  16. this.start = start;
  17. this.end = end;
  18. this.original = content;
  19. this.intro = '';
  20. this.outro = '';
  21. this.content = content;
  22. this.storeName = false;
  23. this.edited = false;
  24. {
  25. this.previous = null;
  26. this.next = null;
  27. }
  28. }
  29. appendLeft(content) {
  30. this.outro += content;
  31. }
  32. appendRight(content) {
  33. this.intro = this.intro + content;
  34. }
  35. clone() {
  36. const chunk = new Chunk(this.start, this.end, this.original);
  37. chunk.intro = this.intro;
  38. chunk.outro = this.outro;
  39. chunk.content = this.content;
  40. chunk.storeName = this.storeName;
  41. chunk.edited = this.edited;
  42. return chunk;
  43. }
  44. contains(index) {
  45. return this.start < index && index < this.end;
  46. }
  47. eachNext(fn) {
  48. let chunk = this;
  49. while (chunk) {
  50. fn(chunk);
  51. chunk = chunk.next;
  52. }
  53. }
  54. eachPrevious(fn) {
  55. let chunk = this;
  56. while (chunk) {
  57. fn(chunk);
  58. chunk = chunk.previous;
  59. }
  60. }
  61. edit(content, storeName, contentOnly) {
  62. this.content = content;
  63. if (!contentOnly) {
  64. this.intro = '';
  65. this.outro = '';
  66. }
  67. this.storeName = storeName;
  68. this.edited = true;
  69. return this;
  70. }
  71. prependLeft(content) {
  72. this.outro = content + this.outro;
  73. }
  74. prependRight(content) {
  75. this.intro = content + this.intro;
  76. }
  77. reset() {
  78. this.intro = '';
  79. this.outro = '';
  80. if (this.edited) {
  81. this.content = this.original;
  82. this.storeName = false;
  83. this.edited = false;
  84. }
  85. }
  86. split(index) {
  87. const sliceIndex = index - this.start;
  88. const originalBefore = this.original.slice(0, sliceIndex);
  89. const originalAfter = this.original.slice(sliceIndex);
  90. this.original = originalBefore;
  91. const newChunk = new Chunk(index, this.end, originalAfter);
  92. newChunk.outro = this.outro;
  93. this.outro = '';
  94. this.end = index;
  95. if (this.edited) {
  96. // after split we should save the edit content record into the correct chunk
  97. // to make sure sourcemap correct
  98. // For example:
  99. // ' test'.trim()
  100. // split -> ' ' + 'test'
  101. // ✔️ edit -> '' + 'test'
  102. // ✖️ edit -> 'test' + ''
  103. // TODO is this block necessary?...
  104. newChunk.edit('', false);
  105. this.content = '';
  106. } else {
  107. this.content = originalBefore;
  108. }
  109. newChunk.next = this.next;
  110. if (newChunk.next) newChunk.next.previous = newChunk;
  111. newChunk.previous = this;
  112. this.next = newChunk;
  113. return newChunk;
  114. }
  115. toString() {
  116. return this.intro + this.content + this.outro;
  117. }
  118. trimEnd(rx) {
  119. this.outro = this.outro.replace(rx, '');
  120. if (this.outro.length) return true;
  121. const trimmed = this.content.replace(rx, '');
  122. if (trimmed.length) {
  123. if (trimmed !== this.content) {
  124. this.split(this.start + trimmed.length).edit('', undefined, true);
  125. if (this.edited) {
  126. // save the change, if it has been edited
  127. this.edit(trimmed, this.storeName, true);
  128. }
  129. }
  130. return true;
  131. } else {
  132. this.edit('', undefined, true);
  133. this.intro = this.intro.replace(rx, '');
  134. if (this.intro.length) return true;
  135. }
  136. }
  137. trimStart(rx) {
  138. this.intro = this.intro.replace(rx, '');
  139. if (this.intro.length) return true;
  140. const trimmed = this.content.replace(rx, '');
  141. if (trimmed.length) {
  142. if (trimmed !== this.content) {
  143. const newChunk = this.split(this.end - trimmed.length);
  144. if (this.edited) {
  145. // save the change, if it has been edited
  146. newChunk.edit(trimmed, this.storeName, true);
  147. }
  148. this.edit('', undefined, true);
  149. }
  150. return true;
  151. } else {
  152. this.edit('', undefined, true);
  153. this.outro = this.outro.replace(rx, '');
  154. if (this.outro.length) return true;
  155. }
  156. }
  157. }
  158. function getBtoa() {
  159. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  160. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  161. } else if (typeof Buffer === 'function') {
  162. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  163. } else {
  164. return () => {
  165. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  166. };
  167. }
  168. }
  169. const btoa = /*#__PURE__*/ getBtoa();
  170. class SourceMap {
  171. constructor(properties) {
  172. this.version = 3;
  173. this.file = properties.file;
  174. this.sources = properties.sources;
  175. this.sourcesContent = properties.sourcesContent;
  176. this.names = properties.names;
  177. this.mappings = sourcemapCodec.encode(properties.mappings);
  178. if (typeof properties.x_google_ignoreList !== 'undefined') {
  179. this.x_google_ignoreList = properties.x_google_ignoreList;
  180. }
  181. }
  182. toString() {
  183. return JSON.stringify(this);
  184. }
  185. toUrl() {
  186. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  187. }
  188. }
  189. function guessIndent(code) {
  190. const lines = code.split('\n');
  191. const tabbed = lines.filter((line) => /^\t+/.test(line));
  192. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  193. if (tabbed.length === 0 && spaced.length === 0) {
  194. return null;
  195. }
  196. // More lines tabbed than spaced? Assume tabs, and
  197. // default to tabs in the case of a tie (or nothing
  198. // to go on)
  199. if (tabbed.length >= spaced.length) {
  200. return '\t';
  201. }
  202. // Otherwise, we need to guess the multiple
  203. const min = spaced.reduce((previous, current) => {
  204. const numSpaces = /^ +/.exec(current)[0].length;
  205. return Math.min(numSpaces, previous);
  206. }, Infinity);
  207. return new Array(min + 1).join(' ');
  208. }
  209. function getRelativePath(from, to) {
  210. const fromParts = from.split(/[/\\]/);
  211. const toParts = to.split(/[/\\]/);
  212. fromParts.pop(); // get dirname
  213. while (fromParts[0] === toParts[0]) {
  214. fromParts.shift();
  215. toParts.shift();
  216. }
  217. if (fromParts.length) {
  218. let i = fromParts.length;
  219. while (i--) fromParts[i] = '..';
  220. }
  221. return fromParts.concat(toParts).join('/');
  222. }
  223. const toString = Object.prototype.toString;
  224. function isObject(thing) {
  225. return toString.call(thing) === '[object Object]';
  226. }
  227. function getLocator(source) {
  228. const originalLines = source.split('\n');
  229. const lineOffsets = [];
  230. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  231. lineOffsets.push(pos);
  232. pos += originalLines[i].length + 1;
  233. }
  234. return function locate(index) {
  235. let i = 0;
  236. let j = lineOffsets.length;
  237. while (i < j) {
  238. const m = (i + j) >> 1;
  239. if (index < lineOffsets[m]) {
  240. j = m;
  241. } else {
  242. i = m + 1;
  243. }
  244. }
  245. const line = i - 1;
  246. const column = index - lineOffsets[line];
  247. return { line, column };
  248. };
  249. }
  250. const wordRegex = /\w/;
  251. class Mappings {
  252. constructor(hires) {
  253. this.hires = hires;
  254. this.generatedCodeLine = 0;
  255. this.generatedCodeColumn = 0;
  256. this.raw = [];
  257. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  258. this.pending = null;
  259. }
  260. addEdit(sourceIndex, content, loc, nameIndex) {
  261. if (content.length) {
  262. const contentLengthMinusOne = content.length - 1;
  263. let contentLineEnd = content.indexOf('\n', 0);
  264. let previousContentLineEnd = -1;
  265. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  266. // else code afterwards would fill one line too many
  267. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  268. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  269. if (nameIndex >= 0) {
  270. segment.push(nameIndex);
  271. }
  272. this.rawSegments.push(segment);
  273. this.generatedCodeLine += 1;
  274. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  275. this.generatedCodeColumn = 0;
  276. previousContentLineEnd = contentLineEnd;
  277. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  278. }
  279. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  280. if (nameIndex >= 0) {
  281. segment.push(nameIndex);
  282. }
  283. this.rawSegments.push(segment);
  284. this.advance(content.slice(previousContentLineEnd + 1));
  285. } else if (this.pending) {
  286. this.rawSegments.push(this.pending);
  287. this.advance(content);
  288. }
  289. this.pending = null;
  290. }
  291. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  292. let originalCharIndex = chunk.start;
  293. let first = true;
  294. // when iterating each char, check if it's in a word boundary
  295. let charInHiresBoundary = false;
  296. while (originalCharIndex < chunk.end) {
  297. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  298. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  299. if (this.hires === 'boundary') {
  300. // in hires "boundary", group segments per word boundary than per char
  301. if (wordRegex.test(original[originalCharIndex])) {
  302. // for first char in the boundary found, start the boundary by pushing a segment
  303. if (!charInHiresBoundary) {
  304. this.rawSegments.push(segment);
  305. charInHiresBoundary = true;
  306. }
  307. } else {
  308. // for non-word char, end the boundary by pushing a segment
  309. this.rawSegments.push(segment);
  310. charInHiresBoundary = false;
  311. }
  312. } else {
  313. this.rawSegments.push(segment);
  314. }
  315. }
  316. if (original[originalCharIndex] === '\n') {
  317. loc.line += 1;
  318. loc.column = 0;
  319. this.generatedCodeLine += 1;
  320. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  321. this.generatedCodeColumn = 0;
  322. first = true;
  323. } else {
  324. loc.column += 1;
  325. this.generatedCodeColumn += 1;
  326. first = false;
  327. }
  328. originalCharIndex += 1;
  329. }
  330. this.pending = null;
  331. }
  332. advance(str) {
  333. if (!str) return;
  334. const lines = str.split('\n');
  335. if (lines.length > 1) {
  336. for (let i = 0; i < lines.length - 1; i++) {
  337. this.generatedCodeLine++;
  338. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  339. }
  340. this.generatedCodeColumn = 0;
  341. }
  342. this.generatedCodeColumn += lines[lines.length - 1].length;
  343. }
  344. }
  345. const n = '\n';
  346. const warned = {
  347. insertLeft: false,
  348. insertRight: false,
  349. storeName: false,
  350. };
  351. class MagicString {
  352. constructor(string, options = {}) {
  353. const chunk = new Chunk(0, string.length, string);
  354. Object.defineProperties(this, {
  355. original: { writable: true, value: string },
  356. outro: { writable: true, value: '' },
  357. intro: { writable: true, value: '' },
  358. firstChunk: { writable: true, value: chunk },
  359. lastChunk: { writable: true, value: chunk },
  360. lastSearchedChunk: { writable: true, value: chunk },
  361. byStart: { writable: true, value: {} },
  362. byEnd: { writable: true, value: {} },
  363. filename: { writable: true, value: options.filename },
  364. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  365. sourcemapLocations: { writable: true, value: new BitSet() },
  366. storedNames: { writable: true, value: {} },
  367. indentStr: { writable: true, value: undefined },
  368. ignoreList: { writable: true, value: options.ignoreList },
  369. });
  370. this.byStart[0] = chunk;
  371. this.byEnd[string.length] = chunk;
  372. }
  373. addSourcemapLocation(char) {
  374. this.sourcemapLocations.add(char);
  375. }
  376. append(content) {
  377. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  378. this.outro += content;
  379. return this;
  380. }
  381. appendLeft(index, content) {
  382. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  383. this._split(index);
  384. const chunk = this.byEnd[index];
  385. if (chunk) {
  386. chunk.appendLeft(content);
  387. } else {
  388. this.intro += content;
  389. }
  390. return this;
  391. }
  392. appendRight(index, content) {
  393. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  394. this._split(index);
  395. const chunk = this.byStart[index];
  396. if (chunk) {
  397. chunk.appendRight(content);
  398. } else {
  399. this.outro += content;
  400. }
  401. return this;
  402. }
  403. clone() {
  404. const cloned = new MagicString(this.original, { filename: this.filename });
  405. let originalChunk = this.firstChunk;
  406. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  407. while (originalChunk) {
  408. cloned.byStart[clonedChunk.start] = clonedChunk;
  409. cloned.byEnd[clonedChunk.end] = clonedChunk;
  410. const nextOriginalChunk = originalChunk.next;
  411. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  412. if (nextClonedChunk) {
  413. clonedChunk.next = nextClonedChunk;
  414. nextClonedChunk.previous = clonedChunk;
  415. clonedChunk = nextClonedChunk;
  416. }
  417. originalChunk = nextOriginalChunk;
  418. }
  419. cloned.lastChunk = clonedChunk;
  420. if (this.indentExclusionRanges) {
  421. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  422. }
  423. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  424. cloned.intro = this.intro;
  425. cloned.outro = this.outro;
  426. return cloned;
  427. }
  428. generateDecodedMap(options) {
  429. options = options || {};
  430. const sourceIndex = 0;
  431. const names = Object.keys(this.storedNames);
  432. const mappings = new Mappings(options.hires);
  433. const locate = getLocator(this.original);
  434. if (this.intro) {
  435. mappings.advance(this.intro);
  436. }
  437. this.firstChunk.eachNext((chunk) => {
  438. const loc = locate(chunk.start);
  439. if (chunk.intro.length) mappings.advance(chunk.intro);
  440. if (chunk.edited) {
  441. mappings.addEdit(
  442. sourceIndex,
  443. chunk.content,
  444. loc,
  445. chunk.storeName ? names.indexOf(chunk.original) : -1,
  446. );
  447. } else {
  448. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  449. }
  450. if (chunk.outro.length) mappings.advance(chunk.outro);
  451. });
  452. return {
  453. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  454. sources: [
  455. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  456. ],
  457. sourcesContent: options.includeContent ? [this.original] : undefined,
  458. names,
  459. mappings: mappings.raw,
  460. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  461. };
  462. }
  463. generateMap(options) {
  464. return new SourceMap(this.generateDecodedMap(options));
  465. }
  466. _ensureindentStr() {
  467. if (this.indentStr === undefined) {
  468. this.indentStr = guessIndent(this.original);
  469. }
  470. }
  471. _getRawIndentString() {
  472. this._ensureindentStr();
  473. return this.indentStr;
  474. }
  475. getIndentString() {
  476. this._ensureindentStr();
  477. return this.indentStr === null ? '\t' : this.indentStr;
  478. }
  479. indent(indentStr, options) {
  480. const pattern = /^[^\r\n]/gm;
  481. if (isObject(indentStr)) {
  482. options = indentStr;
  483. indentStr = undefined;
  484. }
  485. if (indentStr === undefined) {
  486. this._ensureindentStr();
  487. indentStr = this.indentStr || '\t';
  488. }
  489. if (indentStr === '') return this; // noop
  490. options = options || {};
  491. // Process exclusion ranges
  492. const isExcluded = {};
  493. if (options.exclude) {
  494. const exclusions =
  495. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  496. exclusions.forEach((exclusion) => {
  497. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  498. isExcluded[i] = true;
  499. }
  500. });
  501. }
  502. let shouldIndentNextCharacter = options.indentStart !== false;
  503. const replacer = (match) => {
  504. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  505. shouldIndentNextCharacter = true;
  506. return match;
  507. };
  508. this.intro = this.intro.replace(pattern, replacer);
  509. let charIndex = 0;
  510. let chunk = this.firstChunk;
  511. while (chunk) {
  512. const end = chunk.end;
  513. if (chunk.edited) {
  514. if (!isExcluded[charIndex]) {
  515. chunk.content = chunk.content.replace(pattern, replacer);
  516. if (chunk.content.length) {
  517. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  518. }
  519. }
  520. } else {
  521. charIndex = chunk.start;
  522. while (charIndex < end) {
  523. if (!isExcluded[charIndex]) {
  524. const char = this.original[charIndex];
  525. if (char === '\n') {
  526. shouldIndentNextCharacter = true;
  527. } else if (char !== '\r' && shouldIndentNextCharacter) {
  528. shouldIndentNextCharacter = false;
  529. if (charIndex === chunk.start) {
  530. chunk.prependRight(indentStr);
  531. } else {
  532. this._splitChunk(chunk, charIndex);
  533. chunk = chunk.next;
  534. chunk.prependRight(indentStr);
  535. }
  536. }
  537. }
  538. charIndex += 1;
  539. }
  540. }
  541. charIndex = chunk.end;
  542. chunk = chunk.next;
  543. }
  544. this.outro = this.outro.replace(pattern, replacer);
  545. return this;
  546. }
  547. insert() {
  548. throw new Error(
  549. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  550. );
  551. }
  552. insertLeft(index, content) {
  553. if (!warned.insertLeft) {
  554. console.warn(
  555. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  556. ); // eslint-disable-line no-console
  557. warned.insertLeft = true;
  558. }
  559. return this.appendLeft(index, content);
  560. }
  561. insertRight(index, content) {
  562. if (!warned.insertRight) {
  563. console.warn(
  564. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  565. ); // eslint-disable-line no-console
  566. warned.insertRight = true;
  567. }
  568. return this.prependRight(index, content);
  569. }
  570. move(start, end, index) {
  571. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  572. this._split(start);
  573. this._split(end);
  574. this._split(index);
  575. const first = this.byStart[start];
  576. const last = this.byEnd[end];
  577. const oldLeft = first.previous;
  578. const oldRight = last.next;
  579. const newRight = this.byStart[index];
  580. if (!newRight && last === this.lastChunk) return this;
  581. const newLeft = newRight ? newRight.previous : this.lastChunk;
  582. if (oldLeft) oldLeft.next = oldRight;
  583. if (oldRight) oldRight.previous = oldLeft;
  584. if (newLeft) newLeft.next = first;
  585. if (newRight) newRight.previous = last;
  586. if (!first.previous) this.firstChunk = last.next;
  587. if (!last.next) {
  588. this.lastChunk = first.previous;
  589. this.lastChunk.next = null;
  590. }
  591. first.previous = newLeft;
  592. last.next = newRight || null;
  593. if (!newLeft) this.firstChunk = first;
  594. if (!newRight) this.lastChunk = last;
  595. return this;
  596. }
  597. overwrite(start, end, content, options) {
  598. options = options || {};
  599. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  600. }
  601. update(start, end, content, options) {
  602. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  603. if (this.original.length !== 0) {
  604. while (start < 0) start += this.original.length;
  605. while (end < 0) end += this.original.length;
  606. }
  607. if (end > this.original.length) throw new Error('end is out of bounds');
  608. if (start === end)
  609. throw new Error(
  610. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  611. );
  612. this._split(start);
  613. this._split(end);
  614. if (options === true) {
  615. if (!warned.storeName) {
  616. console.warn(
  617. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  618. ); // eslint-disable-line no-console
  619. warned.storeName = true;
  620. }
  621. options = { storeName: true };
  622. }
  623. const storeName = options !== undefined ? options.storeName : false;
  624. const overwrite = options !== undefined ? options.overwrite : false;
  625. if (storeName) {
  626. const original = this.original.slice(start, end);
  627. Object.defineProperty(this.storedNames, original, {
  628. writable: true,
  629. value: true,
  630. enumerable: true,
  631. });
  632. }
  633. const first = this.byStart[start];
  634. const last = this.byEnd[end];
  635. if (first) {
  636. let chunk = first;
  637. while (chunk !== last) {
  638. if (chunk.next !== this.byStart[chunk.end]) {
  639. throw new Error('Cannot overwrite across a split point');
  640. }
  641. chunk = chunk.next;
  642. chunk.edit('', false);
  643. }
  644. first.edit(content, storeName, !overwrite);
  645. } else {
  646. // must be inserting at the end
  647. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  648. // TODO last chunk in the array may not be the last chunk, if it's moved...
  649. last.next = newChunk;
  650. newChunk.previous = last;
  651. }
  652. return this;
  653. }
  654. prepend(content) {
  655. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  656. this.intro = content + this.intro;
  657. return this;
  658. }
  659. prependLeft(index, content) {
  660. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  661. this._split(index);
  662. const chunk = this.byEnd[index];
  663. if (chunk) {
  664. chunk.prependLeft(content);
  665. } else {
  666. this.intro = content + this.intro;
  667. }
  668. return this;
  669. }
  670. prependRight(index, content) {
  671. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  672. this._split(index);
  673. const chunk = this.byStart[index];
  674. if (chunk) {
  675. chunk.prependRight(content);
  676. } else {
  677. this.outro = content + this.outro;
  678. }
  679. return this;
  680. }
  681. remove(start, end) {
  682. if (this.original.length !== 0) {
  683. while (start < 0) start += this.original.length;
  684. while (end < 0) end += this.original.length;
  685. }
  686. if (start === end) return this;
  687. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  688. if (start > end) throw new Error('end must be greater than start');
  689. this._split(start);
  690. this._split(end);
  691. let chunk = this.byStart[start];
  692. while (chunk) {
  693. chunk.intro = '';
  694. chunk.outro = '';
  695. chunk.edit('');
  696. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  697. }
  698. return this;
  699. }
  700. reset(start, end) {
  701. if (this.original.length !== 0) {
  702. while (start < 0) start += this.original.length;
  703. while (end < 0) end += this.original.length;
  704. }
  705. if (start === end) return this;
  706. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  707. if (start > end) throw new Error('end must be greater than start');
  708. this._split(start);
  709. this._split(end);
  710. let chunk = this.byStart[start];
  711. while (chunk) {
  712. chunk.reset();
  713. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  714. }
  715. return this;
  716. }
  717. lastChar() {
  718. if (this.outro.length) return this.outro[this.outro.length - 1];
  719. let chunk = this.lastChunk;
  720. do {
  721. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  722. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  723. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  724. } while ((chunk = chunk.previous));
  725. if (this.intro.length) return this.intro[this.intro.length - 1];
  726. return '';
  727. }
  728. lastLine() {
  729. let lineIndex = this.outro.lastIndexOf(n);
  730. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  731. let lineStr = this.outro;
  732. let chunk = this.lastChunk;
  733. do {
  734. if (chunk.outro.length > 0) {
  735. lineIndex = chunk.outro.lastIndexOf(n);
  736. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  737. lineStr = chunk.outro + lineStr;
  738. }
  739. if (chunk.content.length > 0) {
  740. lineIndex = chunk.content.lastIndexOf(n);
  741. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  742. lineStr = chunk.content + lineStr;
  743. }
  744. if (chunk.intro.length > 0) {
  745. lineIndex = chunk.intro.lastIndexOf(n);
  746. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  747. lineStr = chunk.intro + lineStr;
  748. }
  749. } while ((chunk = chunk.previous));
  750. lineIndex = this.intro.lastIndexOf(n);
  751. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  752. return this.intro + lineStr;
  753. }
  754. slice(start = 0, end = this.original.length) {
  755. if (this.original.length !== 0) {
  756. while (start < 0) start += this.original.length;
  757. while (end < 0) end += this.original.length;
  758. }
  759. let result = '';
  760. // find start chunk
  761. let chunk = this.firstChunk;
  762. while (chunk && (chunk.start > start || chunk.end <= start)) {
  763. // found end chunk before start
  764. if (chunk.start < end && chunk.end >= end) {
  765. return result;
  766. }
  767. chunk = chunk.next;
  768. }
  769. if (chunk && chunk.edited && chunk.start !== start)
  770. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  771. const startChunk = chunk;
  772. while (chunk) {
  773. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  774. result += chunk.intro;
  775. }
  776. const containsEnd = chunk.start < end && chunk.end >= end;
  777. if (containsEnd && chunk.edited && chunk.end !== end)
  778. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  779. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  780. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  781. result += chunk.content.slice(sliceStart, sliceEnd);
  782. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  783. result += chunk.outro;
  784. }
  785. if (containsEnd) {
  786. break;
  787. }
  788. chunk = chunk.next;
  789. }
  790. return result;
  791. }
  792. // TODO deprecate this? not really very useful
  793. snip(start, end) {
  794. const clone = this.clone();
  795. clone.remove(0, start);
  796. clone.remove(end, clone.original.length);
  797. return clone;
  798. }
  799. _split(index) {
  800. if (this.byStart[index] || this.byEnd[index]) return;
  801. let chunk = this.lastSearchedChunk;
  802. const searchForward = index > chunk.end;
  803. while (chunk) {
  804. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  805. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  806. }
  807. }
  808. _splitChunk(chunk, index) {
  809. if (chunk.edited && chunk.content.length) {
  810. // zero-length edited chunks are a special case (overlapping replacements)
  811. const loc = getLocator(this.original)(index);
  812. throw new Error(
  813. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  814. );
  815. }
  816. const newChunk = chunk.split(index);
  817. this.byEnd[index] = chunk;
  818. this.byStart[index] = newChunk;
  819. this.byEnd[newChunk.end] = newChunk;
  820. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  821. this.lastSearchedChunk = chunk;
  822. return true;
  823. }
  824. toString() {
  825. let str = this.intro;
  826. let chunk = this.firstChunk;
  827. while (chunk) {
  828. str += chunk.toString();
  829. chunk = chunk.next;
  830. }
  831. return str + this.outro;
  832. }
  833. isEmpty() {
  834. let chunk = this.firstChunk;
  835. do {
  836. if (
  837. (chunk.intro.length && chunk.intro.trim()) ||
  838. (chunk.content.length && chunk.content.trim()) ||
  839. (chunk.outro.length && chunk.outro.trim())
  840. )
  841. return false;
  842. } while ((chunk = chunk.next));
  843. return true;
  844. }
  845. length() {
  846. let chunk = this.firstChunk;
  847. let length = 0;
  848. do {
  849. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  850. } while ((chunk = chunk.next));
  851. return length;
  852. }
  853. trimLines() {
  854. return this.trim('[\\r\\n]');
  855. }
  856. trim(charType) {
  857. return this.trimStart(charType).trimEnd(charType);
  858. }
  859. trimEndAborted(charType) {
  860. const rx = new RegExp((charType || '\\s') + '+$');
  861. this.outro = this.outro.replace(rx, '');
  862. if (this.outro.length) return true;
  863. let chunk = this.lastChunk;
  864. do {
  865. const end = chunk.end;
  866. const aborted = chunk.trimEnd(rx);
  867. // if chunk was trimmed, we have a new lastChunk
  868. if (chunk.end !== end) {
  869. if (this.lastChunk === chunk) {
  870. this.lastChunk = chunk.next;
  871. }
  872. this.byEnd[chunk.end] = chunk;
  873. this.byStart[chunk.next.start] = chunk.next;
  874. this.byEnd[chunk.next.end] = chunk.next;
  875. }
  876. if (aborted) return true;
  877. chunk = chunk.previous;
  878. } while (chunk);
  879. return false;
  880. }
  881. trimEnd(charType) {
  882. this.trimEndAborted(charType);
  883. return this;
  884. }
  885. trimStartAborted(charType) {
  886. const rx = new RegExp('^' + (charType || '\\s') + '+');
  887. this.intro = this.intro.replace(rx, '');
  888. if (this.intro.length) return true;
  889. let chunk = this.firstChunk;
  890. do {
  891. const end = chunk.end;
  892. const aborted = chunk.trimStart(rx);
  893. if (chunk.end !== end) {
  894. // special case...
  895. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  896. this.byEnd[chunk.end] = chunk;
  897. this.byStart[chunk.next.start] = chunk.next;
  898. this.byEnd[chunk.next.end] = chunk.next;
  899. }
  900. if (aborted) return true;
  901. chunk = chunk.next;
  902. } while (chunk);
  903. return false;
  904. }
  905. trimStart(charType) {
  906. this.trimStartAborted(charType);
  907. return this;
  908. }
  909. hasChanged() {
  910. return this.original !== this.toString();
  911. }
  912. _replaceRegexp(searchValue, replacement) {
  913. function getReplacement(match, str) {
  914. if (typeof replacement === 'string') {
  915. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  916. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  917. if (i === '$') return '$';
  918. if (i === '&') return match[0];
  919. const num = +i;
  920. if (num < match.length) return match[+i];
  921. return `$${i}`;
  922. });
  923. } else {
  924. return replacement(...match, match.index, str, match.groups);
  925. }
  926. }
  927. function matchAll(re, str) {
  928. let match;
  929. const matches = [];
  930. while ((match = re.exec(str))) {
  931. matches.push(match);
  932. }
  933. return matches;
  934. }
  935. if (searchValue.global) {
  936. const matches = matchAll(searchValue, this.original);
  937. matches.forEach((match) => {
  938. if (match.index != null) {
  939. const replacement = getReplacement(match, this.original);
  940. if (replacement !== match[0]) {
  941. this.overwrite(
  942. match.index,
  943. match.index + match[0].length,
  944. replacement
  945. );
  946. }
  947. }
  948. });
  949. } else {
  950. const match = this.original.match(searchValue);
  951. if (match && match.index != null) {
  952. const replacement = getReplacement(match, this.original);
  953. if (replacement !== match[0]) {
  954. this.overwrite(
  955. match.index,
  956. match.index + match[0].length,
  957. replacement
  958. );
  959. }
  960. }
  961. }
  962. return this;
  963. }
  964. _replaceString(string, replacement) {
  965. const { original } = this;
  966. const index = original.indexOf(string);
  967. if (index !== -1) {
  968. this.overwrite(index, index + string.length, replacement);
  969. }
  970. return this;
  971. }
  972. replace(searchValue, replacement) {
  973. if (typeof searchValue === 'string') {
  974. return this._replaceString(searchValue, replacement);
  975. }
  976. return this._replaceRegexp(searchValue, replacement);
  977. }
  978. _replaceAllString(string, replacement) {
  979. const { original } = this;
  980. const stringLength = string.length;
  981. for (
  982. let index = original.indexOf(string);
  983. index !== -1;
  984. index = original.indexOf(string, index + stringLength)
  985. ) {
  986. const previous = original.slice(index, index + stringLength);
  987. if (previous !== replacement)
  988. this.overwrite(index, index + stringLength, replacement);
  989. }
  990. return this;
  991. }
  992. replaceAll(searchValue, replacement) {
  993. if (typeof searchValue === 'string') {
  994. return this._replaceAllString(searchValue, replacement);
  995. }
  996. if (!searchValue.global) {
  997. throw new TypeError(
  998. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  999. );
  1000. }
  1001. return this._replaceRegexp(searchValue, replacement);
  1002. }
  1003. }
  1004. const hasOwnProp = Object.prototype.hasOwnProperty;
  1005. class Bundle {
  1006. constructor(options = {}) {
  1007. this.intro = options.intro || '';
  1008. this.separator = options.separator !== undefined ? options.separator : '\n';
  1009. this.sources = [];
  1010. this.uniqueSources = [];
  1011. this.uniqueSourceIndexByFilename = {};
  1012. }
  1013. addSource(source) {
  1014. if (source instanceof MagicString) {
  1015. return this.addSource({
  1016. content: source,
  1017. filename: source.filename,
  1018. separator: this.separator,
  1019. });
  1020. }
  1021. if (!isObject(source) || !source.content) {
  1022. throw new Error(
  1023. 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
  1024. );
  1025. }
  1026. ['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
  1027. if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
  1028. });
  1029. if (source.separator === undefined) {
  1030. // TODO there's a bunch of this sort of thing, needs cleaning up
  1031. source.separator = this.separator;
  1032. }
  1033. if (source.filename) {
  1034. if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
  1035. this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
  1036. this.uniqueSources.push({ filename: source.filename, content: source.content.original });
  1037. } else {
  1038. const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
  1039. if (source.content.original !== uniqueSource.content) {
  1040. throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
  1041. }
  1042. }
  1043. }
  1044. this.sources.push(source);
  1045. return this;
  1046. }
  1047. append(str, options) {
  1048. this.addSource({
  1049. content: new MagicString(str),
  1050. separator: (options && options.separator) || '',
  1051. });
  1052. return this;
  1053. }
  1054. clone() {
  1055. const bundle = new Bundle({
  1056. intro: this.intro,
  1057. separator: this.separator,
  1058. });
  1059. this.sources.forEach((source) => {
  1060. bundle.addSource({
  1061. filename: source.filename,
  1062. content: source.content.clone(),
  1063. separator: source.separator,
  1064. });
  1065. });
  1066. return bundle;
  1067. }
  1068. generateDecodedMap(options = {}) {
  1069. const names = [];
  1070. let x_google_ignoreList = undefined;
  1071. this.sources.forEach((source) => {
  1072. Object.keys(source.content.storedNames).forEach((name) => {
  1073. if (!~names.indexOf(name)) names.push(name);
  1074. });
  1075. });
  1076. const mappings = new Mappings(options.hires);
  1077. if (this.intro) {
  1078. mappings.advance(this.intro);
  1079. }
  1080. this.sources.forEach((source, i) => {
  1081. if (i > 0) {
  1082. mappings.advance(this.separator);
  1083. }
  1084. const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
  1085. const magicString = source.content;
  1086. const locate = getLocator(magicString.original);
  1087. if (magicString.intro) {
  1088. mappings.advance(magicString.intro);
  1089. }
  1090. magicString.firstChunk.eachNext((chunk) => {
  1091. const loc = locate(chunk.start);
  1092. if (chunk.intro.length) mappings.advance(chunk.intro);
  1093. if (source.filename) {
  1094. if (chunk.edited) {
  1095. mappings.addEdit(
  1096. sourceIndex,
  1097. chunk.content,
  1098. loc,
  1099. chunk.storeName ? names.indexOf(chunk.original) : -1,
  1100. );
  1101. } else {
  1102. mappings.addUneditedChunk(
  1103. sourceIndex,
  1104. chunk,
  1105. magicString.original,
  1106. loc,
  1107. magicString.sourcemapLocations,
  1108. );
  1109. }
  1110. } else {
  1111. mappings.advance(chunk.content);
  1112. }
  1113. if (chunk.outro.length) mappings.advance(chunk.outro);
  1114. });
  1115. if (magicString.outro) {
  1116. mappings.advance(magicString.outro);
  1117. }
  1118. if (source.ignoreList && sourceIndex !== -1) {
  1119. if (x_google_ignoreList === undefined) {
  1120. x_google_ignoreList = [];
  1121. }
  1122. x_google_ignoreList.push(sourceIndex);
  1123. }
  1124. });
  1125. return {
  1126. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  1127. sources: this.uniqueSources.map((source) => {
  1128. return options.file ? getRelativePath(options.file, source.filename) : source.filename;
  1129. }),
  1130. sourcesContent: this.uniqueSources.map((source) => {
  1131. return options.includeContent ? source.content : null;
  1132. }),
  1133. names,
  1134. mappings: mappings.raw,
  1135. x_google_ignoreList,
  1136. };
  1137. }
  1138. generateMap(options) {
  1139. return new SourceMap(this.generateDecodedMap(options));
  1140. }
  1141. getIndentString() {
  1142. const indentStringCounts = {};
  1143. this.sources.forEach((source) => {
  1144. const indentStr = source.content._getRawIndentString();
  1145. if (indentStr === null) return;
  1146. if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
  1147. indentStringCounts[indentStr] += 1;
  1148. });
  1149. return (
  1150. Object.keys(indentStringCounts).sort((a, b) => {
  1151. return indentStringCounts[a] - indentStringCounts[b];
  1152. })[0] || '\t'
  1153. );
  1154. }
  1155. indent(indentStr) {
  1156. if (!arguments.length) {
  1157. indentStr = this.getIndentString();
  1158. }
  1159. if (indentStr === '') return this; // noop
  1160. let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
  1161. this.sources.forEach((source, i) => {
  1162. const separator = source.separator !== undefined ? source.separator : this.separator;
  1163. const indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
  1164. source.content.indent(indentStr, {
  1165. exclude: source.indentExclusionRanges,
  1166. indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
  1167. });
  1168. trailingNewline = source.content.lastChar() === '\n';
  1169. });
  1170. if (this.intro) {
  1171. this.intro =
  1172. indentStr +
  1173. this.intro.replace(/^[^\n]/gm, (match, index) => {
  1174. return index > 0 ? indentStr + match : match;
  1175. });
  1176. }
  1177. return this;
  1178. }
  1179. prepend(str) {
  1180. this.intro = str + this.intro;
  1181. return this;
  1182. }
  1183. toString() {
  1184. const body = this.sources
  1185. .map((source, i) => {
  1186. const separator = source.separator !== undefined ? source.separator : this.separator;
  1187. const str = (i > 0 ? separator : '') + source.content.toString();
  1188. return str;
  1189. })
  1190. .join('');
  1191. return this.intro + body;
  1192. }
  1193. isEmpty() {
  1194. if (this.intro.length && this.intro.trim()) return false;
  1195. if (this.sources.some((source) => !source.content.isEmpty())) return false;
  1196. return true;
  1197. }
  1198. length() {
  1199. return this.sources.reduce(
  1200. (length, source) => length + source.content.length(),
  1201. this.intro.length,
  1202. );
  1203. }
  1204. trimLines() {
  1205. return this.trim('[\\r\\n]');
  1206. }
  1207. trim(charType) {
  1208. return this.trimStart(charType).trimEnd(charType);
  1209. }
  1210. trimStart(charType) {
  1211. const rx = new RegExp('^' + (charType || '\\s') + '+');
  1212. this.intro = this.intro.replace(rx, '');
  1213. if (!this.intro) {
  1214. let source;
  1215. let i = 0;
  1216. do {
  1217. source = this.sources[i++];
  1218. if (!source) {
  1219. break;
  1220. }
  1221. } while (!source.content.trimStartAborted(charType));
  1222. }
  1223. return this;
  1224. }
  1225. trimEnd(charType) {
  1226. const rx = new RegExp((charType || '\\s') + '+$');
  1227. let source;
  1228. let i = this.sources.length - 1;
  1229. do {
  1230. source = this.sources[i--];
  1231. if (!source) {
  1232. this.intro = this.intro.replace(rx, '');
  1233. break;
  1234. }
  1235. } while (!source.content.trimEndAborted(charType));
  1236. return this;
  1237. }
  1238. }
  1239. MagicString.Bundle = Bundle;
  1240. MagicString.SourceMap = SourceMap;
  1241. MagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121
  1242. module.exports = MagicString;
  1243. //# sourceMappingURL=magic-string.cjs.js.map