rusty_source_map/constants.rs
1#![allow(non_upper_case_globals)]
2#![allow(dead_code)]
3
4// intellij replace
5// ^(\s*)([a-zA-Z]*):
6// $1"$2":
7
8// exports.testGeneratedCode =
9// " ONE.foo=function(a){return baz(a);};\n TWO.inc=function(a){return a+1;};";
10pub(crate) const testGeneratedCode: &str =
11 r##" ONE.foo=function(a){return baz(a);};\n TWO.inc=function(a){return a+1;};"##;
12// exports.testMap = {
13// version: 3,
14// file: "min.js",
15// names: ["bar", "baz", "n"],
16// sources: ["one.js", "two.js"],
17// sourceRoot: "/the/root",
18// mappings:
19// "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
20// };
21pub(crate) const testMap: &str = r##"{
22 "version": 3,
23 "file": "min.js",
24 "names": ["bar", "baz", "n"],
25 "sources": ["one.js", "two.js"],
26 "sourceRoot": "/the/root",
27 "mappings":
28 "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
29}"##;
30
31// exports.testMapNoSourceRoot = {
32// version: 3,
33// file: "min.js",
34// names: ["bar", "baz", "n"],
35// sources: ["one.js", "two.js"],
36// mappings:
37// "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
38// };
39pub(crate) const testMapNoSourceRoot: &str = r##" {
40"version": 3,
41"file": "min.js",
42"names": ["bar", "baz", "n"],
43"sources": ["one.js", "two.js"],
44"mappings":
45 "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
46}"##;
47
48// exports.testMapEmptySourceRoot = {
49// version: 3,
50// file: "min.js",
51// names: ["bar", "baz", "n"],
52// sources: ["one.js", "two.js"],
53// sourceRoot: "",
54// mappings:
55// "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
56// };
57pub(crate) const testMapEmptySourceRoot: &str = r##"{
58"version": 3,
59"file": "min.js",
60"names": ["bar", "baz", "n"],
61"sources": ["one.js", "two.js"],
62"sourceRoot": "",
63"mappings":
64 "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
65}"##;
66
67// exports.testMapSingleSource = {
68// version: 3,
69// file: "min.js",
70// names: ["bar", "baz"],
71// sources: ["one.js"],
72// sourceRoot: "",
73// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID"
74// };
75pub(crate) const testMapSingleSource: &str = r##"
76{
77"version": 3,
78"file": "min.js",
79"names": ["bar", "baz"],
80"sources": ["one.js"],
81"sourceRoot": "",
82"mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID"
83}
84"##;
85
86// exports.testMapEmptyMappings = {
87// version: 3,
88// file: "min.js",
89// names: [],
90// sources: ["one.js", "two.js"],
91// sourcesContent: [" ONE.foo = 1;", " TWO.inc = 2;"],
92// sourceRoot: "",
93// mappings: ""
94// };
95pub(crate) const testMapEmptyMappings: &str = r##"
96{
97"version": 3,
98"file": "min.js",
99"names": [],
100"sources": ["one.js", "two.js"],
101"sourcesContent": [" ONE.foo = 1;", " TWO.inc = 2;"],
102"sourceRoot": "",
103"mappings": ""
104}
105"##;
106
107// exports.testMapEmptyMappingsRelativeSources = {
108// version: 3,
109// file: "min.js",
110// names: [],
111// sources: ["./one.js", "./two.js"],
112// sourcesContent: [" ONE.foo = 1;", " TWO.inc = 2;"],
113// sourceRoot: "/the/root",
114// mappings: ""
115// };
116pub(crate) const testMapEmptyMappingsRelativeSources: &str = r##"
117{
118"version": 3,
119"file": "min.js",
120"names": [],
121"sources": ["./one.js", "./two.js"],
122"sourcesContent": [" ONE.foo = 1;", " TWO.inc = 2;"],
123"sourceRoot": "/the/root",
124"mappings": ""
125}
126"##;
127
128// exports.testMapEmptyMappingsRelativeSources_generatedExpected = {
129// version: 3,
130// file: "min.js",
131// names: [],
132// sources: ["one.js", "two.js"],
133// sourcesContent: [" ONE.foo = 1;", " TWO.inc = 2;"],
134// sourceRoot: "/the/root",
135// mappings: ""
136// };
137pub(crate) const testMapEmptyMappingsRelativeSources_generatedExpected: &str = r##"
138{
139"version": 3,
140"file": "min.js",
141"names": [],
142"sources": ["one.js", "two.js"],
143"sourcesContent": [" ONE.foo = 1;", " TWO.inc = 2;"],
144"sourceRoot": "/the/root",
145"mappings": ""
146}
147"##;
148
149// exports.testMapMultiSourcesMappingRefersSingleSourceOnly = {
150// version: 3,
151// file: "min.js",
152// names: ["bar", "baz"],
153// sources: ["one.js", "withoutMappings.js"],
154// sourceRoot: "",
155// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID"
156// };
157pub(crate) const testMapMultiSourcesMappingRefersSingleSourceOnly: &str = r##"
158{
159"version": 3,
160"file": "min.js",
161"names": ["bar", "baz"],
162"sources": ["one.js", "withoutMappings.js"],
163"sourceRoot": "",
164 mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID"
165}
166"##;
167
168// // This mapping is identical to above, but uses the indexed format instead.
169// exports.indexedTestMap = {
170// version: 3,
171// file: "min.js",
172// sections: [
173// {
174// offset: {
175// line: 0,
176// column: 0
177// },
178// map: {
179// version: 3,
180// sources: ["one.js"],
181// sourcesContent: [
182// " ONE.foo = function (bar) {\n return baz(bar);\n };"
183// ],
184// names: ["bar", "baz"],
185// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
186// file: "min.js",
187// sourceRoot: "/the/root"
188// }
189// },
190// {
191// offset: {
192// line: 1,
193// column: 0
194// },
195// map: {
196// version: 3,
197// sources: ["two.js"],
198// sourcesContent: [" TWO.inc = function (n) {\n return n + 1;\n };"],
199// names: ["n"],
200// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
201// file: "min.js",
202// sourceRoot: "/the/root"
203// }
204// }
205// ]
206// };
207pub(crate) const indexedTestMap: &str = r##"{
208 "version": 3,
209 "file": "min.js",
210 "sections": [
211 {
212 "offset": {
213 "line": 0,
214 "column": 0
215 },
216 "map": {
217 "version": 3,
218 "sources": ["one.js"],
219 "sourcesContent": [
220 " ONE.foo = function (bar) {\n return baz(bar);\n };"
221 ],
222 "names": ["bar", "baz"],
223 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
224 "file": "min.js",
225 "sourceRoot": "/the/root"
226 }
227 },
228 {
229 "offset": {
230 "line": 1,
231 "column": 0
232 },
233 "map": {
234 "version": 3,
235 "sources": ["two.js"],
236 "sourcesContent": [" TWO.inc = function (n) {\n return n + 1;\n };"],
237 "names": ["n"],
238 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
239 "file": "min.js",
240 "sourceRoot": "/the/root"
241 }
242 }
243 ]
244}
245"##;
246
247// exports.indexedTestMapDifferentSourceRoots = {
248// version: 3,
249// file: "min.js",
250// sections: [
251// {
252// offset: {
253// line: 0,
254// column: 0
255// },
256// map: {
257// version: 3,
258// sources: ["one.js"],
259// sourcesContent: [
260// " ONE.foo = function (bar) {\n return baz(bar);\n };"
261// ],
262// names: ["bar", "baz"],
263// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
264// file: "min.js",
265// sourceRoot: "/the/root"
266// }
267// },
268// {
269// offset: {
270// line: 1,
271// column: 0
272// },
273// map: {
274// version: 3,
275// sources: ["two.js"],
276// sourcesContent: [" TWO.inc = function (n) {\n return n + 1;\n };"],
277// names: ["n"],
278// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
279// file: "min.js",
280// sourceRoot: "/different/root"
281// }
282// }
283// ]
284// };
285pub(crate) const indexedTestMapDifferentSourceRoots: &str = r##"
286{
287"version": 3,
288"file": "min.js",
289 "sections": [
290 {
291 "offset": {
292 "line": 0,
293 "column": 0
294 },
295 "map": {
296 "version": 3,
297 "sources": ["one.js"],
298 "sourcesContent": [
299 " ONE.foo = function (bar) {\n return baz(bar);\n };"
300 ],
301 "names": ["bar", "baz"],
302 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
303 "file": "min.js",
304 "sourceRoot": "/the/root"
305 }
306 },
307 {
308 "offset": {
309 "line": 1,
310 "column": 0
311 },
312 "map": {
313 "version": 3,
314 "sources": ["two.js"],
315 "sourcesContent": [" TWO.inc = function (n) {\n return n + 1;\n };"],
316 "names": ["n"],
317 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
318 "file": "min.js",
319 "sourceRoot": "/different/root"
320 }
321 }
322 ]
323}
324"##;
325
326// exports.indexedTestMapColumnOffset = {
327// version: 3,
328// file: "min.js",
329// sections: [
330// {
331// offset: {
332// line: 0,
333// column: 0
334// },
335// map: {
336// version: 3,
337// sources: ["one.js"],
338// sourcesContent: [
339// " ONE.foo = function (bar) {\n return baz(bar);\n };"
340// ],
341// names: ["bar", "baz"],
342// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
343// file: "min.js",
344// sourceRoot: "/the/root"
345// }
346// },
347// {
348// offset: {
349// line: 0,
350// // Previous section's last generated mapping is [32, Infinity), so
351// // we're placing this a bit after that.
352// column: 50
353// },
354// map: {
355// version: 3,
356// sources: ["two.js"],
357// sourcesContent: [" TWO.inc = function (n) {\n return n + 1;\n };"],
358// names: ["n"],
359// mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
360// file: "min.js",
361// sourceRoot: "/the/root"
362// }
363// }
364// ]
365// };
366pub(crate) const indexedTestMapColumnOffset: &str = r##"
367{
368 "version": 3,
369 "file": "min.js",
370 "sections": [
371 {
372 "offset": {
373 "line": 0,
374 "column": 0
375 },
376 "map": {
377 "version": 3,
378 "sources": ["one.js"],
379 "sourcesContent": [
380 " ONE.foo = function (bar) {\n return baz(bar);\n };"
381 ],
382 "names": ["bar", "baz"],
383 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID",
384 "file": "min.js",
385 "sourceRoot": "/the/root"
386 }
387 },
388 {
389 "offset": {
390 "line": 0,
391 // Previous section's last generated mapping is [32, Infinity), so
392 // we're placing this a bit after that.
393 "column": 50
394 },
395 "map": {
396 "version": 3,
397 "sources": ["two.js"],
398 "sourcesContent": [" TWO.inc = function (n) {\n return n + 1;\n };"],
399 "names": ["n"],
400 "mappings": "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA",
401 "file": "min.js",
402 "sourceRoot": "/the/root"
403 }
404 }
405 ]
406}
407"##;
408
409// exports.testMapWithSourcesContent = {
410// version: 3,
411// file: "min.js",
412// names: ["bar", "baz", "n"],
413// sources: ["one.js", "two.js"],
414// sourcesContent: [
415// " ONE.foo = function (bar) {\n return baz(bar);\n };",
416// " TWO.inc = function (n) {\n return n + 1;\n };"
417// ],
418// sourceRoot: "/the/root",
419// mappings:
420// "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
421// };
422pub(crate) const testMapWithSourcesContent: &str = r##"
423{
424 "version": 3,
425 "file": "min.js",
426 "names": ["bar", "baz", "n"],
427 "sources": ["one.js", "two.js"],
428 "sourcesContent": [
429 " ONE.foo = function (bar) {\n return baz(bar);\n };",
430 " TWO.inc = function (n) {\n return n + 1;\n };"
431 ],
432 "sourceRoot": "/the/root",
433 "mappings":
434 "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
435}
436"##;
437
438// exports.testMapRelativeSources = {
439// version: 3,
440// file: "min.js",
441// names: ["bar", "baz", "n"],
442// sources: ["./one.js", "./two.js"],
443// sourcesContent: [
444// " ONE.foo = function (bar) {\n return baz(bar);\n };",
445// " TWO.inc = function (n) {\n return n + 1;\n };"
446// ],
447// sourceRoot: "/the/root",
448// mappings:
449// "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
450// };
451pub(crate) const testMapRelativeSources: &str = r##"
452{
453 "version": 3,
454 "file": "min.js",
455 "names": ["bar", "baz", "n"],
456 "sources": ["./one.js", "./two.js"],
457 "sourcesContent": [
458 " ONE.foo = function (bar) {\n return baz(bar);\n };",
459 " TWO.inc = function (n) {\n return n + 1;\n };"
460 ],
461 "sourceRoot": "/the/root",
462 "mappings":
463 "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"
464}
465"##;
466
467// exports.emptyMap = {
468// version: 3,
469// file: "min.js",
470// names: [],
471// sources: [],
472// mappings: ""
473// };
474pub(crate) const emptyMap: &str = r##"
475{
476 "version": 3,
477 "file": "min.js",
478 "names": [],
479 "sources": [],
480 "mappings": ""
481}
482"##;
483
484// exports.mapWithSourcelessMapping = {
485// version: 3,
486// file: "example.js",
487// names: [],
488// sources: ["example.js"],
489// mappings: "AAgCA,C"
490// };
491pub(crate) const mapWithSourcelessMapping: &str = r##"
492{
493 "version": 3,
494 "file": "example.js",
495 "names": [],
496 "sources": ["example.js"],
497 "mappings": "AAgCA,C"
498}
499"##;