@posthog/rrweb-snapshot 0.0.30 → 0.0.32
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.
- package/dist/record.cjs +980 -0
- package/dist/record.cjs.map +1 -0
- package/dist/record.d.cts +265 -0
- package/dist/record.d.ts +265 -0
- package/dist/record.js +981 -0
- package/dist/record.js.map +1 -0
- package/dist/record.umd.cjs +1556 -0
- package/dist/record.umd.cjs.map +7 -0
- package/dist/record.umd.min.cjs +32 -0
- package/dist/record.umd.min.cjs.map +7 -0
- package/dist/replay.cjs +4356 -0
- package/dist/replay.cjs.map +1 -0
- package/dist/replay.d.cts +219 -0
- package/dist/replay.d.ts +219 -0
- package/dist/replay.js +4357 -0
- package/dist/replay.js.map +1 -0
- package/dist/replay.umd.cjs +4962 -0
- package/dist/replay.umd.cjs.map +7 -0
- package/dist/replay.umd.min.cjs +60 -0
- package/dist/replay.umd.min.cjs.map +7 -0
- package/dist/rrweb-snapshot.cjs +38 -5816
- package/dist/rrweb-snapshot.cjs.map +1 -1
- package/dist/rrweb-snapshot.js +24 -5802
- package/dist/rrweb-snapshot.js.map +1 -1
- package/dist/rrweb-snapshot.umd.cjs +5581 -5468
- package/dist/rrweb-snapshot.umd.cjs.map +4 -4
- package/dist/rrweb-snapshot.umd.min.cjs +15 -15
- package/dist/rrweb-snapshot.umd.min.cjs.map +4 -4
- package/dist/types-FDk_ocpu.js +535 -0
- package/dist/types-FDk_ocpu.js.map +1 -0
- package/dist/types-pLXhbZlp.cjs +534 -0
- package/dist/types-pLXhbZlp.cjs.map +1 -0
- package/dist/types-pLXhbZlp.umd.cjs +567 -0
- package/dist/types-pLXhbZlp.umd.cjs.map +7 -0
- package/dist/types-pLXhbZlp.umd.min.cjs +32 -0
- package/dist/types-pLXhbZlp.umd.min.cjs.map +7 -0
- package/package.json +26 -6
- /package/dist/{index.d.cts → rrweb-snapshot.d.cts} +0 -0
- /package/dist/{index.d.ts → rrweb-snapshot.d.ts} +0 -0
|
@@ -0,0 +1,4962 @@
|
|
|
1
|
+
(function (g, f) {
|
|
2
|
+
if ("object" == typeof exports && "object" == typeof module) {
|
|
3
|
+
module.exports = f();
|
|
4
|
+
} else if ("function" == typeof define && define.amd) {
|
|
5
|
+
define("rrwebSnapshotReplay", [], f);
|
|
6
|
+
} else if ("object" == typeof exports) {
|
|
7
|
+
exports["rrwebSnapshotReplay"] = f();
|
|
8
|
+
} else {
|
|
9
|
+
g["rrwebSnapshotReplay"] = f();
|
|
10
|
+
}
|
|
11
|
+
}(this, () => {
|
|
12
|
+
var exports = {};
|
|
13
|
+
var module = { exports };
|
|
14
|
+
"use strict";
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __defProps = Object.defineProperties;
|
|
17
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
18
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
19
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
20
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
21
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
22
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
23
|
+
var __spreadValues = (a, b) => {
|
|
24
|
+
for (var prop in b || (b = {}))
|
|
25
|
+
if (__hasOwnProp.call(b, prop))
|
|
26
|
+
__defNormalProp(a, prop, b[prop]);
|
|
27
|
+
if (__getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
29
|
+
if (__propIsEnum.call(b, prop))
|
|
30
|
+
__defNormalProp(a, prop, b[prop]);
|
|
31
|
+
}
|
|
32
|
+
return a;
|
|
33
|
+
};
|
|
34
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
35
|
+
var __objRest = (source, exclude) => {
|
|
36
|
+
var target = {};
|
|
37
|
+
for (var prop in source)
|
|
38
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
39
|
+
target[prop] = source[prop];
|
|
40
|
+
if (source != null && __getOwnPropSymbols)
|
|
41
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
42
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
43
|
+
target[prop] = source[prop];
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
};
|
|
47
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
48
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// dist/types-pLXhbZlp.cjs
|
|
52
|
+
var require_types_pLXhbZlp = __commonJS({
|
|
53
|
+
"dist/types-pLXhbZlp.cjs"(exports2) {
|
|
54
|
+
"use strict";
|
|
55
|
+
var __defProp2 = Object.defineProperty;
|
|
56
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
57
|
+
var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
58
|
+
var NodeType$1 = /* @__PURE__ */ ((NodeType2) => {
|
|
59
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
60
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
61
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
62
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
63
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
64
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
65
|
+
return NodeType2;
|
|
66
|
+
})(NodeType$1 || {});
|
|
67
|
+
var testableAccessors = {
|
|
68
|
+
Node: ["childNodes", "parentNode", "parentElement", "textContent"],
|
|
69
|
+
ShadowRoot: ["host", "styleSheets"],
|
|
70
|
+
Element: ["shadowRoot", "querySelector", "querySelectorAll"],
|
|
71
|
+
MutationObserver: []
|
|
72
|
+
};
|
|
73
|
+
var testableMethods = {
|
|
74
|
+
Node: ["contains", "getRootNode"],
|
|
75
|
+
ShadowRoot: ["getSelection"],
|
|
76
|
+
Element: [],
|
|
77
|
+
MutationObserver: ["constructor"]
|
|
78
|
+
};
|
|
79
|
+
var untaintedBasePrototype = {};
|
|
80
|
+
function angularZoneUnpatchedAlternative(key) {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
const angularUnpatchedVersionSymbol = (_b = (_a = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a.__symbol__) == null ? void 0 : _b.call(_a, key);
|
|
83
|
+
if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
|
|
84
|
+
return globalThis[angularUnpatchedVersionSymbol];
|
|
85
|
+
} else {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function getUntaintedPrototype(key) {
|
|
90
|
+
if (untaintedBasePrototype[key])
|
|
91
|
+
return untaintedBasePrototype[key];
|
|
92
|
+
const candidate = angularZoneUnpatchedAlternative(key) || globalThis[key];
|
|
93
|
+
const defaultPrototype = candidate.prototype;
|
|
94
|
+
const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
|
|
95
|
+
const isUntaintedAccessors = Boolean(
|
|
96
|
+
accessorNames && // @ts-expect-error 2345
|
|
97
|
+
accessorNames.every(
|
|
98
|
+
(accessor) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
return Boolean(
|
|
101
|
+
(_b = (_a = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a.get) == null ? void 0 : _b.toString().includes("[native code]")
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
const methodNames = key in testableMethods ? testableMethods[key] : void 0;
|
|
107
|
+
const isUntaintedMethods = Boolean(
|
|
108
|
+
methodNames && methodNames.every(
|
|
109
|
+
// @ts-expect-error 2345
|
|
110
|
+
(method) => {
|
|
111
|
+
var _a;
|
|
112
|
+
return typeof defaultPrototype[method] === "function" && ((_a = defaultPrototype[method]) == null ? void 0 : _a.toString().includes("[native code]"));
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
if (isUntaintedAccessors && isUntaintedMethods) {
|
|
117
|
+
untaintedBasePrototype[key] = candidate.prototype;
|
|
118
|
+
return candidate.prototype;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const iframeEl = document.createElement("iframe");
|
|
122
|
+
document.body.appendChild(iframeEl);
|
|
123
|
+
const win = iframeEl.contentWindow;
|
|
124
|
+
if (!win) return candidate.prototype;
|
|
125
|
+
const untaintedObject = win[key].prototype;
|
|
126
|
+
document.body.removeChild(iframeEl);
|
|
127
|
+
if (!untaintedObject) return defaultPrototype;
|
|
128
|
+
return untaintedBasePrototype[key] = untaintedObject;
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return defaultPrototype;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
var untaintedAccessorCache = {};
|
|
134
|
+
function getUntaintedAccessor(key, instance, accessor) {
|
|
135
|
+
var _a;
|
|
136
|
+
const cacheKey = `${key}.${String(accessor)}`;
|
|
137
|
+
if (untaintedAccessorCache[cacheKey])
|
|
138
|
+
return untaintedAccessorCache[cacheKey].call(
|
|
139
|
+
instance
|
|
140
|
+
);
|
|
141
|
+
const untaintedPrototype = getUntaintedPrototype(key);
|
|
142
|
+
const untaintedAccessor = (_a = Object.getOwnPropertyDescriptor(
|
|
143
|
+
untaintedPrototype,
|
|
144
|
+
accessor
|
|
145
|
+
)) == null ? void 0 : _a.get;
|
|
146
|
+
if (!untaintedAccessor) return instance[accessor];
|
|
147
|
+
untaintedAccessorCache[cacheKey] = untaintedAccessor;
|
|
148
|
+
return untaintedAccessor.call(instance);
|
|
149
|
+
}
|
|
150
|
+
var untaintedMethodCache = {};
|
|
151
|
+
function getUntaintedMethod(key, instance, method) {
|
|
152
|
+
const cacheKey = `${key}.${String(method)}`;
|
|
153
|
+
if (untaintedMethodCache[cacheKey])
|
|
154
|
+
return untaintedMethodCache[cacheKey].bind(
|
|
155
|
+
instance
|
|
156
|
+
);
|
|
157
|
+
const untaintedPrototype = getUntaintedPrototype(key);
|
|
158
|
+
const untaintedMethod = untaintedPrototype[method];
|
|
159
|
+
if (typeof untaintedMethod !== "function") return instance[method];
|
|
160
|
+
untaintedMethodCache[cacheKey] = untaintedMethod;
|
|
161
|
+
return untaintedMethod.bind(instance);
|
|
162
|
+
}
|
|
163
|
+
function childNodes(n) {
|
|
164
|
+
return getUntaintedAccessor("Node", n, "childNodes");
|
|
165
|
+
}
|
|
166
|
+
function parentNode(n) {
|
|
167
|
+
return getUntaintedAccessor("Node", n, "parentNode");
|
|
168
|
+
}
|
|
169
|
+
function parentElement(n) {
|
|
170
|
+
return getUntaintedAccessor("Node", n, "parentElement");
|
|
171
|
+
}
|
|
172
|
+
function textContent(n) {
|
|
173
|
+
return getUntaintedAccessor("Node", n, "textContent");
|
|
174
|
+
}
|
|
175
|
+
function contains(n, other) {
|
|
176
|
+
return getUntaintedMethod("Node", n, "contains")(other);
|
|
177
|
+
}
|
|
178
|
+
function getRootNode(n) {
|
|
179
|
+
return getUntaintedMethod("Node", n, "getRootNode")();
|
|
180
|
+
}
|
|
181
|
+
function host(n) {
|
|
182
|
+
if (!n || !("host" in n)) return null;
|
|
183
|
+
return getUntaintedAccessor("ShadowRoot", n, "host");
|
|
184
|
+
}
|
|
185
|
+
function styleSheets(n) {
|
|
186
|
+
return n.styleSheets;
|
|
187
|
+
}
|
|
188
|
+
function shadowRoot(n) {
|
|
189
|
+
if (!n || !("shadowRoot" in n)) return null;
|
|
190
|
+
return getUntaintedAccessor("Element", n, "shadowRoot");
|
|
191
|
+
}
|
|
192
|
+
function querySelector(n, selectors) {
|
|
193
|
+
return getUntaintedAccessor("Element", n, "querySelector")(selectors);
|
|
194
|
+
}
|
|
195
|
+
function querySelectorAll(n, selectors) {
|
|
196
|
+
return getUntaintedAccessor("Element", n, "querySelectorAll")(selectors);
|
|
197
|
+
}
|
|
198
|
+
function mutationObserverCtor() {
|
|
199
|
+
return getUntaintedPrototype("MutationObserver").constructor;
|
|
200
|
+
}
|
|
201
|
+
function patch(source, name, replacement) {
|
|
202
|
+
try {
|
|
203
|
+
if (!(name in source)) {
|
|
204
|
+
return () => {
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const original = source[name];
|
|
208
|
+
const wrapped = replacement(original);
|
|
209
|
+
if (typeof wrapped === "function") {
|
|
210
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
211
|
+
Object.defineProperties(wrapped, {
|
|
212
|
+
__rrweb_original__: {
|
|
213
|
+
enumerable: false,
|
|
214
|
+
value: original
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
source[name] = wrapped;
|
|
219
|
+
return () => {
|
|
220
|
+
source[name] = original;
|
|
221
|
+
};
|
|
222
|
+
} catch (e) {
|
|
223
|
+
return () => {
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
var index = {
|
|
228
|
+
childNodes,
|
|
229
|
+
parentNode,
|
|
230
|
+
parentElement,
|
|
231
|
+
textContent,
|
|
232
|
+
contains,
|
|
233
|
+
getRootNode,
|
|
234
|
+
host,
|
|
235
|
+
styleSheets,
|
|
236
|
+
shadowRoot,
|
|
237
|
+
querySelector,
|
|
238
|
+
querySelectorAll,
|
|
239
|
+
mutationObserver: mutationObserverCtor,
|
|
240
|
+
patch
|
|
241
|
+
};
|
|
242
|
+
function isElement(n) {
|
|
243
|
+
return n.nodeType === n.ELEMENT_NODE;
|
|
244
|
+
}
|
|
245
|
+
function isShadowRoot(n) {
|
|
246
|
+
const hostEl = (
|
|
247
|
+
// anchor and textarea elements also have a `host` property
|
|
248
|
+
// but only shadow roots have a `mode` property
|
|
249
|
+
n && "host" in n && "mode" in n && index.host(n) || null
|
|
250
|
+
);
|
|
251
|
+
return Boolean(
|
|
252
|
+
hostEl && "shadowRoot" in hostEl && index.shadowRoot(hostEl) === n
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
function isNativeShadowDom(shadowRoot2) {
|
|
256
|
+
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
257
|
+
}
|
|
258
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
259
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
260
|
+
cssText = cssText.replace(
|
|
261
|
+
/\sbackground-clip:\s*text;/g,
|
|
262
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
return cssText;
|
|
266
|
+
}
|
|
267
|
+
function escapeImportStatement(rule2) {
|
|
268
|
+
const { cssText } = rule2;
|
|
269
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
270
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
271
|
+
if (rule2.layerName === "") {
|
|
272
|
+
statement.push(`layer`);
|
|
273
|
+
} else if (rule2.layerName) {
|
|
274
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
275
|
+
}
|
|
276
|
+
if (rule2.supportsText) {
|
|
277
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
278
|
+
}
|
|
279
|
+
if (rule2.media.length) {
|
|
280
|
+
statement.push(rule2.media.mediaText);
|
|
281
|
+
}
|
|
282
|
+
return statement.join(" ") + ";";
|
|
283
|
+
}
|
|
284
|
+
function stringifyStylesheet(s) {
|
|
285
|
+
try {
|
|
286
|
+
const rules = s.rules || s.cssRules;
|
|
287
|
+
if (!rules) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
let sheetHref = s.href;
|
|
291
|
+
if (!sheetHref && s.ownerNode) {
|
|
292
|
+
sheetHref = s.ownerNode.baseURI;
|
|
293
|
+
}
|
|
294
|
+
const stringifiedRules = Array.from(
|
|
295
|
+
rules,
|
|
296
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
297
|
+
).join("");
|
|
298
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function stringifyRule(rule2, sheetHref) {
|
|
304
|
+
var _a;
|
|
305
|
+
if (isCSSImportRule(rule2)) {
|
|
306
|
+
let importStringified;
|
|
307
|
+
try {
|
|
308
|
+
importStringified = // for same-origin stylesheets,
|
|
309
|
+
// we can access the imported stylesheet rules directly
|
|
310
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
311
|
+
escapeImportStatement(rule2);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
importStringified = rule2.cssText;
|
|
314
|
+
}
|
|
315
|
+
try {
|
|
316
|
+
if (importStringified && ((_a = rule2.styleSheet) == null ? void 0 : _a.href)) {
|
|
317
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
318
|
+
}
|
|
319
|
+
} catch (e) {
|
|
320
|
+
}
|
|
321
|
+
return importStringified;
|
|
322
|
+
} else {
|
|
323
|
+
let ruleStringified = rule2.cssText;
|
|
324
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
325
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
326
|
+
}
|
|
327
|
+
if (sheetHref) {
|
|
328
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
329
|
+
}
|
|
330
|
+
return ruleStringified;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function fixSafariColons(cssStringified) {
|
|
334
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
335
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
336
|
+
}
|
|
337
|
+
function isCSSImportRule(rule2) {
|
|
338
|
+
return "styleSheet" in rule2;
|
|
339
|
+
}
|
|
340
|
+
function isCSSStyleRule(rule2) {
|
|
341
|
+
return "selectorText" in rule2;
|
|
342
|
+
}
|
|
343
|
+
var Mirror = class {
|
|
344
|
+
constructor() {
|
|
345
|
+
__publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
|
|
346
|
+
__publicField(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
|
|
347
|
+
}
|
|
348
|
+
getId(n) {
|
|
349
|
+
var _a;
|
|
350
|
+
if (!n) return -1;
|
|
351
|
+
const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id;
|
|
352
|
+
return id != null ? id : -1;
|
|
353
|
+
}
|
|
354
|
+
getNode(id) {
|
|
355
|
+
return this.idNodeMap.get(id) || null;
|
|
356
|
+
}
|
|
357
|
+
getIds() {
|
|
358
|
+
return Array.from(this.idNodeMap.keys());
|
|
359
|
+
}
|
|
360
|
+
getMeta(n) {
|
|
361
|
+
return this.nodeMetaMap.get(n) || null;
|
|
362
|
+
}
|
|
363
|
+
// removes the node from idNodeMap
|
|
364
|
+
// doesn't remove the node from nodeMetaMap
|
|
365
|
+
removeNodeFromMap(n) {
|
|
366
|
+
const id = this.getId(n);
|
|
367
|
+
this.idNodeMap.delete(id);
|
|
368
|
+
if (n.childNodes) {
|
|
369
|
+
n.childNodes.forEach(
|
|
370
|
+
(childNode) => this.removeNodeFromMap(childNode)
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
has(id) {
|
|
375
|
+
return this.idNodeMap.has(id);
|
|
376
|
+
}
|
|
377
|
+
hasNode(node2) {
|
|
378
|
+
return this.nodeMetaMap.has(node2);
|
|
379
|
+
}
|
|
380
|
+
add(n, meta) {
|
|
381
|
+
const id = meta.id;
|
|
382
|
+
this.idNodeMap.set(id, n);
|
|
383
|
+
this.nodeMetaMap.set(n, meta);
|
|
384
|
+
}
|
|
385
|
+
replace(id, n) {
|
|
386
|
+
const oldNode = this.getNode(id);
|
|
387
|
+
if (oldNode) {
|
|
388
|
+
const meta = this.nodeMetaMap.get(oldNode);
|
|
389
|
+
if (meta) this.nodeMetaMap.set(n, meta);
|
|
390
|
+
}
|
|
391
|
+
this.idNodeMap.set(id, n);
|
|
392
|
+
}
|
|
393
|
+
reset() {
|
|
394
|
+
this.idNodeMap = /* @__PURE__ */ new Map();
|
|
395
|
+
this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
function createMirror() {
|
|
399
|
+
return new Mirror();
|
|
400
|
+
}
|
|
401
|
+
function maskInputValue({
|
|
402
|
+
element,
|
|
403
|
+
maskInputOptions,
|
|
404
|
+
tagName,
|
|
405
|
+
type,
|
|
406
|
+
value,
|
|
407
|
+
maskInputFn
|
|
408
|
+
}) {
|
|
409
|
+
let text = value || "";
|
|
410
|
+
const actualType = type && toLowerCase(type);
|
|
411
|
+
if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
|
|
412
|
+
if (maskInputFn) {
|
|
413
|
+
text = maskInputFn(text, element);
|
|
414
|
+
} else {
|
|
415
|
+
text = "*".repeat(text.length);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return text;
|
|
419
|
+
}
|
|
420
|
+
function toLowerCase(str) {
|
|
421
|
+
return str.toLowerCase();
|
|
422
|
+
}
|
|
423
|
+
var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
424
|
+
function is2DCanvasBlank(canvas) {
|
|
425
|
+
const ctx = canvas.getContext("2d");
|
|
426
|
+
if (!ctx) return true;
|
|
427
|
+
const chunkSize = 50;
|
|
428
|
+
for (let x = 0; x < canvas.width; x += chunkSize) {
|
|
429
|
+
for (let y = 0; y < canvas.height; y += chunkSize) {
|
|
430
|
+
const getImageData = ctx.getImageData;
|
|
431
|
+
const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
|
|
432
|
+
const pixelBuffer = new Uint32Array(
|
|
433
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
434
|
+
originalGetImageData.call(
|
|
435
|
+
ctx,
|
|
436
|
+
x,
|
|
437
|
+
y,
|
|
438
|
+
Math.min(chunkSize, canvas.width - x),
|
|
439
|
+
Math.min(chunkSize, canvas.height - y)
|
|
440
|
+
).data.buffer
|
|
441
|
+
);
|
|
442
|
+
if (pixelBuffer.some((pixel) => pixel !== 0)) return false;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
function isNodeMetaEqual(a, b) {
|
|
448
|
+
if (!a || !b || a.type !== b.type) return false;
|
|
449
|
+
if (a.type === NodeType$1.Document)
|
|
450
|
+
return a.compatMode === b.compatMode;
|
|
451
|
+
else if (a.type === NodeType$1.DocumentType)
|
|
452
|
+
return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
|
|
453
|
+
else if (a.type === NodeType$1.Comment || a.type === NodeType$1.Text || a.type === NodeType$1.CDATA)
|
|
454
|
+
return a.textContent === b.textContent;
|
|
455
|
+
else if (a.type === NodeType$1.Element)
|
|
456
|
+
return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
function getInputType(element) {
|
|
460
|
+
const type = element.type;
|
|
461
|
+
return element.hasAttribute("data-rr-is-password") ? "password" : type ? (
|
|
462
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
463
|
+
toLowerCase(type)
|
|
464
|
+
) : null;
|
|
465
|
+
}
|
|
466
|
+
function extractFileExtension(path, baseURL) {
|
|
467
|
+
var _a;
|
|
468
|
+
let url;
|
|
469
|
+
try {
|
|
470
|
+
url = new URL(path, baseURL != null ? baseURL : window.location.href);
|
|
471
|
+
} catch (err) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
const regex = /\.([0-9a-z]+)(?:$)/i;
|
|
475
|
+
const match = url.pathname.match(regex);
|
|
476
|
+
return (_a = match == null ? void 0 : match[1]) != null ? _a : null;
|
|
477
|
+
}
|
|
478
|
+
function extractOrigin(url) {
|
|
479
|
+
let origin = "";
|
|
480
|
+
if (url.indexOf("//") > -1) {
|
|
481
|
+
origin = url.split("/").slice(0, 3).join("/");
|
|
482
|
+
} else {
|
|
483
|
+
origin = url.split("/")[0];
|
|
484
|
+
}
|
|
485
|
+
origin = origin.split("?")[0];
|
|
486
|
+
return origin;
|
|
487
|
+
}
|
|
488
|
+
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
489
|
+
var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
490
|
+
var URL_WWW_MATCH = /^www\..*/i;
|
|
491
|
+
var DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
492
|
+
function absolutifyURLs(cssText, href) {
|
|
493
|
+
return (cssText || "").replace(
|
|
494
|
+
URL_IN_CSS_REF,
|
|
495
|
+
(origin, quote1, path1, quote2, path2, path3) => {
|
|
496
|
+
const filePath = path1 || path2 || path3;
|
|
497
|
+
const maybeQuote = quote1 || quote2 || "";
|
|
498
|
+
if (!filePath) {
|
|
499
|
+
return origin;
|
|
500
|
+
}
|
|
501
|
+
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
502
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
503
|
+
}
|
|
504
|
+
if (DATA_URI.test(filePath)) {
|
|
505
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
506
|
+
}
|
|
507
|
+
if (filePath[0] === "/") {
|
|
508
|
+
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
509
|
+
}
|
|
510
|
+
const stack = href.split("/");
|
|
511
|
+
const parts = filePath.split("/");
|
|
512
|
+
stack.pop();
|
|
513
|
+
for (const part of parts) {
|
|
514
|
+
if (part === ".") {
|
|
515
|
+
continue;
|
|
516
|
+
} else if (part === "..") {
|
|
517
|
+
stack.pop();
|
|
518
|
+
} else {
|
|
519
|
+
stack.push(part);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
var STRIPED_PLACEHOLDER_SVG = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==";
|
|
527
|
+
var MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION = 4096;
|
|
528
|
+
function recompressBase64Image(img, dataURL, type, quality) {
|
|
529
|
+
if (!img.complete || img.naturalWidth === 0) {
|
|
530
|
+
return dataURL;
|
|
531
|
+
}
|
|
532
|
+
if (img.naturalWidth > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION || img.naturalHeight > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION) {
|
|
533
|
+
return dataURL;
|
|
534
|
+
}
|
|
535
|
+
try {
|
|
536
|
+
const canvas = document.createElement("canvas");
|
|
537
|
+
canvas.width = img.naturalWidth;
|
|
538
|
+
canvas.height = img.naturalHeight;
|
|
539
|
+
const ctx = canvas.getContext("2d");
|
|
540
|
+
if (!ctx) {
|
|
541
|
+
return dataURL;
|
|
542
|
+
}
|
|
543
|
+
ctx.drawImage(img, 0, 0);
|
|
544
|
+
const recompressed = canvas.toDataURL(type || "image/webp", quality != null ? quality : 0.4);
|
|
545
|
+
return recompressed;
|
|
546
|
+
} catch (err) {
|
|
547
|
+
return dataURL;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function checkDataURLSize(dataURL, maxLength) {
|
|
551
|
+
if (!maxLength || dataURL.length <= maxLength) {
|
|
552
|
+
return dataURL;
|
|
553
|
+
}
|
|
554
|
+
return STRIPED_PLACEHOLDER_SVG;
|
|
555
|
+
}
|
|
556
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
557
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
558
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
559
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
560
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
561
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
562
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
563
|
+
return NodeType2;
|
|
564
|
+
})(NodeType || {});
|
|
565
|
+
exports2.Mirror = Mirror;
|
|
566
|
+
exports2.NodeType = NodeType;
|
|
567
|
+
exports2.NodeType$1 = NodeType$1;
|
|
568
|
+
exports2.absolutifyURLs = absolutifyURLs;
|
|
569
|
+
exports2.checkDataURLSize = checkDataURLSize;
|
|
570
|
+
exports2.createMirror = createMirror;
|
|
571
|
+
exports2.escapeImportStatement = escapeImportStatement;
|
|
572
|
+
exports2.extractFileExtension = extractFileExtension;
|
|
573
|
+
exports2.fixSafariColons = fixSafariColons;
|
|
574
|
+
exports2.getInputType = getInputType;
|
|
575
|
+
exports2.index = index;
|
|
576
|
+
exports2.is2DCanvasBlank = is2DCanvasBlank;
|
|
577
|
+
exports2.isCSSImportRule = isCSSImportRule;
|
|
578
|
+
exports2.isCSSStyleRule = isCSSStyleRule;
|
|
579
|
+
exports2.isElement = isElement;
|
|
580
|
+
exports2.isNativeShadowDom = isNativeShadowDom;
|
|
581
|
+
exports2.isNodeMetaEqual = isNodeMetaEqual;
|
|
582
|
+
exports2.isShadowRoot = isShadowRoot;
|
|
583
|
+
exports2.maskInputValue = maskInputValue;
|
|
584
|
+
exports2.recompressBase64Image = recompressBase64Image;
|
|
585
|
+
exports2.stringifyRule = stringifyRule;
|
|
586
|
+
exports2.stringifyStylesheet = stringifyStylesheet;
|
|
587
|
+
exports2.toLowerCase = toLowerCase;
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
// dist/replay.cjs
|
|
592
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
593
|
+
var types = require_types_pLXhbZlp();
|
|
594
|
+
var MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
|
|
595
|
+
var MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
|
|
596
|
+
var mediaSelectorPlugin = {
|
|
597
|
+
postcssPlugin: "postcss-custom-selectors",
|
|
598
|
+
prepare() {
|
|
599
|
+
return {
|
|
600
|
+
postcssPlugin: "postcss-custom-selectors",
|
|
601
|
+
AtRule: function(atrule) {
|
|
602
|
+
if (atrule.params.match(MEDIA_SELECTOR_GLOBAL)) {
|
|
603
|
+
atrule.params = atrule.params.replace(MEDIA_SELECTOR_GLOBAL, "$1-$2");
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
var pseudoClassPlugin = {
|
|
610
|
+
postcssPlugin: "postcss-hover-classes",
|
|
611
|
+
prepare: function() {
|
|
612
|
+
const fixed = [];
|
|
613
|
+
return {
|
|
614
|
+
Rule: function(rule2) {
|
|
615
|
+
if (fixed.indexOf(rule2) !== -1) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
fixed.push(rule2);
|
|
619
|
+
rule2.selectors.forEach(function(selector) {
|
|
620
|
+
if (selector.includes(":hover")) {
|
|
621
|
+
rule2.selector += ",\n" + selector.replace(/:hover/g, ".\\:hover");
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
function getDefaultExportFromCjs(x) {
|
|
629
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
630
|
+
}
|
|
631
|
+
function getAugmentedNamespace(n) {
|
|
632
|
+
if (n.__esModule) return n;
|
|
633
|
+
var f = n.default;
|
|
634
|
+
if (typeof f == "function") {
|
|
635
|
+
var a = function a2() {
|
|
636
|
+
if (this instanceof a2) {
|
|
637
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
638
|
+
}
|
|
639
|
+
return f.apply(this, arguments);
|
|
640
|
+
};
|
|
641
|
+
a.prototype = f.prototype;
|
|
642
|
+
} else a = {};
|
|
643
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
644
|
+
Object.keys(n).forEach(function(k) {
|
|
645
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
646
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
647
|
+
enumerable: true,
|
|
648
|
+
get: function() {
|
|
649
|
+
return n[k];
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
return a;
|
|
654
|
+
}
|
|
655
|
+
var picocolors_browser = { exports: {} };
|
|
656
|
+
var hasRequiredPicocolors_browser;
|
|
657
|
+
function requirePicocolors_browser() {
|
|
658
|
+
if (hasRequiredPicocolors_browser) return picocolors_browser.exports;
|
|
659
|
+
hasRequiredPicocolors_browser = 1;
|
|
660
|
+
var x = String;
|
|
661
|
+
var create = function() {
|
|
662
|
+
return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x, blackBright: x, redBright: x, greenBright: x, yellowBright: x, blueBright: x, magentaBright: x, cyanBright: x, whiteBright: x, bgBlackBright: x, bgRedBright: x, bgGreenBright: x, bgYellowBright: x, bgBlueBright: x, bgMagentaBright: x, bgCyanBright: x, bgWhiteBright: x };
|
|
663
|
+
};
|
|
664
|
+
picocolors_browser.exports = create();
|
|
665
|
+
picocolors_browser.exports.createColors = create;
|
|
666
|
+
return picocolors_browser.exports;
|
|
667
|
+
}
|
|
668
|
+
var __viteBrowserExternal = {};
|
|
669
|
+
var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
670
|
+
__proto__: null,
|
|
671
|
+
default: __viteBrowserExternal
|
|
672
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
673
|
+
var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
|
|
674
|
+
var cssSyntaxError;
|
|
675
|
+
var hasRequiredCssSyntaxError;
|
|
676
|
+
function requireCssSyntaxError() {
|
|
677
|
+
if (hasRequiredCssSyntaxError) return cssSyntaxError;
|
|
678
|
+
hasRequiredCssSyntaxError = 1;
|
|
679
|
+
let pico = /* @__PURE__ */ requirePicocolors_browser();
|
|
680
|
+
let terminalHighlight = require$$2;
|
|
681
|
+
class CssSyntaxError extends Error {
|
|
682
|
+
constructor(message, line, column, source, file, plugin) {
|
|
683
|
+
super(message);
|
|
684
|
+
this.name = "CssSyntaxError";
|
|
685
|
+
this.reason = message;
|
|
686
|
+
if (file) {
|
|
687
|
+
this.file = file;
|
|
688
|
+
}
|
|
689
|
+
if (source) {
|
|
690
|
+
this.source = source;
|
|
691
|
+
}
|
|
692
|
+
if (plugin) {
|
|
693
|
+
this.plugin = plugin;
|
|
694
|
+
}
|
|
695
|
+
if (typeof line !== "undefined" && typeof column !== "undefined") {
|
|
696
|
+
if (typeof line === "number") {
|
|
697
|
+
this.line = line;
|
|
698
|
+
this.column = column;
|
|
699
|
+
} else {
|
|
700
|
+
this.line = line.line;
|
|
701
|
+
this.column = line.column;
|
|
702
|
+
this.endLine = column.line;
|
|
703
|
+
this.endColumn = column.column;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
this.setMessage();
|
|
707
|
+
if (Error.captureStackTrace) {
|
|
708
|
+
Error.captureStackTrace(this, CssSyntaxError);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
setMessage() {
|
|
712
|
+
this.message = this.plugin ? this.plugin + ": " : "";
|
|
713
|
+
this.message += this.file ? this.file : "<css input>";
|
|
714
|
+
if (typeof this.line !== "undefined") {
|
|
715
|
+
this.message += ":" + this.line + ":" + this.column;
|
|
716
|
+
}
|
|
717
|
+
this.message += ": " + this.reason;
|
|
718
|
+
}
|
|
719
|
+
showSourceCode(color) {
|
|
720
|
+
if (!this.source) return "";
|
|
721
|
+
let css = this.source;
|
|
722
|
+
if (color == null) color = pico.isColorSupported;
|
|
723
|
+
let aside = (text) => text;
|
|
724
|
+
let mark = (text) => text;
|
|
725
|
+
let highlight = (text) => text;
|
|
726
|
+
if (color) {
|
|
727
|
+
let { bold, gray, red } = pico.createColors(true);
|
|
728
|
+
mark = (text) => bold(red(text));
|
|
729
|
+
aside = (text) => gray(text);
|
|
730
|
+
if (terminalHighlight) {
|
|
731
|
+
highlight = (text) => terminalHighlight(text);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
let lines = css.split(/\r?\n/);
|
|
735
|
+
let start = Math.max(this.line - 3, 0);
|
|
736
|
+
let end = Math.min(this.line + 2, lines.length);
|
|
737
|
+
let maxWidth = String(end).length;
|
|
738
|
+
return lines.slice(start, end).map((line, index) => {
|
|
739
|
+
let number = start + 1 + index;
|
|
740
|
+
let gutter = " " + (" " + number).slice(-maxWidth) + " | ";
|
|
741
|
+
if (number === this.line) {
|
|
742
|
+
if (line.length > 160) {
|
|
743
|
+
let padding = 20;
|
|
744
|
+
let subLineStart = Math.max(0, this.column - padding);
|
|
745
|
+
let subLineEnd = Math.max(
|
|
746
|
+
this.column + padding,
|
|
747
|
+
this.endColumn + padding
|
|
748
|
+
);
|
|
749
|
+
let subLine = line.slice(subLineStart, subLineEnd);
|
|
750
|
+
let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " ");
|
|
751
|
+
return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^");
|
|
752
|
+
}
|
|
753
|
+
let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
|
|
754
|
+
return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^");
|
|
755
|
+
}
|
|
756
|
+
return " " + aside(gutter) + highlight(line);
|
|
757
|
+
}).join("\n");
|
|
758
|
+
}
|
|
759
|
+
toString() {
|
|
760
|
+
let code = this.showSourceCode();
|
|
761
|
+
if (code) {
|
|
762
|
+
code = "\n\n" + code + "\n";
|
|
763
|
+
}
|
|
764
|
+
return this.name + ": " + this.message + code;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
cssSyntaxError = CssSyntaxError;
|
|
768
|
+
CssSyntaxError.default = CssSyntaxError;
|
|
769
|
+
return cssSyntaxError;
|
|
770
|
+
}
|
|
771
|
+
var stringifier;
|
|
772
|
+
var hasRequiredStringifier;
|
|
773
|
+
function requireStringifier() {
|
|
774
|
+
if (hasRequiredStringifier) return stringifier;
|
|
775
|
+
hasRequiredStringifier = 1;
|
|
776
|
+
const DEFAULT_RAW = {
|
|
777
|
+
after: "\n",
|
|
778
|
+
beforeClose: "\n",
|
|
779
|
+
beforeComment: "\n",
|
|
780
|
+
beforeDecl: "\n",
|
|
781
|
+
beforeOpen: " ",
|
|
782
|
+
beforeRule: "\n",
|
|
783
|
+
colon: ": ",
|
|
784
|
+
commentLeft: " ",
|
|
785
|
+
commentRight: " ",
|
|
786
|
+
emptyBody: "",
|
|
787
|
+
indent: " ",
|
|
788
|
+
semicolon: false
|
|
789
|
+
};
|
|
790
|
+
function capitalize(str) {
|
|
791
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
792
|
+
}
|
|
793
|
+
class Stringifier {
|
|
794
|
+
constructor(builder) {
|
|
795
|
+
this.builder = builder;
|
|
796
|
+
}
|
|
797
|
+
atrule(node2, semicolon) {
|
|
798
|
+
let name = "@" + node2.name;
|
|
799
|
+
let params = node2.params ? this.rawValue(node2, "params") : "";
|
|
800
|
+
if (typeof node2.raws.afterName !== "undefined") {
|
|
801
|
+
name += node2.raws.afterName;
|
|
802
|
+
} else if (params) {
|
|
803
|
+
name += " ";
|
|
804
|
+
}
|
|
805
|
+
if (node2.nodes) {
|
|
806
|
+
this.block(node2, name + params);
|
|
807
|
+
} else {
|
|
808
|
+
let end = (node2.raws.between || "") + (semicolon ? ";" : "");
|
|
809
|
+
this.builder(name + params + end, node2);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
beforeAfter(node2, detect) {
|
|
813
|
+
let value;
|
|
814
|
+
if (node2.type === "decl") {
|
|
815
|
+
value = this.raw(node2, null, "beforeDecl");
|
|
816
|
+
} else if (node2.type === "comment") {
|
|
817
|
+
value = this.raw(node2, null, "beforeComment");
|
|
818
|
+
} else if (detect === "before") {
|
|
819
|
+
value = this.raw(node2, null, "beforeRule");
|
|
820
|
+
} else {
|
|
821
|
+
value = this.raw(node2, null, "beforeClose");
|
|
822
|
+
}
|
|
823
|
+
let buf = node2.parent;
|
|
824
|
+
let depth = 0;
|
|
825
|
+
while (buf && buf.type !== "root") {
|
|
826
|
+
depth += 1;
|
|
827
|
+
buf = buf.parent;
|
|
828
|
+
}
|
|
829
|
+
if (value.includes("\n")) {
|
|
830
|
+
let indent = this.raw(node2, null, "indent");
|
|
831
|
+
if (indent.length) {
|
|
832
|
+
for (let step = 0; step < depth; step++) value += indent;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return value;
|
|
836
|
+
}
|
|
837
|
+
block(node2, start) {
|
|
838
|
+
let between = this.raw(node2, "between", "beforeOpen");
|
|
839
|
+
this.builder(start + between + "{", node2, "start");
|
|
840
|
+
let after;
|
|
841
|
+
if (node2.nodes && node2.nodes.length) {
|
|
842
|
+
this.body(node2);
|
|
843
|
+
after = this.raw(node2, "after");
|
|
844
|
+
} else {
|
|
845
|
+
after = this.raw(node2, "after", "emptyBody");
|
|
846
|
+
}
|
|
847
|
+
if (after) this.builder(after);
|
|
848
|
+
this.builder("}", node2, "end");
|
|
849
|
+
}
|
|
850
|
+
body(node2) {
|
|
851
|
+
let last = node2.nodes.length - 1;
|
|
852
|
+
while (last > 0) {
|
|
853
|
+
if (node2.nodes[last].type !== "comment") break;
|
|
854
|
+
last -= 1;
|
|
855
|
+
}
|
|
856
|
+
let semicolon = this.raw(node2, "semicolon");
|
|
857
|
+
for (let i = 0; i < node2.nodes.length; i++) {
|
|
858
|
+
let child = node2.nodes[i];
|
|
859
|
+
let before = this.raw(child, "before");
|
|
860
|
+
if (before) this.builder(before);
|
|
861
|
+
this.stringify(child, last !== i || semicolon);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
comment(node2) {
|
|
865
|
+
let left = this.raw(node2, "left", "commentLeft");
|
|
866
|
+
let right = this.raw(node2, "right", "commentRight");
|
|
867
|
+
this.builder("/*" + left + node2.text + right + "*/", node2);
|
|
868
|
+
}
|
|
869
|
+
decl(node2, semicolon) {
|
|
870
|
+
let between = this.raw(node2, "between", "colon");
|
|
871
|
+
let string = node2.prop + between + this.rawValue(node2, "value");
|
|
872
|
+
if (node2.important) {
|
|
873
|
+
string += node2.raws.important || " !important";
|
|
874
|
+
}
|
|
875
|
+
if (semicolon) string += ";";
|
|
876
|
+
this.builder(string, node2);
|
|
877
|
+
}
|
|
878
|
+
document(node2) {
|
|
879
|
+
this.body(node2);
|
|
880
|
+
}
|
|
881
|
+
raw(node2, own, detect) {
|
|
882
|
+
let value;
|
|
883
|
+
if (!detect) detect = own;
|
|
884
|
+
if (own) {
|
|
885
|
+
value = node2.raws[own];
|
|
886
|
+
if (typeof value !== "undefined") return value;
|
|
887
|
+
}
|
|
888
|
+
let parent = node2.parent;
|
|
889
|
+
if (detect === "before") {
|
|
890
|
+
if (!parent || parent.type === "root" && parent.first === node2) {
|
|
891
|
+
return "";
|
|
892
|
+
}
|
|
893
|
+
if (parent && parent.type === "document") {
|
|
894
|
+
return "";
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (!parent) return DEFAULT_RAW[detect];
|
|
898
|
+
let root2 = node2.root();
|
|
899
|
+
if (!root2.rawCache) root2.rawCache = {};
|
|
900
|
+
if (typeof root2.rawCache[detect] !== "undefined") {
|
|
901
|
+
return root2.rawCache[detect];
|
|
902
|
+
}
|
|
903
|
+
if (detect === "before" || detect === "after") {
|
|
904
|
+
return this.beforeAfter(node2, detect);
|
|
905
|
+
} else {
|
|
906
|
+
let method = "raw" + capitalize(detect);
|
|
907
|
+
if (this[method]) {
|
|
908
|
+
value = this[method](root2, node2);
|
|
909
|
+
} else {
|
|
910
|
+
root2.walk((i) => {
|
|
911
|
+
value = i.raws[own];
|
|
912
|
+
if (typeof value !== "undefined") return false;
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
if (typeof value === "undefined") value = DEFAULT_RAW[detect];
|
|
917
|
+
root2.rawCache[detect] = value;
|
|
918
|
+
return value;
|
|
919
|
+
}
|
|
920
|
+
rawBeforeClose(root2) {
|
|
921
|
+
let value;
|
|
922
|
+
root2.walk((i) => {
|
|
923
|
+
if (i.nodes && i.nodes.length > 0) {
|
|
924
|
+
if (typeof i.raws.after !== "undefined") {
|
|
925
|
+
value = i.raws.after;
|
|
926
|
+
if (value.includes("\n")) {
|
|
927
|
+
value = value.replace(/[^\n]+$/, "");
|
|
928
|
+
}
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
if (value) value = value.replace(/\S/g, "");
|
|
934
|
+
return value;
|
|
935
|
+
}
|
|
936
|
+
rawBeforeComment(root2, node2) {
|
|
937
|
+
let value;
|
|
938
|
+
root2.walkComments((i) => {
|
|
939
|
+
if (typeof i.raws.before !== "undefined") {
|
|
940
|
+
value = i.raws.before;
|
|
941
|
+
if (value.includes("\n")) {
|
|
942
|
+
value = value.replace(/[^\n]+$/, "");
|
|
943
|
+
}
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
if (typeof value === "undefined") {
|
|
948
|
+
value = this.raw(node2, null, "beforeDecl");
|
|
949
|
+
} else if (value) {
|
|
950
|
+
value = value.replace(/\S/g, "");
|
|
951
|
+
}
|
|
952
|
+
return value;
|
|
953
|
+
}
|
|
954
|
+
rawBeforeDecl(root2, node2) {
|
|
955
|
+
let value;
|
|
956
|
+
root2.walkDecls((i) => {
|
|
957
|
+
if (typeof i.raws.before !== "undefined") {
|
|
958
|
+
value = i.raws.before;
|
|
959
|
+
if (value.includes("\n")) {
|
|
960
|
+
value = value.replace(/[^\n]+$/, "");
|
|
961
|
+
}
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
if (typeof value === "undefined") {
|
|
966
|
+
value = this.raw(node2, null, "beforeRule");
|
|
967
|
+
} else if (value) {
|
|
968
|
+
value = value.replace(/\S/g, "");
|
|
969
|
+
}
|
|
970
|
+
return value;
|
|
971
|
+
}
|
|
972
|
+
rawBeforeOpen(root2) {
|
|
973
|
+
let value;
|
|
974
|
+
root2.walk((i) => {
|
|
975
|
+
if (i.type !== "decl") {
|
|
976
|
+
value = i.raws.between;
|
|
977
|
+
if (typeof value !== "undefined") return false;
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
return value;
|
|
981
|
+
}
|
|
982
|
+
rawBeforeRule(root2) {
|
|
983
|
+
let value;
|
|
984
|
+
root2.walk((i) => {
|
|
985
|
+
if (i.nodes && (i.parent !== root2 || root2.first !== i)) {
|
|
986
|
+
if (typeof i.raws.before !== "undefined") {
|
|
987
|
+
value = i.raws.before;
|
|
988
|
+
if (value.includes("\n")) {
|
|
989
|
+
value = value.replace(/[^\n]+$/, "");
|
|
990
|
+
}
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
if (value) value = value.replace(/\S/g, "");
|
|
996
|
+
return value;
|
|
997
|
+
}
|
|
998
|
+
rawColon(root2) {
|
|
999
|
+
let value;
|
|
1000
|
+
root2.walkDecls((i) => {
|
|
1001
|
+
if (typeof i.raws.between !== "undefined") {
|
|
1002
|
+
value = i.raws.between.replace(/[^\s:]/g, "");
|
|
1003
|
+
return false;
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
return value;
|
|
1007
|
+
}
|
|
1008
|
+
rawEmptyBody(root2) {
|
|
1009
|
+
let value;
|
|
1010
|
+
root2.walk((i) => {
|
|
1011
|
+
if (i.nodes && i.nodes.length === 0) {
|
|
1012
|
+
value = i.raws.after;
|
|
1013
|
+
if (typeof value !== "undefined") return false;
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
return value;
|
|
1017
|
+
}
|
|
1018
|
+
rawIndent(root2) {
|
|
1019
|
+
if (root2.raws.indent) return root2.raws.indent;
|
|
1020
|
+
let value;
|
|
1021
|
+
root2.walk((i) => {
|
|
1022
|
+
let p = i.parent;
|
|
1023
|
+
if (p && p !== root2 && p.parent && p.parent === root2) {
|
|
1024
|
+
if (typeof i.raws.before !== "undefined") {
|
|
1025
|
+
let parts = i.raws.before.split("\n");
|
|
1026
|
+
value = parts[parts.length - 1];
|
|
1027
|
+
value = value.replace(/\S/g, "");
|
|
1028
|
+
return false;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
return value;
|
|
1033
|
+
}
|
|
1034
|
+
rawSemicolon(root2) {
|
|
1035
|
+
let value;
|
|
1036
|
+
root2.walk((i) => {
|
|
1037
|
+
if (i.nodes && i.nodes.length && i.last.type === "decl") {
|
|
1038
|
+
value = i.raws.semicolon;
|
|
1039
|
+
if (typeof value !== "undefined") return false;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
return value;
|
|
1043
|
+
}
|
|
1044
|
+
rawValue(node2, prop) {
|
|
1045
|
+
let value = node2[prop];
|
|
1046
|
+
let raw = node2.raws[prop];
|
|
1047
|
+
if (raw && raw.value === value) {
|
|
1048
|
+
return raw.raw;
|
|
1049
|
+
}
|
|
1050
|
+
return value;
|
|
1051
|
+
}
|
|
1052
|
+
root(node2) {
|
|
1053
|
+
this.body(node2);
|
|
1054
|
+
if (node2.raws.after) this.builder(node2.raws.after);
|
|
1055
|
+
}
|
|
1056
|
+
rule(node2) {
|
|
1057
|
+
this.block(node2, this.rawValue(node2, "selector"));
|
|
1058
|
+
if (node2.raws.ownSemicolon) {
|
|
1059
|
+
this.builder(node2.raws.ownSemicolon, node2, "end");
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
stringify(node2, semicolon) {
|
|
1063
|
+
if (!this[node2.type]) {
|
|
1064
|
+
throw new Error(
|
|
1065
|
+
"Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier."
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
this[node2.type](node2, semicolon);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
stringifier = Stringifier;
|
|
1072
|
+
Stringifier.default = Stringifier;
|
|
1073
|
+
return stringifier;
|
|
1074
|
+
}
|
|
1075
|
+
var stringify_1;
|
|
1076
|
+
var hasRequiredStringify;
|
|
1077
|
+
function requireStringify() {
|
|
1078
|
+
if (hasRequiredStringify) return stringify_1;
|
|
1079
|
+
hasRequiredStringify = 1;
|
|
1080
|
+
let Stringifier = requireStringifier();
|
|
1081
|
+
function stringify(node2, builder) {
|
|
1082
|
+
let str = new Stringifier(builder);
|
|
1083
|
+
str.stringify(node2);
|
|
1084
|
+
}
|
|
1085
|
+
stringify_1 = stringify;
|
|
1086
|
+
stringify.default = stringify;
|
|
1087
|
+
return stringify_1;
|
|
1088
|
+
}
|
|
1089
|
+
var symbols = {};
|
|
1090
|
+
var hasRequiredSymbols;
|
|
1091
|
+
function requireSymbols() {
|
|
1092
|
+
if (hasRequiredSymbols) return symbols;
|
|
1093
|
+
hasRequiredSymbols = 1;
|
|
1094
|
+
symbols.isClean = Symbol("isClean");
|
|
1095
|
+
symbols.my = Symbol("my");
|
|
1096
|
+
return symbols;
|
|
1097
|
+
}
|
|
1098
|
+
var node;
|
|
1099
|
+
var hasRequiredNode;
|
|
1100
|
+
function requireNode() {
|
|
1101
|
+
if (hasRequiredNode) return node;
|
|
1102
|
+
hasRequiredNode = 1;
|
|
1103
|
+
let CssSyntaxError = requireCssSyntaxError();
|
|
1104
|
+
let Stringifier = requireStringifier();
|
|
1105
|
+
let stringify = requireStringify();
|
|
1106
|
+
let { isClean, my } = requireSymbols();
|
|
1107
|
+
function cloneNode(obj, parent) {
|
|
1108
|
+
let cloned = new obj.constructor();
|
|
1109
|
+
for (let i in obj) {
|
|
1110
|
+
if (!Object.prototype.hasOwnProperty.call(obj, i)) {
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
if (i === "proxyCache") continue;
|
|
1114
|
+
let value = obj[i];
|
|
1115
|
+
let type = typeof value;
|
|
1116
|
+
if (i === "parent" && type === "object") {
|
|
1117
|
+
if (parent) cloned[i] = parent;
|
|
1118
|
+
} else if (i === "source") {
|
|
1119
|
+
cloned[i] = value;
|
|
1120
|
+
} else if (Array.isArray(value)) {
|
|
1121
|
+
cloned[i] = value.map((j) => cloneNode(j, cloned));
|
|
1122
|
+
} else {
|
|
1123
|
+
if (type === "object" && value !== null) value = cloneNode(value);
|
|
1124
|
+
cloned[i] = value;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
return cloned;
|
|
1128
|
+
}
|
|
1129
|
+
function sourceOffset(inputCSS, position) {
|
|
1130
|
+
if (position && typeof position.offset !== "undefined") {
|
|
1131
|
+
return position.offset;
|
|
1132
|
+
}
|
|
1133
|
+
let column = 1;
|
|
1134
|
+
let line = 1;
|
|
1135
|
+
let offset = 0;
|
|
1136
|
+
for (let i = 0; i < inputCSS.length; i++) {
|
|
1137
|
+
if (line === position.line && column === position.column) {
|
|
1138
|
+
offset = i;
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
if (inputCSS[i] === "\n") {
|
|
1142
|
+
column = 1;
|
|
1143
|
+
line += 1;
|
|
1144
|
+
} else {
|
|
1145
|
+
column += 1;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return offset;
|
|
1149
|
+
}
|
|
1150
|
+
class Node {
|
|
1151
|
+
constructor(defaults = {}) {
|
|
1152
|
+
this.raws = {};
|
|
1153
|
+
this[isClean] = false;
|
|
1154
|
+
this[my] = true;
|
|
1155
|
+
for (let name in defaults) {
|
|
1156
|
+
if (name === "nodes") {
|
|
1157
|
+
this.nodes = [];
|
|
1158
|
+
for (let node2 of defaults[name]) {
|
|
1159
|
+
if (typeof node2.clone === "function") {
|
|
1160
|
+
this.append(node2.clone());
|
|
1161
|
+
} else {
|
|
1162
|
+
this.append(node2);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
} else {
|
|
1166
|
+
this[name] = defaults[name];
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
addToError(error) {
|
|
1171
|
+
error.postcssNode = this;
|
|
1172
|
+
if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
|
|
1173
|
+
let s = this.source;
|
|
1174
|
+
error.stack = error.stack.replace(
|
|
1175
|
+
/\n\s{4}at /,
|
|
1176
|
+
`$&${s.input.from}:${s.start.line}:${s.start.column}$&`
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
return error;
|
|
1180
|
+
}
|
|
1181
|
+
after(add) {
|
|
1182
|
+
this.parent.insertAfter(this, add);
|
|
1183
|
+
return this;
|
|
1184
|
+
}
|
|
1185
|
+
assign(overrides = {}) {
|
|
1186
|
+
for (let name in overrides) {
|
|
1187
|
+
this[name] = overrides[name];
|
|
1188
|
+
}
|
|
1189
|
+
return this;
|
|
1190
|
+
}
|
|
1191
|
+
before(add) {
|
|
1192
|
+
this.parent.insertBefore(this, add);
|
|
1193
|
+
return this;
|
|
1194
|
+
}
|
|
1195
|
+
cleanRaws(keepBetween) {
|
|
1196
|
+
delete this.raws.before;
|
|
1197
|
+
delete this.raws.after;
|
|
1198
|
+
if (!keepBetween) delete this.raws.between;
|
|
1199
|
+
}
|
|
1200
|
+
clone(overrides = {}) {
|
|
1201
|
+
let cloned = cloneNode(this);
|
|
1202
|
+
for (let name in overrides) {
|
|
1203
|
+
cloned[name] = overrides[name];
|
|
1204
|
+
}
|
|
1205
|
+
return cloned;
|
|
1206
|
+
}
|
|
1207
|
+
cloneAfter(overrides = {}) {
|
|
1208
|
+
let cloned = this.clone(overrides);
|
|
1209
|
+
this.parent.insertAfter(this, cloned);
|
|
1210
|
+
return cloned;
|
|
1211
|
+
}
|
|
1212
|
+
cloneBefore(overrides = {}) {
|
|
1213
|
+
let cloned = this.clone(overrides);
|
|
1214
|
+
this.parent.insertBefore(this, cloned);
|
|
1215
|
+
return cloned;
|
|
1216
|
+
}
|
|
1217
|
+
error(message, opts = {}) {
|
|
1218
|
+
if (this.source) {
|
|
1219
|
+
let { end, start } = this.rangeBy(opts);
|
|
1220
|
+
return this.source.input.error(
|
|
1221
|
+
message,
|
|
1222
|
+
{ column: start.column, line: start.line },
|
|
1223
|
+
{ column: end.column, line: end.line },
|
|
1224
|
+
opts
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
return new CssSyntaxError(message);
|
|
1228
|
+
}
|
|
1229
|
+
getProxyProcessor() {
|
|
1230
|
+
return {
|
|
1231
|
+
get(node2, prop) {
|
|
1232
|
+
if (prop === "proxyOf") {
|
|
1233
|
+
return node2;
|
|
1234
|
+
} else if (prop === "root") {
|
|
1235
|
+
return () => node2.root().toProxy();
|
|
1236
|
+
} else {
|
|
1237
|
+
return node2[prop];
|
|
1238
|
+
}
|
|
1239
|
+
},
|
|
1240
|
+
set(node2, prop, value) {
|
|
1241
|
+
if (node2[prop] === value) return true;
|
|
1242
|
+
node2[prop] = value;
|
|
1243
|
+
if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */
|
|
1244
|
+
prop === "text") {
|
|
1245
|
+
node2.markDirty();
|
|
1246
|
+
}
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
/* c8 ignore next 3 */
|
|
1252
|
+
markClean() {
|
|
1253
|
+
this[isClean] = true;
|
|
1254
|
+
}
|
|
1255
|
+
markDirty() {
|
|
1256
|
+
if (this[isClean]) {
|
|
1257
|
+
this[isClean] = false;
|
|
1258
|
+
let next = this;
|
|
1259
|
+
while (next = next.parent) {
|
|
1260
|
+
next[isClean] = false;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
next() {
|
|
1265
|
+
if (!this.parent) return void 0;
|
|
1266
|
+
let index = this.parent.index(this);
|
|
1267
|
+
return this.parent.nodes[index + 1];
|
|
1268
|
+
}
|
|
1269
|
+
positionBy(opts) {
|
|
1270
|
+
let pos = this.source.start;
|
|
1271
|
+
if (opts.index) {
|
|
1272
|
+
pos = this.positionInside(opts.index);
|
|
1273
|
+
} else if (opts.word) {
|
|
1274
|
+
let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
|
|
1275
|
+
let stringRepresentation = inputString.slice(
|
|
1276
|
+
sourceOffset(inputString, this.source.start),
|
|
1277
|
+
sourceOffset(inputString, this.source.end)
|
|
1278
|
+
);
|
|
1279
|
+
let index = stringRepresentation.indexOf(opts.word);
|
|
1280
|
+
if (index !== -1) pos = this.positionInside(index);
|
|
1281
|
+
}
|
|
1282
|
+
return pos;
|
|
1283
|
+
}
|
|
1284
|
+
positionInside(index) {
|
|
1285
|
+
let column = this.source.start.column;
|
|
1286
|
+
let line = this.source.start.line;
|
|
1287
|
+
let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
|
|
1288
|
+
let offset = sourceOffset(inputString, this.source.start);
|
|
1289
|
+
let end = offset + index;
|
|
1290
|
+
for (let i = offset; i < end; i++) {
|
|
1291
|
+
if (inputString[i] === "\n") {
|
|
1292
|
+
column = 1;
|
|
1293
|
+
line += 1;
|
|
1294
|
+
} else {
|
|
1295
|
+
column += 1;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
return { column, line };
|
|
1299
|
+
}
|
|
1300
|
+
prev() {
|
|
1301
|
+
if (!this.parent) return void 0;
|
|
1302
|
+
let index = this.parent.index(this);
|
|
1303
|
+
return this.parent.nodes[index - 1];
|
|
1304
|
+
}
|
|
1305
|
+
rangeBy(opts) {
|
|
1306
|
+
let start = {
|
|
1307
|
+
column: this.source.start.column,
|
|
1308
|
+
line: this.source.start.line
|
|
1309
|
+
};
|
|
1310
|
+
let end = this.source.end ? {
|
|
1311
|
+
column: this.source.end.column + 1,
|
|
1312
|
+
line: this.source.end.line
|
|
1313
|
+
} : {
|
|
1314
|
+
column: start.column + 1,
|
|
1315
|
+
line: start.line
|
|
1316
|
+
};
|
|
1317
|
+
if (opts.word) {
|
|
1318
|
+
let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
|
|
1319
|
+
let stringRepresentation = inputString.slice(
|
|
1320
|
+
sourceOffset(inputString, this.source.start),
|
|
1321
|
+
sourceOffset(inputString, this.source.end)
|
|
1322
|
+
);
|
|
1323
|
+
let index = stringRepresentation.indexOf(opts.word);
|
|
1324
|
+
if (index !== -1) {
|
|
1325
|
+
start = this.positionInside(index);
|
|
1326
|
+
end = this.positionInside(
|
|
1327
|
+
index + opts.word.length
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
} else {
|
|
1331
|
+
if (opts.start) {
|
|
1332
|
+
start = {
|
|
1333
|
+
column: opts.start.column,
|
|
1334
|
+
line: opts.start.line
|
|
1335
|
+
};
|
|
1336
|
+
} else if (opts.index) {
|
|
1337
|
+
start = this.positionInside(opts.index);
|
|
1338
|
+
}
|
|
1339
|
+
if (opts.end) {
|
|
1340
|
+
end = {
|
|
1341
|
+
column: opts.end.column,
|
|
1342
|
+
line: opts.end.line
|
|
1343
|
+
};
|
|
1344
|
+
} else if (typeof opts.endIndex === "number") {
|
|
1345
|
+
end = this.positionInside(opts.endIndex);
|
|
1346
|
+
} else if (opts.index) {
|
|
1347
|
+
end = this.positionInside(opts.index + 1);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
if (end.line < start.line || end.line === start.line && end.column <= start.column) {
|
|
1351
|
+
end = { column: start.column + 1, line: start.line };
|
|
1352
|
+
}
|
|
1353
|
+
return { end, start };
|
|
1354
|
+
}
|
|
1355
|
+
raw(prop, defaultType) {
|
|
1356
|
+
let str = new Stringifier();
|
|
1357
|
+
return str.raw(this, prop, defaultType);
|
|
1358
|
+
}
|
|
1359
|
+
remove() {
|
|
1360
|
+
if (this.parent) {
|
|
1361
|
+
this.parent.removeChild(this);
|
|
1362
|
+
}
|
|
1363
|
+
this.parent = void 0;
|
|
1364
|
+
return this;
|
|
1365
|
+
}
|
|
1366
|
+
replaceWith(...nodes) {
|
|
1367
|
+
if (this.parent) {
|
|
1368
|
+
let bookmark = this;
|
|
1369
|
+
let foundSelf = false;
|
|
1370
|
+
for (let node2 of nodes) {
|
|
1371
|
+
if (node2 === this) {
|
|
1372
|
+
foundSelf = true;
|
|
1373
|
+
} else if (foundSelf) {
|
|
1374
|
+
this.parent.insertAfter(bookmark, node2);
|
|
1375
|
+
bookmark = node2;
|
|
1376
|
+
} else {
|
|
1377
|
+
this.parent.insertBefore(bookmark, node2);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
if (!foundSelf) {
|
|
1381
|
+
this.remove();
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
return this;
|
|
1385
|
+
}
|
|
1386
|
+
root() {
|
|
1387
|
+
let result2 = this;
|
|
1388
|
+
while (result2.parent && result2.parent.type !== "document") {
|
|
1389
|
+
result2 = result2.parent;
|
|
1390
|
+
}
|
|
1391
|
+
return result2;
|
|
1392
|
+
}
|
|
1393
|
+
toJSON(_, inputs) {
|
|
1394
|
+
let fixed = {};
|
|
1395
|
+
let emitInputs = inputs == null;
|
|
1396
|
+
inputs = inputs || /* @__PURE__ */ new Map();
|
|
1397
|
+
let inputsNextIndex = 0;
|
|
1398
|
+
for (let name in this) {
|
|
1399
|
+
if (!Object.prototype.hasOwnProperty.call(this, name)) {
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
if (name === "parent" || name === "proxyCache") continue;
|
|
1403
|
+
let value = this[name];
|
|
1404
|
+
if (Array.isArray(value)) {
|
|
1405
|
+
fixed[name] = value.map((i) => {
|
|
1406
|
+
if (typeof i === "object" && i.toJSON) {
|
|
1407
|
+
return i.toJSON(null, inputs);
|
|
1408
|
+
} else {
|
|
1409
|
+
return i;
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
} else if (typeof value === "object" && value.toJSON) {
|
|
1413
|
+
fixed[name] = value.toJSON(null, inputs);
|
|
1414
|
+
} else if (name === "source") {
|
|
1415
|
+
let inputId = inputs.get(value.input);
|
|
1416
|
+
if (inputId == null) {
|
|
1417
|
+
inputId = inputsNextIndex;
|
|
1418
|
+
inputs.set(value.input, inputsNextIndex);
|
|
1419
|
+
inputsNextIndex++;
|
|
1420
|
+
}
|
|
1421
|
+
fixed[name] = {
|
|
1422
|
+
end: value.end,
|
|
1423
|
+
inputId,
|
|
1424
|
+
start: value.start
|
|
1425
|
+
};
|
|
1426
|
+
} else {
|
|
1427
|
+
fixed[name] = value;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
if (emitInputs) {
|
|
1431
|
+
fixed.inputs = [...inputs.keys()].map((input2) => input2.toJSON());
|
|
1432
|
+
}
|
|
1433
|
+
return fixed;
|
|
1434
|
+
}
|
|
1435
|
+
toProxy() {
|
|
1436
|
+
if (!this.proxyCache) {
|
|
1437
|
+
this.proxyCache = new Proxy(this, this.getProxyProcessor());
|
|
1438
|
+
}
|
|
1439
|
+
return this.proxyCache;
|
|
1440
|
+
}
|
|
1441
|
+
toString(stringifier2 = stringify) {
|
|
1442
|
+
if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
|
|
1443
|
+
let result2 = "";
|
|
1444
|
+
stringifier2(this, (i) => {
|
|
1445
|
+
result2 += i;
|
|
1446
|
+
});
|
|
1447
|
+
return result2;
|
|
1448
|
+
}
|
|
1449
|
+
warn(result2, text, opts) {
|
|
1450
|
+
let data = { node: this };
|
|
1451
|
+
for (let i in opts) data[i] = opts[i];
|
|
1452
|
+
return result2.warn(text, data);
|
|
1453
|
+
}
|
|
1454
|
+
get proxyOf() {
|
|
1455
|
+
return this;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
node = Node;
|
|
1459
|
+
Node.default = Node;
|
|
1460
|
+
return node;
|
|
1461
|
+
}
|
|
1462
|
+
var comment;
|
|
1463
|
+
var hasRequiredComment;
|
|
1464
|
+
function requireComment() {
|
|
1465
|
+
if (hasRequiredComment) return comment;
|
|
1466
|
+
hasRequiredComment = 1;
|
|
1467
|
+
let Node = requireNode();
|
|
1468
|
+
class Comment extends Node {
|
|
1469
|
+
constructor(defaults) {
|
|
1470
|
+
super(defaults);
|
|
1471
|
+
this.type = "comment";
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
comment = Comment;
|
|
1475
|
+
Comment.default = Comment;
|
|
1476
|
+
return comment;
|
|
1477
|
+
}
|
|
1478
|
+
var declaration;
|
|
1479
|
+
var hasRequiredDeclaration;
|
|
1480
|
+
function requireDeclaration() {
|
|
1481
|
+
if (hasRequiredDeclaration) return declaration;
|
|
1482
|
+
hasRequiredDeclaration = 1;
|
|
1483
|
+
let Node = requireNode();
|
|
1484
|
+
class Declaration extends Node {
|
|
1485
|
+
constructor(defaults) {
|
|
1486
|
+
if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
|
|
1487
|
+
defaults = __spreadProps(__spreadValues({}, defaults), { value: String(defaults.value) });
|
|
1488
|
+
}
|
|
1489
|
+
super(defaults);
|
|
1490
|
+
this.type = "decl";
|
|
1491
|
+
}
|
|
1492
|
+
get variable() {
|
|
1493
|
+
return this.prop.startsWith("--") || this.prop[0] === "$";
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
declaration = Declaration;
|
|
1497
|
+
Declaration.default = Declaration;
|
|
1498
|
+
return declaration;
|
|
1499
|
+
}
|
|
1500
|
+
var container;
|
|
1501
|
+
var hasRequiredContainer;
|
|
1502
|
+
function requireContainer() {
|
|
1503
|
+
if (hasRequiredContainer) return container;
|
|
1504
|
+
hasRequiredContainer = 1;
|
|
1505
|
+
let Comment = requireComment();
|
|
1506
|
+
let Declaration = requireDeclaration();
|
|
1507
|
+
let Node = requireNode();
|
|
1508
|
+
let { isClean, my } = requireSymbols();
|
|
1509
|
+
let AtRule, parse, Root, Rule;
|
|
1510
|
+
function cleanSource(nodes) {
|
|
1511
|
+
return nodes.map((i) => {
|
|
1512
|
+
if (i.nodes) i.nodes = cleanSource(i.nodes);
|
|
1513
|
+
delete i.source;
|
|
1514
|
+
return i;
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
function markTreeDirty(node2) {
|
|
1518
|
+
node2[isClean] = false;
|
|
1519
|
+
if (node2.proxyOf.nodes) {
|
|
1520
|
+
for (let i of node2.proxyOf.nodes) {
|
|
1521
|
+
markTreeDirty(i);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
class Container extends Node {
|
|
1526
|
+
append(...children) {
|
|
1527
|
+
for (let child of children) {
|
|
1528
|
+
let nodes = this.normalize(child, this.last);
|
|
1529
|
+
for (let node2 of nodes) this.proxyOf.nodes.push(node2);
|
|
1530
|
+
}
|
|
1531
|
+
this.markDirty();
|
|
1532
|
+
return this;
|
|
1533
|
+
}
|
|
1534
|
+
cleanRaws(keepBetween) {
|
|
1535
|
+
super.cleanRaws(keepBetween);
|
|
1536
|
+
if (this.nodes) {
|
|
1537
|
+
for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
each(callback) {
|
|
1541
|
+
if (!this.proxyOf.nodes) return void 0;
|
|
1542
|
+
let iterator = this.getIterator();
|
|
1543
|
+
let index, result2;
|
|
1544
|
+
while (this.indexes[iterator] < this.proxyOf.nodes.length) {
|
|
1545
|
+
index = this.indexes[iterator];
|
|
1546
|
+
result2 = callback(this.proxyOf.nodes[index], index);
|
|
1547
|
+
if (result2 === false) break;
|
|
1548
|
+
this.indexes[iterator] += 1;
|
|
1549
|
+
}
|
|
1550
|
+
delete this.indexes[iterator];
|
|
1551
|
+
return result2;
|
|
1552
|
+
}
|
|
1553
|
+
every(condition) {
|
|
1554
|
+
return this.nodes.every(condition);
|
|
1555
|
+
}
|
|
1556
|
+
getIterator() {
|
|
1557
|
+
if (!this.lastEach) this.lastEach = 0;
|
|
1558
|
+
if (!this.indexes) this.indexes = {};
|
|
1559
|
+
this.lastEach += 1;
|
|
1560
|
+
let iterator = this.lastEach;
|
|
1561
|
+
this.indexes[iterator] = 0;
|
|
1562
|
+
return iterator;
|
|
1563
|
+
}
|
|
1564
|
+
getProxyProcessor() {
|
|
1565
|
+
return {
|
|
1566
|
+
get(node2, prop) {
|
|
1567
|
+
if (prop === "proxyOf") {
|
|
1568
|
+
return node2;
|
|
1569
|
+
} else if (!node2[prop]) {
|
|
1570
|
+
return node2[prop];
|
|
1571
|
+
} else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
|
|
1572
|
+
return (...args) => {
|
|
1573
|
+
return node2[prop](
|
|
1574
|
+
...args.map((i) => {
|
|
1575
|
+
if (typeof i === "function") {
|
|
1576
|
+
return (child, index) => i(child.toProxy(), index);
|
|
1577
|
+
} else {
|
|
1578
|
+
return i;
|
|
1579
|
+
}
|
|
1580
|
+
})
|
|
1581
|
+
);
|
|
1582
|
+
};
|
|
1583
|
+
} else if (prop === "every" || prop === "some") {
|
|
1584
|
+
return (cb) => {
|
|
1585
|
+
return node2[prop](
|
|
1586
|
+
(child, ...other) => cb(child.toProxy(), ...other)
|
|
1587
|
+
);
|
|
1588
|
+
};
|
|
1589
|
+
} else if (prop === "root") {
|
|
1590
|
+
return () => node2.root().toProxy();
|
|
1591
|
+
} else if (prop === "nodes") {
|
|
1592
|
+
return node2.nodes.map((i) => i.toProxy());
|
|
1593
|
+
} else if (prop === "first" || prop === "last") {
|
|
1594
|
+
return node2[prop].toProxy();
|
|
1595
|
+
} else {
|
|
1596
|
+
return node2[prop];
|
|
1597
|
+
}
|
|
1598
|
+
},
|
|
1599
|
+
set(node2, prop, value) {
|
|
1600
|
+
if (node2[prop] === value) return true;
|
|
1601
|
+
node2[prop] = value;
|
|
1602
|
+
if (prop === "name" || prop === "params" || prop === "selector") {
|
|
1603
|
+
node2.markDirty();
|
|
1604
|
+
}
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
index(child) {
|
|
1610
|
+
if (typeof child === "number") return child;
|
|
1611
|
+
if (child.proxyOf) child = child.proxyOf;
|
|
1612
|
+
return this.proxyOf.nodes.indexOf(child);
|
|
1613
|
+
}
|
|
1614
|
+
insertAfter(exist, add) {
|
|
1615
|
+
let existIndex = this.index(exist);
|
|
1616
|
+
let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
|
|
1617
|
+
existIndex = this.index(exist);
|
|
1618
|
+
for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
|
|
1619
|
+
let index;
|
|
1620
|
+
for (let id in this.indexes) {
|
|
1621
|
+
index = this.indexes[id];
|
|
1622
|
+
if (existIndex < index) {
|
|
1623
|
+
this.indexes[id] = index + nodes.length;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
this.markDirty();
|
|
1627
|
+
return this;
|
|
1628
|
+
}
|
|
1629
|
+
insertBefore(exist, add) {
|
|
1630
|
+
let existIndex = this.index(exist);
|
|
1631
|
+
let type = existIndex === 0 ? "prepend" : false;
|
|
1632
|
+
let nodes = this.normalize(
|
|
1633
|
+
add,
|
|
1634
|
+
this.proxyOf.nodes[existIndex],
|
|
1635
|
+
type
|
|
1636
|
+
).reverse();
|
|
1637
|
+
existIndex = this.index(exist);
|
|
1638
|
+
for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
|
|
1639
|
+
let index;
|
|
1640
|
+
for (let id in this.indexes) {
|
|
1641
|
+
index = this.indexes[id];
|
|
1642
|
+
if (existIndex <= index) {
|
|
1643
|
+
this.indexes[id] = index + nodes.length;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
this.markDirty();
|
|
1647
|
+
return this;
|
|
1648
|
+
}
|
|
1649
|
+
normalize(nodes, sample) {
|
|
1650
|
+
if (typeof nodes === "string") {
|
|
1651
|
+
nodes = cleanSource(parse(nodes).nodes);
|
|
1652
|
+
} else if (typeof nodes === "undefined") {
|
|
1653
|
+
nodes = [];
|
|
1654
|
+
} else if (Array.isArray(nodes)) {
|
|
1655
|
+
nodes = nodes.slice(0);
|
|
1656
|
+
for (let i of nodes) {
|
|
1657
|
+
if (i.parent) i.parent.removeChild(i, "ignore");
|
|
1658
|
+
}
|
|
1659
|
+
} else if (nodes.type === "root" && this.type !== "document") {
|
|
1660
|
+
nodes = nodes.nodes.slice(0);
|
|
1661
|
+
for (let i of nodes) {
|
|
1662
|
+
if (i.parent) i.parent.removeChild(i, "ignore");
|
|
1663
|
+
}
|
|
1664
|
+
} else if (nodes.type) {
|
|
1665
|
+
nodes = [nodes];
|
|
1666
|
+
} else if (nodes.prop) {
|
|
1667
|
+
if (typeof nodes.value === "undefined") {
|
|
1668
|
+
throw new Error("Value field is missed in node creation");
|
|
1669
|
+
} else if (typeof nodes.value !== "string") {
|
|
1670
|
+
nodes.value = String(nodes.value);
|
|
1671
|
+
}
|
|
1672
|
+
nodes = [new Declaration(nodes)];
|
|
1673
|
+
} else if (nodes.selector || nodes.selectors) {
|
|
1674
|
+
nodes = [new Rule(nodes)];
|
|
1675
|
+
} else if (nodes.name) {
|
|
1676
|
+
nodes = [new AtRule(nodes)];
|
|
1677
|
+
} else if (nodes.text) {
|
|
1678
|
+
nodes = [new Comment(nodes)];
|
|
1679
|
+
} else {
|
|
1680
|
+
throw new Error("Unknown node type in node creation");
|
|
1681
|
+
}
|
|
1682
|
+
let processed = nodes.map((i) => {
|
|
1683
|
+
if (!i[my]) Container.rebuild(i);
|
|
1684
|
+
i = i.proxyOf;
|
|
1685
|
+
if (i.parent) i.parent.removeChild(i);
|
|
1686
|
+
if (i[isClean]) markTreeDirty(i);
|
|
1687
|
+
if (!i.raws) i.raws = {};
|
|
1688
|
+
if (typeof i.raws.before === "undefined") {
|
|
1689
|
+
if (sample && typeof sample.raws.before !== "undefined") {
|
|
1690
|
+
i.raws.before = sample.raws.before.replace(/\S/g, "");
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
i.parent = this.proxyOf;
|
|
1694
|
+
return i;
|
|
1695
|
+
});
|
|
1696
|
+
return processed;
|
|
1697
|
+
}
|
|
1698
|
+
prepend(...children) {
|
|
1699
|
+
children = children.reverse();
|
|
1700
|
+
for (let child of children) {
|
|
1701
|
+
let nodes = this.normalize(child, this.first, "prepend").reverse();
|
|
1702
|
+
for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
|
|
1703
|
+
for (let id in this.indexes) {
|
|
1704
|
+
this.indexes[id] = this.indexes[id] + nodes.length;
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
this.markDirty();
|
|
1708
|
+
return this;
|
|
1709
|
+
}
|
|
1710
|
+
push(child) {
|
|
1711
|
+
child.parent = this;
|
|
1712
|
+
this.proxyOf.nodes.push(child);
|
|
1713
|
+
return this;
|
|
1714
|
+
}
|
|
1715
|
+
removeAll() {
|
|
1716
|
+
for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
|
|
1717
|
+
this.proxyOf.nodes = [];
|
|
1718
|
+
this.markDirty();
|
|
1719
|
+
return this;
|
|
1720
|
+
}
|
|
1721
|
+
removeChild(child) {
|
|
1722
|
+
child = this.index(child);
|
|
1723
|
+
this.proxyOf.nodes[child].parent = void 0;
|
|
1724
|
+
this.proxyOf.nodes.splice(child, 1);
|
|
1725
|
+
let index;
|
|
1726
|
+
for (let id in this.indexes) {
|
|
1727
|
+
index = this.indexes[id];
|
|
1728
|
+
if (index >= child) {
|
|
1729
|
+
this.indexes[id] = index - 1;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
this.markDirty();
|
|
1733
|
+
return this;
|
|
1734
|
+
}
|
|
1735
|
+
replaceValues(pattern, opts, callback) {
|
|
1736
|
+
if (!callback) {
|
|
1737
|
+
callback = opts;
|
|
1738
|
+
opts = {};
|
|
1739
|
+
}
|
|
1740
|
+
this.walkDecls((decl) => {
|
|
1741
|
+
if (opts.props && !opts.props.includes(decl.prop)) return;
|
|
1742
|
+
if (opts.fast && !decl.value.includes(opts.fast)) return;
|
|
1743
|
+
decl.value = decl.value.replace(pattern, callback);
|
|
1744
|
+
});
|
|
1745
|
+
this.markDirty();
|
|
1746
|
+
return this;
|
|
1747
|
+
}
|
|
1748
|
+
some(condition) {
|
|
1749
|
+
return this.nodes.some(condition);
|
|
1750
|
+
}
|
|
1751
|
+
walk(callback) {
|
|
1752
|
+
return this.each((child, i) => {
|
|
1753
|
+
let result2;
|
|
1754
|
+
try {
|
|
1755
|
+
result2 = callback(child, i);
|
|
1756
|
+
} catch (e) {
|
|
1757
|
+
throw child.addToError(e);
|
|
1758
|
+
}
|
|
1759
|
+
if (result2 !== false && child.walk) {
|
|
1760
|
+
result2 = child.walk(callback);
|
|
1761
|
+
}
|
|
1762
|
+
return result2;
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
walkAtRules(name, callback) {
|
|
1766
|
+
if (!callback) {
|
|
1767
|
+
callback = name;
|
|
1768
|
+
return this.walk((child, i) => {
|
|
1769
|
+
if (child.type === "atrule") {
|
|
1770
|
+
return callback(child, i);
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
if (name instanceof RegExp) {
|
|
1775
|
+
return this.walk((child, i) => {
|
|
1776
|
+
if (child.type === "atrule" && name.test(child.name)) {
|
|
1777
|
+
return callback(child, i);
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
return this.walk((child, i) => {
|
|
1782
|
+
if (child.type === "atrule" && child.name === name) {
|
|
1783
|
+
return callback(child, i);
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
walkComments(callback) {
|
|
1788
|
+
return this.walk((child, i) => {
|
|
1789
|
+
if (child.type === "comment") {
|
|
1790
|
+
return callback(child, i);
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
walkDecls(prop, callback) {
|
|
1795
|
+
if (!callback) {
|
|
1796
|
+
callback = prop;
|
|
1797
|
+
return this.walk((child, i) => {
|
|
1798
|
+
if (child.type === "decl") {
|
|
1799
|
+
return callback(child, i);
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
if (prop instanceof RegExp) {
|
|
1804
|
+
return this.walk((child, i) => {
|
|
1805
|
+
if (child.type === "decl" && prop.test(child.prop)) {
|
|
1806
|
+
return callback(child, i);
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
return this.walk((child, i) => {
|
|
1811
|
+
if (child.type === "decl" && child.prop === prop) {
|
|
1812
|
+
return callback(child, i);
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
walkRules(selector, callback) {
|
|
1817
|
+
if (!callback) {
|
|
1818
|
+
callback = selector;
|
|
1819
|
+
return this.walk((child, i) => {
|
|
1820
|
+
if (child.type === "rule") {
|
|
1821
|
+
return callback(child, i);
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
if (selector instanceof RegExp) {
|
|
1826
|
+
return this.walk((child, i) => {
|
|
1827
|
+
if (child.type === "rule" && selector.test(child.selector)) {
|
|
1828
|
+
return callback(child, i);
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
return this.walk((child, i) => {
|
|
1833
|
+
if (child.type === "rule" && child.selector === selector) {
|
|
1834
|
+
return callback(child, i);
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
get first() {
|
|
1839
|
+
if (!this.proxyOf.nodes) return void 0;
|
|
1840
|
+
return this.proxyOf.nodes[0];
|
|
1841
|
+
}
|
|
1842
|
+
get last() {
|
|
1843
|
+
if (!this.proxyOf.nodes) return void 0;
|
|
1844
|
+
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
Container.registerParse = (dependant) => {
|
|
1848
|
+
parse = dependant;
|
|
1849
|
+
};
|
|
1850
|
+
Container.registerRule = (dependant) => {
|
|
1851
|
+
Rule = dependant;
|
|
1852
|
+
};
|
|
1853
|
+
Container.registerAtRule = (dependant) => {
|
|
1854
|
+
AtRule = dependant;
|
|
1855
|
+
};
|
|
1856
|
+
Container.registerRoot = (dependant) => {
|
|
1857
|
+
Root = dependant;
|
|
1858
|
+
};
|
|
1859
|
+
container = Container;
|
|
1860
|
+
Container.default = Container;
|
|
1861
|
+
Container.rebuild = (node2) => {
|
|
1862
|
+
if (node2.type === "atrule") {
|
|
1863
|
+
Object.setPrototypeOf(node2, AtRule.prototype);
|
|
1864
|
+
} else if (node2.type === "rule") {
|
|
1865
|
+
Object.setPrototypeOf(node2, Rule.prototype);
|
|
1866
|
+
} else if (node2.type === "decl") {
|
|
1867
|
+
Object.setPrototypeOf(node2, Declaration.prototype);
|
|
1868
|
+
} else if (node2.type === "comment") {
|
|
1869
|
+
Object.setPrototypeOf(node2, Comment.prototype);
|
|
1870
|
+
} else if (node2.type === "root") {
|
|
1871
|
+
Object.setPrototypeOf(node2, Root.prototype);
|
|
1872
|
+
}
|
|
1873
|
+
node2[my] = true;
|
|
1874
|
+
if (node2.nodes) {
|
|
1875
|
+
node2.nodes.forEach((child) => {
|
|
1876
|
+
Container.rebuild(child);
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
return container;
|
|
1881
|
+
}
|
|
1882
|
+
var atRule;
|
|
1883
|
+
var hasRequiredAtRule;
|
|
1884
|
+
function requireAtRule() {
|
|
1885
|
+
if (hasRequiredAtRule) return atRule;
|
|
1886
|
+
hasRequiredAtRule = 1;
|
|
1887
|
+
let Container = requireContainer();
|
|
1888
|
+
class AtRule extends Container {
|
|
1889
|
+
constructor(defaults) {
|
|
1890
|
+
super(defaults);
|
|
1891
|
+
this.type = "atrule";
|
|
1892
|
+
}
|
|
1893
|
+
append(...children) {
|
|
1894
|
+
if (!this.proxyOf.nodes) this.nodes = [];
|
|
1895
|
+
return super.append(...children);
|
|
1896
|
+
}
|
|
1897
|
+
prepend(...children) {
|
|
1898
|
+
if (!this.proxyOf.nodes) this.nodes = [];
|
|
1899
|
+
return super.prepend(...children);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
atRule = AtRule;
|
|
1903
|
+
AtRule.default = AtRule;
|
|
1904
|
+
Container.registerAtRule(AtRule);
|
|
1905
|
+
return atRule;
|
|
1906
|
+
}
|
|
1907
|
+
var document2;
|
|
1908
|
+
var hasRequiredDocument;
|
|
1909
|
+
function requireDocument() {
|
|
1910
|
+
if (hasRequiredDocument) return document2;
|
|
1911
|
+
hasRequiredDocument = 1;
|
|
1912
|
+
let Container = requireContainer();
|
|
1913
|
+
let LazyResult, Processor;
|
|
1914
|
+
class Document extends Container {
|
|
1915
|
+
constructor(defaults) {
|
|
1916
|
+
super(__spreadValues({ type: "document" }, defaults));
|
|
1917
|
+
if (!this.nodes) {
|
|
1918
|
+
this.nodes = [];
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
toResult(opts = {}) {
|
|
1922
|
+
let lazy = new LazyResult(new Processor(), this, opts);
|
|
1923
|
+
return lazy.stringify();
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
Document.registerLazyResult = (dependant) => {
|
|
1927
|
+
LazyResult = dependant;
|
|
1928
|
+
};
|
|
1929
|
+
Document.registerProcessor = (dependant) => {
|
|
1930
|
+
Processor = dependant;
|
|
1931
|
+
};
|
|
1932
|
+
document2 = Document;
|
|
1933
|
+
Document.default = Document;
|
|
1934
|
+
return document2;
|
|
1935
|
+
}
|
|
1936
|
+
var nonSecure;
|
|
1937
|
+
var hasRequiredNonSecure;
|
|
1938
|
+
function requireNonSecure() {
|
|
1939
|
+
if (hasRequiredNonSecure) return nonSecure;
|
|
1940
|
+
hasRequiredNonSecure = 1;
|
|
1941
|
+
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1942
|
+
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
1943
|
+
return (size = defaultSize) => {
|
|
1944
|
+
let id = "";
|
|
1945
|
+
let i = size | 0;
|
|
1946
|
+
while (i--) {
|
|
1947
|
+
id += alphabet[Math.random() * alphabet.length | 0];
|
|
1948
|
+
}
|
|
1949
|
+
return id;
|
|
1950
|
+
};
|
|
1951
|
+
};
|
|
1952
|
+
let nanoid = (size = 21) => {
|
|
1953
|
+
let id = "";
|
|
1954
|
+
let i = size | 0;
|
|
1955
|
+
while (i--) {
|
|
1956
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
1957
|
+
}
|
|
1958
|
+
return id;
|
|
1959
|
+
};
|
|
1960
|
+
nonSecure = { nanoid, customAlphabet };
|
|
1961
|
+
return nonSecure;
|
|
1962
|
+
}
|
|
1963
|
+
var previousMap;
|
|
1964
|
+
var hasRequiredPreviousMap;
|
|
1965
|
+
function requirePreviousMap() {
|
|
1966
|
+
if (hasRequiredPreviousMap) return previousMap;
|
|
1967
|
+
hasRequiredPreviousMap = 1;
|
|
1968
|
+
let { existsSync, readFileSync } = require$$2;
|
|
1969
|
+
let { dirname, join } = require$$2;
|
|
1970
|
+
let { SourceMapConsumer, SourceMapGenerator } = require$$2;
|
|
1971
|
+
function fromBase64(str) {
|
|
1972
|
+
if (Buffer) {
|
|
1973
|
+
return Buffer.from(str, "base64").toString();
|
|
1974
|
+
} else {
|
|
1975
|
+
return window.atob(str);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
class PreviousMap {
|
|
1979
|
+
constructor(css, opts) {
|
|
1980
|
+
if (opts.map === false) return;
|
|
1981
|
+
this.loadAnnotation(css);
|
|
1982
|
+
this.inline = this.startWith(this.annotation, "data:");
|
|
1983
|
+
let prev = opts.map ? opts.map.prev : void 0;
|
|
1984
|
+
let text = this.loadMap(opts.from, prev);
|
|
1985
|
+
if (!this.mapFile && opts.from) {
|
|
1986
|
+
this.mapFile = opts.from;
|
|
1987
|
+
}
|
|
1988
|
+
if (this.mapFile) this.root = dirname(this.mapFile);
|
|
1989
|
+
if (text) this.text = text;
|
|
1990
|
+
}
|
|
1991
|
+
consumer() {
|
|
1992
|
+
if (!this.consumerCache) {
|
|
1993
|
+
this.consumerCache = new SourceMapConsumer(this.text);
|
|
1994
|
+
}
|
|
1995
|
+
return this.consumerCache;
|
|
1996
|
+
}
|
|
1997
|
+
decodeInline(text) {
|
|
1998
|
+
let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
|
|
1999
|
+
let baseUri = /^data:application\/json;base64,/;
|
|
2000
|
+
let charsetUri = /^data:application\/json;charset=utf-?8,/;
|
|
2001
|
+
let uri = /^data:application\/json,/;
|
|
2002
|
+
let uriMatch = text.match(charsetUri) || text.match(uri);
|
|
2003
|
+
if (uriMatch) {
|
|
2004
|
+
return decodeURIComponent(text.substr(uriMatch[0].length));
|
|
2005
|
+
}
|
|
2006
|
+
let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
|
|
2007
|
+
if (baseUriMatch) {
|
|
2008
|
+
return fromBase64(text.substr(baseUriMatch[0].length));
|
|
2009
|
+
}
|
|
2010
|
+
let encoding = text.match(/data:application\/json;([^,]+),/)[1];
|
|
2011
|
+
throw new Error("Unsupported source map encoding " + encoding);
|
|
2012
|
+
}
|
|
2013
|
+
getAnnotationURL(sourceMapString) {
|
|
2014
|
+
return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
|
|
2015
|
+
}
|
|
2016
|
+
isMap(map) {
|
|
2017
|
+
if (typeof map !== "object") return false;
|
|
2018
|
+
return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
|
|
2019
|
+
}
|
|
2020
|
+
loadAnnotation(css) {
|
|
2021
|
+
let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
|
|
2022
|
+
if (!comments) return;
|
|
2023
|
+
let start = css.lastIndexOf(comments.pop());
|
|
2024
|
+
let end = css.indexOf("*/", start);
|
|
2025
|
+
if (start > -1 && end > -1) {
|
|
2026
|
+
this.annotation = this.getAnnotationURL(css.substring(start, end));
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
loadFile(path) {
|
|
2030
|
+
this.root = dirname(path);
|
|
2031
|
+
if (existsSync(path)) {
|
|
2032
|
+
this.mapFile = path;
|
|
2033
|
+
return readFileSync(path, "utf-8").toString().trim();
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
loadMap(file, prev) {
|
|
2037
|
+
if (prev === false) return false;
|
|
2038
|
+
if (prev) {
|
|
2039
|
+
if (typeof prev === "string") {
|
|
2040
|
+
return prev;
|
|
2041
|
+
} else if (typeof prev === "function") {
|
|
2042
|
+
let prevPath = prev(file);
|
|
2043
|
+
if (prevPath) {
|
|
2044
|
+
let map = this.loadFile(prevPath);
|
|
2045
|
+
if (!map) {
|
|
2046
|
+
throw new Error(
|
|
2047
|
+
"Unable to load previous source map: " + prevPath.toString()
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
return map;
|
|
2051
|
+
}
|
|
2052
|
+
} else if (prev instanceof SourceMapConsumer) {
|
|
2053
|
+
return SourceMapGenerator.fromSourceMap(prev).toString();
|
|
2054
|
+
} else if (prev instanceof SourceMapGenerator) {
|
|
2055
|
+
return prev.toString();
|
|
2056
|
+
} else if (this.isMap(prev)) {
|
|
2057
|
+
return JSON.stringify(prev);
|
|
2058
|
+
} else {
|
|
2059
|
+
throw new Error(
|
|
2060
|
+
"Unsupported previous source map format: " + prev.toString()
|
|
2061
|
+
);
|
|
2062
|
+
}
|
|
2063
|
+
} else if (this.inline) {
|
|
2064
|
+
return this.decodeInline(this.annotation);
|
|
2065
|
+
} else if (this.annotation) {
|
|
2066
|
+
let map = this.annotation;
|
|
2067
|
+
if (file) map = join(dirname(file), map);
|
|
2068
|
+
return this.loadFile(map);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
startWith(string, start) {
|
|
2072
|
+
if (!string) return false;
|
|
2073
|
+
return string.substr(0, start.length) === start;
|
|
2074
|
+
}
|
|
2075
|
+
withContent() {
|
|
2076
|
+
return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
previousMap = PreviousMap;
|
|
2080
|
+
PreviousMap.default = PreviousMap;
|
|
2081
|
+
return previousMap;
|
|
2082
|
+
}
|
|
2083
|
+
var input;
|
|
2084
|
+
var hasRequiredInput;
|
|
2085
|
+
function requireInput() {
|
|
2086
|
+
if (hasRequiredInput) return input;
|
|
2087
|
+
hasRequiredInput = 1;
|
|
2088
|
+
let { nanoid } = /* @__PURE__ */ requireNonSecure();
|
|
2089
|
+
let { isAbsolute, resolve } = require$$2;
|
|
2090
|
+
let { SourceMapConsumer, SourceMapGenerator } = require$$2;
|
|
2091
|
+
let { fileURLToPath, pathToFileURL } = require$$2;
|
|
2092
|
+
let CssSyntaxError = requireCssSyntaxError();
|
|
2093
|
+
let PreviousMap = requirePreviousMap();
|
|
2094
|
+
let terminalHighlight = require$$2;
|
|
2095
|
+
let fromOffsetCache = Symbol("fromOffsetCache");
|
|
2096
|
+
let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
|
|
2097
|
+
let pathAvailable = Boolean(resolve && isAbsolute);
|
|
2098
|
+
class Input {
|
|
2099
|
+
constructor(css, opts = {}) {
|
|
2100
|
+
if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
|
|
2101
|
+
throw new Error(`PostCSS received ${css} instead of CSS string`);
|
|
2102
|
+
}
|
|
2103
|
+
this.css = css.toString();
|
|
2104
|
+
if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") {
|
|
2105
|
+
this.hasBOM = true;
|
|
2106
|
+
this.css = this.css.slice(1);
|
|
2107
|
+
} else {
|
|
2108
|
+
this.hasBOM = false;
|
|
2109
|
+
}
|
|
2110
|
+
this.document = this.css;
|
|
2111
|
+
if (opts.document) this.document = opts.document.toString();
|
|
2112
|
+
if (opts.from) {
|
|
2113
|
+
if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
|
|
2114
|
+
this.file = opts.from;
|
|
2115
|
+
} else {
|
|
2116
|
+
this.file = resolve(opts.from);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
if (pathAvailable && sourceMapAvailable) {
|
|
2120
|
+
let map = new PreviousMap(this.css, opts);
|
|
2121
|
+
if (map.text) {
|
|
2122
|
+
this.map = map;
|
|
2123
|
+
let file = map.consumer().file;
|
|
2124
|
+
if (!this.file && file) this.file = this.mapResolve(file);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
if (!this.file) {
|
|
2128
|
+
this.id = "<input css " + nanoid(6) + ">";
|
|
2129
|
+
}
|
|
2130
|
+
if (this.map) this.map.file = this.from;
|
|
2131
|
+
}
|
|
2132
|
+
error(message, line, column, opts = {}) {
|
|
2133
|
+
let endColumn, endLine, result2;
|
|
2134
|
+
if (line && typeof line === "object") {
|
|
2135
|
+
let start = line;
|
|
2136
|
+
let end = column;
|
|
2137
|
+
if (typeof start.offset === "number") {
|
|
2138
|
+
let pos = this.fromOffset(start.offset);
|
|
2139
|
+
line = pos.line;
|
|
2140
|
+
column = pos.col;
|
|
2141
|
+
} else {
|
|
2142
|
+
line = start.line;
|
|
2143
|
+
column = start.column;
|
|
2144
|
+
}
|
|
2145
|
+
if (typeof end.offset === "number") {
|
|
2146
|
+
let pos = this.fromOffset(end.offset);
|
|
2147
|
+
endLine = pos.line;
|
|
2148
|
+
endColumn = pos.col;
|
|
2149
|
+
} else {
|
|
2150
|
+
endLine = end.line;
|
|
2151
|
+
endColumn = end.column;
|
|
2152
|
+
}
|
|
2153
|
+
} else if (!column) {
|
|
2154
|
+
let pos = this.fromOffset(line);
|
|
2155
|
+
line = pos.line;
|
|
2156
|
+
column = pos.col;
|
|
2157
|
+
}
|
|
2158
|
+
let origin = this.origin(line, column, endLine, endColumn);
|
|
2159
|
+
if (origin) {
|
|
2160
|
+
result2 = new CssSyntaxError(
|
|
2161
|
+
message,
|
|
2162
|
+
origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
|
|
2163
|
+
origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
|
|
2164
|
+
origin.source,
|
|
2165
|
+
origin.file,
|
|
2166
|
+
opts.plugin
|
|
2167
|
+
);
|
|
2168
|
+
} else {
|
|
2169
|
+
result2 = new CssSyntaxError(
|
|
2170
|
+
message,
|
|
2171
|
+
endLine === void 0 ? line : { column, line },
|
|
2172
|
+
endLine === void 0 ? column : { column: endColumn, line: endLine },
|
|
2173
|
+
this.css,
|
|
2174
|
+
this.file,
|
|
2175
|
+
opts.plugin
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
result2.input = { column, endColumn, endLine, line, source: this.css };
|
|
2179
|
+
if (this.file) {
|
|
2180
|
+
if (pathToFileURL) {
|
|
2181
|
+
result2.input.url = pathToFileURL(this.file).toString();
|
|
2182
|
+
}
|
|
2183
|
+
result2.input.file = this.file;
|
|
2184
|
+
}
|
|
2185
|
+
return result2;
|
|
2186
|
+
}
|
|
2187
|
+
fromOffset(offset) {
|
|
2188
|
+
let lastLine, lineToIndex;
|
|
2189
|
+
if (!this[fromOffsetCache]) {
|
|
2190
|
+
let lines = this.css.split("\n");
|
|
2191
|
+
lineToIndex = new Array(lines.length);
|
|
2192
|
+
let prevIndex = 0;
|
|
2193
|
+
for (let i = 0, l = lines.length; i < l; i++) {
|
|
2194
|
+
lineToIndex[i] = prevIndex;
|
|
2195
|
+
prevIndex += lines[i].length + 1;
|
|
2196
|
+
}
|
|
2197
|
+
this[fromOffsetCache] = lineToIndex;
|
|
2198
|
+
} else {
|
|
2199
|
+
lineToIndex = this[fromOffsetCache];
|
|
2200
|
+
}
|
|
2201
|
+
lastLine = lineToIndex[lineToIndex.length - 1];
|
|
2202
|
+
let min = 0;
|
|
2203
|
+
if (offset >= lastLine) {
|
|
2204
|
+
min = lineToIndex.length - 1;
|
|
2205
|
+
} else {
|
|
2206
|
+
let max = lineToIndex.length - 2;
|
|
2207
|
+
let mid;
|
|
2208
|
+
while (min < max) {
|
|
2209
|
+
mid = min + (max - min >> 1);
|
|
2210
|
+
if (offset < lineToIndex[mid]) {
|
|
2211
|
+
max = mid - 1;
|
|
2212
|
+
} else if (offset >= lineToIndex[mid + 1]) {
|
|
2213
|
+
min = mid + 1;
|
|
2214
|
+
} else {
|
|
2215
|
+
min = mid;
|
|
2216
|
+
break;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
return {
|
|
2221
|
+
col: offset - lineToIndex[min] + 1,
|
|
2222
|
+
line: min + 1
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
mapResolve(file) {
|
|
2226
|
+
if (/^\w+:\/\//.test(file)) {
|
|
2227
|
+
return file;
|
|
2228
|
+
}
|
|
2229
|
+
return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file);
|
|
2230
|
+
}
|
|
2231
|
+
origin(line, column, endLine, endColumn) {
|
|
2232
|
+
if (!this.map) return false;
|
|
2233
|
+
let consumer = this.map.consumer();
|
|
2234
|
+
let from = consumer.originalPositionFor({ column, line });
|
|
2235
|
+
if (!from.source) return false;
|
|
2236
|
+
let to;
|
|
2237
|
+
if (typeof endLine === "number") {
|
|
2238
|
+
to = consumer.originalPositionFor({ column: endColumn, line: endLine });
|
|
2239
|
+
}
|
|
2240
|
+
let fromUrl;
|
|
2241
|
+
if (isAbsolute(from.source)) {
|
|
2242
|
+
fromUrl = pathToFileURL(from.source);
|
|
2243
|
+
} else {
|
|
2244
|
+
fromUrl = new URL(
|
|
2245
|
+
from.source,
|
|
2246
|
+
this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
|
|
2247
|
+
);
|
|
2248
|
+
}
|
|
2249
|
+
let result2 = {
|
|
2250
|
+
column: from.column,
|
|
2251
|
+
endColumn: to && to.column,
|
|
2252
|
+
endLine: to && to.line,
|
|
2253
|
+
line: from.line,
|
|
2254
|
+
url: fromUrl.toString()
|
|
2255
|
+
};
|
|
2256
|
+
if (fromUrl.protocol === "file:") {
|
|
2257
|
+
if (fileURLToPath) {
|
|
2258
|
+
result2.file = fileURLToPath(fromUrl);
|
|
2259
|
+
} else {
|
|
2260
|
+
throw new Error(`file: protocol is not available in this PostCSS build`);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
let source = consumer.sourceContentFor(from.source);
|
|
2264
|
+
if (source) result2.source = source;
|
|
2265
|
+
return result2;
|
|
2266
|
+
}
|
|
2267
|
+
toJSON() {
|
|
2268
|
+
let json = {};
|
|
2269
|
+
for (let name of ["hasBOM", "css", "file", "id"]) {
|
|
2270
|
+
if (this[name] != null) {
|
|
2271
|
+
json[name] = this[name];
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
if (this.map) {
|
|
2275
|
+
json.map = __spreadValues({}, this.map);
|
|
2276
|
+
if (json.map.consumerCache) {
|
|
2277
|
+
json.map.consumerCache = void 0;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
return json;
|
|
2281
|
+
}
|
|
2282
|
+
get from() {
|
|
2283
|
+
return this.file || this.id;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
input = Input;
|
|
2287
|
+
Input.default = Input;
|
|
2288
|
+
if (terminalHighlight && terminalHighlight.registerInput) {
|
|
2289
|
+
terminalHighlight.registerInput(Input);
|
|
2290
|
+
}
|
|
2291
|
+
return input;
|
|
2292
|
+
}
|
|
2293
|
+
var root;
|
|
2294
|
+
var hasRequiredRoot;
|
|
2295
|
+
function requireRoot() {
|
|
2296
|
+
if (hasRequiredRoot) return root;
|
|
2297
|
+
hasRequiredRoot = 1;
|
|
2298
|
+
let Container = requireContainer();
|
|
2299
|
+
let LazyResult, Processor;
|
|
2300
|
+
class Root extends Container {
|
|
2301
|
+
constructor(defaults) {
|
|
2302
|
+
super(defaults);
|
|
2303
|
+
this.type = "root";
|
|
2304
|
+
if (!this.nodes) this.nodes = [];
|
|
2305
|
+
}
|
|
2306
|
+
normalize(child, sample, type) {
|
|
2307
|
+
let nodes = super.normalize(child);
|
|
2308
|
+
if (sample) {
|
|
2309
|
+
if (type === "prepend") {
|
|
2310
|
+
if (this.nodes.length > 1) {
|
|
2311
|
+
sample.raws.before = this.nodes[1].raws.before;
|
|
2312
|
+
} else {
|
|
2313
|
+
delete sample.raws.before;
|
|
2314
|
+
}
|
|
2315
|
+
} else if (this.first !== sample) {
|
|
2316
|
+
for (let node2 of nodes) {
|
|
2317
|
+
node2.raws.before = sample.raws.before;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
return nodes;
|
|
2322
|
+
}
|
|
2323
|
+
removeChild(child, ignore) {
|
|
2324
|
+
let index = this.index(child);
|
|
2325
|
+
if (!ignore && index === 0 && this.nodes.length > 1) {
|
|
2326
|
+
this.nodes[1].raws.before = this.nodes[index].raws.before;
|
|
2327
|
+
}
|
|
2328
|
+
return super.removeChild(child);
|
|
2329
|
+
}
|
|
2330
|
+
toResult(opts = {}) {
|
|
2331
|
+
let lazy = new LazyResult(new Processor(), this, opts);
|
|
2332
|
+
return lazy.stringify();
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
Root.registerLazyResult = (dependant) => {
|
|
2336
|
+
LazyResult = dependant;
|
|
2337
|
+
};
|
|
2338
|
+
Root.registerProcessor = (dependant) => {
|
|
2339
|
+
Processor = dependant;
|
|
2340
|
+
};
|
|
2341
|
+
root = Root;
|
|
2342
|
+
Root.default = Root;
|
|
2343
|
+
Container.registerRoot(Root);
|
|
2344
|
+
return root;
|
|
2345
|
+
}
|
|
2346
|
+
var list_1;
|
|
2347
|
+
var hasRequiredList;
|
|
2348
|
+
function requireList() {
|
|
2349
|
+
if (hasRequiredList) return list_1;
|
|
2350
|
+
hasRequiredList = 1;
|
|
2351
|
+
let list = {
|
|
2352
|
+
comma(string) {
|
|
2353
|
+
return list.split(string, [","], true);
|
|
2354
|
+
},
|
|
2355
|
+
space(string) {
|
|
2356
|
+
let spaces = [" ", "\n", " "];
|
|
2357
|
+
return list.split(string, spaces);
|
|
2358
|
+
},
|
|
2359
|
+
split(string, separators, last) {
|
|
2360
|
+
let array = [];
|
|
2361
|
+
let current = "";
|
|
2362
|
+
let split = false;
|
|
2363
|
+
let func = 0;
|
|
2364
|
+
let inQuote = false;
|
|
2365
|
+
let prevQuote = "";
|
|
2366
|
+
let escape = false;
|
|
2367
|
+
for (let letter of string) {
|
|
2368
|
+
if (escape) {
|
|
2369
|
+
escape = false;
|
|
2370
|
+
} else if (letter === "\\") {
|
|
2371
|
+
escape = true;
|
|
2372
|
+
} else if (inQuote) {
|
|
2373
|
+
if (letter === prevQuote) {
|
|
2374
|
+
inQuote = false;
|
|
2375
|
+
}
|
|
2376
|
+
} else if (letter === '"' || letter === "'") {
|
|
2377
|
+
inQuote = true;
|
|
2378
|
+
prevQuote = letter;
|
|
2379
|
+
} else if (letter === "(") {
|
|
2380
|
+
func += 1;
|
|
2381
|
+
} else if (letter === ")") {
|
|
2382
|
+
if (func > 0) func -= 1;
|
|
2383
|
+
} else if (func === 0) {
|
|
2384
|
+
if (separators.includes(letter)) split = true;
|
|
2385
|
+
}
|
|
2386
|
+
if (split) {
|
|
2387
|
+
if (current !== "") array.push(current.trim());
|
|
2388
|
+
current = "";
|
|
2389
|
+
split = false;
|
|
2390
|
+
} else {
|
|
2391
|
+
current += letter;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
if (last || current !== "") array.push(current.trim());
|
|
2395
|
+
return array;
|
|
2396
|
+
}
|
|
2397
|
+
};
|
|
2398
|
+
list_1 = list;
|
|
2399
|
+
list.default = list;
|
|
2400
|
+
return list_1;
|
|
2401
|
+
}
|
|
2402
|
+
var rule;
|
|
2403
|
+
var hasRequiredRule;
|
|
2404
|
+
function requireRule() {
|
|
2405
|
+
if (hasRequiredRule) return rule;
|
|
2406
|
+
hasRequiredRule = 1;
|
|
2407
|
+
let Container = requireContainer();
|
|
2408
|
+
let list = requireList();
|
|
2409
|
+
class Rule extends Container {
|
|
2410
|
+
constructor(defaults) {
|
|
2411
|
+
super(defaults);
|
|
2412
|
+
this.type = "rule";
|
|
2413
|
+
if (!this.nodes) this.nodes = [];
|
|
2414
|
+
}
|
|
2415
|
+
get selectors() {
|
|
2416
|
+
return list.comma(this.selector);
|
|
2417
|
+
}
|
|
2418
|
+
set selectors(values) {
|
|
2419
|
+
let match = this.selector ? this.selector.match(/,\s*/) : null;
|
|
2420
|
+
let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
|
|
2421
|
+
this.selector = values.join(sep);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
rule = Rule;
|
|
2425
|
+
Rule.default = Rule;
|
|
2426
|
+
Container.registerRule(Rule);
|
|
2427
|
+
return rule;
|
|
2428
|
+
}
|
|
2429
|
+
var fromJSON_1;
|
|
2430
|
+
var hasRequiredFromJSON;
|
|
2431
|
+
function requireFromJSON() {
|
|
2432
|
+
if (hasRequiredFromJSON) return fromJSON_1;
|
|
2433
|
+
hasRequiredFromJSON = 1;
|
|
2434
|
+
let AtRule = requireAtRule();
|
|
2435
|
+
let Comment = requireComment();
|
|
2436
|
+
let Declaration = requireDeclaration();
|
|
2437
|
+
let Input = requireInput();
|
|
2438
|
+
let PreviousMap = requirePreviousMap();
|
|
2439
|
+
let Root = requireRoot();
|
|
2440
|
+
let Rule = requireRule();
|
|
2441
|
+
function fromJSON(json, inputs) {
|
|
2442
|
+
if (Array.isArray(json)) return json.map((n) => fromJSON(n));
|
|
2443
|
+
let _a = json, { inputs: ownInputs } = _a, defaults = __objRest(_a, ["inputs"]);
|
|
2444
|
+
if (ownInputs) {
|
|
2445
|
+
inputs = [];
|
|
2446
|
+
for (let input2 of ownInputs) {
|
|
2447
|
+
let inputHydrated = __spreadProps(__spreadValues({}, input2), { __proto__: Input.prototype });
|
|
2448
|
+
if (inputHydrated.map) {
|
|
2449
|
+
inputHydrated.map = __spreadProps(__spreadValues({}, inputHydrated.map), {
|
|
2450
|
+
__proto__: PreviousMap.prototype
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
inputs.push(inputHydrated);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
if (defaults.nodes) {
|
|
2457
|
+
defaults.nodes = json.nodes.map((n) => fromJSON(n, inputs));
|
|
2458
|
+
}
|
|
2459
|
+
if (defaults.source) {
|
|
2460
|
+
let _b = defaults.source, { inputId } = _b, source = __objRest(_b, ["inputId"]);
|
|
2461
|
+
defaults.source = source;
|
|
2462
|
+
if (inputId != null) {
|
|
2463
|
+
defaults.source.input = inputs[inputId];
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
if (defaults.type === "root") {
|
|
2467
|
+
return new Root(defaults);
|
|
2468
|
+
} else if (defaults.type === "decl") {
|
|
2469
|
+
return new Declaration(defaults);
|
|
2470
|
+
} else if (defaults.type === "rule") {
|
|
2471
|
+
return new Rule(defaults);
|
|
2472
|
+
} else if (defaults.type === "comment") {
|
|
2473
|
+
return new Comment(defaults);
|
|
2474
|
+
} else if (defaults.type === "atrule") {
|
|
2475
|
+
return new AtRule(defaults);
|
|
2476
|
+
} else {
|
|
2477
|
+
throw new Error("Unknown node type: " + json.type);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
fromJSON_1 = fromJSON;
|
|
2481
|
+
fromJSON.default = fromJSON;
|
|
2482
|
+
return fromJSON_1;
|
|
2483
|
+
}
|
|
2484
|
+
var mapGenerator;
|
|
2485
|
+
var hasRequiredMapGenerator;
|
|
2486
|
+
function requireMapGenerator() {
|
|
2487
|
+
if (hasRequiredMapGenerator) return mapGenerator;
|
|
2488
|
+
hasRequiredMapGenerator = 1;
|
|
2489
|
+
let { dirname, relative, resolve, sep } = require$$2;
|
|
2490
|
+
let { SourceMapConsumer, SourceMapGenerator } = require$$2;
|
|
2491
|
+
let { pathToFileURL } = require$$2;
|
|
2492
|
+
let Input = requireInput();
|
|
2493
|
+
let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
|
|
2494
|
+
let pathAvailable = Boolean(dirname && resolve && relative && sep);
|
|
2495
|
+
class MapGenerator {
|
|
2496
|
+
constructor(stringify, root2, opts, cssString) {
|
|
2497
|
+
this.stringify = stringify;
|
|
2498
|
+
this.mapOpts = opts.map || {};
|
|
2499
|
+
this.root = root2;
|
|
2500
|
+
this.opts = opts;
|
|
2501
|
+
this.css = cssString;
|
|
2502
|
+
this.originalCSS = cssString;
|
|
2503
|
+
this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
|
|
2504
|
+
this.memoizedFileURLs = /* @__PURE__ */ new Map();
|
|
2505
|
+
this.memoizedPaths = /* @__PURE__ */ new Map();
|
|
2506
|
+
this.memoizedURLs = /* @__PURE__ */ new Map();
|
|
2507
|
+
}
|
|
2508
|
+
addAnnotation() {
|
|
2509
|
+
let content;
|
|
2510
|
+
if (this.isInline()) {
|
|
2511
|
+
content = "data:application/json;base64," + this.toBase64(this.map.toString());
|
|
2512
|
+
} else if (typeof this.mapOpts.annotation === "string") {
|
|
2513
|
+
content = this.mapOpts.annotation;
|
|
2514
|
+
} else if (typeof this.mapOpts.annotation === "function") {
|
|
2515
|
+
content = this.mapOpts.annotation(this.opts.to, this.root);
|
|
2516
|
+
} else {
|
|
2517
|
+
content = this.outputFile() + ".map";
|
|
2518
|
+
}
|
|
2519
|
+
let eol = "\n";
|
|
2520
|
+
if (this.css.includes("\r\n")) eol = "\r\n";
|
|
2521
|
+
this.css += eol + "/*# sourceMappingURL=" + content + " */";
|
|
2522
|
+
}
|
|
2523
|
+
applyPrevMaps() {
|
|
2524
|
+
for (let prev of this.previous()) {
|
|
2525
|
+
let from = this.toUrl(this.path(prev.file));
|
|
2526
|
+
let root2 = prev.root || dirname(prev.file);
|
|
2527
|
+
let map;
|
|
2528
|
+
if (this.mapOpts.sourcesContent === false) {
|
|
2529
|
+
map = new SourceMapConsumer(prev.text);
|
|
2530
|
+
if (map.sourcesContent) {
|
|
2531
|
+
map.sourcesContent = null;
|
|
2532
|
+
}
|
|
2533
|
+
} else {
|
|
2534
|
+
map = prev.consumer();
|
|
2535
|
+
}
|
|
2536
|
+
this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
clearAnnotation() {
|
|
2540
|
+
if (this.mapOpts.annotation === false) return;
|
|
2541
|
+
if (this.root) {
|
|
2542
|
+
let node2;
|
|
2543
|
+
for (let i = this.root.nodes.length - 1; i >= 0; i--) {
|
|
2544
|
+
node2 = this.root.nodes[i];
|
|
2545
|
+
if (node2.type !== "comment") continue;
|
|
2546
|
+
if (node2.text.startsWith("# sourceMappingURL=")) {
|
|
2547
|
+
this.root.removeChild(i);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
} else if (this.css) {
|
|
2551
|
+
this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, "");
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
generate() {
|
|
2555
|
+
this.clearAnnotation();
|
|
2556
|
+
if (pathAvailable && sourceMapAvailable && this.isMap()) {
|
|
2557
|
+
return this.generateMap();
|
|
2558
|
+
} else {
|
|
2559
|
+
let result2 = "";
|
|
2560
|
+
this.stringify(this.root, (i) => {
|
|
2561
|
+
result2 += i;
|
|
2562
|
+
});
|
|
2563
|
+
return [result2];
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
generateMap() {
|
|
2567
|
+
if (this.root) {
|
|
2568
|
+
this.generateString();
|
|
2569
|
+
} else if (this.previous().length === 1) {
|
|
2570
|
+
let prev = this.previous()[0].consumer();
|
|
2571
|
+
prev.file = this.outputFile();
|
|
2572
|
+
this.map = SourceMapGenerator.fromSourceMap(prev, {
|
|
2573
|
+
ignoreInvalidMapping: true
|
|
2574
|
+
});
|
|
2575
|
+
} else {
|
|
2576
|
+
this.map = new SourceMapGenerator({
|
|
2577
|
+
file: this.outputFile(),
|
|
2578
|
+
ignoreInvalidMapping: true
|
|
2579
|
+
});
|
|
2580
|
+
this.map.addMapping({
|
|
2581
|
+
generated: { column: 0, line: 1 },
|
|
2582
|
+
original: { column: 0, line: 1 },
|
|
2583
|
+
source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
if (this.isSourcesContent()) this.setSourcesContent();
|
|
2587
|
+
if (this.root && this.previous().length > 0) this.applyPrevMaps();
|
|
2588
|
+
if (this.isAnnotation()) this.addAnnotation();
|
|
2589
|
+
if (this.isInline()) {
|
|
2590
|
+
return [this.css];
|
|
2591
|
+
} else {
|
|
2592
|
+
return [this.css, this.map];
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
generateString() {
|
|
2596
|
+
this.css = "";
|
|
2597
|
+
this.map = new SourceMapGenerator({
|
|
2598
|
+
file: this.outputFile(),
|
|
2599
|
+
ignoreInvalidMapping: true
|
|
2600
|
+
});
|
|
2601
|
+
let line = 1;
|
|
2602
|
+
let column = 1;
|
|
2603
|
+
let noSource = "<no source>";
|
|
2604
|
+
let mapping = {
|
|
2605
|
+
generated: { column: 0, line: 0 },
|
|
2606
|
+
original: { column: 0, line: 0 },
|
|
2607
|
+
source: ""
|
|
2608
|
+
};
|
|
2609
|
+
let last, lines;
|
|
2610
|
+
this.stringify(this.root, (str, node2, type) => {
|
|
2611
|
+
this.css += str;
|
|
2612
|
+
if (node2 && type !== "end") {
|
|
2613
|
+
mapping.generated.line = line;
|
|
2614
|
+
mapping.generated.column = column - 1;
|
|
2615
|
+
if (node2.source && node2.source.start) {
|
|
2616
|
+
mapping.source = this.sourcePath(node2);
|
|
2617
|
+
mapping.original.line = node2.source.start.line;
|
|
2618
|
+
mapping.original.column = node2.source.start.column - 1;
|
|
2619
|
+
this.map.addMapping(mapping);
|
|
2620
|
+
} else {
|
|
2621
|
+
mapping.source = noSource;
|
|
2622
|
+
mapping.original.line = 1;
|
|
2623
|
+
mapping.original.column = 0;
|
|
2624
|
+
this.map.addMapping(mapping);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
lines = str.match(/\n/g);
|
|
2628
|
+
if (lines) {
|
|
2629
|
+
line += lines.length;
|
|
2630
|
+
last = str.lastIndexOf("\n");
|
|
2631
|
+
column = str.length - last;
|
|
2632
|
+
} else {
|
|
2633
|
+
column += str.length;
|
|
2634
|
+
}
|
|
2635
|
+
if (node2 && type !== "start") {
|
|
2636
|
+
let p = node2.parent || { raws: {} };
|
|
2637
|
+
let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
|
|
2638
|
+
if (!childless || node2 !== p.last || p.raws.semicolon) {
|
|
2639
|
+
if (node2.source && node2.source.end) {
|
|
2640
|
+
mapping.source = this.sourcePath(node2);
|
|
2641
|
+
mapping.original.line = node2.source.end.line;
|
|
2642
|
+
mapping.original.column = node2.source.end.column - 1;
|
|
2643
|
+
mapping.generated.line = line;
|
|
2644
|
+
mapping.generated.column = column - 2;
|
|
2645
|
+
this.map.addMapping(mapping);
|
|
2646
|
+
} else {
|
|
2647
|
+
mapping.source = noSource;
|
|
2648
|
+
mapping.original.line = 1;
|
|
2649
|
+
mapping.original.column = 0;
|
|
2650
|
+
mapping.generated.line = line;
|
|
2651
|
+
mapping.generated.column = column - 1;
|
|
2652
|
+
this.map.addMapping(mapping);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
isAnnotation() {
|
|
2659
|
+
if (this.isInline()) {
|
|
2660
|
+
return true;
|
|
2661
|
+
}
|
|
2662
|
+
if (typeof this.mapOpts.annotation !== "undefined") {
|
|
2663
|
+
return this.mapOpts.annotation;
|
|
2664
|
+
}
|
|
2665
|
+
if (this.previous().length) {
|
|
2666
|
+
return this.previous().some((i) => i.annotation);
|
|
2667
|
+
}
|
|
2668
|
+
return true;
|
|
2669
|
+
}
|
|
2670
|
+
isInline() {
|
|
2671
|
+
if (typeof this.mapOpts.inline !== "undefined") {
|
|
2672
|
+
return this.mapOpts.inline;
|
|
2673
|
+
}
|
|
2674
|
+
let annotation = this.mapOpts.annotation;
|
|
2675
|
+
if (typeof annotation !== "undefined" && annotation !== true) {
|
|
2676
|
+
return false;
|
|
2677
|
+
}
|
|
2678
|
+
if (this.previous().length) {
|
|
2679
|
+
return this.previous().some((i) => i.inline);
|
|
2680
|
+
}
|
|
2681
|
+
return true;
|
|
2682
|
+
}
|
|
2683
|
+
isMap() {
|
|
2684
|
+
if (typeof this.opts.map !== "undefined") {
|
|
2685
|
+
return !!this.opts.map;
|
|
2686
|
+
}
|
|
2687
|
+
return this.previous().length > 0;
|
|
2688
|
+
}
|
|
2689
|
+
isSourcesContent() {
|
|
2690
|
+
if (typeof this.mapOpts.sourcesContent !== "undefined") {
|
|
2691
|
+
return this.mapOpts.sourcesContent;
|
|
2692
|
+
}
|
|
2693
|
+
if (this.previous().length) {
|
|
2694
|
+
return this.previous().some((i) => i.withContent());
|
|
2695
|
+
}
|
|
2696
|
+
return true;
|
|
2697
|
+
}
|
|
2698
|
+
outputFile() {
|
|
2699
|
+
if (this.opts.to) {
|
|
2700
|
+
return this.path(this.opts.to);
|
|
2701
|
+
} else if (this.opts.from) {
|
|
2702
|
+
return this.path(this.opts.from);
|
|
2703
|
+
} else {
|
|
2704
|
+
return "to.css";
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
path(file) {
|
|
2708
|
+
if (this.mapOpts.absolute) return file;
|
|
2709
|
+
if (file.charCodeAt(0) === 60) return file;
|
|
2710
|
+
if (/^\w+:\/\//.test(file)) return file;
|
|
2711
|
+
let cached = this.memoizedPaths.get(file);
|
|
2712
|
+
if (cached) return cached;
|
|
2713
|
+
let from = this.opts.to ? dirname(this.opts.to) : ".";
|
|
2714
|
+
if (typeof this.mapOpts.annotation === "string") {
|
|
2715
|
+
from = dirname(resolve(from, this.mapOpts.annotation));
|
|
2716
|
+
}
|
|
2717
|
+
let path = relative(from, file);
|
|
2718
|
+
this.memoizedPaths.set(file, path);
|
|
2719
|
+
return path;
|
|
2720
|
+
}
|
|
2721
|
+
previous() {
|
|
2722
|
+
if (!this.previousMaps) {
|
|
2723
|
+
this.previousMaps = [];
|
|
2724
|
+
if (this.root) {
|
|
2725
|
+
this.root.walk((node2) => {
|
|
2726
|
+
if (node2.source && node2.source.input.map) {
|
|
2727
|
+
let map = node2.source.input.map;
|
|
2728
|
+
if (!this.previousMaps.includes(map)) {
|
|
2729
|
+
this.previousMaps.push(map);
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
} else {
|
|
2734
|
+
let input2 = new Input(this.originalCSS, this.opts);
|
|
2735
|
+
if (input2.map) this.previousMaps.push(input2.map);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
return this.previousMaps;
|
|
2739
|
+
}
|
|
2740
|
+
setSourcesContent() {
|
|
2741
|
+
let already = {};
|
|
2742
|
+
if (this.root) {
|
|
2743
|
+
this.root.walk((node2) => {
|
|
2744
|
+
if (node2.source) {
|
|
2745
|
+
let from = node2.source.input.from;
|
|
2746
|
+
if (from && !already[from]) {
|
|
2747
|
+
already[from] = true;
|
|
2748
|
+
let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
|
|
2749
|
+
this.map.setSourceContent(fromUrl, node2.source.input.css);
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
});
|
|
2753
|
+
} else if (this.css) {
|
|
2754
|
+
let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
|
|
2755
|
+
this.map.setSourceContent(from, this.css);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
sourcePath(node2) {
|
|
2759
|
+
if (this.mapOpts.from) {
|
|
2760
|
+
return this.toUrl(this.mapOpts.from);
|
|
2761
|
+
} else if (this.usesFileUrls) {
|
|
2762
|
+
return this.toFileUrl(node2.source.input.from);
|
|
2763
|
+
} else {
|
|
2764
|
+
return this.toUrl(this.path(node2.source.input.from));
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
toBase64(str) {
|
|
2768
|
+
if (Buffer) {
|
|
2769
|
+
return Buffer.from(str).toString("base64");
|
|
2770
|
+
} else {
|
|
2771
|
+
return window.btoa(unescape(encodeURIComponent(str)));
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
toFileUrl(path) {
|
|
2775
|
+
let cached = this.memoizedFileURLs.get(path);
|
|
2776
|
+
if (cached) return cached;
|
|
2777
|
+
if (pathToFileURL) {
|
|
2778
|
+
let fileURL = pathToFileURL(path).toString();
|
|
2779
|
+
this.memoizedFileURLs.set(path, fileURL);
|
|
2780
|
+
return fileURL;
|
|
2781
|
+
} else {
|
|
2782
|
+
throw new Error(
|
|
2783
|
+
"`map.absolute` option is not available in this PostCSS build"
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
toUrl(path) {
|
|
2788
|
+
let cached = this.memoizedURLs.get(path);
|
|
2789
|
+
if (cached) return cached;
|
|
2790
|
+
if (sep === "\\") {
|
|
2791
|
+
path = path.replace(/\\/g, "/");
|
|
2792
|
+
}
|
|
2793
|
+
let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
|
|
2794
|
+
this.memoizedURLs.set(path, url);
|
|
2795
|
+
return url;
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
mapGenerator = MapGenerator;
|
|
2799
|
+
return mapGenerator;
|
|
2800
|
+
}
|
|
2801
|
+
var tokenize;
|
|
2802
|
+
var hasRequiredTokenize;
|
|
2803
|
+
function requireTokenize() {
|
|
2804
|
+
if (hasRequiredTokenize) return tokenize;
|
|
2805
|
+
hasRequiredTokenize = 1;
|
|
2806
|
+
const SINGLE_QUOTE = "'".charCodeAt(0);
|
|
2807
|
+
const DOUBLE_QUOTE = '"'.charCodeAt(0);
|
|
2808
|
+
const BACKSLASH = "\\".charCodeAt(0);
|
|
2809
|
+
const SLASH = "/".charCodeAt(0);
|
|
2810
|
+
const NEWLINE = "\n".charCodeAt(0);
|
|
2811
|
+
const SPACE = " ".charCodeAt(0);
|
|
2812
|
+
const FEED = "\f".charCodeAt(0);
|
|
2813
|
+
const TAB = " ".charCodeAt(0);
|
|
2814
|
+
const CR = "\r".charCodeAt(0);
|
|
2815
|
+
const OPEN_SQUARE = "[".charCodeAt(0);
|
|
2816
|
+
const CLOSE_SQUARE = "]".charCodeAt(0);
|
|
2817
|
+
const OPEN_PARENTHESES = "(".charCodeAt(0);
|
|
2818
|
+
const CLOSE_PARENTHESES = ")".charCodeAt(0);
|
|
2819
|
+
const OPEN_CURLY = "{".charCodeAt(0);
|
|
2820
|
+
const CLOSE_CURLY = "}".charCodeAt(0);
|
|
2821
|
+
const SEMICOLON = ";".charCodeAt(0);
|
|
2822
|
+
const ASTERISK = "*".charCodeAt(0);
|
|
2823
|
+
const COLON = ":".charCodeAt(0);
|
|
2824
|
+
const AT = "@".charCodeAt(0);
|
|
2825
|
+
const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
|
|
2826
|
+
const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
|
|
2827
|
+
const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
|
|
2828
|
+
const RE_HEX_ESCAPE = /[\da-f]/i;
|
|
2829
|
+
tokenize = function tokenizer(input2, options = {}) {
|
|
2830
|
+
let css = input2.css.valueOf();
|
|
2831
|
+
let ignore = options.ignoreErrors;
|
|
2832
|
+
let code, content, escape, next, quote;
|
|
2833
|
+
let currentToken, escaped, escapePos, n, prev;
|
|
2834
|
+
let length = css.length;
|
|
2835
|
+
let pos = 0;
|
|
2836
|
+
let buffer = [];
|
|
2837
|
+
let returned = [];
|
|
2838
|
+
function position() {
|
|
2839
|
+
return pos;
|
|
2840
|
+
}
|
|
2841
|
+
function unclosed(what) {
|
|
2842
|
+
throw input2.error("Unclosed " + what, pos);
|
|
2843
|
+
}
|
|
2844
|
+
function endOfFile() {
|
|
2845
|
+
return returned.length === 0 && pos >= length;
|
|
2846
|
+
}
|
|
2847
|
+
function nextToken(opts) {
|
|
2848
|
+
if (returned.length) return returned.pop();
|
|
2849
|
+
if (pos >= length) return;
|
|
2850
|
+
let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
|
|
2851
|
+
code = css.charCodeAt(pos);
|
|
2852
|
+
switch (code) {
|
|
2853
|
+
case NEWLINE:
|
|
2854
|
+
case SPACE:
|
|
2855
|
+
case TAB:
|
|
2856
|
+
case CR:
|
|
2857
|
+
case FEED: {
|
|
2858
|
+
next = pos;
|
|
2859
|
+
do {
|
|
2860
|
+
next += 1;
|
|
2861
|
+
code = css.charCodeAt(next);
|
|
2862
|
+
} while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
|
|
2863
|
+
currentToken = ["space", css.slice(pos, next)];
|
|
2864
|
+
pos = next - 1;
|
|
2865
|
+
break;
|
|
2866
|
+
}
|
|
2867
|
+
case OPEN_SQUARE:
|
|
2868
|
+
case CLOSE_SQUARE:
|
|
2869
|
+
case OPEN_CURLY:
|
|
2870
|
+
case CLOSE_CURLY:
|
|
2871
|
+
case COLON:
|
|
2872
|
+
case SEMICOLON:
|
|
2873
|
+
case CLOSE_PARENTHESES: {
|
|
2874
|
+
let controlChar = String.fromCharCode(code);
|
|
2875
|
+
currentToken = [controlChar, controlChar, pos];
|
|
2876
|
+
break;
|
|
2877
|
+
}
|
|
2878
|
+
case OPEN_PARENTHESES: {
|
|
2879
|
+
prev = buffer.length ? buffer.pop()[1] : "";
|
|
2880
|
+
n = css.charCodeAt(pos + 1);
|
|
2881
|
+
if (prev === "url" && n !== SINGLE_QUOTE && n !== DOUBLE_QUOTE && n !== SPACE && n !== NEWLINE && n !== TAB && n !== FEED && n !== CR) {
|
|
2882
|
+
next = pos;
|
|
2883
|
+
do {
|
|
2884
|
+
escaped = false;
|
|
2885
|
+
next = css.indexOf(")", next + 1);
|
|
2886
|
+
if (next === -1) {
|
|
2887
|
+
if (ignore || ignoreUnclosed) {
|
|
2888
|
+
next = pos;
|
|
2889
|
+
break;
|
|
2890
|
+
} else {
|
|
2891
|
+
unclosed("bracket");
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
escapePos = next;
|
|
2895
|
+
while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
|
|
2896
|
+
escapePos -= 1;
|
|
2897
|
+
escaped = !escaped;
|
|
2898
|
+
}
|
|
2899
|
+
} while (escaped);
|
|
2900
|
+
currentToken = ["brackets", css.slice(pos, next + 1), pos, next];
|
|
2901
|
+
pos = next;
|
|
2902
|
+
} else {
|
|
2903
|
+
next = css.indexOf(")", pos + 1);
|
|
2904
|
+
content = css.slice(pos, next + 1);
|
|
2905
|
+
if (next === -1 || RE_BAD_BRACKET.test(content)) {
|
|
2906
|
+
currentToken = ["(", "(", pos];
|
|
2907
|
+
} else {
|
|
2908
|
+
currentToken = ["brackets", content, pos, next];
|
|
2909
|
+
pos = next;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
break;
|
|
2913
|
+
}
|
|
2914
|
+
case SINGLE_QUOTE:
|
|
2915
|
+
case DOUBLE_QUOTE: {
|
|
2916
|
+
quote = code === SINGLE_QUOTE ? "'" : '"';
|
|
2917
|
+
next = pos;
|
|
2918
|
+
do {
|
|
2919
|
+
escaped = false;
|
|
2920
|
+
next = css.indexOf(quote, next + 1);
|
|
2921
|
+
if (next === -1) {
|
|
2922
|
+
if (ignore || ignoreUnclosed) {
|
|
2923
|
+
next = pos + 1;
|
|
2924
|
+
break;
|
|
2925
|
+
} else {
|
|
2926
|
+
unclosed("string");
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
escapePos = next;
|
|
2930
|
+
while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
|
|
2931
|
+
escapePos -= 1;
|
|
2932
|
+
escaped = !escaped;
|
|
2933
|
+
}
|
|
2934
|
+
} while (escaped);
|
|
2935
|
+
currentToken = ["string", css.slice(pos, next + 1), pos, next];
|
|
2936
|
+
pos = next;
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
case AT: {
|
|
2940
|
+
RE_AT_END.lastIndex = pos + 1;
|
|
2941
|
+
RE_AT_END.test(css);
|
|
2942
|
+
if (RE_AT_END.lastIndex === 0) {
|
|
2943
|
+
next = css.length - 1;
|
|
2944
|
+
} else {
|
|
2945
|
+
next = RE_AT_END.lastIndex - 2;
|
|
2946
|
+
}
|
|
2947
|
+
currentToken = ["at-word", css.slice(pos, next + 1), pos, next];
|
|
2948
|
+
pos = next;
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2951
|
+
case BACKSLASH: {
|
|
2952
|
+
next = pos;
|
|
2953
|
+
escape = true;
|
|
2954
|
+
while (css.charCodeAt(next + 1) === BACKSLASH) {
|
|
2955
|
+
next += 1;
|
|
2956
|
+
escape = !escape;
|
|
2957
|
+
}
|
|
2958
|
+
code = css.charCodeAt(next + 1);
|
|
2959
|
+
if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
|
|
2960
|
+
next += 1;
|
|
2961
|
+
if (RE_HEX_ESCAPE.test(css.charAt(next))) {
|
|
2962
|
+
while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
|
|
2963
|
+
next += 1;
|
|
2964
|
+
}
|
|
2965
|
+
if (css.charCodeAt(next + 1) === SPACE) {
|
|
2966
|
+
next += 1;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
currentToken = ["word", css.slice(pos, next + 1), pos, next];
|
|
2971
|
+
pos = next;
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
default: {
|
|
2975
|
+
if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
|
|
2976
|
+
next = css.indexOf("*/", pos + 2) + 1;
|
|
2977
|
+
if (next === 0) {
|
|
2978
|
+
if (ignore || ignoreUnclosed) {
|
|
2979
|
+
next = css.length;
|
|
2980
|
+
} else {
|
|
2981
|
+
unclosed("comment");
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
currentToken = ["comment", css.slice(pos, next + 1), pos, next];
|
|
2985
|
+
pos = next;
|
|
2986
|
+
} else {
|
|
2987
|
+
RE_WORD_END.lastIndex = pos + 1;
|
|
2988
|
+
RE_WORD_END.test(css);
|
|
2989
|
+
if (RE_WORD_END.lastIndex === 0) {
|
|
2990
|
+
next = css.length - 1;
|
|
2991
|
+
} else {
|
|
2992
|
+
next = RE_WORD_END.lastIndex - 2;
|
|
2993
|
+
}
|
|
2994
|
+
currentToken = ["word", css.slice(pos, next + 1), pos, next];
|
|
2995
|
+
buffer.push(currentToken);
|
|
2996
|
+
pos = next;
|
|
2997
|
+
}
|
|
2998
|
+
break;
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
pos++;
|
|
3002
|
+
return currentToken;
|
|
3003
|
+
}
|
|
3004
|
+
function back(token) {
|
|
3005
|
+
returned.push(token);
|
|
3006
|
+
}
|
|
3007
|
+
return {
|
|
3008
|
+
back,
|
|
3009
|
+
endOfFile,
|
|
3010
|
+
nextToken,
|
|
3011
|
+
position
|
|
3012
|
+
};
|
|
3013
|
+
};
|
|
3014
|
+
return tokenize;
|
|
3015
|
+
}
|
|
3016
|
+
var parser;
|
|
3017
|
+
var hasRequiredParser;
|
|
3018
|
+
function requireParser() {
|
|
3019
|
+
if (hasRequiredParser) return parser;
|
|
3020
|
+
hasRequiredParser = 1;
|
|
3021
|
+
let AtRule = requireAtRule();
|
|
3022
|
+
let Comment = requireComment();
|
|
3023
|
+
let Declaration = requireDeclaration();
|
|
3024
|
+
let Root = requireRoot();
|
|
3025
|
+
let Rule = requireRule();
|
|
3026
|
+
let tokenizer = requireTokenize();
|
|
3027
|
+
const SAFE_COMMENT_NEIGHBOR = {
|
|
3028
|
+
empty: true,
|
|
3029
|
+
space: true
|
|
3030
|
+
};
|
|
3031
|
+
function findLastWithPosition(tokens) {
|
|
3032
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
3033
|
+
let token = tokens[i];
|
|
3034
|
+
let pos = token[3] || token[2];
|
|
3035
|
+
if (pos) return pos;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
class Parser {
|
|
3039
|
+
constructor(input2) {
|
|
3040
|
+
this.input = input2;
|
|
3041
|
+
this.root = new Root();
|
|
3042
|
+
this.current = this.root;
|
|
3043
|
+
this.spaces = "";
|
|
3044
|
+
this.semicolon = false;
|
|
3045
|
+
this.createTokenizer();
|
|
3046
|
+
this.root.source = { input: input2, start: { column: 1, line: 1, offset: 0 } };
|
|
3047
|
+
}
|
|
3048
|
+
atrule(token) {
|
|
3049
|
+
let node2 = new AtRule();
|
|
3050
|
+
node2.name = token[1].slice(1);
|
|
3051
|
+
if (node2.name === "") {
|
|
3052
|
+
this.unnamedAtrule(node2, token);
|
|
3053
|
+
}
|
|
3054
|
+
this.init(node2, token[2]);
|
|
3055
|
+
let type;
|
|
3056
|
+
let prev;
|
|
3057
|
+
let shift;
|
|
3058
|
+
let last = false;
|
|
3059
|
+
let open = false;
|
|
3060
|
+
let params = [];
|
|
3061
|
+
let brackets = [];
|
|
3062
|
+
while (!this.tokenizer.endOfFile()) {
|
|
3063
|
+
token = this.tokenizer.nextToken();
|
|
3064
|
+
type = token[0];
|
|
3065
|
+
if (type === "(" || type === "[") {
|
|
3066
|
+
brackets.push(type === "(" ? ")" : "]");
|
|
3067
|
+
} else if (type === "{" && brackets.length > 0) {
|
|
3068
|
+
brackets.push("}");
|
|
3069
|
+
} else if (type === brackets[brackets.length - 1]) {
|
|
3070
|
+
brackets.pop();
|
|
3071
|
+
}
|
|
3072
|
+
if (brackets.length === 0) {
|
|
3073
|
+
if (type === ";") {
|
|
3074
|
+
node2.source.end = this.getPosition(token[2]);
|
|
3075
|
+
node2.source.end.offset++;
|
|
3076
|
+
this.semicolon = true;
|
|
3077
|
+
break;
|
|
3078
|
+
} else if (type === "{") {
|
|
3079
|
+
open = true;
|
|
3080
|
+
break;
|
|
3081
|
+
} else if (type === "}") {
|
|
3082
|
+
if (params.length > 0) {
|
|
3083
|
+
shift = params.length - 1;
|
|
3084
|
+
prev = params[shift];
|
|
3085
|
+
while (prev && prev[0] === "space") {
|
|
3086
|
+
prev = params[--shift];
|
|
3087
|
+
}
|
|
3088
|
+
if (prev) {
|
|
3089
|
+
node2.source.end = this.getPosition(prev[3] || prev[2]);
|
|
3090
|
+
node2.source.end.offset++;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
this.end(token);
|
|
3094
|
+
break;
|
|
3095
|
+
} else {
|
|
3096
|
+
params.push(token);
|
|
3097
|
+
}
|
|
3098
|
+
} else {
|
|
3099
|
+
params.push(token);
|
|
3100
|
+
}
|
|
3101
|
+
if (this.tokenizer.endOfFile()) {
|
|
3102
|
+
last = true;
|
|
3103
|
+
break;
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
node2.raws.between = this.spacesAndCommentsFromEnd(params);
|
|
3107
|
+
if (params.length) {
|
|
3108
|
+
node2.raws.afterName = this.spacesAndCommentsFromStart(params);
|
|
3109
|
+
this.raw(node2, "params", params);
|
|
3110
|
+
if (last) {
|
|
3111
|
+
token = params[params.length - 1];
|
|
3112
|
+
node2.source.end = this.getPosition(token[3] || token[2]);
|
|
3113
|
+
node2.source.end.offset++;
|
|
3114
|
+
this.spaces = node2.raws.between;
|
|
3115
|
+
node2.raws.between = "";
|
|
3116
|
+
}
|
|
3117
|
+
} else {
|
|
3118
|
+
node2.raws.afterName = "";
|
|
3119
|
+
node2.params = "";
|
|
3120
|
+
}
|
|
3121
|
+
if (open) {
|
|
3122
|
+
node2.nodes = [];
|
|
3123
|
+
this.current = node2;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
checkMissedSemicolon(tokens) {
|
|
3127
|
+
let colon = this.colon(tokens);
|
|
3128
|
+
if (colon === false) return;
|
|
3129
|
+
let founded = 0;
|
|
3130
|
+
let token;
|
|
3131
|
+
for (let j = colon - 1; j >= 0; j--) {
|
|
3132
|
+
token = tokens[j];
|
|
3133
|
+
if (token[0] !== "space") {
|
|
3134
|
+
founded += 1;
|
|
3135
|
+
if (founded === 2) break;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
throw this.input.error(
|
|
3139
|
+
"Missed semicolon",
|
|
3140
|
+
token[0] === "word" ? token[3] + 1 : token[2]
|
|
3141
|
+
);
|
|
3142
|
+
}
|
|
3143
|
+
colon(tokens) {
|
|
3144
|
+
let brackets = 0;
|
|
3145
|
+
let prev, token, type;
|
|
3146
|
+
for (let [i, element] of tokens.entries()) {
|
|
3147
|
+
token = element;
|
|
3148
|
+
type = token[0];
|
|
3149
|
+
if (type === "(") {
|
|
3150
|
+
brackets += 1;
|
|
3151
|
+
}
|
|
3152
|
+
if (type === ")") {
|
|
3153
|
+
brackets -= 1;
|
|
3154
|
+
}
|
|
3155
|
+
if (brackets === 0 && type === ":") {
|
|
3156
|
+
if (!prev) {
|
|
3157
|
+
this.doubleColon(token);
|
|
3158
|
+
} else if (prev[0] === "word" && prev[1] === "progid") {
|
|
3159
|
+
continue;
|
|
3160
|
+
} else {
|
|
3161
|
+
return i;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
prev = token;
|
|
3165
|
+
}
|
|
3166
|
+
return false;
|
|
3167
|
+
}
|
|
3168
|
+
comment(token) {
|
|
3169
|
+
let node2 = new Comment();
|
|
3170
|
+
this.init(node2, token[2]);
|
|
3171
|
+
node2.source.end = this.getPosition(token[3] || token[2]);
|
|
3172
|
+
node2.source.end.offset++;
|
|
3173
|
+
let text = token[1].slice(2, -2);
|
|
3174
|
+
if (/^\s*$/.test(text)) {
|
|
3175
|
+
node2.text = "";
|
|
3176
|
+
node2.raws.left = text;
|
|
3177
|
+
node2.raws.right = "";
|
|
3178
|
+
} else {
|
|
3179
|
+
let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
|
|
3180
|
+
node2.text = match[2];
|
|
3181
|
+
node2.raws.left = match[1];
|
|
3182
|
+
node2.raws.right = match[3];
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
createTokenizer() {
|
|
3186
|
+
this.tokenizer = tokenizer(this.input);
|
|
3187
|
+
}
|
|
3188
|
+
decl(tokens, customProperty) {
|
|
3189
|
+
let node2 = new Declaration();
|
|
3190
|
+
this.init(node2, tokens[0][2]);
|
|
3191
|
+
let last = tokens[tokens.length - 1];
|
|
3192
|
+
if (last[0] === ";") {
|
|
3193
|
+
this.semicolon = true;
|
|
3194
|
+
tokens.pop();
|
|
3195
|
+
}
|
|
3196
|
+
node2.source.end = this.getPosition(
|
|
3197
|
+
last[3] || last[2] || findLastWithPosition(tokens)
|
|
3198
|
+
);
|
|
3199
|
+
node2.source.end.offset++;
|
|
3200
|
+
while (tokens[0][0] !== "word") {
|
|
3201
|
+
if (tokens.length === 1) this.unknownWord(tokens);
|
|
3202
|
+
node2.raws.before += tokens.shift()[1];
|
|
3203
|
+
}
|
|
3204
|
+
node2.source.start = this.getPosition(tokens[0][2]);
|
|
3205
|
+
node2.prop = "";
|
|
3206
|
+
while (tokens.length) {
|
|
3207
|
+
let type = tokens[0][0];
|
|
3208
|
+
if (type === ":" || type === "space" || type === "comment") {
|
|
3209
|
+
break;
|
|
3210
|
+
}
|
|
3211
|
+
node2.prop += tokens.shift()[1];
|
|
3212
|
+
}
|
|
3213
|
+
node2.raws.between = "";
|
|
3214
|
+
let token;
|
|
3215
|
+
while (tokens.length) {
|
|
3216
|
+
token = tokens.shift();
|
|
3217
|
+
if (token[0] === ":") {
|
|
3218
|
+
node2.raws.between += token[1];
|
|
3219
|
+
break;
|
|
3220
|
+
} else {
|
|
3221
|
+
if (token[0] === "word" && /\w/.test(token[1])) {
|
|
3222
|
+
this.unknownWord([token]);
|
|
3223
|
+
}
|
|
3224
|
+
node2.raws.between += token[1];
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
if (node2.prop[0] === "_" || node2.prop[0] === "*") {
|
|
3228
|
+
node2.raws.before += node2.prop[0];
|
|
3229
|
+
node2.prop = node2.prop.slice(1);
|
|
3230
|
+
}
|
|
3231
|
+
let firstSpaces = [];
|
|
3232
|
+
let next;
|
|
3233
|
+
while (tokens.length) {
|
|
3234
|
+
next = tokens[0][0];
|
|
3235
|
+
if (next !== "space" && next !== "comment") break;
|
|
3236
|
+
firstSpaces.push(tokens.shift());
|
|
3237
|
+
}
|
|
3238
|
+
this.precheckMissedSemicolon(tokens);
|
|
3239
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
3240
|
+
token = tokens[i];
|
|
3241
|
+
if (token[1].toLowerCase() === "!important") {
|
|
3242
|
+
node2.important = true;
|
|
3243
|
+
let string = this.stringFrom(tokens, i);
|
|
3244
|
+
string = this.spacesFromEnd(tokens) + string;
|
|
3245
|
+
if (string !== " !important") node2.raws.important = string;
|
|
3246
|
+
break;
|
|
3247
|
+
} else if (token[1].toLowerCase() === "important") {
|
|
3248
|
+
let cache = tokens.slice(0);
|
|
3249
|
+
let str = "";
|
|
3250
|
+
for (let j = i; j > 0; j--) {
|
|
3251
|
+
let type = cache[j][0];
|
|
3252
|
+
if (str.trim().startsWith("!") && type !== "space") {
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
str = cache.pop()[1] + str;
|
|
3256
|
+
}
|
|
3257
|
+
if (str.trim().startsWith("!")) {
|
|
3258
|
+
node2.important = true;
|
|
3259
|
+
node2.raws.important = str;
|
|
3260
|
+
tokens = cache;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (token[0] !== "space" && token[0] !== "comment") {
|
|
3264
|
+
break;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
let hasWord = tokens.some((i) => i[0] !== "space" && i[0] !== "comment");
|
|
3268
|
+
if (hasWord) {
|
|
3269
|
+
node2.raws.between += firstSpaces.map((i) => i[1]).join("");
|
|
3270
|
+
firstSpaces = [];
|
|
3271
|
+
}
|
|
3272
|
+
this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
|
|
3273
|
+
if (node2.value.includes(":") && !customProperty) {
|
|
3274
|
+
this.checkMissedSemicolon(tokens);
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
doubleColon(token) {
|
|
3278
|
+
throw this.input.error(
|
|
3279
|
+
"Double colon",
|
|
3280
|
+
{ offset: token[2] },
|
|
3281
|
+
{ offset: token[2] + token[1].length }
|
|
3282
|
+
);
|
|
3283
|
+
}
|
|
3284
|
+
emptyRule(token) {
|
|
3285
|
+
let node2 = new Rule();
|
|
3286
|
+
this.init(node2, token[2]);
|
|
3287
|
+
node2.selector = "";
|
|
3288
|
+
node2.raws.between = "";
|
|
3289
|
+
this.current = node2;
|
|
3290
|
+
}
|
|
3291
|
+
end(token) {
|
|
3292
|
+
if (this.current.nodes && this.current.nodes.length) {
|
|
3293
|
+
this.current.raws.semicolon = this.semicolon;
|
|
3294
|
+
}
|
|
3295
|
+
this.semicolon = false;
|
|
3296
|
+
this.current.raws.after = (this.current.raws.after || "") + this.spaces;
|
|
3297
|
+
this.spaces = "";
|
|
3298
|
+
if (this.current.parent) {
|
|
3299
|
+
this.current.source.end = this.getPosition(token[2]);
|
|
3300
|
+
this.current.source.end.offset++;
|
|
3301
|
+
this.current = this.current.parent;
|
|
3302
|
+
} else {
|
|
3303
|
+
this.unexpectedClose(token);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
endFile() {
|
|
3307
|
+
if (this.current.parent) this.unclosedBlock();
|
|
3308
|
+
if (this.current.nodes && this.current.nodes.length) {
|
|
3309
|
+
this.current.raws.semicolon = this.semicolon;
|
|
3310
|
+
}
|
|
3311
|
+
this.current.raws.after = (this.current.raws.after || "") + this.spaces;
|
|
3312
|
+
this.root.source.end = this.getPosition(this.tokenizer.position());
|
|
3313
|
+
}
|
|
3314
|
+
freeSemicolon(token) {
|
|
3315
|
+
this.spaces += token[1];
|
|
3316
|
+
if (this.current.nodes) {
|
|
3317
|
+
let prev = this.current.nodes[this.current.nodes.length - 1];
|
|
3318
|
+
if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
|
|
3319
|
+
prev.raws.ownSemicolon = this.spaces;
|
|
3320
|
+
this.spaces = "";
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
// Helpers
|
|
3325
|
+
getPosition(offset) {
|
|
3326
|
+
let pos = this.input.fromOffset(offset);
|
|
3327
|
+
return {
|
|
3328
|
+
column: pos.col,
|
|
3329
|
+
line: pos.line,
|
|
3330
|
+
offset
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
init(node2, offset) {
|
|
3334
|
+
this.current.push(node2);
|
|
3335
|
+
node2.source = {
|
|
3336
|
+
input: this.input,
|
|
3337
|
+
start: this.getPosition(offset)
|
|
3338
|
+
};
|
|
3339
|
+
node2.raws.before = this.spaces;
|
|
3340
|
+
this.spaces = "";
|
|
3341
|
+
if (node2.type !== "comment") this.semicolon = false;
|
|
3342
|
+
}
|
|
3343
|
+
other(start) {
|
|
3344
|
+
let end = false;
|
|
3345
|
+
let type = null;
|
|
3346
|
+
let colon = false;
|
|
3347
|
+
let bracket = null;
|
|
3348
|
+
let brackets = [];
|
|
3349
|
+
let customProperty = start[1].startsWith("--");
|
|
3350
|
+
let tokens = [];
|
|
3351
|
+
let token = start;
|
|
3352
|
+
while (token) {
|
|
3353
|
+
type = token[0];
|
|
3354
|
+
tokens.push(token);
|
|
3355
|
+
if (type === "(" || type === "[") {
|
|
3356
|
+
if (!bracket) bracket = token;
|
|
3357
|
+
brackets.push(type === "(" ? ")" : "]");
|
|
3358
|
+
} else if (customProperty && colon && type === "{") {
|
|
3359
|
+
if (!bracket) bracket = token;
|
|
3360
|
+
brackets.push("}");
|
|
3361
|
+
} else if (brackets.length === 0) {
|
|
3362
|
+
if (type === ";") {
|
|
3363
|
+
if (colon) {
|
|
3364
|
+
this.decl(tokens, customProperty);
|
|
3365
|
+
return;
|
|
3366
|
+
} else {
|
|
3367
|
+
break;
|
|
3368
|
+
}
|
|
3369
|
+
} else if (type === "{") {
|
|
3370
|
+
this.rule(tokens);
|
|
3371
|
+
return;
|
|
3372
|
+
} else if (type === "}") {
|
|
3373
|
+
this.tokenizer.back(tokens.pop());
|
|
3374
|
+
end = true;
|
|
3375
|
+
break;
|
|
3376
|
+
} else if (type === ":") {
|
|
3377
|
+
colon = true;
|
|
3378
|
+
}
|
|
3379
|
+
} else if (type === brackets[brackets.length - 1]) {
|
|
3380
|
+
brackets.pop();
|
|
3381
|
+
if (brackets.length === 0) bracket = null;
|
|
3382
|
+
}
|
|
3383
|
+
token = this.tokenizer.nextToken();
|
|
3384
|
+
}
|
|
3385
|
+
if (this.tokenizer.endOfFile()) end = true;
|
|
3386
|
+
if (brackets.length > 0) this.unclosedBracket(bracket);
|
|
3387
|
+
if (end && colon) {
|
|
3388
|
+
if (!customProperty) {
|
|
3389
|
+
while (tokens.length) {
|
|
3390
|
+
token = tokens[tokens.length - 1][0];
|
|
3391
|
+
if (token !== "space" && token !== "comment") break;
|
|
3392
|
+
this.tokenizer.back(tokens.pop());
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
this.decl(tokens, customProperty);
|
|
3396
|
+
} else {
|
|
3397
|
+
this.unknownWord(tokens);
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
parse() {
|
|
3401
|
+
let token;
|
|
3402
|
+
while (!this.tokenizer.endOfFile()) {
|
|
3403
|
+
token = this.tokenizer.nextToken();
|
|
3404
|
+
switch (token[0]) {
|
|
3405
|
+
case "space":
|
|
3406
|
+
this.spaces += token[1];
|
|
3407
|
+
break;
|
|
3408
|
+
case ";":
|
|
3409
|
+
this.freeSemicolon(token);
|
|
3410
|
+
break;
|
|
3411
|
+
case "}":
|
|
3412
|
+
this.end(token);
|
|
3413
|
+
break;
|
|
3414
|
+
case "comment":
|
|
3415
|
+
this.comment(token);
|
|
3416
|
+
break;
|
|
3417
|
+
case "at-word":
|
|
3418
|
+
this.atrule(token);
|
|
3419
|
+
break;
|
|
3420
|
+
case "{":
|
|
3421
|
+
this.emptyRule(token);
|
|
3422
|
+
break;
|
|
3423
|
+
default:
|
|
3424
|
+
this.other(token);
|
|
3425
|
+
break;
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
this.endFile();
|
|
3429
|
+
}
|
|
3430
|
+
precheckMissedSemicolon() {
|
|
3431
|
+
}
|
|
3432
|
+
raw(node2, prop, tokens, customProperty) {
|
|
3433
|
+
let token, type;
|
|
3434
|
+
let length = tokens.length;
|
|
3435
|
+
let value = "";
|
|
3436
|
+
let clean = true;
|
|
3437
|
+
let next, prev;
|
|
3438
|
+
for (let i = 0; i < length; i += 1) {
|
|
3439
|
+
token = tokens[i];
|
|
3440
|
+
type = token[0];
|
|
3441
|
+
if (type === "space" && i === length - 1 && !customProperty) {
|
|
3442
|
+
clean = false;
|
|
3443
|
+
} else if (type === "comment") {
|
|
3444
|
+
prev = tokens[i - 1] ? tokens[i - 1][0] : "empty";
|
|
3445
|
+
next = tokens[i + 1] ? tokens[i + 1][0] : "empty";
|
|
3446
|
+
if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
|
|
3447
|
+
if (value.slice(-1) === ",") {
|
|
3448
|
+
clean = false;
|
|
3449
|
+
} else {
|
|
3450
|
+
value += token[1];
|
|
3451
|
+
}
|
|
3452
|
+
} else {
|
|
3453
|
+
clean = false;
|
|
3454
|
+
}
|
|
3455
|
+
} else {
|
|
3456
|
+
value += token[1];
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
if (!clean) {
|
|
3460
|
+
let raw = tokens.reduce((all, i) => all + i[1], "");
|
|
3461
|
+
node2.raws[prop] = { raw, value };
|
|
3462
|
+
}
|
|
3463
|
+
node2[prop] = value;
|
|
3464
|
+
}
|
|
3465
|
+
rule(tokens) {
|
|
3466
|
+
tokens.pop();
|
|
3467
|
+
let node2 = new Rule();
|
|
3468
|
+
this.init(node2, tokens[0][2]);
|
|
3469
|
+
node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
|
|
3470
|
+
this.raw(node2, "selector", tokens);
|
|
3471
|
+
this.current = node2;
|
|
3472
|
+
}
|
|
3473
|
+
spacesAndCommentsFromEnd(tokens) {
|
|
3474
|
+
let lastTokenType;
|
|
3475
|
+
let spaces = "";
|
|
3476
|
+
while (tokens.length) {
|
|
3477
|
+
lastTokenType = tokens[tokens.length - 1][0];
|
|
3478
|
+
if (lastTokenType !== "space" && lastTokenType !== "comment") break;
|
|
3479
|
+
spaces = tokens.pop()[1] + spaces;
|
|
3480
|
+
}
|
|
3481
|
+
return spaces;
|
|
3482
|
+
}
|
|
3483
|
+
// Errors
|
|
3484
|
+
spacesAndCommentsFromStart(tokens) {
|
|
3485
|
+
let next;
|
|
3486
|
+
let spaces = "";
|
|
3487
|
+
while (tokens.length) {
|
|
3488
|
+
next = tokens[0][0];
|
|
3489
|
+
if (next !== "space" && next !== "comment") break;
|
|
3490
|
+
spaces += tokens.shift()[1];
|
|
3491
|
+
}
|
|
3492
|
+
return spaces;
|
|
3493
|
+
}
|
|
3494
|
+
spacesFromEnd(tokens) {
|
|
3495
|
+
let lastTokenType;
|
|
3496
|
+
let spaces = "";
|
|
3497
|
+
while (tokens.length) {
|
|
3498
|
+
lastTokenType = tokens[tokens.length - 1][0];
|
|
3499
|
+
if (lastTokenType !== "space") break;
|
|
3500
|
+
spaces = tokens.pop()[1] + spaces;
|
|
3501
|
+
}
|
|
3502
|
+
return spaces;
|
|
3503
|
+
}
|
|
3504
|
+
stringFrom(tokens, from) {
|
|
3505
|
+
let result2 = "";
|
|
3506
|
+
for (let i = from; i < tokens.length; i++) {
|
|
3507
|
+
result2 += tokens[i][1];
|
|
3508
|
+
}
|
|
3509
|
+
tokens.splice(from, tokens.length - from);
|
|
3510
|
+
return result2;
|
|
3511
|
+
}
|
|
3512
|
+
unclosedBlock() {
|
|
3513
|
+
let pos = this.current.source.start;
|
|
3514
|
+
throw this.input.error("Unclosed block", pos.line, pos.column);
|
|
3515
|
+
}
|
|
3516
|
+
unclosedBracket(bracket) {
|
|
3517
|
+
throw this.input.error(
|
|
3518
|
+
"Unclosed bracket",
|
|
3519
|
+
{ offset: bracket[2] },
|
|
3520
|
+
{ offset: bracket[2] + 1 }
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
unexpectedClose(token) {
|
|
3524
|
+
throw this.input.error(
|
|
3525
|
+
"Unexpected }",
|
|
3526
|
+
{ offset: token[2] },
|
|
3527
|
+
{ offset: token[2] + 1 }
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
unknownWord(tokens) {
|
|
3531
|
+
throw this.input.error(
|
|
3532
|
+
"Unknown word",
|
|
3533
|
+
{ offset: tokens[0][2] },
|
|
3534
|
+
{ offset: tokens[0][2] + tokens[0][1].length }
|
|
3535
|
+
);
|
|
3536
|
+
}
|
|
3537
|
+
unnamedAtrule(node2, token) {
|
|
3538
|
+
throw this.input.error(
|
|
3539
|
+
"At-rule without name",
|
|
3540
|
+
{ offset: token[2] },
|
|
3541
|
+
{ offset: token[2] + token[1].length }
|
|
3542
|
+
);
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
parser = Parser;
|
|
3546
|
+
return parser;
|
|
3547
|
+
}
|
|
3548
|
+
var parse_1;
|
|
3549
|
+
var hasRequiredParse;
|
|
3550
|
+
function requireParse() {
|
|
3551
|
+
if (hasRequiredParse) return parse_1;
|
|
3552
|
+
hasRequiredParse = 1;
|
|
3553
|
+
let Container = requireContainer();
|
|
3554
|
+
let Input = requireInput();
|
|
3555
|
+
let Parser = requireParser();
|
|
3556
|
+
function parse(css, opts) {
|
|
3557
|
+
let input2 = new Input(css, opts);
|
|
3558
|
+
let parser2 = new Parser(input2);
|
|
3559
|
+
try {
|
|
3560
|
+
parser2.parse();
|
|
3561
|
+
} catch (e) {
|
|
3562
|
+
if (true) {
|
|
3563
|
+
if (e.name === "CssSyntaxError" && opts && opts.from) {
|
|
3564
|
+
if (/\.scss$/i.test(opts.from)) {
|
|
3565
|
+
e.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
|
|
3566
|
+
} else if (/\.sass/i.test(opts.from)) {
|
|
3567
|
+
e.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
|
|
3568
|
+
} else if (/\.less$/i.test(opts.from)) {
|
|
3569
|
+
e.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
throw e;
|
|
3574
|
+
}
|
|
3575
|
+
return parser2.root;
|
|
3576
|
+
}
|
|
3577
|
+
parse_1 = parse;
|
|
3578
|
+
parse.default = parse;
|
|
3579
|
+
Container.registerParse(parse);
|
|
3580
|
+
return parse_1;
|
|
3581
|
+
}
|
|
3582
|
+
var warning;
|
|
3583
|
+
var hasRequiredWarning;
|
|
3584
|
+
function requireWarning() {
|
|
3585
|
+
if (hasRequiredWarning) return warning;
|
|
3586
|
+
hasRequiredWarning = 1;
|
|
3587
|
+
class Warning {
|
|
3588
|
+
constructor(text, opts = {}) {
|
|
3589
|
+
this.type = "warning";
|
|
3590
|
+
this.text = text;
|
|
3591
|
+
if (opts.node && opts.node.source) {
|
|
3592
|
+
let range = opts.node.rangeBy(opts);
|
|
3593
|
+
this.line = range.start.line;
|
|
3594
|
+
this.column = range.start.column;
|
|
3595
|
+
this.endLine = range.end.line;
|
|
3596
|
+
this.endColumn = range.end.column;
|
|
3597
|
+
}
|
|
3598
|
+
for (let opt in opts) this[opt] = opts[opt];
|
|
3599
|
+
}
|
|
3600
|
+
toString() {
|
|
3601
|
+
if (this.node) {
|
|
3602
|
+
return this.node.error(this.text, {
|
|
3603
|
+
index: this.index,
|
|
3604
|
+
plugin: this.plugin,
|
|
3605
|
+
word: this.word
|
|
3606
|
+
}).message;
|
|
3607
|
+
}
|
|
3608
|
+
if (this.plugin) {
|
|
3609
|
+
return this.plugin + ": " + this.text;
|
|
3610
|
+
}
|
|
3611
|
+
return this.text;
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
warning = Warning;
|
|
3615
|
+
Warning.default = Warning;
|
|
3616
|
+
return warning;
|
|
3617
|
+
}
|
|
3618
|
+
var result;
|
|
3619
|
+
var hasRequiredResult;
|
|
3620
|
+
function requireResult() {
|
|
3621
|
+
if (hasRequiredResult) return result;
|
|
3622
|
+
hasRequiredResult = 1;
|
|
3623
|
+
let Warning = requireWarning();
|
|
3624
|
+
class Result {
|
|
3625
|
+
constructor(processor2, root2, opts) {
|
|
3626
|
+
this.processor = processor2;
|
|
3627
|
+
this.messages = [];
|
|
3628
|
+
this.root = root2;
|
|
3629
|
+
this.opts = opts;
|
|
3630
|
+
this.css = void 0;
|
|
3631
|
+
this.map = void 0;
|
|
3632
|
+
}
|
|
3633
|
+
toString() {
|
|
3634
|
+
return this.css;
|
|
3635
|
+
}
|
|
3636
|
+
warn(text, opts = {}) {
|
|
3637
|
+
if (!opts.plugin) {
|
|
3638
|
+
if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
|
|
3639
|
+
opts.plugin = this.lastPlugin.postcssPlugin;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
let warning2 = new Warning(text, opts);
|
|
3643
|
+
this.messages.push(warning2);
|
|
3644
|
+
return warning2;
|
|
3645
|
+
}
|
|
3646
|
+
warnings() {
|
|
3647
|
+
return this.messages.filter((i) => i.type === "warning");
|
|
3648
|
+
}
|
|
3649
|
+
get content() {
|
|
3650
|
+
return this.css;
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
result = Result;
|
|
3654
|
+
Result.default = Result;
|
|
3655
|
+
return result;
|
|
3656
|
+
}
|
|
3657
|
+
var warnOnce;
|
|
3658
|
+
var hasRequiredWarnOnce;
|
|
3659
|
+
function requireWarnOnce() {
|
|
3660
|
+
if (hasRequiredWarnOnce) return warnOnce;
|
|
3661
|
+
hasRequiredWarnOnce = 1;
|
|
3662
|
+
let printed = {};
|
|
3663
|
+
warnOnce = function warnOnce2(message) {
|
|
3664
|
+
if (printed[message]) return;
|
|
3665
|
+
printed[message] = true;
|
|
3666
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
3667
|
+
console.warn(message);
|
|
3668
|
+
}
|
|
3669
|
+
};
|
|
3670
|
+
return warnOnce;
|
|
3671
|
+
}
|
|
3672
|
+
var lazyResult;
|
|
3673
|
+
var hasRequiredLazyResult;
|
|
3674
|
+
function requireLazyResult() {
|
|
3675
|
+
if (hasRequiredLazyResult) return lazyResult;
|
|
3676
|
+
hasRequiredLazyResult = 1;
|
|
3677
|
+
let Container = requireContainer();
|
|
3678
|
+
let Document = requireDocument();
|
|
3679
|
+
let MapGenerator = requireMapGenerator();
|
|
3680
|
+
let parse = requireParse();
|
|
3681
|
+
let Result = requireResult();
|
|
3682
|
+
let Root = requireRoot();
|
|
3683
|
+
let stringify = requireStringify();
|
|
3684
|
+
let { isClean, my } = requireSymbols();
|
|
3685
|
+
let warnOnce2 = requireWarnOnce();
|
|
3686
|
+
const TYPE_TO_CLASS_NAME = {
|
|
3687
|
+
atrule: "AtRule",
|
|
3688
|
+
comment: "Comment",
|
|
3689
|
+
decl: "Declaration",
|
|
3690
|
+
document: "Document",
|
|
3691
|
+
root: "Root",
|
|
3692
|
+
rule: "Rule"
|
|
3693
|
+
};
|
|
3694
|
+
const PLUGIN_PROPS = {
|
|
3695
|
+
AtRule: true,
|
|
3696
|
+
AtRuleExit: true,
|
|
3697
|
+
Comment: true,
|
|
3698
|
+
CommentExit: true,
|
|
3699
|
+
Declaration: true,
|
|
3700
|
+
DeclarationExit: true,
|
|
3701
|
+
Document: true,
|
|
3702
|
+
DocumentExit: true,
|
|
3703
|
+
Once: true,
|
|
3704
|
+
OnceExit: true,
|
|
3705
|
+
postcssPlugin: true,
|
|
3706
|
+
prepare: true,
|
|
3707
|
+
Root: true,
|
|
3708
|
+
RootExit: true,
|
|
3709
|
+
Rule: true,
|
|
3710
|
+
RuleExit: true
|
|
3711
|
+
};
|
|
3712
|
+
const NOT_VISITORS = {
|
|
3713
|
+
Once: true,
|
|
3714
|
+
postcssPlugin: true,
|
|
3715
|
+
prepare: true
|
|
3716
|
+
};
|
|
3717
|
+
const CHILDREN = 0;
|
|
3718
|
+
function isPromise(obj) {
|
|
3719
|
+
return typeof obj === "object" && typeof obj.then === "function";
|
|
3720
|
+
}
|
|
3721
|
+
function getEvents(node2) {
|
|
3722
|
+
let key = false;
|
|
3723
|
+
let type = TYPE_TO_CLASS_NAME[node2.type];
|
|
3724
|
+
if (node2.type === "decl") {
|
|
3725
|
+
key = node2.prop.toLowerCase();
|
|
3726
|
+
} else if (node2.type === "atrule") {
|
|
3727
|
+
key = node2.name.toLowerCase();
|
|
3728
|
+
}
|
|
3729
|
+
if (key && node2.append) {
|
|
3730
|
+
return [
|
|
3731
|
+
type,
|
|
3732
|
+
type + "-" + key,
|
|
3733
|
+
CHILDREN,
|
|
3734
|
+
type + "Exit",
|
|
3735
|
+
type + "Exit-" + key
|
|
3736
|
+
];
|
|
3737
|
+
} else if (key) {
|
|
3738
|
+
return [type, type + "-" + key, type + "Exit", type + "Exit-" + key];
|
|
3739
|
+
} else if (node2.append) {
|
|
3740
|
+
return [type, CHILDREN, type + "Exit"];
|
|
3741
|
+
} else {
|
|
3742
|
+
return [type, type + "Exit"];
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
function toStack(node2) {
|
|
3746
|
+
let events;
|
|
3747
|
+
if (node2.type === "document") {
|
|
3748
|
+
events = ["Document", CHILDREN, "DocumentExit"];
|
|
3749
|
+
} else if (node2.type === "root") {
|
|
3750
|
+
events = ["Root", CHILDREN, "RootExit"];
|
|
3751
|
+
} else {
|
|
3752
|
+
events = getEvents(node2);
|
|
3753
|
+
}
|
|
3754
|
+
return {
|
|
3755
|
+
eventIndex: 0,
|
|
3756
|
+
events,
|
|
3757
|
+
iterator: 0,
|
|
3758
|
+
node: node2,
|
|
3759
|
+
visitorIndex: 0,
|
|
3760
|
+
visitors: []
|
|
3761
|
+
};
|
|
3762
|
+
}
|
|
3763
|
+
function cleanMarks(node2) {
|
|
3764
|
+
node2[isClean] = false;
|
|
3765
|
+
if (node2.nodes) node2.nodes.forEach((i) => cleanMarks(i));
|
|
3766
|
+
return node2;
|
|
3767
|
+
}
|
|
3768
|
+
let postcss2 = {};
|
|
3769
|
+
class LazyResult {
|
|
3770
|
+
constructor(processor2, css, opts) {
|
|
3771
|
+
this.stringified = false;
|
|
3772
|
+
this.processed = false;
|
|
3773
|
+
let root2;
|
|
3774
|
+
if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) {
|
|
3775
|
+
root2 = cleanMarks(css);
|
|
3776
|
+
} else if (css instanceof LazyResult || css instanceof Result) {
|
|
3777
|
+
root2 = cleanMarks(css.root);
|
|
3778
|
+
if (css.map) {
|
|
3779
|
+
if (typeof opts.map === "undefined") opts.map = {};
|
|
3780
|
+
if (!opts.map.inline) opts.map.inline = false;
|
|
3781
|
+
opts.map.prev = css.map;
|
|
3782
|
+
}
|
|
3783
|
+
} else {
|
|
3784
|
+
let parser2 = parse;
|
|
3785
|
+
if (opts.syntax) parser2 = opts.syntax.parse;
|
|
3786
|
+
if (opts.parser) parser2 = opts.parser;
|
|
3787
|
+
if (parser2.parse) parser2 = parser2.parse;
|
|
3788
|
+
try {
|
|
3789
|
+
root2 = parser2(css, opts);
|
|
3790
|
+
} catch (error) {
|
|
3791
|
+
this.processed = true;
|
|
3792
|
+
this.error = error;
|
|
3793
|
+
}
|
|
3794
|
+
if (root2 && !root2[my]) {
|
|
3795
|
+
Container.rebuild(root2);
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
this.result = new Result(processor2, root2, opts);
|
|
3799
|
+
this.helpers = __spreadProps(__spreadValues({}, postcss2), { postcss: postcss2, result: this.result });
|
|
3800
|
+
this.plugins = this.processor.plugins.map((plugin) => {
|
|
3801
|
+
if (typeof plugin === "object" && plugin.prepare) {
|
|
3802
|
+
return __spreadValues(__spreadValues({}, plugin), plugin.prepare(this.result));
|
|
3803
|
+
} else {
|
|
3804
|
+
return plugin;
|
|
3805
|
+
}
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3808
|
+
async() {
|
|
3809
|
+
if (this.error) return Promise.reject(this.error);
|
|
3810
|
+
if (this.processed) return Promise.resolve(this.result);
|
|
3811
|
+
if (!this.processing) {
|
|
3812
|
+
this.processing = this.runAsync();
|
|
3813
|
+
}
|
|
3814
|
+
return this.processing;
|
|
3815
|
+
}
|
|
3816
|
+
catch(onRejected) {
|
|
3817
|
+
return this.async().catch(onRejected);
|
|
3818
|
+
}
|
|
3819
|
+
finally(onFinally) {
|
|
3820
|
+
return this.async().then(onFinally, onFinally);
|
|
3821
|
+
}
|
|
3822
|
+
getAsyncError() {
|
|
3823
|
+
throw new Error("Use process(css).then(cb) to work with async plugins");
|
|
3824
|
+
}
|
|
3825
|
+
handleError(error, node2) {
|
|
3826
|
+
let plugin = this.result.lastPlugin;
|
|
3827
|
+
try {
|
|
3828
|
+
if (node2) node2.addToError(error);
|
|
3829
|
+
this.error = error;
|
|
3830
|
+
if (error.name === "CssSyntaxError" && !error.plugin) {
|
|
3831
|
+
error.plugin = plugin.postcssPlugin;
|
|
3832
|
+
error.setMessage();
|
|
3833
|
+
} else if (plugin.postcssVersion) {
|
|
3834
|
+
if (true) {
|
|
3835
|
+
let pluginName = plugin.postcssPlugin;
|
|
3836
|
+
let pluginVer = plugin.postcssVersion;
|
|
3837
|
+
let runtimeVer = this.result.processor.version;
|
|
3838
|
+
let a = pluginVer.split(".");
|
|
3839
|
+
let b = runtimeVer.split(".");
|
|
3840
|
+
if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
|
|
3841
|
+
console.error(
|
|
3842
|
+
"Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below."
|
|
3843
|
+
);
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
} catch (err) {
|
|
3848
|
+
if (console && console.error) console.error(err);
|
|
3849
|
+
}
|
|
3850
|
+
return error;
|
|
3851
|
+
}
|
|
3852
|
+
prepareVisitors() {
|
|
3853
|
+
this.listeners = {};
|
|
3854
|
+
let add = (plugin, type, cb) => {
|
|
3855
|
+
if (!this.listeners[type]) this.listeners[type] = [];
|
|
3856
|
+
this.listeners[type].push([plugin, cb]);
|
|
3857
|
+
};
|
|
3858
|
+
for (let plugin of this.plugins) {
|
|
3859
|
+
if (typeof plugin === "object") {
|
|
3860
|
+
for (let event in plugin) {
|
|
3861
|
+
if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
|
|
3862
|
+
throw new Error(
|
|
3863
|
+
`Unknown event ${event} in ${plugin.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`
|
|
3864
|
+
);
|
|
3865
|
+
}
|
|
3866
|
+
if (!NOT_VISITORS[event]) {
|
|
3867
|
+
if (typeof plugin[event] === "object") {
|
|
3868
|
+
for (let filter in plugin[event]) {
|
|
3869
|
+
if (filter === "*") {
|
|
3870
|
+
add(plugin, event, plugin[event][filter]);
|
|
3871
|
+
} else {
|
|
3872
|
+
add(
|
|
3873
|
+
plugin,
|
|
3874
|
+
event + "-" + filter.toLowerCase(),
|
|
3875
|
+
plugin[event][filter]
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
} else if (typeof plugin[event] === "function") {
|
|
3880
|
+
add(plugin, event, plugin[event]);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
this.hasListener = Object.keys(this.listeners).length > 0;
|
|
3887
|
+
}
|
|
3888
|
+
async runAsync() {
|
|
3889
|
+
this.plugin = 0;
|
|
3890
|
+
for (let i = 0; i < this.plugins.length; i++) {
|
|
3891
|
+
let plugin = this.plugins[i];
|
|
3892
|
+
let promise = this.runOnRoot(plugin);
|
|
3893
|
+
if (isPromise(promise)) {
|
|
3894
|
+
try {
|
|
3895
|
+
await promise;
|
|
3896
|
+
} catch (error) {
|
|
3897
|
+
throw this.handleError(error);
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
this.prepareVisitors();
|
|
3902
|
+
if (this.hasListener) {
|
|
3903
|
+
let root2 = this.result.root;
|
|
3904
|
+
while (!root2[isClean]) {
|
|
3905
|
+
root2[isClean] = true;
|
|
3906
|
+
let stack = [toStack(root2)];
|
|
3907
|
+
while (stack.length > 0) {
|
|
3908
|
+
let promise = this.visitTick(stack);
|
|
3909
|
+
if (isPromise(promise)) {
|
|
3910
|
+
try {
|
|
3911
|
+
await promise;
|
|
3912
|
+
} catch (e) {
|
|
3913
|
+
let node2 = stack[stack.length - 1].node;
|
|
3914
|
+
throw this.handleError(e, node2);
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
if (this.listeners.OnceExit) {
|
|
3920
|
+
for (let [plugin, visitor] of this.listeners.OnceExit) {
|
|
3921
|
+
this.result.lastPlugin = plugin;
|
|
3922
|
+
try {
|
|
3923
|
+
if (root2.type === "document") {
|
|
3924
|
+
let roots = root2.nodes.map(
|
|
3925
|
+
(subRoot) => visitor(subRoot, this.helpers)
|
|
3926
|
+
);
|
|
3927
|
+
await Promise.all(roots);
|
|
3928
|
+
} else {
|
|
3929
|
+
await visitor(root2, this.helpers);
|
|
3930
|
+
}
|
|
3931
|
+
} catch (e) {
|
|
3932
|
+
throw this.handleError(e);
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
this.processed = true;
|
|
3938
|
+
return this.stringify();
|
|
3939
|
+
}
|
|
3940
|
+
runOnRoot(plugin) {
|
|
3941
|
+
this.result.lastPlugin = plugin;
|
|
3942
|
+
try {
|
|
3943
|
+
if (typeof plugin === "object" && plugin.Once) {
|
|
3944
|
+
if (this.result.root.type === "document") {
|
|
3945
|
+
let roots = this.result.root.nodes.map(
|
|
3946
|
+
(root2) => plugin.Once(root2, this.helpers)
|
|
3947
|
+
);
|
|
3948
|
+
if (isPromise(roots[0])) {
|
|
3949
|
+
return Promise.all(roots);
|
|
3950
|
+
}
|
|
3951
|
+
return roots;
|
|
3952
|
+
}
|
|
3953
|
+
return plugin.Once(this.result.root, this.helpers);
|
|
3954
|
+
} else if (typeof plugin === "function") {
|
|
3955
|
+
return plugin(this.result.root, this.result);
|
|
3956
|
+
}
|
|
3957
|
+
} catch (error) {
|
|
3958
|
+
throw this.handleError(error);
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
stringify() {
|
|
3962
|
+
if (this.error) throw this.error;
|
|
3963
|
+
if (this.stringified) return this.result;
|
|
3964
|
+
this.stringified = true;
|
|
3965
|
+
this.sync();
|
|
3966
|
+
let opts = this.result.opts;
|
|
3967
|
+
let str = stringify;
|
|
3968
|
+
if (opts.syntax) str = opts.syntax.stringify;
|
|
3969
|
+
if (opts.stringifier) str = opts.stringifier;
|
|
3970
|
+
if (str.stringify) str = str.stringify;
|
|
3971
|
+
let map = new MapGenerator(str, this.result.root, this.result.opts);
|
|
3972
|
+
let data = map.generate();
|
|
3973
|
+
this.result.css = data[0];
|
|
3974
|
+
this.result.map = data[1];
|
|
3975
|
+
return this.result;
|
|
3976
|
+
}
|
|
3977
|
+
sync() {
|
|
3978
|
+
if (this.error) throw this.error;
|
|
3979
|
+
if (this.processed) return this.result;
|
|
3980
|
+
this.processed = true;
|
|
3981
|
+
if (this.processing) {
|
|
3982
|
+
throw this.getAsyncError();
|
|
3983
|
+
}
|
|
3984
|
+
for (let plugin of this.plugins) {
|
|
3985
|
+
let promise = this.runOnRoot(plugin);
|
|
3986
|
+
if (isPromise(promise)) {
|
|
3987
|
+
throw this.getAsyncError();
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
this.prepareVisitors();
|
|
3991
|
+
if (this.hasListener) {
|
|
3992
|
+
let root2 = this.result.root;
|
|
3993
|
+
while (!root2[isClean]) {
|
|
3994
|
+
root2[isClean] = true;
|
|
3995
|
+
this.walkSync(root2);
|
|
3996
|
+
}
|
|
3997
|
+
if (this.listeners.OnceExit) {
|
|
3998
|
+
if (root2.type === "document") {
|
|
3999
|
+
for (let subRoot of root2.nodes) {
|
|
4000
|
+
this.visitSync(this.listeners.OnceExit, subRoot);
|
|
4001
|
+
}
|
|
4002
|
+
} else {
|
|
4003
|
+
this.visitSync(this.listeners.OnceExit, root2);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
return this.result;
|
|
4008
|
+
}
|
|
4009
|
+
then(onFulfilled, onRejected) {
|
|
4010
|
+
if (true) {
|
|
4011
|
+
if (!("from" in this.opts)) {
|
|
4012
|
+
warnOnce2(
|
|
4013
|
+
"Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning."
|
|
4014
|
+
);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
return this.async().then(onFulfilled, onRejected);
|
|
4018
|
+
}
|
|
4019
|
+
toString() {
|
|
4020
|
+
return this.css;
|
|
4021
|
+
}
|
|
4022
|
+
visitSync(visitors, node2) {
|
|
4023
|
+
for (let [plugin, visitor] of visitors) {
|
|
4024
|
+
this.result.lastPlugin = plugin;
|
|
4025
|
+
let promise;
|
|
4026
|
+
try {
|
|
4027
|
+
promise = visitor(node2, this.helpers);
|
|
4028
|
+
} catch (e) {
|
|
4029
|
+
throw this.handleError(e, node2.proxyOf);
|
|
4030
|
+
}
|
|
4031
|
+
if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
|
|
4032
|
+
return true;
|
|
4033
|
+
}
|
|
4034
|
+
if (isPromise(promise)) {
|
|
4035
|
+
throw this.getAsyncError();
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
visitTick(stack) {
|
|
4040
|
+
let visit2 = stack[stack.length - 1];
|
|
4041
|
+
let { node: node2, visitors } = visit2;
|
|
4042
|
+
if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
|
|
4043
|
+
stack.pop();
|
|
4044
|
+
return;
|
|
4045
|
+
}
|
|
4046
|
+
if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
|
|
4047
|
+
let [plugin, visitor] = visitors[visit2.visitorIndex];
|
|
4048
|
+
visit2.visitorIndex += 1;
|
|
4049
|
+
if (visit2.visitorIndex === visitors.length) {
|
|
4050
|
+
visit2.visitors = [];
|
|
4051
|
+
visit2.visitorIndex = 0;
|
|
4052
|
+
}
|
|
4053
|
+
this.result.lastPlugin = plugin;
|
|
4054
|
+
try {
|
|
4055
|
+
return visitor(node2.toProxy(), this.helpers);
|
|
4056
|
+
} catch (e) {
|
|
4057
|
+
throw this.handleError(e, node2);
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
4060
|
+
if (visit2.iterator !== 0) {
|
|
4061
|
+
let iterator = visit2.iterator;
|
|
4062
|
+
let child;
|
|
4063
|
+
while (child = node2.nodes[node2.indexes[iterator]]) {
|
|
4064
|
+
node2.indexes[iterator] += 1;
|
|
4065
|
+
if (!child[isClean]) {
|
|
4066
|
+
child[isClean] = true;
|
|
4067
|
+
stack.push(toStack(child));
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
visit2.iterator = 0;
|
|
4072
|
+
delete node2.indexes[iterator];
|
|
4073
|
+
}
|
|
4074
|
+
let events = visit2.events;
|
|
4075
|
+
while (visit2.eventIndex < events.length) {
|
|
4076
|
+
let event = events[visit2.eventIndex];
|
|
4077
|
+
visit2.eventIndex += 1;
|
|
4078
|
+
if (event === CHILDREN) {
|
|
4079
|
+
if (node2.nodes && node2.nodes.length) {
|
|
4080
|
+
node2[isClean] = true;
|
|
4081
|
+
visit2.iterator = node2.getIterator();
|
|
4082
|
+
}
|
|
4083
|
+
return;
|
|
4084
|
+
} else if (this.listeners[event]) {
|
|
4085
|
+
visit2.visitors = this.listeners[event];
|
|
4086
|
+
return;
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
stack.pop();
|
|
4090
|
+
}
|
|
4091
|
+
walkSync(node2) {
|
|
4092
|
+
node2[isClean] = true;
|
|
4093
|
+
let events = getEvents(node2);
|
|
4094
|
+
for (let event of events) {
|
|
4095
|
+
if (event === CHILDREN) {
|
|
4096
|
+
if (node2.nodes) {
|
|
4097
|
+
node2.each((child) => {
|
|
4098
|
+
if (!child[isClean]) this.walkSync(child);
|
|
4099
|
+
});
|
|
4100
|
+
}
|
|
4101
|
+
} else {
|
|
4102
|
+
let visitors = this.listeners[event];
|
|
4103
|
+
if (visitors) {
|
|
4104
|
+
if (this.visitSync(visitors, node2.toProxy())) return;
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
warnings() {
|
|
4110
|
+
return this.sync().warnings();
|
|
4111
|
+
}
|
|
4112
|
+
get content() {
|
|
4113
|
+
return this.stringify().content;
|
|
4114
|
+
}
|
|
4115
|
+
get css() {
|
|
4116
|
+
return this.stringify().css;
|
|
4117
|
+
}
|
|
4118
|
+
get map() {
|
|
4119
|
+
return this.stringify().map;
|
|
4120
|
+
}
|
|
4121
|
+
get messages() {
|
|
4122
|
+
return this.sync().messages;
|
|
4123
|
+
}
|
|
4124
|
+
get opts() {
|
|
4125
|
+
return this.result.opts;
|
|
4126
|
+
}
|
|
4127
|
+
get processor() {
|
|
4128
|
+
return this.result.processor;
|
|
4129
|
+
}
|
|
4130
|
+
get root() {
|
|
4131
|
+
return this.sync().root;
|
|
4132
|
+
}
|
|
4133
|
+
get [Symbol.toStringTag]() {
|
|
4134
|
+
return "LazyResult";
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
LazyResult.registerPostcss = (dependant) => {
|
|
4138
|
+
postcss2 = dependant;
|
|
4139
|
+
};
|
|
4140
|
+
lazyResult = LazyResult;
|
|
4141
|
+
LazyResult.default = LazyResult;
|
|
4142
|
+
Root.registerLazyResult(LazyResult);
|
|
4143
|
+
Document.registerLazyResult(LazyResult);
|
|
4144
|
+
return lazyResult;
|
|
4145
|
+
}
|
|
4146
|
+
var noWorkResult;
|
|
4147
|
+
var hasRequiredNoWorkResult;
|
|
4148
|
+
function requireNoWorkResult() {
|
|
4149
|
+
if (hasRequiredNoWorkResult) return noWorkResult;
|
|
4150
|
+
hasRequiredNoWorkResult = 1;
|
|
4151
|
+
let MapGenerator = requireMapGenerator();
|
|
4152
|
+
let parse = requireParse();
|
|
4153
|
+
const Result = requireResult();
|
|
4154
|
+
let stringify = requireStringify();
|
|
4155
|
+
let warnOnce2 = requireWarnOnce();
|
|
4156
|
+
class NoWorkResult {
|
|
4157
|
+
constructor(processor2, css, opts) {
|
|
4158
|
+
css = css.toString();
|
|
4159
|
+
this.stringified = false;
|
|
4160
|
+
this._processor = processor2;
|
|
4161
|
+
this._css = css;
|
|
4162
|
+
this._opts = opts;
|
|
4163
|
+
this._map = void 0;
|
|
4164
|
+
let root2;
|
|
4165
|
+
let str = stringify;
|
|
4166
|
+
this.result = new Result(this._processor, root2, this._opts);
|
|
4167
|
+
this.result.css = css;
|
|
4168
|
+
let self = this;
|
|
4169
|
+
Object.defineProperty(this.result, "root", {
|
|
4170
|
+
get() {
|
|
4171
|
+
return self.root;
|
|
4172
|
+
}
|
|
4173
|
+
});
|
|
4174
|
+
let map = new MapGenerator(str, root2, this._opts, css);
|
|
4175
|
+
if (map.isMap()) {
|
|
4176
|
+
let [generatedCSS, generatedMap] = map.generate();
|
|
4177
|
+
if (generatedCSS) {
|
|
4178
|
+
this.result.css = generatedCSS;
|
|
4179
|
+
}
|
|
4180
|
+
if (generatedMap) {
|
|
4181
|
+
this.result.map = generatedMap;
|
|
4182
|
+
}
|
|
4183
|
+
} else {
|
|
4184
|
+
map.clearAnnotation();
|
|
4185
|
+
this.result.css = map.css;
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
async() {
|
|
4189
|
+
if (this.error) return Promise.reject(this.error);
|
|
4190
|
+
return Promise.resolve(this.result);
|
|
4191
|
+
}
|
|
4192
|
+
catch(onRejected) {
|
|
4193
|
+
return this.async().catch(onRejected);
|
|
4194
|
+
}
|
|
4195
|
+
finally(onFinally) {
|
|
4196
|
+
return this.async().then(onFinally, onFinally);
|
|
4197
|
+
}
|
|
4198
|
+
sync() {
|
|
4199
|
+
if (this.error) throw this.error;
|
|
4200
|
+
return this.result;
|
|
4201
|
+
}
|
|
4202
|
+
then(onFulfilled, onRejected) {
|
|
4203
|
+
if (true) {
|
|
4204
|
+
if (!("from" in this._opts)) {
|
|
4205
|
+
warnOnce2(
|
|
4206
|
+
"Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning."
|
|
4207
|
+
);
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
return this.async().then(onFulfilled, onRejected);
|
|
4211
|
+
}
|
|
4212
|
+
toString() {
|
|
4213
|
+
return this._css;
|
|
4214
|
+
}
|
|
4215
|
+
warnings() {
|
|
4216
|
+
return [];
|
|
4217
|
+
}
|
|
4218
|
+
get content() {
|
|
4219
|
+
return this.result.css;
|
|
4220
|
+
}
|
|
4221
|
+
get css() {
|
|
4222
|
+
return this.result.css;
|
|
4223
|
+
}
|
|
4224
|
+
get map() {
|
|
4225
|
+
return this.result.map;
|
|
4226
|
+
}
|
|
4227
|
+
get messages() {
|
|
4228
|
+
return [];
|
|
4229
|
+
}
|
|
4230
|
+
get opts() {
|
|
4231
|
+
return this.result.opts;
|
|
4232
|
+
}
|
|
4233
|
+
get processor() {
|
|
4234
|
+
return this.result.processor;
|
|
4235
|
+
}
|
|
4236
|
+
get root() {
|
|
4237
|
+
if (this._root) {
|
|
4238
|
+
return this._root;
|
|
4239
|
+
}
|
|
4240
|
+
let root2;
|
|
4241
|
+
let parser2 = parse;
|
|
4242
|
+
try {
|
|
4243
|
+
root2 = parser2(this._css, this._opts);
|
|
4244
|
+
} catch (error) {
|
|
4245
|
+
this.error = error;
|
|
4246
|
+
}
|
|
4247
|
+
if (this.error) {
|
|
4248
|
+
throw this.error;
|
|
4249
|
+
} else {
|
|
4250
|
+
this._root = root2;
|
|
4251
|
+
return root2;
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
get [Symbol.toStringTag]() {
|
|
4255
|
+
return "NoWorkResult";
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
noWorkResult = NoWorkResult;
|
|
4259
|
+
NoWorkResult.default = NoWorkResult;
|
|
4260
|
+
return noWorkResult;
|
|
4261
|
+
}
|
|
4262
|
+
var processor;
|
|
4263
|
+
var hasRequiredProcessor;
|
|
4264
|
+
function requireProcessor() {
|
|
4265
|
+
if (hasRequiredProcessor) return processor;
|
|
4266
|
+
hasRequiredProcessor = 1;
|
|
4267
|
+
let Document = requireDocument();
|
|
4268
|
+
let LazyResult = requireLazyResult();
|
|
4269
|
+
let NoWorkResult = requireNoWorkResult();
|
|
4270
|
+
let Root = requireRoot();
|
|
4271
|
+
class Processor {
|
|
4272
|
+
constructor(plugins = []) {
|
|
4273
|
+
this.version = "8.5.1";
|
|
4274
|
+
this.plugins = this.normalize(plugins);
|
|
4275
|
+
}
|
|
4276
|
+
normalize(plugins) {
|
|
4277
|
+
let normalized = [];
|
|
4278
|
+
for (let i of plugins) {
|
|
4279
|
+
if (i.postcss === true) {
|
|
4280
|
+
i = i();
|
|
4281
|
+
} else if (i.postcss) {
|
|
4282
|
+
i = i.postcss;
|
|
4283
|
+
}
|
|
4284
|
+
if (typeof i === "object" && Array.isArray(i.plugins)) {
|
|
4285
|
+
normalized = normalized.concat(i.plugins);
|
|
4286
|
+
} else if (typeof i === "object" && i.postcssPlugin) {
|
|
4287
|
+
normalized.push(i);
|
|
4288
|
+
} else if (typeof i === "function") {
|
|
4289
|
+
normalized.push(i);
|
|
4290
|
+
} else if (typeof i === "object" && (i.parse || i.stringify)) {
|
|
4291
|
+
if (true) {
|
|
4292
|
+
throw new Error(
|
|
4293
|
+
"PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation."
|
|
4294
|
+
);
|
|
4295
|
+
}
|
|
4296
|
+
} else {
|
|
4297
|
+
throw new Error(i + " is not a PostCSS plugin");
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
return normalized;
|
|
4301
|
+
}
|
|
4302
|
+
process(css, opts = {}) {
|
|
4303
|
+
if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
|
|
4304
|
+
return new NoWorkResult(this, css, opts);
|
|
4305
|
+
} else {
|
|
4306
|
+
return new LazyResult(this, css, opts);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
use(plugin) {
|
|
4310
|
+
this.plugins = this.plugins.concat(this.normalize([plugin]));
|
|
4311
|
+
return this;
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
processor = Processor;
|
|
4315
|
+
Processor.default = Processor;
|
|
4316
|
+
Root.registerProcessor(Processor);
|
|
4317
|
+
Document.registerProcessor(Processor);
|
|
4318
|
+
return processor;
|
|
4319
|
+
}
|
|
4320
|
+
var postcss_1;
|
|
4321
|
+
var hasRequiredPostcss;
|
|
4322
|
+
function requirePostcss() {
|
|
4323
|
+
if (hasRequiredPostcss) return postcss_1;
|
|
4324
|
+
hasRequiredPostcss = 1;
|
|
4325
|
+
let AtRule = requireAtRule();
|
|
4326
|
+
let Comment = requireComment();
|
|
4327
|
+
let Container = requireContainer();
|
|
4328
|
+
let CssSyntaxError = requireCssSyntaxError();
|
|
4329
|
+
let Declaration = requireDeclaration();
|
|
4330
|
+
let Document = requireDocument();
|
|
4331
|
+
let fromJSON = requireFromJSON();
|
|
4332
|
+
let Input = requireInput();
|
|
4333
|
+
let LazyResult = requireLazyResult();
|
|
4334
|
+
let list = requireList();
|
|
4335
|
+
let Node = requireNode();
|
|
4336
|
+
let parse = requireParse();
|
|
4337
|
+
let Processor = requireProcessor();
|
|
4338
|
+
let Result = requireResult();
|
|
4339
|
+
let Root = requireRoot();
|
|
4340
|
+
let Rule = requireRule();
|
|
4341
|
+
let stringify = requireStringify();
|
|
4342
|
+
let Warning = requireWarning();
|
|
4343
|
+
function postcss2(...plugins) {
|
|
4344
|
+
if (plugins.length === 1 && Array.isArray(plugins[0])) {
|
|
4345
|
+
plugins = plugins[0];
|
|
4346
|
+
}
|
|
4347
|
+
return new Processor(plugins);
|
|
4348
|
+
}
|
|
4349
|
+
postcss2.plugin = function plugin(name, initializer) {
|
|
4350
|
+
let warningPrinted = false;
|
|
4351
|
+
function creator(...args) {
|
|
4352
|
+
if (console && console.warn && !warningPrinted) {
|
|
4353
|
+
warningPrinted = true;
|
|
4354
|
+
console.warn(
|
|
4355
|
+
name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"
|
|
4356
|
+
);
|
|
4357
|
+
if (process.env.LANG && process.env.LANG.startsWith("cn")) {
|
|
4358
|
+
console.warn(
|
|
4359
|
+
name + ": \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:\nhttps://www.w3ctech.com/topic/2226"
|
|
4360
|
+
);
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
let transformer = initializer(...args);
|
|
4364
|
+
transformer.postcssPlugin = name;
|
|
4365
|
+
transformer.postcssVersion = new Processor().version;
|
|
4366
|
+
return transformer;
|
|
4367
|
+
}
|
|
4368
|
+
let cache;
|
|
4369
|
+
Object.defineProperty(creator, "postcss", {
|
|
4370
|
+
get() {
|
|
4371
|
+
if (!cache) cache = creator();
|
|
4372
|
+
return cache;
|
|
4373
|
+
}
|
|
4374
|
+
});
|
|
4375
|
+
creator.process = function(css, processOpts, pluginOpts) {
|
|
4376
|
+
return postcss2([creator(pluginOpts)]).process(css, processOpts);
|
|
4377
|
+
};
|
|
4378
|
+
return creator;
|
|
4379
|
+
};
|
|
4380
|
+
postcss2.stringify = stringify;
|
|
4381
|
+
postcss2.parse = parse;
|
|
4382
|
+
postcss2.fromJSON = fromJSON;
|
|
4383
|
+
postcss2.list = list;
|
|
4384
|
+
postcss2.comment = (defaults) => new Comment(defaults);
|
|
4385
|
+
postcss2.atRule = (defaults) => new AtRule(defaults);
|
|
4386
|
+
postcss2.decl = (defaults) => new Declaration(defaults);
|
|
4387
|
+
postcss2.rule = (defaults) => new Rule(defaults);
|
|
4388
|
+
postcss2.root = (defaults) => new Root(defaults);
|
|
4389
|
+
postcss2.document = (defaults) => new Document(defaults);
|
|
4390
|
+
postcss2.CssSyntaxError = CssSyntaxError;
|
|
4391
|
+
postcss2.Declaration = Declaration;
|
|
4392
|
+
postcss2.Container = Container;
|
|
4393
|
+
postcss2.Processor = Processor;
|
|
4394
|
+
postcss2.Document = Document;
|
|
4395
|
+
postcss2.Comment = Comment;
|
|
4396
|
+
postcss2.Warning = Warning;
|
|
4397
|
+
postcss2.AtRule = AtRule;
|
|
4398
|
+
postcss2.Result = Result;
|
|
4399
|
+
postcss2.Input = Input;
|
|
4400
|
+
postcss2.Rule = Rule;
|
|
4401
|
+
postcss2.Root = Root;
|
|
4402
|
+
postcss2.Node = Node;
|
|
4403
|
+
LazyResult.registerPostcss(postcss2);
|
|
4404
|
+
postcss_1 = postcss2;
|
|
4405
|
+
postcss2.default = postcss2;
|
|
4406
|
+
return postcss_1;
|
|
4407
|
+
}
|
|
4408
|
+
var safeParser$1;
|
|
4409
|
+
var hasRequiredSafeParser;
|
|
4410
|
+
function requireSafeParser() {
|
|
4411
|
+
if (hasRequiredSafeParser) return safeParser$1;
|
|
4412
|
+
hasRequiredSafeParser = 1;
|
|
4413
|
+
let Comment = requireComment();
|
|
4414
|
+
let Parser = requireParser();
|
|
4415
|
+
let tokenizer = requireTokenize();
|
|
4416
|
+
class SafeParser extends Parser {
|
|
4417
|
+
checkMissedSemicolon() {
|
|
4418
|
+
}
|
|
4419
|
+
comment(token) {
|
|
4420
|
+
let node2 = new Comment();
|
|
4421
|
+
this.init(node2, token[2]);
|
|
4422
|
+
let pos = this.input.fromOffset(token[3]) || this.input.fromOffset(this.input.css.length - 1);
|
|
4423
|
+
node2.source.end = {
|
|
4424
|
+
column: pos.col,
|
|
4425
|
+
line: pos.line,
|
|
4426
|
+
offset: token[3] + 1
|
|
4427
|
+
};
|
|
4428
|
+
let text = token[1].slice(2);
|
|
4429
|
+
if (text.slice(-2) === "*/") text = text.slice(0, -2);
|
|
4430
|
+
if (/^\s*$/.test(text)) {
|
|
4431
|
+
node2.text = "";
|
|
4432
|
+
node2.raws.left = text;
|
|
4433
|
+
node2.raws.right = "";
|
|
4434
|
+
} else {
|
|
4435
|
+
let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
|
|
4436
|
+
node2.text = match[2];
|
|
4437
|
+
node2.raws.left = match[1];
|
|
4438
|
+
node2.raws.right = match[3];
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
createTokenizer() {
|
|
4442
|
+
this.tokenizer = tokenizer(this.input, { ignoreErrors: true });
|
|
4443
|
+
}
|
|
4444
|
+
decl(tokens) {
|
|
4445
|
+
if (tokens.length > 1 && tokens.some((i) => i[0] === "word")) {
|
|
4446
|
+
super.decl(tokens);
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
doubleColon() {
|
|
4450
|
+
}
|
|
4451
|
+
endFile() {
|
|
4452
|
+
if (this.current.nodes && this.current.nodes.length) {
|
|
4453
|
+
this.current.raws.semicolon = this.semicolon;
|
|
4454
|
+
}
|
|
4455
|
+
this.current.raws.after = (this.current.raws.after || "") + this.spaces;
|
|
4456
|
+
while (this.current.parent) {
|
|
4457
|
+
this.current = this.current.parent;
|
|
4458
|
+
this.current.raws.after = "";
|
|
4459
|
+
}
|
|
4460
|
+
this.root.source.end = this.getPosition(this.tokenizer.position());
|
|
4461
|
+
}
|
|
4462
|
+
precheckMissedSemicolon(tokens) {
|
|
4463
|
+
let colon = this.colon(tokens);
|
|
4464
|
+
if (colon === false) return;
|
|
4465
|
+
let nextStart, prevEnd;
|
|
4466
|
+
for (nextStart = colon - 1; nextStart >= 0; nextStart--) {
|
|
4467
|
+
if (tokens[nextStart][0] === "word") break;
|
|
4468
|
+
}
|
|
4469
|
+
if (nextStart === 0 || nextStart < 0) return;
|
|
4470
|
+
for (prevEnd = nextStart - 1; prevEnd >= 0; prevEnd--) {
|
|
4471
|
+
if (tokens[prevEnd][0] !== "space") {
|
|
4472
|
+
prevEnd += 1;
|
|
4473
|
+
break;
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
let other = tokens.slice(nextStart);
|
|
4477
|
+
let spaces = tokens.slice(prevEnd, nextStart);
|
|
4478
|
+
tokens.splice(prevEnd, tokens.length - prevEnd);
|
|
4479
|
+
this.spaces = spaces.map((i) => i[1]).join("");
|
|
4480
|
+
this.decl(other);
|
|
4481
|
+
}
|
|
4482
|
+
unclosedBracket() {
|
|
4483
|
+
}
|
|
4484
|
+
unexpectedClose() {
|
|
4485
|
+
this.current.raws.after += "}";
|
|
4486
|
+
}
|
|
4487
|
+
unknownWord(tokens) {
|
|
4488
|
+
this.spaces += tokens.map((i) => i[1]).join("");
|
|
4489
|
+
}
|
|
4490
|
+
unnamedAtrule(node2) {
|
|
4491
|
+
node2.name = "";
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
safeParser$1 = SafeParser;
|
|
4495
|
+
return safeParser$1;
|
|
4496
|
+
}
|
|
4497
|
+
var safeParse;
|
|
4498
|
+
var hasRequiredSafeParse;
|
|
4499
|
+
function requireSafeParse() {
|
|
4500
|
+
if (hasRequiredSafeParse) return safeParse;
|
|
4501
|
+
hasRequiredSafeParse = 1;
|
|
4502
|
+
let { Input } = requirePostcss();
|
|
4503
|
+
let SafeParser = requireSafeParser();
|
|
4504
|
+
safeParse = function safeParse2(css, opts) {
|
|
4505
|
+
let input2 = new Input(css, opts);
|
|
4506
|
+
let parser2 = new SafeParser(input2);
|
|
4507
|
+
parser2.parse();
|
|
4508
|
+
return parser2.root;
|
|
4509
|
+
};
|
|
4510
|
+
return safeParse;
|
|
4511
|
+
}
|
|
4512
|
+
var safeParseExports = requireSafeParse();
|
|
4513
|
+
var safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParseExports);
|
|
4514
|
+
var postcssExports = requirePostcss();
|
|
4515
|
+
var postcss = /* @__PURE__ */ getDefaultExportFromCjs(postcssExports);
|
|
4516
|
+
postcss.stringify;
|
|
4517
|
+
postcss.fromJSON;
|
|
4518
|
+
postcss.plugin;
|
|
4519
|
+
postcss.parse;
|
|
4520
|
+
postcss.list;
|
|
4521
|
+
postcss.document;
|
|
4522
|
+
postcss.comment;
|
|
4523
|
+
postcss.atRule;
|
|
4524
|
+
postcss.rule;
|
|
4525
|
+
postcss.decl;
|
|
4526
|
+
postcss.root;
|
|
4527
|
+
postcss.CssSyntaxError;
|
|
4528
|
+
postcss.Declaration;
|
|
4529
|
+
postcss.Container;
|
|
4530
|
+
postcss.Processor;
|
|
4531
|
+
postcss.Document;
|
|
4532
|
+
postcss.Comment;
|
|
4533
|
+
postcss.Warning;
|
|
4534
|
+
postcss.AtRule;
|
|
4535
|
+
postcss.Result;
|
|
4536
|
+
postcss.Input;
|
|
4537
|
+
postcss.Rule;
|
|
4538
|
+
postcss.Root;
|
|
4539
|
+
postcss.Node;
|
|
4540
|
+
var tagMap = {
|
|
4541
|
+
script: "noscript",
|
|
4542
|
+
// camel case svg element tag names
|
|
4543
|
+
altglyph: "altGlyph",
|
|
4544
|
+
altglyphdef: "altGlyphDef",
|
|
4545
|
+
altglyphitem: "altGlyphItem",
|
|
4546
|
+
animatecolor: "animateColor",
|
|
4547
|
+
animatemotion: "animateMotion",
|
|
4548
|
+
animatetransform: "animateTransform",
|
|
4549
|
+
clippath: "clipPath",
|
|
4550
|
+
feblend: "feBlend",
|
|
4551
|
+
fecolormatrix: "feColorMatrix",
|
|
4552
|
+
fecomponenttransfer: "feComponentTransfer",
|
|
4553
|
+
fecomposite: "feComposite",
|
|
4554
|
+
feconvolvematrix: "feConvolveMatrix",
|
|
4555
|
+
fediffuselighting: "feDiffuseLighting",
|
|
4556
|
+
fedisplacementmap: "feDisplacementMap",
|
|
4557
|
+
fedistantlight: "feDistantLight",
|
|
4558
|
+
fedropshadow: "feDropShadow",
|
|
4559
|
+
feflood: "feFlood",
|
|
4560
|
+
fefunca: "feFuncA",
|
|
4561
|
+
fefuncb: "feFuncB",
|
|
4562
|
+
fefuncg: "feFuncG",
|
|
4563
|
+
fefuncr: "feFuncR",
|
|
4564
|
+
fegaussianblur: "feGaussianBlur",
|
|
4565
|
+
feimage: "feImage",
|
|
4566
|
+
femerge: "feMerge",
|
|
4567
|
+
femergenode: "feMergeNode",
|
|
4568
|
+
femorphology: "feMorphology",
|
|
4569
|
+
feoffset: "feOffset",
|
|
4570
|
+
fepointlight: "fePointLight",
|
|
4571
|
+
fespecularlighting: "feSpecularLighting",
|
|
4572
|
+
fespotlight: "feSpotLight",
|
|
4573
|
+
fetile: "feTile",
|
|
4574
|
+
feturbulence: "feTurbulence",
|
|
4575
|
+
foreignobject: "foreignObject",
|
|
4576
|
+
glyphref: "glyphRef",
|
|
4577
|
+
lineargradient: "linearGradient",
|
|
4578
|
+
radialgradient: "radialGradient"
|
|
4579
|
+
};
|
|
4580
|
+
function getTagName(n) {
|
|
4581
|
+
let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
4582
|
+
if (tagName === "link" && n.attributes._cssText) {
|
|
4583
|
+
tagName = "style";
|
|
4584
|
+
}
|
|
4585
|
+
return tagName;
|
|
4586
|
+
}
|
|
4587
|
+
function adaptCssForReplay(cssText, cache) {
|
|
4588
|
+
const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
4589
|
+
if (cachedStyle) return cachedStyle;
|
|
4590
|
+
let result2 = cssText;
|
|
4591
|
+
try {
|
|
4592
|
+
const ast = postcss([
|
|
4593
|
+
mediaSelectorPlugin,
|
|
4594
|
+
pseudoClassPlugin
|
|
4595
|
+
]).process(cssText, { parser: safeParser });
|
|
4596
|
+
result2 = ast.css;
|
|
4597
|
+
} catch (error) {
|
|
4598
|
+
console.warn("Failed to adapt css for replay", error);
|
|
4599
|
+
}
|
|
4600
|
+
cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
|
|
4601
|
+
return result2;
|
|
4602
|
+
}
|
|
4603
|
+
function createCache() {
|
|
4604
|
+
const stylesWithHoverClass = /* @__PURE__ */ new Map();
|
|
4605
|
+
return {
|
|
4606
|
+
stylesWithHoverClass
|
|
4607
|
+
};
|
|
4608
|
+
}
|
|
4609
|
+
function safeDocNode(n, options) {
|
|
4610
|
+
let stringContent = n.textContent;
|
|
4611
|
+
if (n.isStyle && options.hackCss) {
|
|
4612
|
+
try {
|
|
4613
|
+
stringContent = adaptCssForReplay(n.textContent, options.cache);
|
|
4614
|
+
} catch (e) {
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
return options.doc.createTextNode(stringContent);
|
|
4618
|
+
}
|
|
4619
|
+
function buildNode(n, options) {
|
|
4620
|
+
var _a;
|
|
4621
|
+
const { doc, hackCss, cache } = options;
|
|
4622
|
+
switch (n.type) {
|
|
4623
|
+
case types.NodeType$1.Document:
|
|
4624
|
+
return doc.implementation.createDocument(null, "", null);
|
|
4625
|
+
case types.NodeType$1.DocumentType:
|
|
4626
|
+
return doc.implementation.createDocumentType(
|
|
4627
|
+
n.name || "html",
|
|
4628
|
+
n.publicId,
|
|
4629
|
+
n.systemId
|
|
4630
|
+
);
|
|
4631
|
+
case types.NodeType$1.Element: {
|
|
4632
|
+
const tagName = getTagName(n);
|
|
4633
|
+
let node2;
|
|
4634
|
+
if (n.isSVG) {
|
|
4635
|
+
node2 = doc.createElementNS("http://www.w3.org/2000/svg", tagName);
|
|
4636
|
+
} else {
|
|
4637
|
+
if (
|
|
4638
|
+
// If the tag name is a custom element name
|
|
4639
|
+
n.isCustom && // If the browser supports custom elements
|
|
4640
|
+
((_a = doc.defaultView) == null ? void 0 : _a.customElements) && // If the custom element hasn't been defined yet
|
|
4641
|
+
!doc.defaultView.customElements.get(n.tagName)
|
|
4642
|
+
)
|
|
4643
|
+
doc.defaultView.customElements.define(
|
|
4644
|
+
n.tagName,
|
|
4645
|
+
class extends doc.defaultView.HTMLElement {
|
|
4646
|
+
}
|
|
4647
|
+
);
|
|
4648
|
+
node2 = doc.createElement(tagName);
|
|
4649
|
+
}
|
|
4650
|
+
const specialAttributes = {};
|
|
4651
|
+
for (const name in n.attributes) {
|
|
4652
|
+
if (!Object.prototype.hasOwnProperty.call(n.attributes, name)) {
|
|
4653
|
+
continue;
|
|
4654
|
+
}
|
|
4655
|
+
let value = n.attributes[name];
|
|
4656
|
+
if (tagName === "option" && name === "selected" && value === false) {
|
|
4657
|
+
continue;
|
|
4658
|
+
}
|
|
4659
|
+
if (value === null) {
|
|
4660
|
+
continue;
|
|
4661
|
+
}
|
|
4662
|
+
if (value === true) value = "";
|
|
4663
|
+
if (name.startsWith("rr_")) {
|
|
4664
|
+
specialAttributes[name] = value;
|
|
4665
|
+
continue;
|
|
4666
|
+
}
|
|
4667
|
+
const isTextarea = tagName === "textarea" && name === "value";
|
|
4668
|
+
const isRemoteOrDynamicCss = tagName === "style" && name === "_cssText";
|
|
4669
|
+
if (isRemoteOrDynamicCss && hackCss && typeof value === "string") {
|
|
4670
|
+
value = adaptCssForReplay(value, cache);
|
|
4671
|
+
}
|
|
4672
|
+
if ((isTextarea || isRemoteOrDynamicCss) && typeof value === "string") {
|
|
4673
|
+
node2.appendChild(doc.createTextNode(value));
|
|
4674
|
+
n.childNodes = [];
|
|
4675
|
+
continue;
|
|
4676
|
+
}
|
|
4677
|
+
try {
|
|
4678
|
+
if (n.isSVG && name === "xlink:href") {
|
|
4679
|
+
node2.setAttributeNS(
|
|
4680
|
+
"http://www.w3.org/1999/xlink",
|
|
4681
|
+
name,
|
|
4682
|
+
value.toString()
|
|
4683
|
+
);
|
|
4684
|
+
} else if (name === "onload" || name === "onclick" || name.substring(0, 7) === "onmouse") {
|
|
4685
|
+
node2.setAttribute("_" + name, value.toString());
|
|
4686
|
+
} else if (tagName === "meta" && n.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
|
|
4687
|
+
node2.setAttribute("csp-content", value.toString());
|
|
4688
|
+
continue;
|
|
4689
|
+
} else if (tagName === "link" && (n.attributes.rel === "preload" && n.attributes.as === "script" || n.attributes.rel === "modulepreload")) {
|
|
4690
|
+
} else if (tagName === "link" && n.attributes.rel === "prefetch" && typeof n.attributes.href === "string" && types.extractFileExtension(n.attributes.href) === "js") {
|
|
4691
|
+
} else if (tagName === "img" && n.attributes.srcset && n.attributes.rr_dataURL) {
|
|
4692
|
+
node2.setAttribute(
|
|
4693
|
+
"rrweb-original-srcset",
|
|
4694
|
+
n.attributes.srcset
|
|
4695
|
+
);
|
|
4696
|
+
} else {
|
|
4697
|
+
node2.setAttribute(name, value.toString());
|
|
4698
|
+
}
|
|
4699
|
+
} catch (error) {
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
for (const name in specialAttributes) {
|
|
4703
|
+
const value = specialAttributes[name];
|
|
4704
|
+
if (tagName === "canvas" && name === "rr_dataURL") {
|
|
4705
|
+
const image = doc.createElement("img");
|
|
4706
|
+
image.onload = () => {
|
|
4707
|
+
const ctx = node2.getContext("2d");
|
|
4708
|
+
if (ctx) {
|
|
4709
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
4710
|
+
}
|
|
4711
|
+
};
|
|
4712
|
+
image.src = value.toString();
|
|
4713
|
+
if (node2.RRNodeType)
|
|
4714
|
+
node2.rr_dataURL = value.toString();
|
|
4715
|
+
} else if (tagName === "img" && name === "rr_dataURL") {
|
|
4716
|
+
const image = node2;
|
|
4717
|
+
if (!image.currentSrc.startsWith("data:")) {
|
|
4718
|
+
image.setAttribute(
|
|
4719
|
+
"rrweb-original-src",
|
|
4720
|
+
n.attributes.src
|
|
4721
|
+
);
|
|
4722
|
+
image.src = value.toString();
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
if (name === "rr_width") {
|
|
4726
|
+
node2.style.setProperty("width", value.toString());
|
|
4727
|
+
} else if (name === "rr_height") {
|
|
4728
|
+
node2.style.setProperty("height", value.toString());
|
|
4729
|
+
} else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
|
|
4730
|
+
node2.currentTime = value;
|
|
4731
|
+
} else if (name === "rr_mediaState") {
|
|
4732
|
+
switch (value) {
|
|
4733
|
+
case "played":
|
|
4734
|
+
node2.play().catch((e) => console.warn("media playback error", e));
|
|
4735
|
+
break;
|
|
4736
|
+
case "paused":
|
|
4737
|
+
node2.pause();
|
|
4738
|
+
break;
|
|
4739
|
+
}
|
|
4740
|
+
} else if (name === "rr_mediaPlaybackRate" && typeof value === "number") {
|
|
4741
|
+
node2.playbackRate = value;
|
|
4742
|
+
} else if (name === "rr_mediaMuted" && typeof value === "boolean") {
|
|
4743
|
+
node2.muted = value;
|
|
4744
|
+
} else if (name === "rr_mediaLoop" && typeof value === "boolean") {
|
|
4745
|
+
node2.loop = value;
|
|
4746
|
+
} else if (name === "rr_mediaVolume" && typeof value === "number") {
|
|
4747
|
+
node2.volume = value;
|
|
4748
|
+
} else if (name === "rr_open_mode") {
|
|
4749
|
+
node2.setAttribute(
|
|
4750
|
+
"rr_open_mode",
|
|
4751
|
+
value
|
|
4752
|
+
);
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
if (n.isShadowHost) {
|
|
4756
|
+
if (!node2.shadowRoot) {
|
|
4757
|
+
node2.attachShadow({ mode: "open" });
|
|
4758
|
+
} else {
|
|
4759
|
+
while (node2.shadowRoot.firstChild) {
|
|
4760
|
+
node2.shadowRoot.removeChild(node2.shadowRoot.firstChild);
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
}
|
|
4764
|
+
return node2;
|
|
4765
|
+
}
|
|
4766
|
+
case types.NodeType$1.Text:
|
|
4767
|
+
return safeDocNode(n, {
|
|
4768
|
+
cache,
|
|
4769
|
+
doc,
|
|
4770
|
+
hackCss
|
|
4771
|
+
});
|
|
4772
|
+
case types.NodeType$1.CDATA:
|
|
4773
|
+
if (n.textContent.trim() === "") {
|
|
4774
|
+
return null;
|
|
4775
|
+
}
|
|
4776
|
+
return doc.createCDATASection(n.textContent);
|
|
4777
|
+
case types.NodeType$1.Comment:
|
|
4778
|
+
return doc.createComment(n.textContent);
|
|
4779
|
+
default:
|
|
4780
|
+
return null;
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
function buildNodeWithSN(n, options) {
|
|
4784
|
+
const {
|
|
4785
|
+
doc,
|
|
4786
|
+
mirror,
|
|
4787
|
+
skipChild = false,
|
|
4788
|
+
hackCss = true,
|
|
4789
|
+
afterAppend,
|
|
4790
|
+
cache
|
|
4791
|
+
} = options;
|
|
4792
|
+
if (mirror.has(n.id)) {
|
|
4793
|
+
const nodeInMirror = mirror.getNode(n.id);
|
|
4794
|
+
const meta = mirror.getMeta(nodeInMirror);
|
|
4795
|
+
if (types.isNodeMetaEqual(meta, n)) return mirror.getNode(n.id);
|
|
4796
|
+
}
|
|
4797
|
+
let node2 = buildNode(n, { doc, hackCss, cache });
|
|
4798
|
+
if (!node2) {
|
|
4799
|
+
return null;
|
|
4800
|
+
}
|
|
4801
|
+
if (n.rootId && mirror.getNode(n.rootId) !== doc) {
|
|
4802
|
+
mirror.replace(n.rootId, doc);
|
|
4803
|
+
}
|
|
4804
|
+
if (n.type === types.NodeType$1.Document) {
|
|
4805
|
+
doc.close();
|
|
4806
|
+
doc.open();
|
|
4807
|
+
if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== types.NodeType$1.DocumentType) {
|
|
4808
|
+
if (n.childNodes[0].type === types.NodeType$1.Element && "xmlns" in n.childNodes[0].attributes && n.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
|
|
4809
|
+
doc.write(
|
|
4810
|
+
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
|
|
4811
|
+
);
|
|
4812
|
+
} else {
|
|
4813
|
+
doc.write(
|
|
4814
|
+
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'
|
|
4815
|
+
);
|
|
4816
|
+
}
|
|
4817
|
+
}
|
|
4818
|
+
node2 = doc;
|
|
4819
|
+
}
|
|
4820
|
+
mirror.add(node2, n);
|
|
4821
|
+
if ((n.type === types.NodeType$1.Document || n.type === types.NodeType$1.Element) && !skipChild) {
|
|
4822
|
+
for (const childN of n.childNodes) {
|
|
4823
|
+
const childNode = buildNodeWithSN(childN, {
|
|
4824
|
+
doc,
|
|
4825
|
+
mirror,
|
|
4826
|
+
skipChild: false,
|
|
4827
|
+
hackCss,
|
|
4828
|
+
afterAppend,
|
|
4829
|
+
cache
|
|
4830
|
+
});
|
|
4831
|
+
if (!childNode) {
|
|
4832
|
+
console.warn("Failed to rebuild", childN);
|
|
4833
|
+
continue;
|
|
4834
|
+
}
|
|
4835
|
+
if (childN.isShadow && types.isElement(node2) && node2.shadowRoot) {
|
|
4836
|
+
node2.shadowRoot.appendChild(childNode);
|
|
4837
|
+
} else if (n.type === types.NodeType$1.Document && childN.type == types.NodeType$1.Element) {
|
|
4838
|
+
const htmlElement = childNode;
|
|
4839
|
+
let body = null;
|
|
4840
|
+
htmlElement.childNodes.forEach((child) => {
|
|
4841
|
+
if (child.nodeName === "BODY") body = child;
|
|
4842
|
+
});
|
|
4843
|
+
if (body) {
|
|
4844
|
+
htmlElement.removeChild(body);
|
|
4845
|
+
node2.appendChild(childNode);
|
|
4846
|
+
htmlElement.appendChild(body);
|
|
4847
|
+
} else {
|
|
4848
|
+
node2.appendChild(childNode);
|
|
4849
|
+
}
|
|
4850
|
+
} else if (n.type === types.NodeType$1.Document && childN.type === types.NodeType$1.DocumentType) {
|
|
4851
|
+
if (node2.firstChild && node2.firstChild.nodeType === 1) {
|
|
4852
|
+
node2.insertBefore(childNode, node2.firstChild);
|
|
4853
|
+
} else {
|
|
4854
|
+
node2.appendChild(childNode);
|
|
4855
|
+
}
|
|
4856
|
+
} else {
|
|
4857
|
+
node2.appendChild(childNode);
|
|
4858
|
+
}
|
|
4859
|
+
if (afterAppend) {
|
|
4860
|
+
afterAppend(childNode, childN.id);
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
return node2;
|
|
4865
|
+
}
|
|
4866
|
+
function visit(mirror, onVisit) {
|
|
4867
|
+
function walk(node2) {
|
|
4868
|
+
onVisit(node2);
|
|
4869
|
+
}
|
|
4870
|
+
for (const id of mirror.getIds()) {
|
|
4871
|
+
if (mirror.has(id)) {
|
|
4872
|
+
walk(mirror.getNode(id));
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
function handleScroll(node2, mirror) {
|
|
4877
|
+
const n = mirror.getMeta(node2);
|
|
4878
|
+
if ((n == null ? void 0 : n.type) !== types.NodeType$1.Element) {
|
|
4879
|
+
return;
|
|
4880
|
+
}
|
|
4881
|
+
const el = node2;
|
|
4882
|
+
for (const name in n.attributes) {
|
|
4883
|
+
if (!(Object.prototype.hasOwnProperty.call(n.attributes, name) && name.startsWith("rr_"))) {
|
|
4884
|
+
continue;
|
|
4885
|
+
}
|
|
4886
|
+
const value = n.attributes[name];
|
|
4887
|
+
if (name === "rr_scrollLeft") {
|
|
4888
|
+
el.scrollLeft = value;
|
|
4889
|
+
}
|
|
4890
|
+
if (name === "rr_scrollTop") {
|
|
4891
|
+
el.scrollTop = value;
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
function rebuild(n, options) {
|
|
4896
|
+
const {
|
|
4897
|
+
doc,
|
|
4898
|
+
onVisit,
|
|
4899
|
+
hackCss = true,
|
|
4900
|
+
afterAppend,
|
|
4901
|
+
cache,
|
|
4902
|
+
mirror = new types.Mirror()
|
|
4903
|
+
} = options;
|
|
4904
|
+
const node2 = buildNodeWithSN(n, {
|
|
4905
|
+
doc,
|
|
4906
|
+
mirror,
|
|
4907
|
+
skipChild: false,
|
|
4908
|
+
hackCss,
|
|
4909
|
+
afterAppend,
|
|
4910
|
+
cache
|
|
4911
|
+
});
|
|
4912
|
+
visit(mirror, (visitedNode) => {
|
|
4913
|
+
if (onVisit) {
|
|
4914
|
+
onVisit(visitedNode);
|
|
4915
|
+
}
|
|
4916
|
+
handleScroll(visitedNode, mirror);
|
|
4917
|
+
});
|
|
4918
|
+
return node2;
|
|
4919
|
+
}
|
|
4920
|
+
exports.Mirror = types.Mirror;
|
|
4921
|
+
exports.NodeType = types.NodeType;
|
|
4922
|
+
exports.absolutifyURLs = types.absolutifyURLs;
|
|
4923
|
+
exports.checkDataURLSize = types.checkDataURLSize;
|
|
4924
|
+
exports.createMirror = types.createMirror;
|
|
4925
|
+
exports.escapeImportStatement = types.escapeImportStatement;
|
|
4926
|
+
exports.extractFileExtension = types.extractFileExtension;
|
|
4927
|
+
exports.fixSafariColons = types.fixSafariColons;
|
|
4928
|
+
exports.getInputType = types.getInputType;
|
|
4929
|
+
exports.is2DCanvasBlank = types.is2DCanvasBlank;
|
|
4930
|
+
exports.isCSSImportRule = types.isCSSImportRule;
|
|
4931
|
+
exports.isCSSStyleRule = types.isCSSStyleRule;
|
|
4932
|
+
exports.isElement = types.isElement;
|
|
4933
|
+
exports.isNativeShadowDom = types.isNativeShadowDom;
|
|
4934
|
+
exports.isNodeMetaEqual = types.isNodeMetaEqual;
|
|
4935
|
+
exports.isShadowRoot = types.isShadowRoot;
|
|
4936
|
+
exports.maskInputValue = types.maskInputValue;
|
|
4937
|
+
exports.recompressBase64Image = types.recompressBase64Image;
|
|
4938
|
+
exports.stringifyRule = types.stringifyRule;
|
|
4939
|
+
exports.stringifyStylesheet = types.stringifyStylesheet;
|
|
4940
|
+
exports.toLowerCase = types.toLowerCase;
|
|
4941
|
+
exports.adaptCssForReplay = adaptCssForReplay;
|
|
4942
|
+
exports.buildNodeWithSN = buildNodeWithSN;
|
|
4943
|
+
exports.createCache = createCache;
|
|
4944
|
+
exports.rebuild = rebuild;
|
|
4945
|
+
if (typeof module.exports == "object" && typeof exports == "object") {
|
|
4946
|
+
var __cp = (to, from, except, desc) => {
|
|
4947
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
4948
|
+
for (let key of Object.getOwnPropertyNames(from)) {
|
|
4949
|
+
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
|
|
4950
|
+
Object.defineProperty(to, key, {
|
|
4951
|
+
get: () => from[key],
|
|
4952
|
+
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
|
|
4953
|
+
});
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4956
|
+
return to;
|
|
4957
|
+
};
|
|
4958
|
+
module.exports = __cp(module.exports, exports);
|
|
4959
|
+
}
|
|
4960
|
+
return module.exports;
|
|
4961
|
+
}))
|
|
4962
|
+
//# sourceMappingURL=replay.umd.cjs.map
|