@itilite/lumina-ui 1.0.0-alpha → 1.0.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/{AdvancedDateRangePicker-Eh6n4ne0.d.mts → AdvancedDateRangePicker-ozItnkhp.d.mts} +1 -1
  2. package/dist/{AdvancedDateRangePicker-Eh6n4ne0.d.ts → AdvancedDateRangePicker-ozItnkhp.d.ts} +1 -1
  3. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.d.mts +1 -1
  4. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.d.ts +1 -1
  5. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.d.mts +1 -2
  6. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.d.ts +1 -2
  7. package/dist/atom/LoadingSpinner/LoadingSpinner.d.mts +2 -2
  8. package/dist/atom/LoadingSpinner/LoadingSpinner.d.ts +2 -2
  9. package/dist/index.d.mts +14 -15
  10. package/dist/index.d.ts +14 -15
  11. package/dist/index.mjs +8 -8
  12. package/dist/styles.css +328 -312
  13. package/package.json +1 -1
  14. package/dist/AdvancedDateRangePicker-CN9WN0rH.d.mts +0 -56
  15. package/dist/AdvancedDateRangePicker-CN9WN0rH.d.ts +0 -56
  16. package/dist/AdvancedDateRangePicker-CzN1HGsC.d.mts +0 -57
  17. package/dist/AdvancedDateRangePicker-CzN1HGsC.d.ts +0 -57
  18. package/dist/AdvancedDateRangePicker-DAPxgRl3.d.mts +0 -54
  19. package/dist/AdvancedDateRangePicker-DAPxgRl3.d.ts +0 -54
  20. package/dist/AdvancedDateRangePicker-DW94285G.d.mts +0 -56
  21. package/dist/AdvancedDateRangePicker-DW94285G.d.ts +0 -56
  22. package/dist/Avatar-DX2JwvAs.d.mts +0 -17
  23. package/dist/Avatar-DX2JwvAs.d.ts +0 -17
  24. package/dist/Table-BA0D3p1m.d.mts +0 -78
  25. package/dist/Table-BA0D3p1m.d.ts +0 -78
  26. package/dist/Table-BLZ6c46U.d.mts +0 -77
  27. package/dist/Table-BLZ6c46U.d.ts +0 -77
  28. package/dist/Table-BMqYnFi4.d.mts +0 -25
  29. package/dist/Table-BMqYnFi4.d.ts +0 -25
  30. package/dist/Table-BRcthrYV.d.mts +0 -98
  31. package/dist/Table-BRcthrYV.d.ts +0 -98
  32. package/dist/Table-BWlFCfBG.d.mts +0 -106
  33. package/dist/Table-BWlFCfBG.d.ts +0 -106
  34. package/dist/Table-CHFmNrme.d.mts +0 -77
  35. package/dist/Table-CHFmNrme.d.ts +0 -77
  36. package/dist/Table-CX6UwQiD.d.mts +0 -116
  37. package/dist/Table-CX6UwQiD.d.ts +0 -116
  38. package/dist/Table-Chud2XSq.d.mts +0 -99
  39. package/dist/Table-Chud2XSq.d.ts +0 -99
  40. package/dist/Table-D5QRe_j3.d.mts +0 -121
  41. package/dist/Table-D5QRe_j3.d.ts +0 -121
  42. package/dist/Table-DAgFGahx.d.mts +0 -39
  43. package/dist/Table-DAgFGahx.d.ts +0 -39
  44. package/dist/Table-DWniK7At.d.mts +0 -87
  45. package/dist/Table-DWniK7At.d.ts +0 -87
  46. package/dist/Table-PyFlnUDu.d.mts +0 -47
  47. package/dist/Table-PyFlnUDu.d.ts +0 -47
  48. package/dist/Table-wqyg13Y9.d.mts +0 -77
  49. package/dist/Table-wqyg13Y9.d.ts +0 -77
  50. package/dist/Tag-l7I5oeyk.d.mts +0 -13
  51. package/dist/Tag-l7I5oeyk.d.ts +0 -13
  52. package/dist/atom/Table/LuminaPagination.d.mts +0 -7
  53. package/dist/atom/Table/LuminaPagination.d.ts +0 -7
  54. package/dist/atom/Table/LuminaPagination.js +0 -153
  55. package/dist/atom/Table/LuminaPagination.mjs +0 -9
  56. package/dist/atom/Table/TableAccordion.d.mts +0 -9
  57. package/dist/atom/Table/TableAccordion.d.ts +0 -9
  58. package/dist/atom/Table/TableAccordion.js +0 -91
  59. package/dist/atom/Table/TableAccordion.mjs +0 -10
  60. package/dist/atom/Table/TableColumnHeader.d.mts +0 -7
  61. package/dist/atom/Table/TableColumnHeader.d.ts +0 -7
  62. package/dist/atom/Table/TableColumnHeader.js +0 -151
  63. package/dist/atom/Table/TableColumnHeader.mjs +0 -10
  64. package/dist/atom/Table/TableToolbar.d.mts +0 -9
  65. package/dist/atom/Table/TableToolbar.d.ts +0 -9
  66. package/dist/atom/Table/TableToolbar.js +0 -114
  67. package/dist/atom/Table/TableToolbar.mjs +0 -10
  68. package/dist/atom/Table/__tests__/Table.test.d.mts +0 -2
  69. package/dist/atom/Table/__tests__/Table.test.d.ts +0 -2
  70. package/dist/atom/Table/__tests__/Table.test.js +0 -61133
  71. package/dist/atom/Table/__tests__/Table.test.mjs +0 -59522
  72. package/dist/atom/TableAccordion/index.d.mts +0 -17
  73. package/dist/atom/TableAccordion/index.d.ts +0 -17
  74. package/dist/atom/TableAccordion/index.js +0 -91
  75. package/dist/atom/TableAccordion/index.mjs +0 -9
  76. package/dist/atom/TableToolbar/index.d.mts +0 -23
  77. package/dist/atom/TableToolbar/index.d.ts +0 -23
  78. package/dist/atom/TableToolbar/index.js +0 -114
  79. package/dist/atom/TableToolbar/index.mjs +0 -9
  80. package/dist/chunk-2PIFDGVK.mjs +0 -420
  81. package/dist/chunk-35KDS27M.mjs +0 -618
  82. package/dist/chunk-3S4X3YO2.mjs +0 -64
  83. package/dist/chunk-3XUHGVYA.mjs +0 -77
  84. package/dist/chunk-5HF6Y37C.mjs +0 -642
  85. package/dist/chunk-5OGQ4YIR.mjs +0 -238
  86. package/dist/chunk-6FCSXN7R.mjs +0 -388
  87. package/dist/chunk-7W72LPSU.mjs +0 -66
  88. package/dist/chunk-A66QDQHK.mjs +0 -627
  89. package/dist/chunk-ABLIL47F.mjs +0 -618
  90. package/dist/chunk-AEPDEUGY.mjs +0 -627
  91. package/dist/chunk-AFLEGUF3.mjs +0 -232
  92. package/dist/chunk-APCEITHQ.mjs +0 -232
  93. package/dist/chunk-AVQBFGBT.mjs +0 -141
  94. package/dist/chunk-B5BOBELW.mjs +0 -213
  95. package/dist/chunk-BQ4PVLJ4.mjs +0 -262
  96. package/dist/chunk-DBNLBCQK.mjs +0 -64
  97. package/dist/chunk-DLLT6V65.mjs +0 -141
  98. package/dist/chunk-DOQQRYTS.mjs +0 -73
  99. package/dist/chunk-DSVR2DVF.mjs +0 -660
  100. package/dist/chunk-DXUPULDI.mjs +0 -424
  101. package/dist/chunk-E465D6OH.mjs +0 -644
  102. package/dist/chunk-E4FCLHYA.mjs +0 -678
  103. package/dist/chunk-ENQN5BAN.mjs +0 -225
  104. package/dist/chunk-F6VMSH4N.mjs +0 -79
  105. package/dist/chunk-FKGGN3FA.mjs +0 -412
  106. package/dist/chunk-GFTO2N3Q.mjs +0 -432
  107. package/dist/chunk-GM6H6RPJ.mjs +0 -232
  108. package/dist/chunk-HF3VJBMY.mjs +0 -244
  109. package/dist/chunk-HISCHZ5H.mjs +0 -77
  110. package/dist/chunk-HWQBE6PT.mjs +0 -99
  111. package/dist/chunk-HXM657YW.mjs +0 -115
  112. package/dist/chunk-I5VHKSQR.mjs +0 -64
  113. package/dist/chunk-ICSZZNTY.mjs +0 -384
  114. package/dist/chunk-IZGLD7U3.mjs +0 -667
  115. package/dist/chunk-J7X2PZG6.mjs +0 -232
  116. package/dist/chunk-JUXBLRMQ.mjs +0 -50
  117. package/dist/chunk-JXFSGADI.mjs +0 -678
  118. package/dist/chunk-KGKRSR6D.mjs +0 -388
  119. package/dist/chunk-KQKNFGWZ.mjs +0 -388
  120. package/dist/chunk-LCH4DXJY.mjs +0 -92
  121. package/dist/chunk-LCXU3K57.mjs +0 -232
  122. package/dist/chunk-LRN4XOIR.mjs +0 -71
  123. package/dist/chunk-LROMXY35.mjs +0 -116
  124. package/dist/chunk-LUNPHYAR.mjs +0 -681
  125. package/dist/chunk-LVOTEPLC.mjs +0 -64
  126. package/dist/chunk-M2ZM3X5Y.mjs +0 -56
  127. package/dist/chunk-M4MIYHAV.mjs +0 -43
  128. package/dist/chunk-M7F7DOC4.mjs +0 -41
  129. package/dist/chunk-MHWFVML4.mjs +0 -115
  130. package/dist/chunk-MPTVYTYS.mjs +0 -0
  131. package/dist/chunk-MQFW3LZR.mjs +0 -111
  132. package/dist/chunk-N355RJGH.mjs +0 -141
  133. package/dist/chunk-N3YFQDW7.mjs +0 -77
  134. package/dist/chunk-NGCBOOIE.mjs +0 -225
  135. package/dist/chunk-NWQQYJSP.mjs +0 -688
  136. package/dist/chunk-NYQV556V.mjs +0 -667
  137. package/dist/chunk-O5C3355V.mjs +0 -246
  138. package/dist/chunk-OCP43S7U.mjs +0 -241
  139. package/dist/chunk-OHLFRULE.mjs +0 -432
  140. package/dist/chunk-PLO46EKV.mjs +0 -65
  141. package/dist/chunk-PSBEYGD4.mjs +0 -618
  142. package/dist/chunk-PWIBJI6Z.mjs +0 -115
  143. package/dist/chunk-Q5KPXEH5.mjs +0 -223
  144. package/dist/chunk-QC34HHAY.mjs +0 -57
  145. package/dist/chunk-QVWV36BK.mjs +0 -73
  146. package/dist/chunk-QWK3MYDM.mjs +0 -64
  147. package/dist/chunk-RE44YAMD.mjs +0 -47
  148. package/dist/chunk-RH6DAYBU.mjs +0 -369
  149. package/dist/chunk-RSSEJENT.mjs +0 -269
  150. package/dist/chunk-SJBS5QCJ.mjs +0 -225
  151. package/dist/chunk-SWRFCTJW.mjs +0 -77
  152. package/dist/chunk-T4XNCAIB.mjs +0 -231
  153. package/dist/chunk-TCX5IFQ4.mjs +0 -627
  154. package/dist/chunk-TSAUBT2F.mjs +0 -74
  155. package/dist/chunk-U7Q7ILSE.mjs +0 -690
  156. package/dist/chunk-UHTUJJH7.mjs +0 -112
  157. package/dist/chunk-UOHYCMUS.mjs +0 -53
  158. package/dist/chunk-UQZBL3F7.mjs +0 -0
  159. package/dist/chunk-URGYNKJM.mjs +0 -229
  160. package/dist/chunk-UTMZY37A.mjs +0 -141
  161. package/dist/chunk-UUEPD2FH.mjs +0 -141
  162. package/dist/chunk-VQOUJQIF.mjs +0 -249
  163. package/dist/chunk-VY3QH43W.mjs +0 -6
  164. package/dist/chunk-W2N3AWY6.mjs +0 -80
  165. package/dist/chunk-WUVS6S7N.mjs +0 -119
  166. package/dist/chunk-WZS2K7X3.mjs +0 -688
  167. package/dist/chunk-X76GNSBB.mjs +0 -87
  168. package/dist/chunk-XG7CZXBW.mjs +0 -244
  169. package/dist/chunk-XXKIBYXD.mjs +0 -109
  170. package/dist/chunk-XXTUVMAY.mjs +0 -51
  171. package/dist/chunk-Y3BIY4DW.mjs +0 -618
  172. package/dist/chunk-Y7FP6ZMW.mjs +0 -225
  173. package/dist/chunk-YELLXCMY.mjs +0 -265
  174. package/dist/chunk-YQEEM26W.mjs +0 -232
  175. package/dist/chunk-ZGFE3OPJ.mjs +0 -678
  176. package/dist/chunk-ZMJ3KDDY.mjs +0 -618
  177. package/dist/chunk-ZYPWQ53U.mjs +0 -6
  178. package/dist/dist-U2IPN4FB.mjs +0 -567
  179. package/dist/magic-string.es-XOWQCRDO.mjs +0 -1311
  180. package/dist/types-CA0Wby2L.d.mts +0 -67
  181. package/dist/types-CA0Wby2L.d.ts +0 -67
  182. package/dist/types-CncMmuJM.d.mts +0 -44
  183. package/dist/types-CncMmuJM.d.ts +0 -44
  184. package/dist/types-D4fdeMWQ.d.mts +0 -62
  185. package/dist/types-D4fdeMWQ.d.ts +0 -62
