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