@@ -1,1311 +0,0 @@
1
- import {
2
- __spreadProps,
3
- __spreadValues
4
- } from "./chunk-HWQBE6PT.mjs";
5
-
6
- // ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
7
- var comma = ",".charCodeAt(0);
8
- var semicolon = ";".charCodeAt(0);
9
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
10
- var intToChar = new Uint8Array(64);
11
- var charToInt = new Uint8Array(128);
12
- for (let i = 0; i < chars.length; i++) {
13
- const c = chars.charCodeAt(i);
14
- intToChar[i] = c;
15
- charToInt[c] = i;
16
- }
17
- function encodeInteger(builder, num, relative) {
18
- let delta = num - relative;
19
- delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
20
- do {
21
- let clamped = delta & 31;
22
- delta >>>= 5;
23
- if (delta > 0) clamped |= 32;
24
- builder.write(intToChar[clamped]);
25
- } while (delta > 0);
26
- return num;
27
- }
28
- var bufLength = 1024 * 16;
29
- var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
30
- decode(buf) {
31
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
32
- return out.toString();
33
- }
34
- } : {
35
- decode(buf) {
36
- let out = "";
37
- for (let i = 0; i < buf.length; i++) {
38
- out += String.fromCharCode(buf[i]);
39
- }
40
- return out;
41
- }
42
- };
43
- var StringWriter = class {
44
- constructor() {
45
- this.pos = 0;
46
- this.out = "";
47
- this.buffer = new Uint8Array(bufLength);
48
- }
49
- write(v) {
50
- const { buffer } = this;
51
- buffer[this.pos++] = v;
52
- if (this.pos === bufLength) {
53
- this.out += td.decode(buffer);
54
- this.pos = 0;
55
- }
56
- }
57
- flush() {
58
- const { buffer, out, pos } = this;
59
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
60
- }
61
- };
62
- function encode(decoded) {
63
- const writer = new StringWriter();
64
- let sourcesIndex = 0;
65
- let sourceLine = 0;
66
- let sourceColumn = 0;
67
- let namesIndex = 0;
68
- for (let i = 0; i < decoded.length; i++) {
69
- const line = decoded[i];
70
- if (i > 0) writer.write(semicolon);
71
- if (line.length === 0) continue;
72
- let genColumn = 0;
73
- for (let j = 0; j < line.length; j++) {
74
- const segment = line[j];
75
- if (j > 0) writer.write(comma);
76
- genColumn = encodeInteger(writer, segment[0], genColumn);
77
- if (segment.length === 1) continue;
78
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
79
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
80
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
81
- if (segment.length === 4) continue;
82
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
83
- }
84
- }
85
- return writer.flush();
86
- }
87
-
88
- // ../../node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
89
- var BitSet = class _BitSet {
90
- constructor(arg) {
91
- this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
92
- }
93
- add(n2) {
94
- this.bits[n2 >> 5] |= 1 << (n2 & 31);
95
- }
96
- has(n2) {
97
- return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
98
- }
99
- };
100
- var Chunk = class _Chunk {
101
- constructor(start, end, content) {
102
- this.start = start;
103
- this.end = end;
104
- this.original = content;
105
- this.intro = "";
106
- this.outro = "";
107
- this.content = content;
108
- this.storeName = false;
109
- this.edited = false;
110
- {
111
- this.previous = null;
112
- this.next = null;
113
- }
114
- }
115
- appendLeft(content) {
116
- this.outro += content;
117
- }
118
- appendRight(content) {
119
- this.intro = this.intro + content;
120
- }
121
- clone() {
122
- const chunk = new _Chunk(this.start, this.end, this.original);
123
- chunk.intro = this.intro;
124
- chunk.outro = this.outro;
125
- chunk.content = this.content;
126
- chunk.storeName = this.storeName;
127
- chunk.edited = this.edited;
128
- return chunk;
129
- }
130
- contains(index) {
131
- return this.start < index && index < this.end;
132
- }
133
- eachNext(fn) {
134
- let chunk = this;
135
- while (chunk) {
136
- fn(chunk);
137
- chunk = chunk.next;
138
- }
139
- }
140
- eachPrevious(fn) {
141
- let chunk = this;
142
- while (chunk) {
143
- fn(chunk);
144
- chunk = chunk.previous;
145
- }
146
- }
147
- edit(content, storeName, contentOnly) {
148
- this.content = content;
149
- if (!contentOnly) {
150
- this.intro = "";
151
- this.outro = "";
152
- }
153
- this.storeName = storeName;
154
- this.edited = true;
155
- return this;
156
- }
157
- prependLeft(content) {
158
- this.outro = content + this.outro;
159
- }
160
- prependRight(content) {
161
- this.intro = content + this.intro;
162
- }
163
- reset() {
164
- this.intro = "";
165
- this.outro = "";
166
- if (this.edited) {
167
- this.content = this.original;
168
- this.storeName = false;
169
- this.edited = false;
170
- }
171
- }
172
- split(index) {
173
- const sliceIndex = index - this.start;
174
- const originalBefore = this.original.slice(0, sliceIndex);
175
- const originalAfter = this.original.slice(sliceIndex);
176
- this.original = originalBefore;
177
- const newChunk = new _Chunk(index, this.end, originalAfter);
178
- newChunk.outro = this.outro;
179
- this.outro = "";
180
- this.end = index;
181
- if (this.edited) {
182
- newChunk.edit("", false);
183
- this.content = "";
184
- } else {
185
- this.content = originalBefore;
186
- }
187
- newChunk.next = this.next;
188
- if (newChunk.next) newChunk.next.previous = newChunk;
189
- newChunk.previous = this;
190
- this.next = newChunk;
191
- return newChunk;
192
- }
193
- toString() {
194
- return this.intro + this.content + this.outro;
195
- }
196
- trimEnd(rx) {
197
- this.outro = this.outro.replace(rx, "");
198
- if (this.outro.length) return true;
199
- const trimmed = this.content.replace(rx, "");
200
- if (trimmed.length) {
201
- if (trimmed !== this.content) {
202
- this.split(this.start + trimmed.length).edit("", void 0, true);
203
- if (this.edited) {
204
- this.edit(trimmed, this.storeName, true);
205
- }
206
- }
207
- return true;
208
- } else {
209
- this.edit("", void 0, true);
210
- this.intro = this.intro.replace(rx, "");
211
- if (this.intro.length) return true;
212
- }
213
- }
214
- trimStart(rx) {
215
- this.intro = this.intro.replace(rx, "");
216
- if (this.intro.length) return true;
217
- const trimmed = this.content.replace(rx, "");
218
- if (trimmed.length) {
219
- if (trimmed !== this.content) {
220
- const newChunk = this.split(this.end - trimmed.length);
221
- if (this.edited) {
222
- newChunk.edit(trimmed, this.storeName, true);
223
- }
224
- this.edit("", void 0, true);
225
- }
226
- return true;
227
- } else {
228
- this.edit("", void 0, true);
229
- this.outro = this.outro.replace(rx, "");
230
- if (this.outro.length) return true;
231
- }
232
- }
233
- };
234
- function getBtoa() {
235
- if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
236
- return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
237
- } else if (typeof Buffer === "function") {
238
- return (str) => Buffer.from(str, "utf-8").toString("base64");
239
- } else {
240
- return () => {
241
- throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
242
- };
243
- }
244
- }
245
- var btoa = /* @__PURE__ */ getBtoa();
246
- var SourceMap = class {
247
- constructor(properties) {
248
- this.version = 3;
249
- this.file = properties.file;
250
- this.sources = properties.sources;
251
- this.sourcesContent = properties.sourcesContent;
252
- this.names = properties.names;
253
- this.mappings = encode(properties.mappings);
254
- if (typeof properties.x_google_ignoreList !== "undefined") {
255
- this.x_google_ignoreList = properties.x_google_ignoreList;
256
- }
257
- if (typeof properties.debugId !== "undefined") {
258
- this.debugId = properties.debugId;
259
- }
260
- }
261
- toString() {
262
- return JSON.stringify(this);
263
- }
264
- toUrl() {
265
- return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
266
- }
267
- };
268
- function guessIndent(code) {
269
- const lines = code.split("\n");
270
- const tabbed = lines.filter((line) => /^\t+/.test(line));
271
- const spaced = lines.filter((line) => /^ {2,}/.test(line));
272
- if (tabbed.length === 0 && spaced.length === 0) {
273
- return null;
274
- }
275
- if (tabbed.length >= spaced.length) {
276
- return " ";
277
- }
278
- const min = spaced.reduce((previous, current) => {
279
- const numSpaces = /^ +/.exec(current)[0].length;
280
- return Math.min(numSpaces, previous);
281
- }, Infinity);
282
- return new Array(min + 1).join(" ");
283
- }
284
- function getRelativePath(from, to) {
285
- const fromParts = from.split(/[/\\]/);
286
- const toParts = to.split(/[/\\]/);
287
- fromParts.pop();
288
- while (fromParts[0] === toParts[0]) {
289
- fromParts.shift();
290
- toParts.shift();
291
- }
292
- if (fromParts.length) {
293
- let i = fromParts.length;
294
- while (i--) fromParts[i] = "..";
295
- }
296
- return fromParts.concat(toParts).join("/");
297
- }
298
- var toString = Object.prototype.toString;
299
- function isObject(thing) {
300
- return toString.call(thing) === "[object Object]";
301
- }
302
- function getLocator(source) {
303
- const originalLines = source.split("\n");
304
- const lineOffsets = [];
305
- for (let i = 0, pos = 0; i < originalLines.length; i++) {
306
- lineOffsets.push(pos);
307
- pos += originalLines[i].length + 1;
308
- }
309
- return function locate(index) {
310
- let i = 0;
311
- let j = lineOffsets.length;
312
- while (i < j) {
313
- const m = i + j >> 1;
314
- if (index < lineOffsets[m]) {
315
- j = m;
316
- } else {
317
- i = m + 1;
318
- }
319
- }
320
- const line = i - 1;
321
- const column = index - lineOffsets[line];
322
- return { line, column };
323
- };
324
- }
325
- var wordRegex = /\w/;
326
- var Mappings = class {
327
- constructor(hires) {
328
- this.hires = hires;
329
- this.generatedCodeLine = 0;
330
- this.generatedCodeColumn = 0;
331
- this.raw = [];
332
- this.rawSegments = this.raw[this.generatedCodeLine] = [];
333
- this.pending = null;
334
- }
335
- addEdit(sourceIndex, content, loc, nameIndex) {
336
- if (content.length) {
337
- const contentLengthMinusOne = content.length - 1;
338
- let contentLineEnd = content.indexOf("\n", 0);
339
- let previousContentLineEnd = -1;
340
- while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
341
- const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
342
- if (nameIndex >= 0) {
343
- segment2.push(nameIndex);
344
- }
345
- this.rawSegments.push(segment2);
346
- this.generatedCodeLine += 1;
347
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
348
- this.generatedCodeColumn = 0;
349
- previousContentLineEnd = contentLineEnd;
350
- contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
351
- }
352
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
353
- if (nameIndex >= 0) {
354
- segment.push(nameIndex);
355
- }
356
- this.rawSegments.push(segment);
357
- this.advance(content.slice(previousContentLineEnd + 1));
358
- } else if (this.pending) {
359
- this.rawSegments.push(this.pending);
360
- this.advance(content);
361
- }
362
- this.pending = null;
363
- }
364
- addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
365
- let originalCharIndex = chunk.start;
366
- let first = true;
367
- let charInHiresBoundary = false;
368
- while (originalCharIndex < chunk.end) {
369
- if (original[originalCharIndex] === "\n") {
370
- loc.line += 1;
371
- loc.column = 0;
372
- this.generatedCodeLine += 1;
373
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
374
- this.generatedCodeColumn = 0;
375
- first = true;
376
- charInHiresBoundary = false;
377
- } else {
378
- if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
379
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
380
- if (this.hires === "boundary") {
381
- if (wordRegex.test(original[originalCharIndex])) {
382
- if (!charInHiresBoundary) {
383
- this.rawSegments.push(segment);
384
- charInHiresBoundary = true;
385
- }
386
- } else {
387
- this.rawSegments.push(segment);
388
- charInHiresBoundary = false;
389
- }
390
- } else {
391
- this.rawSegments.push(segment);
392
- }
393
- }
394
- loc.column += 1;
395
- this.generatedCodeColumn += 1;
396
- first = false;
397
- }
398
- originalCharIndex += 1;
399
- }
400
- this.pending = null;
401
- }
402
- advance(str) {
403
- if (!str) return;
404
- const lines = str.split("\n");
405
- if (lines.length > 1) {
406
- for (let i = 0; i < lines.length - 1; i++) {
407
- this.generatedCodeLine++;
408
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
409
- }
410
- this.generatedCodeColumn = 0;
411
- }
412
- this.generatedCodeColumn += lines[lines.length - 1].length;
413
- }
414
- };
415
- var n = "\n";
416
- var warned = {
417
- insertLeft: false,
418
- insertRight: false,
419
- storeName: false
420
- };
421
- var MagicString = class _MagicString {
422
- constructor(string, options = {}) {
423
- const chunk = new Chunk(0, string.length, string);
424
- Object.defineProperties(this, {
425
- original: { writable: true, value: string },
426
- outro: { writable: true, value: "" },
427
- intro: { writable: true, value: "" },
428
- firstChunk: { writable: true, value: chunk },
429
- lastChunk: { writable: true, value: chunk },
430
- lastSearchedChunk: { writable: true, value: chunk },
431
- byStart: { writable: true, value: {} },
432
- byEnd: { writable: true, value: {} },
433
- filename: { writable: true, value: options.filename },
434
- indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
435
- sourcemapLocations: { writable: true, value: new BitSet() },
436
- storedNames: { writable: true, value: {} },
437
- indentStr: { writable: true, value: void 0 },
438
- ignoreList: { writable: true, value: options.ignoreList },
439
- offset: { writable: true, value: options.offset || 0 }
440
- });
441
- this.byStart[0] = chunk;
442
- this.byEnd[string.length] = chunk;
443
- }
444
- addSourcemapLocation(char) {
445
- this.sourcemapLocations.add(char);
446
- }
447
- append(content) {
448
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
449
- this.outro += content;
450
- return this;
451
- }
452
- appendLeft(index, content) {
453
- index = index + this.offset;
454
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
455
- this._split(index);
456
- const chunk = this.byEnd[index];
457
- if (chunk) {
458
- chunk.appendLeft(content);
459
- } else {
460
- this.intro += content;
461
- }
462
- return this;
463
- }
464
- appendRight(index, content) {
465
- index = index + this.offset;
466
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
467
- this._split(index);
468
- const chunk = this.byStart[index];
469
- if (chunk) {
470
- chunk.appendRight(content);
471
- } else {
472
- this.outro += content;
473
- }
474
- return this;
475
- }
476
- clone() {
477
- const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
478
- let originalChunk = this.firstChunk;
479
- let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
480
- while (originalChunk) {
481
- cloned.byStart[clonedChunk.start] = clonedChunk;
482
- cloned.byEnd[clonedChunk.end] = clonedChunk;
483
- const nextOriginalChunk = originalChunk.next;
484
- const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
485
- if (nextClonedChunk) {
486
- clonedChunk.next = nextClonedChunk;
487
- nextClonedChunk.previous = clonedChunk;
488
- clonedChunk = nextClonedChunk;
489
- }
490
- originalChunk = nextOriginalChunk;
491
- }
492
- cloned.lastChunk = clonedChunk;
493
- if (this.indentExclusionRanges) {
494
- cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
495
- }
496
- cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
497
- cloned.intro = this.intro;
498
- cloned.outro = this.outro;
499
- return cloned;
500
- }
501
- generateDecodedMap(options) {
502
- options = options || {};
503
- const sourceIndex = 0;
504
- const names = Object.keys(this.storedNames);
505
- const mappings = new Mappings(options.hires);
506
- const locate = getLocator(this.original);
507
- if (this.intro) {
508
- mappings.advance(this.intro);
509
- }
510
- this.firstChunk.eachNext((chunk) => {
511
- const loc = locate(chunk.start);
512
- if (chunk.intro.length) mappings.advance(chunk.intro);
513
- if (chunk.edited) {
514
- mappings.addEdit(
515
- sourceIndex,
516
- chunk.content,
517
- loc,
518
- chunk.storeName ? names.indexOf(chunk.original) : -1
519
- );
520
- } else {
521
- mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
522
- }
523
- if (chunk.outro.length) mappings.advance(chunk.outro);
524
- });
525
- if (this.outro) {
526
- mappings.advance(this.outro);
527
- }
528
- return {
529
- file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
530
- sources: [
531
- options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
532
- ],
533
- sourcesContent: options.includeContent ? [this.original] : void 0,
534
- names,
535
- mappings: mappings.raw,
536
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
537
- };
538
- }
539
- generateMap(options) {
540
- return new SourceMap(this.generateDecodedMap(options));
541
- }
542
- _ensureindentStr() {
543
- if (this.indentStr === void 0) {
544
- this.indentStr = guessIndent(this.original);
545
- }
546
- }
547
- _getRawIndentString() {
548
- this._ensureindentStr();
549
- return this.indentStr;
550
- }
551
- getIndentString() {
552
- this._ensureindentStr();
553
- return this.indentStr === null ? " " : this.indentStr;
554
- }
555
- indent(indentStr, options) {
556
- const pattern = /^[^\r\n]/gm;
557
- if (isObject(indentStr)) {
558
- options = indentStr;
559
- indentStr = void 0;
560
- }
561
- if (indentStr === void 0) {
562
- this._ensureindentStr();
563
- indentStr = this.indentStr || " ";
564
- }
565
- if (indentStr === "") return this;
566
- options = options || {};
567
- const isExcluded = {};
568
- if (options.exclude) {
569
- const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
570
- exclusions.forEach((exclusion) => {
571
- for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
572
- isExcluded[i] = true;
573
- }
574
- });
575
- }
576
- let shouldIndentNextCharacter = options.indentStart !== false;
577
- const replacer = (match) => {
578
- if (shouldIndentNextCharacter) return `${indentStr}${match}`;
579
- shouldIndentNextCharacter = true;
580
- return match;
581
- };
582
- this.intro = this.intro.replace(pattern, replacer);
583
- let charIndex = 0;
584
- let chunk = this.firstChunk;
585
- while (chunk) {
586
- const end = chunk.end;
587
- if (chunk.edited) {
588
- if (!isExcluded[charIndex]) {
589
- chunk.content = chunk.content.replace(pattern, replacer);
590
- if (chunk.content.length) {
591
- shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
592
- }
593
- }
594
- } else {
595
- charIndex = chunk.start;
596
- while (charIndex < end) {
597
- if (!isExcluded[charIndex]) {
598
- const char = this.original[charIndex];
599
- if (char === "\n") {
600
- shouldIndentNextCharacter = true;
601
- } else if (char !== "\r" && shouldIndentNextCharacter) {
602
- shouldIndentNextCharacter = false;
603
- if (charIndex === chunk.start) {
604
- chunk.prependRight(indentStr);
605
- } else {
606
- this._splitChunk(chunk, charIndex);
607
- chunk = chunk.next;
608
- chunk.prependRight(indentStr);
609
- }
610
- }
611
- }
612
- charIndex += 1;
613
- }
614
- }
615
- charIndex = chunk.end;
616
- chunk = chunk.next;
617
- }
618
- this.outro = this.outro.replace(pattern, replacer);
619
- return this;
620
- }
621
- insert() {
622
- throw new Error(
623
- "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
624
- );
625
- }
626
- insertLeft(index, content) {
627
- if (!warned.insertLeft) {
628
- console.warn(
629
- "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
630
- );
631
- warned.insertLeft = true;
632
- }
633
- return this.appendLeft(index, content);
634
- }
635
- insertRight(index, content) {
636
- if (!warned.insertRight) {
637
- console.warn(
638
- "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
639
- );
640
- warned.insertRight = true;
641
- }
642
- return this.prependRight(index, content);
643
- }
644
- move(start, end, index) {
645
- start = start + this.offset;
646
- end = end + this.offset;
647
- index = index + this.offset;
648
- if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
649
- this._split(start);
650
- this._split(end);
651
- this._split(index);
652
- const first = this.byStart[start];
653
- const last = this.byEnd[end];
654
- const oldLeft = first.previous;
655
- const oldRight = last.next;
656
- const newRight = this.byStart[index];
657
- if (!newRight && last === this.lastChunk) return this;
658
- const newLeft = newRight ? newRight.previous : this.lastChunk;
659
- if (oldLeft) oldLeft.next = oldRight;
660
- if (oldRight) oldRight.previous = oldLeft;
661
- if (newLeft) newLeft.next = first;
662
- if (newRight) newRight.previous = last;
663
- if (!first.previous) this.firstChunk = last.next;
664
- if (!last.next) {
665
- this.lastChunk = first.previous;
666
- this.lastChunk.next = null;
667
- }
668
- first.previous = newLeft;
669
- last.next = newRight || null;
670
- if (!newLeft) this.firstChunk = first;
671
- if (!newRight) this.lastChunk = last;
672
- return this;
673
- }
674
- overwrite(start, end, content, options) {
675
- options = options || {};
676
- return this.update(start, end, content, __spreadProps(__spreadValues({}, options), { overwrite: !options.contentOnly }));
677
- }
678
- update(start, end, content, options) {
679
- start = start + this.offset;
680
- end = end + this.offset;
681
- if (typeof content !== "string") throw new TypeError("replacement content must be a string");
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 (end > this.original.length) throw new Error("end is out of bounds");
687
- if (start === end)
688
- throw new Error(
689
- "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
690
- );
691
- this._split(start);
692
- this._split(end);
693
- if (options === true) {
694
- if (!warned.storeName) {
695
- console.warn(
696
- "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
697
- );
698
- warned.storeName = true;
699
- }
700
- options = { storeName: true };
701
- }
702
- const storeName = options !== void 0 ? options.storeName : false;
703
- const overwrite = options !== void 0 ? options.overwrite : false;
704
- if (storeName) {
705
- const original = this.original.slice(start, end);
706
- Object.defineProperty(this.storedNames, original, {
707
- writable: true,
708
- value: true,
709
- enumerable: true
710
- });
711
- }
712
- const first = this.byStart[start];
713
- const last = this.byEnd[end];
714
- if (first) {
715
- let chunk = first;
716
- while (chunk !== last) {
717
- if (chunk.next !== this.byStart[chunk.end]) {
718
- throw new Error("Cannot overwrite across a split point");
719
- }
720
- chunk = chunk.next;
721
- chunk.edit("", false);
722
- }
723
- first.edit(content, storeName, !overwrite);
724
- } else {
725
- const newChunk = new Chunk(start, end, "").edit(content, storeName);
726
- last.next = newChunk;
727
- newChunk.previous = last;
728
- }
729
- return this;
730
- }
731
- prepend(content) {
732
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
733
- this.intro = content + this.intro;
734
- return this;
735
- }
736
- prependLeft(index, content) {
737
- index = index + this.offset;
738
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
739
- this._split(index);
740
- const chunk = this.byEnd[index];
741
- if (chunk) {
742
- chunk.prependLeft(content);
743
- } else {
744
- this.intro = content + this.intro;
745
- }
746
- return this;
747
- }
748
- prependRight(index, content) {
749
- index = index + this.offset;
750
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
751
- this._split(index);
752
- const chunk = this.byStart[index];
753
- if (chunk) {
754
- chunk.prependRight(content);
755
- } else {
756
- this.outro = content + this.outro;
757
- }
758
- return this;
759
- }
760
- remove(start, end) {
761
- start = start + this.offset;
762
- end = end + this.offset;
763
- if (this.original.length !== 0) {
764
- while (start < 0) start += this.original.length;
765
- while (end < 0) end += this.original.length;
766
- }
767
- if (start === end) return this;
768
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
769
- if (start > end) throw new Error("end must be greater than start");
770
- this._split(start);
771
- this._split(end);
772
- let chunk = this.byStart[start];
773
- while (chunk) {
774
- chunk.intro = "";
775
- chunk.outro = "";
776
- chunk.edit("");
777
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
778
- }
779
- return this;
780
- }
781
- reset(start, end) {
782
- start = start + this.offset;
783
- end = end + this.offset;
784
- if (this.original.length !== 0) {
785
- while (start < 0) start += this.original.length;
786
- while (end < 0) end += this.original.length;
787
- }
788
- if (start === end) return this;
789
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
790
- if (start > end) throw new Error("end must be greater than start");
791
- this._split(start);
792
- this._split(end);
793
- let chunk = this.byStart[start];
794
- while (chunk) {
795
- chunk.reset();
796
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
797
- }
798
- return this;
799
- }
800
- lastChar() {
801
- if (this.outro.length) return this.outro[this.outro.length - 1];
802
- let chunk = this.lastChunk;
803
- do {
804
- if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
805
- if (chunk.content.length) return chunk.content[chunk.content.length - 1];
806
- if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
807
- } while (chunk = chunk.previous);
808
- if (this.intro.length) return this.intro[this.intro.length - 1];
809
- return "";
810
- }
811
- lastLine() {
812
- let lineIndex = this.outro.lastIndexOf(n);
813
- if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
814
- let lineStr = this.outro;
815
- let chunk = this.lastChunk;
816
- do {
817
- if (chunk.outro.length > 0) {
818
- lineIndex = chunk.outro.lastIndexOf(n);
819
- if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
820
- lineStr = chunk.outro + lineStr;
821
- }
822
- if (chunk.content.length > 0) {
823
- lineIndex = chunk.content.lastIndexOf(n);
824
- if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
825
- lineStr = chunk.content + lineStr;
826
- }
827
- if (chunk.intro.length > 0) {
828
- lineIndex = chunk.intro.lastIndexOf(n);
829
- if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
830
- lineStr = chunk.intro + lineStr;
831
- }
832
- } while (chunk = chunk.previous);
833
- lineIndex = this.intro.lastIndexOf(n);
834
- if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
835
- return this.intro + lineStr;
836
- }
837
- slice(start = 0, end = this.original.length - this.offset) {
838
- start = start + this.offset;
839
- end = end + this.offset;
840
- if (this.original.length !== 0) {
841
- while (start < 0) start += this.original.length;
842
- while (end < 0) end += this.original.length;
843
- }
844
- let result = "";
845
- let chunk = this.firstChunk;
846
- while (chunk && (chunk.start > start || chunk.end <= start)) {
847
- if (chunk.start < end && chunk.end >= end) {
848
- return result;
849
- }
850
- chunk = chunk.next;
851
- }
852
- if (chunk && chunk.edited && chunk.start !== start)
853
- throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
854
- const startChunk = chunk;
855
- while (chunk) {
856
- if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
857
- result += chunk.intro;
858
- }
859
- const containsEnd = chunk.start < end && chunk.end >= end;
860
- if (containsEnd && chunk.edited && chunk.end !== end)
861
- throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
862
- const sliceStart = startChunk === chunk ? start - chunk.start : 0;
863
- const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
864
- result += chunk.content.slice(sliceStart, sliceEnd);
865
- if (chunk.outro && (!containsEnd || chunk.end === end)) {
866
- result += chunk.outro;
867
- }
868
- if (containsEnd) {
869
- break;
870
- }
871
- chunk = chunk.next;
872
- }
873
- return result;
874
- }
875
- // TODO deprecate this? not really very useful
876
- snip(start, end) {
877
- const clone = this.clone();
878
- clone.remove(0, start);
879
- clone.remove(end, clone.original.length);
880
- return clone;
881
- }
882
- _split(index) {
883
- if (this.byStart[index] || this.byEnd[index]) return;
884
- let chunk = this.lastSearchedChunk;
885
- let previousChunk = chunk;
886
- const searchForward = index > chunk.end;
887
- while (chunk) {
888
- if (chunk.contains(index)) return this._splitChunk(chunk, index);
889
- chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
890
- if (chunk === previousChunk) return;
891
- previousChunk = chunk;
892
- }
893
- }
894
- _splitChunk(chunk, index) {
895
- if (chunk.edited && chunk.content.length) {
896
- const loc = getLocator(this.original)(index);
897
- throw new Error(
898
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
899
- );
900
- }
901
- const newChunk = chunk.split(index);
902
- this.byEnd[index] = chunk;
903
- this.byStart[index] = newChunk;
904
- this.byEnd[newChunk.end] = newChunk;
905
- if (chunk === this.lastChunk) this.lastChunk = newChunk;
906
- this.lastSearchedChunk = chunk;
907
- return true;
908
- }
909
- toString() {
910
- let str = this.intro;
911
- let chunk = this.firstChunk;
912
- while (chunk) {
913
- str += chunk.toString();
914
- chunk = chunk.next;
915
- }
916
- return str + this.outro;
917
- }
918
- isEmpty() {
919
- let chunk = this.firstChunk;
920
- do {
921
- if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
922
- return false;
923
- } while (chunk = chunk.next);
924
- return true;
925
- }
926
- length() {
927
- let chunk = this.firstChunk;
928
- let length = 0;
929
- do {
930
- length += chunk.intro.length + chunk.content.length + chunk.outro.length;
931
- } while (chunk = chunk.next);
932
- return length;
933
- }
934
- trimLines() {
935
- return this.trim("[\\r\\n]");
936
- }
937
- trim(charType) {
938
- return this.trimStart(charType).trimEnd(charType);
939
- }
940
- trimEndAborted(charType) {
941
- const rx = new RegExp((charType || "\\s") + "+$");
942
- this.outro = this.outro.replace(rx, "");
943
- if (this.outro.length) return true;
944
- let chunk = this.lastChunk;
945
- do {
946
- const end = chunk.end;
947
- const aborted = chunk.trimEnd(rx);
948
- if (chunk.end !== end) {
949
- if (this.lastChunk === chunk) {
950
- this.lastChunk = chunk.next;
951
- }
952
- this.byEnd[chunk.end] = chunk;
953
- this.byStart[chunk.next.start] = chunk.next;
954
- this.byEnd[chunk.next.end] = chunk.next;
955
- }
956
- if (aborted) return true;
957
- chunk = chunk.previous;
958
- } while (chunk);
959
- return false;
960
- }
961
- trimEnd(charType) {
962
- this.trimEndAborted(charType);
963
- return this;
964
- }
965
- trimStartAborted(charType) {
966
- const rx = new RegExp("^" + (charType || "\\s") + "+");
967
- this.intro = this.intro.replace(rx, "");
968
- if (this.intro.length) return true;
969
- let chunk = this.firstChunk;
970
- do {
971
- const end = chunk.end;
972
- const aborted = chunk.trimStart(rx);
973
- if (chunk.end !== end) {
974
- if (chunk === this.lastChunk) this.lastChunk = chunk.next;
975
- this.byEnd[chunk.end] = chunk;
976
- this.byStart[chunk.next.start] = chunk.next;
977
- this.byEnd[chunk.next.end] = chunk.next;
978
- }
979
- if (aborted) return true;
980
- chunk = chunk.next;
981
- } while (chunk);
982
- return false;
983
- }
984
- trimStart(charType) {
985
- this.trimStartAborted(charType);
986
- return this;
987
- }
988
- hasChanged() {
989
- return this.original !== this.toString();
990
- }
991
- _replaceRegexp(searchValue, replacement) {
992
- function getReplacement(match, str) {
993
- if (typeof replacement === "string") {
994
- return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
995
- if (i === "$") return "$";
996
- if (i === "&") return match[0];
997
- const num = +i;
998
- if (num < match.length) return match[+i];
999
- return `$${i}`;
1000
- });
1001
- } else {
1002
- return replacement(...match, match.index, str, match.groups);
1003
- }
1004
- }
1005
- function matchAll(re, str) {
1006
- let match;
1007
- const matches = [];
1008
- while (match = re.exec(str)) {
1009
- matches.push(match);
1010
- }
1011
- return matches;
1012
- }
1013
- if (searchValue.global) {
1014
- const matches = matchAll(searchValue, this.original);
1015
- matches.forEach((match) => {
1016
- if (match.index != null) {
1017
- const replacement2 = getReplacement(match, this.original);
1018
- if (replacement2 !== match[0]) {
1019
- this.overwrite(match.index, match.index + match[0].length, replacement2);
1020
- }
1021
- }
1022
- });
1023
- } else {
1024
- const match = this.original.match(searchValue);
1025
- if (match && match.index != null) {
1026
- const replacement2 = getReplacement(match, this.original);
1027
- if (replacement2 !== match[0]) {
1028
- this.overwrite(match.index, match.index + match[0].length, replacement2);
1029
- }
1030
- }
1031
- }
1032
- return this;
1033
- }
1034
- _replaceString(string, replacement) {
1035
- const { original } = this;
1036
- const index = original.indexOf(string);
1037
- if (index !== -1) {
1038
- if (typeof replacement === "function") {
1039
- replacement = replacement(string, index, original);
1040
- }
1041
- if (string !== replacement) {
1042
- this.overwrite(index, index + string.length, replacement);
1043
- }
1044
- }
1045
- return this;
1046
- }
1047
- replace(searchValue, replacement) {
1048
- if (typeof searchValue === "string") {
1049
- return this._replaceString(searchValue, replacement);
1050
- }
1051
- return this._replaceRegexp(searchValue, replacement);
1052
- }
1053
- _replaceAllString(string, replacement) {
1054
- const { original } = this;
1055
- const stringLength = string.length;
1056
- for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1057
- const previous = original.slice(index, index + stringLength);
1058
- let _replacement = replacement;
1059
- if (typeof replacement === "function") {
1060
- _replacement = replacement(previous, index, original);
1061
- }
1062
- if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1063
- }
1064
- return this;
1065
- }
1066
- replaceAll(searchValue, replacement) {
1067
- if (typeof searchValue === "string") {
1068
- return this._replaceAllString(searchValue, replacement);
1069
- }
1070
- if (!searchValue.global) {
1071
- throw new TypeError(
1072
- "MagicString.prototype.replaceAll called with a non-global RegExp argument"
1073
- );
1074
- }
1075
- return this._replaceRegexp(searchValue, replacement);
1076
- }
1077
- };
1078
- var hasOwnProp = Object.prototype.hasOwnProperty;
1079
- var Bundle = class _Bundle {
1080
- constructor(options = {}) {
1081
- this.intro = options.intro || "";
1082
- this.separator = options.separator !== void 0 ? options.separator : "\n";
1083
- this.sources = [];
1084
- this.uniqueSources = [];
1085
- this.uniqueSourceIndexByFilename = {};
1086
- }
1087
- addSource(source) {
1088
- if (source instanceof MagicString) {
1089
- return this.addSource({
1090
- content: source,
1091
- filename: source.filename,
1092
- separator: this.separator
1093
- });
1094
- }
1095
- if (!isObject(source) || !source.content) {
1096
- throw new Error(
1097
- "bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`"
1098
- );
1099
- }
1100
- ["filename", "ignoreList", "indentExclusionRanges", "separator"].forEach((option) => {
1101
- if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
1102
- });
1103
- if (source.separator === void 0) {
1104
- source.separator = this.separator;
1105
- }
1106
- if (source.filename) {
1107
- if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
1108
- this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
1109
- this.uniqueSources.push({ filename: source.filename, content: source.content.original });
1110
- } else {
1111
- const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
1112
- if (source.content.original !== uniqueSource.content) {
1113
- throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
1114
- }
1115
- }
1116
- }
1117
- this.sources.push(source);
1118
- return this;
1119
- }
1120
- append(str, options) {
1121
- this.addSource({
1122
- content: new MagicString(str),
1123
- separator: options && options.separator || ""
1124
- });
1125
- return this;
1126
- }
1127
- clone() {
1128
- const bundle = new _Bundle({
1129
- intro: this.intro,
1130
- separator: this.separator
1131
- });
1132
- this.sources.forEach((source) => {
1133
- bundle.addSource({
1134
- filename: source.filename,
1135
- content: source.content.clone(),
1136
- separator: source.separator
1137
- });
1138
- });
1139
- return bundle;
1140
- }
1141
- generateDecodedMap(options = {}) {
1142
- const names = [];
1143
- let x_google_ignoreList = void 0;
1144
- this.sources.forEach((source) => {
1145
- Object.keys(source.content.storedNames).forEach((name) => {
1146
- if (!~names.indexOf(name)) names.push(name);
1147
- });
1148
- });
1149
- const mappings = new Mappings(options.hires);
1150
- if (this.intro) {
1151
- mappings.advance(this.intro);
1152
- }
1153
- this.sources.forEach((source, i) => {
1154
- if (i > 0) {
1155
- mappings.advance(this.separator);
1156
- }
1157
- const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
1158
- const magicString = source.content;
1159
- const locate = getLocator(magicString.original);
1160
- if (magicString.intro) {
1161
- mappings.advance(magicString.intro);
1162
- }
1163
- magicString.firstChunk.eachNext((chunk) => {
1164
- const loc = locate(chunk.start);
1165
- if (chunk.intro.length) mappings.advance(chunk.intro);
1166
- if (source.filename) {
1167
- if (chunk.edited) {
1168
- mappings.addEdit(
1169
- sourceIndex,
1170
- chunk.content,
1171
- loc,
1172
- chunk.storeName ? names.indexOf(chunk.original) : -1
1173
- );
1174
- } else {
1175
- mappings.addUneditedChunk(
1176
- sourceIndex,
1177
- chunk,
1178
- magicString.original,
1179
- loc,
1180
- magicString.sourcemapLocations
1181
- );
1182
- }
1183
- } else {
1184
- mappings.advance(chunk.content);
1185
- }
1186
- if (chunk.outro.length) mappings.advance(chunk.outro);
1187
- });
1188
- if (magicString.outro) {
1189
- mappings.advance(magicString.outro);
1190
- }
1191
- if (source.ignoreList && sourceIndex !== -1) {
1192
- if (x_google_ignoreList === void 0) {
1193
- x_google_ignoreList = [];
1194
- }
1195
- x_google_ignoreList.push(sourceIndex);
1196
- }
1197
- });
1198
- return {
1199
- file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
1200
- sources: this.uniqueSources.map((source) => {
1201
- return options.file ? getRelativePath(options.file, source.filename) : source.filename;
1202
- }),
1203
- sourcesContent: this.uniqueSources.map((source) => {
1204
- return options.includeContent ? source.content : null;
1205
- }),
1206
- names,
1207
- mappings: mappings.raw,
1208
- x_google_ignoreList
1209
- };
1210
- }
1211
- generateMap(options) {
1212
- return new SourceMap(this.generateDecodedMap(options));
1213
- }
1214
- getIndentString() {
1215
- const indentStringCounts = {};
1216
- this.sources.forEach((source) => {
1217
- const indentStr = source.content._getRawIndentString();
1218
- if (indentStr === null) return;
1219
- if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
1220
- indentStringCounts[indentStr] += 1;
1221
- });
1222
- return Object.keys(indentStringCounts).sort((a, b) => {
1223
- return indentStringCounts[a] - indentStringCounts[b];
1224
- })[0] || " ";
1225
- }
1226
- indent(indentStr) {
1227
- if (!arguments.length) {
1228
- indentStr = this.getIndentString();
1229
- }
1230
- if (indentStr === "") return this;
1231
- let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
1232
- this.sources.forEach((source, i) => {
1233
- const separator = source.separator !== void 0 ? source.separator : this.separator;
1234
- const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
1235
- source.content.indent(indentStr, {
1236
- exclude: source.indentExclusionRanges,
1237
- indentStart
1238
- //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1239
- });
1240
- trailingNewline = source.content.lastChar() === "\n";
1241
- });
1242
- if (this.intro) {
1243
- this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
1244
- return index > 0 ? indentStr + match : match;
1245
- });
1246
- }
1247
- return this;
1248
- }
1249
- prepend(str) {
1250
- this.intro = str + this.intro;
1251
- return this;
1252
- }
1253
- toString() {
1254
- const body = this.sources.map((source, i) => {
1255
- const separator = source.separator !== void 0 ? source.separator : this.separator;
1256
- const str = (i > 0 ? separator : "") + source.content.toString();
1257
- return str;
1258
- }).join("");
1259
- return this.intro + body;
1260
- }
1261
- isEmpty() {
1262
- if (this.intro.length && this.intro.trim()) return false;
1263
- if (this.sources.some((source) => !source.content.isEmpty())) return false;
1264
- return true;
1265
- }
1266
- length() {
1267
- return this.sources.reduce(
1268
- (length, source) => length + source.content.length(),
1269
- this.intro.length
1270
- );
1271
- }
1272
- trimLines() {
1273
- return this.trim("[\\r\\n]");
1274
- }
1275
- trim(charType) {
1276
- return this.trimStart(charType).trimEnd(charType);
1277
- }
1278
- trimStart(charType) {
1279
- const rx = new RegExp("^" + (charType || "\\s") + "+");
1280
- this.intro = this.intro.replace(rx, "");
1281
- if (!this.intro) {
1282
- let source;
1283
- let i = 0;
1284
- do {
1285
- source = this.sources[i++];
1286
- if (!source) {
1287
- break;
1288
- }
1289
- } while (!source.content.trimStartAborted(charType));
1290
- }
1291
- return this;
1292
- }
1293
- trimEnd(charType) {
1294
- const rx = new RegExp((charType || "\\s") + "+$");
1295
- let source;
1296
- let i = this.sources.length - 1;
1297
- do {
1298
- source = this.sources[i--];
1299
- if (!source) {
1300
- this.intro = this.intro.replace(rx, "");
1301
- break;
1302
- }
1303
- } while (!source.content.trimEndAborted(charType));
1304
- return this;
1305
- }
1306
- };
1307
- export {
1308
- Bundle,
1309
- SourceMap,
1310
- MagicString as default
1311
- };