playwright-ui5 1.5.0 → 1.6.0

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.
@@ -1,1474 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // node_modules/css-selector-parser/lib/indexes.js
30
- var require_indexes = __commonJS({
31
- "node_modules/css-selector-parser/lib/indexes.js"(exports) {
32
- "use strict";
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.createRegularIndex = exports.createMulticharIndex = exports.emptyRegularIndex = exports.emptyMulticharIndex = void 0;
35
- exports.emptyMulticharIndex = {};
36
- exports.emptyRegularIndex = {};
37
- function extendIndex(item, index) {
38
- var currentIndex = index;
39
- for (var pos = 0; pos < item.length; pos++) {
40
- var isLast = pos === item.length - 1;
41
- var char = item.charAt(pos);
42
- var charIndex = currentIndex[char] || (currentIndex[char] = { chars: {} });
43
- if (isLast) {
44
- charIndex.self = item;
45
- }
46
- currentIndex = charIndex.chars;
47
- }
48
- }
49
- function createMulticharIndex(items) {
50
- if (items.length === 0) {
51
- return exports.emptyMulticharIndex;
52
- }
53
- var index = {};
54
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
55
- var item = items_1[_i];
56
- extendIndex(item, index);
57
- }
58
- return index;
59
- }
60
- exports.createMulticharIndex = createMulticharIndex;
61
- function createRegularIndex(items) {
62
- if (items.length === 0) {
63
- return exports.emptyRegularIndex;
64
- }
65
- var result = {};
66
- for (var _i = 0, items_2 = items; _i < items_2.length; _i++) {
67
- var item = items_2[_i];
68
- result[item] = true;
69
- }
70
- return result;
71
- }
72
- exports.createRegularIndex = createRegularIndex;
73
- }
74
- });
75
-
76
- // node_modules/css-selector-parser/lib/pseudo-class-signatures.js
77
- var require_pseudo_class_signatures = __commonJS({
78
- "node_modules/css-selector-parser/lib/pseudo-class-signatures.js"(exports) {
79
- "use strict";
80
- Object.defineProperty(exports, "__esModule", { value: true });
81
- exports.calculatePseudoClassSignatures = exports.inverseCategories = exports.defaultPseudoClassSignature = exports.emptyPseudoClassSignatures = void 0;
82
- exports.emptyPseudoClassSignatures = {};
83
- exports.defaultPseudoClassSignature = {
84
- type: "String",
85
- optional: true
86
- };
87
- function calculatePseudoClassSignature(types) {
88
- var result = {
89
- optional: false
90
- };
91
- function setResultType(type2) {
92
- if (result.type && result.type !== type2) {
93
- throw new Error('Conflicting pseudo-class argument type: "'.concat(result.type, '" vs "').concat(type2, '".'));
94
- }
95
- result.type = type2;
96
- }
97
- for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
98
- var type = types_1[_i];
99
- if (type === "NoArgument") {
100
- result.optional = true;
101
- }
102
- if (type === "Formula") {
103
- setResultType("Formula");
104
- }
105
- if (type === "FormulaOfSelector") {
106
- setResultType("Formula");
107
- result.ofSelector = true;
108
- }
109
- if (type === "String") {
110
- setResultType("String");
111
- }
112
- if (type === "Selector") {
113
- setResultType("Selector");
114
- }
115
- }
116
- return result;
117
- }
118
- function inverseCategories(obj) {
119
- var result = {};
120
- for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
121
- var category = _a[_i];
122
- var items = obj[category];
123
- if (items) {
124
- for (var _b = 0, _c = items; _b < _c.length; _b++) {
125
- var item = _c[_b];
126
- (result[item] || (result[item] = [])).push(category);
127
- }
128
- }
129
- }
130
- return result;
131
- }
132
- exports.inverseCategories = inverseCategories;
133
- function calculatePseudoClassSignatures(definitions) {
134
- var pseudoClassesToArgumentTypes = inverseCategories(definitions);
135
- var result = {};
136
- for (var _i = 0, _a = Object.keys(pseudoClassesToArgumentTypes); _i < _a.length; _i++) {
137
- var pseudoClass = _a[_i];
138
- var argumentTypes = pseudoClassesToArgumentTypes[pseudoClass];
139
- if (argumentTypes) {
140
- result[pseudoClass] = calculatePseudoClassSignature(argumentTypes);
141
- }
142
- }
143
- return result;
144
- }
145
- exports.calculatePseudoClassSignatures = calculatePseudoClassSignatures;
146
- }
147
- });
148
-
149
- // node_modules/css-selector-parser/lib/syntax-definitions.js
150
- var require_syntax_definitions = __commonJS({
151
- "node_modules/css-selector-parser/lib/syntax-definitions.js"(exports) {
152
- "use strict";
153
- var __assign = exports && exports.__assign || function() {
154
- __assign = Object.assign || function(t) {
155
- for (var s, i = 1, n = arguments.length; i < n; i++) {
156
- s = arguments[i];
157
- for (var p in s)
158
- if (Object.prototype.hasOwnProperty.call(s, p))
159
- t[p] = s[p];
160
- }
161
- return t;
162
- };
163
- return __assign.apply(this, arguments);
164
- };
165
- Object.defineProperty(exports, "__esModule", { value: true });
166
- exports.cssSyntaxDefinitions = exports.extendSyntaxDefinition = exports.getXmlOptions = void 0;
167
- var emptyXmlOptions = {};
168
- var defaultXmlOptions = { wildcard: true };
169
- function getXmlOptions(param) {
170
- if (param) {
171
- if (typeof param === "boolean") {
172
- return defaultXmlOptions;
173
- } else {
174
- return param;
175
- }
176
- } else {
177
- return emptyXmlOptions;
178
- }
179
- }
180
- exports.getXmlOptions = getXmlOptions;
181
- function extendSyntaxDefinition(base, extension) {
182
- var result = __assign({}, base);
183
- if ("tag" in extension) {
184
- if (extension.tag) {
185
- result.tag = __assign({}, getXmlOptions(base.tag));
186
- var extensionOptions = getXmlOptions(extension.tag);
187
- if ("wildcard" in extensionOptions) {
188
- result.tag.wildcard = extensionOptions.wildcard;
189
- }
190
- } else {
191
- result.tag = void 0;
192
- }
193
- }
194
- if ("ids" in extension) {
195
- result.ids = extension.ids;
196
- }
197
- if ("classNames" in extension) {
198
- result.classNames = extension.classNames;
199
- }
200
- if ("namespace" in extension) {
201
- if (extension.namespace) {
202
- result.namespace = __assign({}, getXmlOptions(base.namespace));
203
- var extensionOptions = getXmlOptions(extension.namespace);
204
- if ("wildcard" in extensionOptions) {
205
- result.namespace.wildcard = extensionOptions.wildcard;
206
- }
207
- } else {
208
- result.namespace = void 0;
209
- }
210
- }
211
- if ("combinators" in extension) {
212
- if (extension.combinators) {
213
- result.combinators = result.combinators ? result.combinators.concat(extension.combinators) : extension.combinators;
214
- } else {
215
- result.combinators = void 0;
216
- }
217
- }
218
- if ("attributes" in extension) {
219
- if (extension.attributes) {
220
- result.attributes = __assign({}, base.attributes);
221
- if ("unknownCaseSensitivityModifiers" in extension.attributes) {
222
- result.attributes.unknownCaseSensitivityModifiers = extension.attributes.unknownCaseSensitivityModifiers;
223
- }
224
- if ("operators" in extension.attributes) {
225
- result.attributes.operators = extension.attributes.operators ? result.attributes.operators ? result.attributes.operators.concat(extension.attributes.operators) : extension.attributes.operators : void 0;
226
- }
227
- if ("caseSensitivityModifiers" in extension.attributes) {
228
- result.attributes.caseSensitivityModifiers = extension.attributes.caseSensitivityModifiers ? result.attributes.caseSensitivityModifiers ? result.attributes.caseSensitivityModifiers.concat(extension.attributes.caseSensitivityModifiers) : extension.attributes.caseSensitivityModifiers : void 0;
229
- }
230
- } else {
231
- result.attributes = void 0;
232
- }
233
- }
234
- if ("pseudoElements" in extension) {
235
- if (extension.pseudoElements) {
236
- result.pseudoElements = __assign({}, base.pseudoElements);
237
- if ("unknown" in extension.pseudoElements) {
238
- result.pseudoElements.unknown = extension.pseudoElements.unknown;
239
- }
240
- if ("notation" in extension.pseudoElements) {
241
- result.pseudoElements.notation = extension.pseudoElements.notation;
242
- }
243
- if ("definitions" in extension.pseudoElements) {
244
- result.pseudoElements.definitions = extension.pseudoElements.definitions ? result.pseudoElements.definitions ? result.pseudoElements.definitions.concat(extension.pseudoElements.definitions) : extension.pseudoElements.definitions : void 0;
245
- }
246
- } else {
247
- result.pseudoElements = void 0;
248
- }
249
- }
250
- if ("pseudoClasses" in extension) {
251
- if (extension.pseudoClasses) {
252
- result.pseudoClasses = __assign({}, base.pseudoClasses);
253
- if ("unknown" in extension.pseudoClasses) {
254
- result.pseudoClasses.unknown = extension.pseudoClasses.unknown;
255
- }
256
- if ("definitions" in extension.pseudoClasses) {
257
- var newDefinitions = extension.pseudoClasses.definitions;
258
- if (newDefinitions) {
259
- result.pseudoClasses.definitions = __assign({}, result.pseudoClasses.definitions);
260
- var existingDefinitions = result.pseudoClasses.definitions;
261
- for (var _i = 0, _a = Object.keys(newDefinitions); _i < _a.length; _i++) {
262
- var key = _a[_i];
263
- var newDefinitionForNotation = newDefinitions[key];
264
- var existingDefinitionForNotation = existingDefinitions[key];
265
- if (newDefinitionForNotation) {
266
- existingDefinitions[key] = existingDefinitionForNotation ? existingDefinitionForNotation.concat(newDefinitionForNotation) : newDefinitionForNotation;
267
- } else {
268
- existingDefinitions[key] = void 0;
269
- }
270
- }
271
- } else {
272
- result.pseudoClasses.definitions = void 0;
273
- }
274
- }
275
- } else {
276
- result.pseudoClasses = void 0;
277
- }
278
- }
279
- return result;
280
- }
281
- exports.extendSyntaxDefinition = extendSyntaxDefinition;
282
- var css1SyntaxDefinition = {
283
- tag: {},
284
- ids: true,
285
- classNames: true,
286
- combinators: [],
287
- pseudoElements: {
288
- unknown: "reject",
289
- notation: "singleColon",
290
- definitions: ["first-letter", "first-line"]
291
- },
292
- pseudoClasses: {
293
- unknown: "reject",
294
- definitions: {
295
- NoArgument: ["link", "visited", "active"]
296
- }
297
- }
298
- };
299
- var css2SyntaxDefinition = extendSyntaxDefinition(css1SyntaxDefinition, {
300
- tag: { wildcard: true },
301
- combinators: [">", "+"],
302
- attributes: {
303
- unknownCaseSensitivityModifiers: "reject",
304
- operators: ["=", "~=", "|="]
305
- },
306
- pseudoElements: {
307
- definitions: ["before", "after"]
308
- },
309
- pseudoClasses: {
310
- unknown: "reject",
311
- definitions: {
312
- NoArgument: ["hover", "focus", "first-child"],
313
- String: ["lang"]
314
- }
315
- }
316
- });
317
- var selectors3SyntaxDefinition = extendSyntaxDefinition(css2SyntaxDefinition, {
318
- namespace: {
319
- wildcard: true
320
- },
321
- combinators: ["~"],
322
- attributes: {
323
- operators: ["^=", "$=", "*="]
324
- },
325
- pseudoElements: {
326
- notation: "both"
327
- },
328
- pseudoClasses: {
329
- definitions: {
330
- NoArgument: [
331
- "root",
332
- "last-child",
333
- "first-of-type",
334
- "last-of-type",
335
- "only-child",
336
- "only-of-type",
337
- "empty",
338
- "target",
339
- "enabled",
340
- "disabled",
341
- "checked",
342
- "indeterminate"
343
- ],
344
- Formula: ["nth-child", "nth-last-child", "nth-of-type", "nth-last-of-type"],
345
- Selector: ["not"]
346
- }
347
- }
348
- });
349
- var selectors4SyntaxDefinition = extendSyntaxDefinition(selectors3SyntaxDefinition, {
350
- combinators: ["||"],
351
- attributes: {
352
- caseSensitivityModifiers: ["i", "I", "s", "S"]
353
- },
354
- pseudoClasses: {
355
- definitions: {
356
- NoArgument: [
357
- "any-link",
358
- "local-link",
359
- "target-within",
360
- "scope",
361
- "current",
362
- "past",
363
- "future",
364
- "focus-within",
365
- "focus-visible",
366
- "read-write",
367
- "read-only",
368
- "placeholder-shown",
369
- "default",
370
- "valid",
371
- "invalid",
372
- "in-range",
373
- "out-of-range",
374
- "required",
375
- "optional",
376
- "blank",
377
- "user-invalid"
378
- ],
379
- Formula: ["nth-col", "nth-last-col"],
380
- String: ["dir"],
381
- FormulaOfSelector: ["nth-child", "nth-last-child"],
382
- Selector: ["current", "is", "where", "has"]
383
- }
384
- }
385
- });
386
- var progressiveSyntaxDefinition = extendSyntaxDefinition(selectors4SyntaxDefinition, {
387
- pseudoElements: {
388
- unknown: "accept"
389
- },
390
- pseudoClasses: {
391
- unknown: "accept"
392
- },
393
- attributes: {
394
- unknownCaseSensitivityModifiers: "accept"
395
- }
396
- });
397
- exports.cssSyntaxDefinitions = {
398
- css1: css1SyntaxDefinition,
399
- css2: css2SyntaxDefinition,
400
- css3: selectors3SyntaxDefinition,
401
- "selectors-3": selectors3SyntaxDefinition,
402
- "selectors-4": selectors4SyntaxDefinition,
403
- latest: selectors4SyntaxDefinition,
404
- progressive: progressiveSyntaxDefinition
405
- };
406
- }
407
- });
408
-
409
- // node_modules/css-selector-parser/lib/utils.js
410
- var require_utils = __commonJS({
411
- "node_modules/css-selector-parser/lib/utils.js"(exports) {
412
- "use strict";
413
- Object.defineProperty(exports, "__esModule", { value: true });
414
- exports.escapePseudoClassString = exports.escapeStr = exports.escapeIdentifier = exports.digitsChars = exports.quoteChars = exports.whitespaceChars = exports.stringEscapeChars = exports.strReplacementsRev = exports.identSpecialChars = exports.isHex = exports.isIdent = exports.isIdentStart = void 0;
415
- function isIdentStart(c) {
416
- return c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-" || c === "_";
417
- }
418
- exports.isIdentStart = isIdentStart;
419
- function isIdent(c) {
420
- return c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "-" || c === "_";
421
- }
422
- exports.isIdent = isIdent;
423
- function isHex(c) {
424
- return c >= "a" && c <= "f" || c >= "A" && c <= "F" || c >= "0" && c <= "9";
425
- }
426
- exports.isHex = isHex;
427
- exports.identSpecialChars = {
428
- "!": true,
429
- '"': true,
430
- "#": true,
431
- $: true,
432
- "%": true,
433
- "&": true,
434
- "'": true,
435
- "(": true,
436
- ")": true,
437
- "*": true,
438
- "+": true,
439
- ",": true,
440
- ".": true,
441
- "/": true,
442
- ";": true,
443
- "<": true,
444
- "=": true,
445
- ">": true,
446
- "?": true,
447
- "@": true,
448
- "[": true,
449
- "\\": true,
450
- "]": true,
451
- "^": true,
452
- "`": true,
453
- "{": true,
454
- "|": true,
455
- "}": true,
456
- "~": true
457
- };
458
- exports.strReplacementsRev = {
459
- "\n": "\\n",
460
- "\r": "\\r",
461
- " ": "\\t",
462
- "\f": "\\f",
463
- "\v": "\\v"
464
- };
465
- exports.stringEscapeChars = {
466
- n: "\n",
467
- r: "\r",
468
- t: " ",
469
- f: "\f",
470
- "\\": "\\"
471
- };
472
- exports.whitespaceChars = {
473
- " ": true,
474
- " ": true,
475
- "\n": true,
476
- "\r": true,
477
- "\f": true
478
- };
479
- exports.quoteChars = {
480
- '"': true,
481
- "'": true
482
- };
483
- exports.digitsChars = {
484
- 0: true,
485
- 1: true,
486
- 2: true,
487
- 3: true,
488
- 4: true,
489
- 5: true,
490
- 6: true,
491
- 7: true,
492
- 8: true,
493
- 9: true
494
- };
495
- function escapeIdentifier(s) {
496
- var len = s.length;
497
- var result = "";
498
- var i = 0;
499
- while (i < len) {
500
- var chr = s.charAt(i);
501
- if (exports.identSpecialChars[chr]) {
502
- result += "\\" + chr;
503
- } else {
504
- if (!(chr === "_" || chr === "-" || chr >= "A" && chr <= "Z" || chr >= "a" && chr <= "z" || i !== 0 && chr >= "0" && chr <= "9")) {
505
- var charCode = chr.charCodeAt(0);
506
- if ((charCode & 63488) === 55296) {
507
- var extraCharCode = s.charCodeAt(i++);
508
- if ((charCode & 64512) !== 55296 || (extraCharCode & 64512) !== 56320) {
509
- throw Error("UCS-2(decode): illegal sequence");
510
- }
511
- charCode = ((charCode & 1023) << 10) + (extraCharCode & 1023) + 65536;
512
- }
513
- result += "\\" + charCode.toString(16) + " ";
514
- } else {
515
- result += chr;
516
- }
517
- }
518
- i++;
519
- }
520
- return result.trim();
521
- }
522
- exports.escapeIdentifier = escapeIdentifier;
523
- function escapeStr(s) {
524
- var len = s.length;
525
- var result = "";
526
- var i = 0;
527
- var replacement;
528
- while (i < len) {
529
- var chr = s.charAt(i);
530
- if (chr === '"') {
531
- chr = '\\"';
532
- } else if (chr === "\\") {
533
- chr = "\\\\";
534
- } else if ((replacement = exports.strReplacementsRev[chr]) !== void 0) {
535
- chr = replacement;
536
- }
537
- result += chr;
538
- i++;
539
- }
540
- return '"'.concat(result, '"');
541
- }
542
- exports.escapeStr = escapeStr;
543
- var escapePseudoClassString = function(s) {
544
- return s.replace(/([\\)])/g, "\\$1");
545
- };
546
- exports.escapePseudoClassString = escapePseudoClassString;
547
- }
548
- });
549
-
550
- // node_modules/css-selector-parser/lib/parser.js
551
- var require_parser = __commonJS({
552
- "node_modules/css-selector-parser/lib/parser.js"(exports) {
553
- "use strict";
554
- Object.defineProperty(exports, "__esModule", { value: true });
555
- exports.createParser = void 0;
556
- var indexes_1 = require_indexes();
557
- var pseudo_class_signatures_1 = require_pseudo_class_signatures();
558
- var syntax_definitions_1 = require_syntax_definitions();
559
- var utils_1 = require_utils();
560
- var errorPrefix = "css-selector-parser parse error: ";
561
- function createParser2(options) {
562
- if (options === void 0) {
563
- options = {};
564
- }
565
- var _a = options.syntax, syntax = _a === void 0 ? "latest" : _a, substitutes = options.substitutes, _b = options.strict, strict = _b === void 0 ? true : _b;
566
- var syntaxDefinition = typeof syntax === "string" ? syntax_definitions_1.cssSyntaxDefinitions[syntax] : syntax;
567
- if (syntaxDefinition.baseSyntax) {
568
- syntaxDefinition = (0, syntax_definitions_1.extendSyntaxDefinition)(syntax_definitions_1.cssSyntaxDefinitions[syntaxDefinition.baseSyntax], syntaxDefinition);
569
- }
570
- var _c = syntaxDefinition.tag ? [true, Boolean((0, syntax_definitions_1.getXmlOptions)(syntaxDefinition.tag).wildcard)] : [false, false], tagNameEnabled = _c[0], tagNameWildcardEnabled = _c[1];
571
- var idEnabled = Boolean(syntaxDefinition.ids);
572
- var classNamesEnabled = Boolean(syntaxDefinition.classNames);
573
- var namespaceEnabled = Boolean(syntaxDefinition.namespace);
574
- var namespaceWildcardEnabled = syntaxDefinition.namespace && (syntaxDefinition.namespace === true || syntaxDefinition.namespace.wildcard === true);
575
- if (namespaceEnabled && !tagNameEnabled) {
576
- throw new Error("".concat(errorPrefix, "Namespaces cannot be enabled while tags are disabled."));
577
- }
578
- var substitutesEnabled = Boolean(substitutes);
579
- var combinatorsIndex = syntaxDefinition.combinators ? (0, indexes_1.createMulticharIndex)(syntaxDefinition.combinators) : indexes_1.emptyMulticharIndex;
580
- var _d = syntaxDefinition.attributes ? [
581
- true,
582
- syntaxDefinition.attributes.operators ? (0, indexes_1.createMulticharIndex)(syntaxDefinition.attributes.operators) : indexes_1.emptyMulticharIndex,
583
- syntaxDefinition.attributes.caseSensitivityModifiers ? (0, indexes_1.createRegularIndex)(syntaxDefinition.attributes.caseSensitivityModifiers) : indexes_1.emptyRegularIndex,
584
- syntaxDefinition.attributes.unknownCaseSensitivityModifiers === "accept"
585
- ] : [false, indexes_1.emptyMulticharIndex, indexes_1.emptyRegularIndex, false], attributesEnabled = _d[0], attributesOperatorsIndex = _d[1], attributesCaseSensitivityModifiers = _d[2], attributesAcceptUnknownCaseSensitivityModifiers = _d[3];
586
- var attributesCaseSensitivityModifiersEnabled = attributesAcceptUnknownCaseSensitivityModifiers || Object.keys(attributesCaseSensitivityModifiers).length > 0;
587
- var _e = syntaxDefinition.pseudoClasses ? [
588
- true,
589
- syntaxDefinition.pseudoClasses.definitions ? (0, pseudo_class_signatures_1.calculatePseudoClassSignatures)(syntaxDefinition.pseudoClasses.definitions) : pseudo_class_signatures_1.emptyPseudoClassSignatures,
590
- syntaxDefinition.pseudoClasses.unknown === "accept"
591
- ] : [false, pseudo_class_signatures_1.emptyPseudoClassSignatures, false], pseudoClassesEnabled = _e[0], paeudoClassesDefinitions = _e[1], pseudoClassesAcceptUnknown = _e[2];
592
- var _f = syntaxDefinition.pseudoElements ? [
593
- true,
594
- syntaxDefinition.pseudoElements.notation === "singleColon" || syntaxDefinition.pseudoElements.notation === "both",
595
- !syntaxDefinition.pseudoElements.notation || syntaxDefinition.pseudoElements.notation === "doubleColon" || syntaxDefinition.pseudoElements.notation === "both",
596
- syntaxDefinition.pseudoElements.definitions ? (0, indexes_1.createRegularIndex)(syntaxDefinition.pseudoElements.definitions) : indexes_1.emptyRegularIndex,
597
- syntaxDefinition.pseudoElements.unknown === "accept"
598
- ] : [false, false, false, indexes_1.emptyRegularIndex, false], pseudoElementsEnabled = _f[0], pseudoElementsSingleColonNotationEnabled = _f[1], pseudoElementsDoubleColonNotationEnabled = _f[2], pseudoElementsIndex = _f[3], pseudoElementsAcceptUnknown = _f[4];
599
- var str = "";
600
- var l = str.length;
601
- var pos = 0;
602
- var chr = "";
603
- var is = function(comparison) {
604
- return chr === comparison;
605
- };
606
- var isTagStart = function() {
607
- return is("*") || (0, utils_1.isIdentStart)(chr) || is("\\");
608
- };
609
- var rewind = function(newPos) {
610
- pos = newPos;
611
- chr = str.charAt(pos);
612
- };
613
- var next = function() {
614
- pos++;
615
- chr = str.charAt(pos);
616
- };
617
- var readAndNext = function() {
618
- var current = chr;
619
- pos++;
620
- chr = str.charAt(pos);
621
- return current;
622
- };
623
- function fail(errorMessage) {
624
- var position = Math.min(l - 1, pos);
625
- var error = new Error("".concat(errorPrefix).concat(errorMessage, " Pos: ").concat(position, "."));
626
- error.position = position;
627
- error.name = "ParserError";
628
- throw error;
629
- }
630
- function assert(condition, errorMessage) {
631
- if (!condition) {
632
- return fail(errorMessage);
633
- }
634
- }
635
- var assertNonEof = function() {
636
- assert(pos < l, "Unexpected end of input.");
637
- };
638
- var isEof = function() {
639
- return pos >= l;
640
- };
641
- var pass = function(character) {
642
- assert(pos < l, 'Expected "'.concat(character, '" but end of input reached.'));
643
- assert(chr === character, 'Expected "'.concat(character, '" but "').concat(chr, '" found.'));
644
- pos++;
645
- chr = str.charAt(pos);
646
- };
647
- function matchMulticharIndex(index) {
648
- var match = matchMulticharIndexPos(index, pos);
649
- if (match) {
650
- pos += match.length;
651
- chr = str.charAt(pos);
652
- return match;
653
- }
654
- }
655
- function matchMulticharIndexPos(index, subPos) {
656
- var char = str.charAt(subPos);
657
- var charIndex = index[char];
658
- if (charIndex) {
659
- var subMatch = matchMulticharIndexPos(charIndex.chars, subPos + 1);
660
- if (subMatch) {
661
- return subMatch;
662
- }
663
- if (charIndex.self) {
664
- return charIndex.self;
665
- }
666
- }
667
- }
668
- function parseHex() {
669
- var hex = readAndNext();
670
- while ((0, utils_1.isHex)(chr)) {
671
- hex += readAndNext();
672
- }
673
- if (is(" ")) {
674
- next();
675
- }
676
- return String.fromCharCode(parseInt(hex, 16));
677
- }
678
- function parseString(quote) {
679
- var result = "";
680
- pass(quote);
681
- while (pos < l) {
682
- if (is(quote)) {
683
- next();
684
- return result;
685
- } else if (is("\\")) {
686
- next();
687
- var esc = void 0;
688
- if (is(quote)) {
689
- result += quote;
690
- } else if ((esc = utils_1.stringEscapeChars[chr]) !== void 0) {
691
- result += esc;
692
- } else if ((0, utils_1.isHex)(chr)) {
693
- result += parseHex();
694
- continue;
695
- } else {
696
- result += chr;
697
- }
698
- } else {
699
- result += chr;
700
- }
701
- next();
702
- }
703
- return result;
704
- }
705
- function parseIdentifier() {
706
- var result = "";
707
- while (pos < l) {
708
- if ((0, utils_1.isIdent)(chr)) {
709
- result += readAndNext();
710
- } else if (is("\\")) {
711
- next();
712
- assertNonEof();
713
- if ((0, utils_1.isHex)(chr)) {
714
- result += parseHex();
715
- } else {
716
- result += readAndNext();
717
- }
718
- } else {
719
- return result;
720
- }
721
- }
722
- return result;
723
- }
724
- function parsePseudoClassString() {
725
- var result = "";
726
- while (pos < l) {
727
- if (is(")")) {
728
- break;
729
- } else if (is("\\")) {
730
- next();
731
- if (isEof() && !strict) {
732
- return (result + "\\").trim();
733
- }
734
- assertNonEof();
735
- if ((0, utils_1.isHex)(chr)) {
736
- result += parseHex();
737
- } else {
738
- result += readAndNext();
739
- }
740
- } else {
741
- result += readAndNext();
742
- }
743
- }
744
- return result.trim();
745
- }
746
- function skipWhitespace() {
747
- while (utils_1.whitespaceChars[chr]) {
748
- next();
749
- }
750
- }
751
- function parseSelector2(relative) {
752
- if (relative === void 0) {
753
- relative = false;
754
- }
755
- skipWhitespace();
756
- var rules = [parseRule(relative)];
757
- while (is(",")) {
758
- next();
759
- skipWhitespace();
760
- rules.push(parseRule(relative));
761
- }
762
- return {
763
- type: "Selector",
764
- rules
765
- };
766
- }
767
- function parseAttribute() {
768
- pass("[");
769
- skipWhitespace();
770
- var attr;
771
- if (is("|")) {
772
- assert(namespaceEnabled, "Namespaces are not enabled.");
773
- next();
774
- attr = {
775
- type: "Attribute",
776
- name: parseIdentifier(),
777
- namespace: { type: "NoNamespace" }
778
- };
779
- } else if (is("*")) {
780
- assert(namespaceEnabled, "Namespaces are not enabled.");
781
- assert(namespaceWildcardEnabled, "Wildcard namespace is not enabled.");
782
- next();
783
- pass("|");
784
- attr = {
785
- type: "Attribute",
786
- name: parseIdentifier(),
787
- namespace: { type: "WildcardNamespace" }
788
- };
789
- } else {
790
- var identifier = parseIdentifier();
791
- attr = {
792
- type: "Attribute",
793
- name: identifier
794
- };
795
- if (is("|")) {
796
- var savedPos = pos;
797
- next();
798
- if ((0, utils_1.isIdentStart)(chr) || is("\\")) {
799
- assert(namespaceEnabled, "Namespaces are not enabled.");
800
- attr = {
801
- type: "Attribute",
802
- name: parseIdentifier(),
803
- namespace: { type: "NamespaceName", name: identifier }
804
- };
805
- } else {
806
- rewind(savedPos);
807
- }
808
- }
809
- }
810
- assert(attr.name, "Expected attribute name.");
811
- skipWhitespace();
812
- if (isEof() && !strict) {
813
- return attr;
814
- }
815
- if (is("]")) {
816
- next();
817
- } else {
818
- attr.operator = matchMulticharIndex(attributesOperatorsIndex);
819
- assert(attr.operator, "Expected a valid attribute selector operator.");
820
- skipWhitespace();
821
- assertNonEof();
822
- if (utils_1.quoteChars[chr]) {
823
- attr.value = {
824
- type: "String",
825
- value: parseString(chr)
826
- };
827
- } else if (substitutesEnabled && is("$")) {
828
- next();
829
- attr.value = {
830
- type: "Substitution",
831
- name: parseIdentifier()
832
- };
833
- assert(attr.value.name, "Expected substitute name.");
834
- } else {
835
- attr.value = {
836
- type: "String",
837
- value: parseIdentifier()
838
- };
839
- assert(attr.value.value, "Expected attribute value.");
840
- }
841
- skipWhitespace();
842
- if (isEof() && !strict) {
843
- return attr;
844
- }
845
- if (!is("]")) {
846
- attr.caseSensitivityModifier = parseIdentifier();
847
- assert(attr.caseSensitivityModifier, "Expected end of attribute selector.");
848
- assert(attributesCaseSensitivityModifiersEnabled, "Attribute case sensitivity modifiers are not enabled.");
849
- assert(attributesAcceptUnknownCaseSensitivityModifiers || attributesCaseSensitivityModifiers[attr.caseSensitivityModifier], "Unknown attribute case sensitivity modifier.");
850
- skipWhitespace();
851
- if (isEof() && !strict) {
852
- return attr;
853
- }
854
- }
855
- pass("]");
856
- }
857
- return attr;
858
- }
859
- function parseNumber(signed) {
860
- var result = "";
861
- if (signed && is("-")) {
862
- result = readAndNext();
863
- }
864
- while (utils_1.digitsChars[chr]) {
865
- result += readAndNext();
866
- }
867
- assert(result !== "" && result !== "-", "Formula parse error.");
868
- return parseInt(result);
869
- }
870
- var isNumberStart = function() {
871
- return is("-") || is("+") || utils_1.digitsChars[chr];
872
- };
873
- function parseFormula() {
874
- var firstNumber = null;
875
- if (isNumberStart()) {
876
- if (is("+")) {
877
- next();
878
- assert(!is("-"), "Formula parse error.");
879
- }
880
- firstNumber = parseNumber(true);
881
- if (!is("\\") && !is("n")) {
882
- return [0, firstNumber];
883
- }
884
- }
885
- if (firstNumber === null) {
886
- firstNumber = 1;
887
- }
888
- var ident = parseIdentifier();
889
- if (ident === "even") {
890
- skipWhitespace();
891
- return [2, 0];
892
- }
893
- if (ident === "odd") {
894
- skipWhitespace();
895
- return [2, 1];
896
- }
897
- assert(ident === "n", "Formula parse error");
898
- skipWhitespace();
899
- if (is("+") || is("-")) {
900
- var sign = is("+") ? 1 : -1;
901
- next();
902
- skipWhitespace();
903
- return [firstNumber, sign * parseNumber(false)];
904
- } else {
905
- return [firstNumber, 0];
906
- }
907
- }
908
- function parsePseudoClass(pseudoName) {
909
- var pseudo = {
910
- type: "PseudoClass",
911
- name: pseudoName
912
- };
913
- var pseudoDefinition = paeudoClassesDefinitions[pseudoName];
914
- if (!pseudoDefinition && pseudoClassesAcceptUnknown) {
915
- pseudoDefinition = pseudo_class_signatures_1.defaultPseudoClassSignature;
916
- }
917
- assert(pseudoDefinition, 'Unknown pseudo-class: "'.concat(pseudoName, '".'));
918
- pseudoDefinition = pseudoDefinition;
919
- if (is("(")) {
920
- next();
921
- skipWhitespace();
922
- if (substitutesEnabled && is("$")) {
923
- next();
924
- pseudo.argument = {
925
- type: "Substitution",
926
- name: parseIdentifier()
927
- };
928
- assert(pseudo.argument.name, "Expected substitute name.");
929
- } else if (pseudoDefinition.type === "String") {
930
- pseudo.argument = {
931
- type: "String",
932
- value: parsePseudoClassString()
933
- };
934
- assert(pseudo.argument.value, "Expected pseudo-class argument value.");
935
- } else if (pseudoDefinition.type === "Selector") {
936
- pseudo.argument = parseSelector2(true);
937
- } else if (pseudoDefinition.type === "Formula") {
938
- var _a2 = parseFormula(), a = _a2[0], b = _a2[1];
939
- pseudo.argument = {
940
- type: "Formula",
941
- a,
942
- b
943
- };
944
- if (pseudoDefinition.ofSelector) {
945
- skipWhitespace();
946
- if (is("o") || is("\\")) {
947
- var ident = parseIdentifier();
948
- assert(ident === "of", "Formula of selector parse error.");
949
- skipWhitespace();
950
- pseudo.argument = {
951
- type: "FormulaOfSelector",
952
- a,
953
- b,
954
- selector: parseRule()
955
- };
956
- }
957
- }
958
- } else {
959
- return fail("Invalid pseudo-class signature.");
960
- }
961
- skipWhitespace();
962
- if (isEof() && !strict) {
963
- return pseudo;
964
- }
965
- pass(")");
966
- } else {
967
- assert(pseudoDefinition.optional, 'Argument is required for pseudo-class "'.concat(pseudoName, '".'));
968
- }
969
- return pseudo;
970
- }
971
- function parseTagName() {
972
- if (is("*")) {
973
- assert(tagNameWildcardEnabled, "Wildcard tag name is not enabled.");
974
- next();
975
- return { type: "WildcardTag" };
976
- } else if ((0, utils_1.isIdentStart)(chr) || is("\\")) {
977
- assert(tagNameEnabled, "Tag names are not enabled.");
978
- return {
979
- type: "TagName",
980
- name: parseIdentifier()
981
- };
982
- } else {
983
- return fail("Expected tag name.");
984
- }
985
- }
986
- function parseTagNameWithNamespace() {
987
- if (is("*")) {
988
- var savedPos = pos;
989
- next();
990
- if (!is("|")) {
991
- rewind(savedPos);
992
- return parseTagName();
993
- }
994
- next();
995
- if (!isTagStart()) {
996
- rewind(savedPos);
997
- return parseTagName();
998
- }
999
- assert(namespaceEnabled, "Namespaces are not enabled.");
1000
- assert(namespaceWildcardEnabled, "Wildcard namespace is not enabled.");
1001
- var tagName = parseTagName();
1002
- tagName.namespace = { type: "WildcardNamespace" };
1003
- return tagName;
1004
- } else if (is("|")) {
1005
- assert(namespaceEnabled, "Namespaces are not enabled.");
1006
- next();
1007
- var tagName = parseTagName();
1008
- tagName.namespace = { type: "NoNamespace" };
1009
- return tagName;
1010
- } else if ((0, utils_1.isIdentStart)(chr) || is("\\")) {
1011
- var identifier = parseIdentifier();
1012
- if (!is("|")) {
1013
- assert(tagNameEnabled, "Tag names are not enabled.");
1014
- return {
1015
- type: "TagName",
1016
- name: identifier
1017
- };
1018
- }
1019
- var savedPos = pos;
1020
- next();
1021
- if (!isTagStart()) {
1022
- rewind(savedPos);
1023
- return {
1024
- type: "TagName",
1025
- name: identifier
1026
- };
1027
- }
1028
- assert(namespaceEnabled, "Namespaces are not enabled.");
1029
- var tagName = parseTagName();
1030
- tagName.namespace = { type: "NamespaceName", name: identifier };
1031
- return tagName;
1032
- } else {
1033
- return fail("Expected tag name.");
1034
- }
1035
- }
1036
- function parseRule(relative) {
1037
- if (relative === void 0) {
1038
- relative = false;
1039
- }
1040
- var rule = {};
1041
- var isRuleStart = true;
1042
- if (relative) {
1043
- var combinator = matchMulticharIndex(combinatorsIndex);
1044
- if (combinator) {
1045
- rule.combinator = combinator;
1046
- skipWhitespace();
1047
- }
1048
- }
1049
- while (pos < l) {
1050
- if (isTagStart()) {
1051
- assert(isRuleStart, "Unexpected tag/namespace start.");
1052
- rule.tag = parseTagNameWithNamespace();
1053
- } else if (is("|")) {
1054
- var savedPos = pos;
1055
- next();
1056
- if (isTagStart()) {
1057
- assert(isRuleStart, "Unexpected tag/namespace start.");
1058
- rewind(savedPos);
1059
- rule.tag = parseTagNameWithNamespace();
1060
- } else {
1061
- rewind(savedPos);
1062
- break;
1063
- }
1064
- } else if (is(".")) {
1065
- assert(classNamesEnabled, "Class names are not enabled.");
1066
- next();
1067
- var className = parseIdentifier();
1068
- assert(className, "Expected class name.");
1069
- (rule.classNames = rule.classNames || []).push(className);
1070
- } else if (is("#")) {
1071
- assert(idEnabled, "IDs are not enabled.");
1072
- next();
1073
- var idName = parseIdentifier();
1074
- assert(idName, "Expected ID name.");
1075
- (rule.ids = rule.ids || []).push(idName);
1076
- } else if (is("[")) {
1077
- assert(attributesEnabled, "Attributes are not enabled.");
1078
- (rule.attributes = rule.attributes || []).push(parseAttribute());
1079
- } else if (is(":")) {
1080
- var isDoubleColon = false;
1081
- var isPseudoElement = false;
1082
- next();
1083
- if (is(":")) {
1084
- assert(pseudoElementsEnabled, "Pseudo elements are not enabled.");
1085
- assert(pseudoElementsDoubleColonNotationEnabled, "Pseudo elements double colon notation is not enabled.");
1086
- isDoubleColon = true;
1087
- next();
1088
- }
1089
- var pseudoName = parseIdentifier();
1090
- assert(isDoubleColon || pseudoName, "Expected pseudo-class name.");
1091
- assert(!isDoubleColon || pseudoName, "Expected pseudo-element name.");
1092
- assert(!isDoubleColon || pseudoElementsAcceptUnknown || pseudoElementsIndex[pseudoName], 'Unknown pseudo-element "'.concat(pseudoName, '".'));
1093
- isPseudoElement = pseudoElementsEnabled && (isDoubleColon || !isDoubleColon && pseudoElementsSingleColonNotationEnabled && pseudoElementsIndex[pseudoName]);
1094
- if (isPseudoElement) {
1095
- rule.pseudoElement = pseudoName;
1096
- if (!utils_1.whitespaceChars[chr] && !is(",") && !is(")") && !isEof()) {
1097
- return fail("Pseudo-element should be the last component of a CSS selector rule.");
1098
- }
1099
- } else {
1100
- assert(pseudoClassesEnabled, "Pseudo classes are not enabled.");
1101
- (rule.pseudoClasses = rule.pseudoClasses || []).push(parsePseudoClass(pseudoName));
1102
- }
1103
- } else {
1104
- break;
1105
- }
1106
- isRuleStart = false;
1107
- }
1108
- if (isRuleStart) {
1109
- if (isEof()) {
1110
- return fail("Expected rule but end of input reached.");
1111
- } else {
1112
- return fail('Expected rule but "'.concat(chr, '" found.'));
1113
- }
1114
- }
1115
- rule.type = "Rule";
1116
- skipWhitespace();
1117
- if (!isEof() && !is(",") && !is(")")) {
1118
- var combinator = matchMulticharIndex(combinatorsIndex);
1119
- skipWhitespace();
1120
- rule.nestedRule = parseRule();
1121
- rule.nestedRule.combinator = combinator;
1122
- }
1123
- return rule;
1124
- }
1125
- return function(input) {
1126
- if (typeof input !== "string") {
1127
- throw new Error("".concat(errorPrefix, "Expected string input."));
1128
- }
1129
- str = input;
1130
- l = str.length;
1131
- pos = 0;
1132
- chr = str.charAt(0);
1133
- return parseSelector2();
1134
- };
1135
- }
1136
- exports.createParser = createParser2;
1137
- }
1138
- });
1139
-
1140
- // node_modules/css-selector-parser/lib/render.js
1141
- var require_render = __commonJS({
1142
- "node_modules/css-selector-parser/lib/render.js"(exports) {
1143
- "use strict";
1144
- Object.defineProperty(exports, "__esModule", { value: true });
1145
- exports.render = void 0;
1146
- var utils_1 = require_utils();
1147
- function renderNamespace(namespace) {
1148
- if (namespace.type === "WildcardNamespace") {
1149
- return "*|";
1150
- } else if (namespace.type === "NamespaceName") {
1151
- return "".concat((0, utils_1.escapeIdentifier)(namespace.name), "|");
1152
- } else if (namespace.type === "NoNamespace") {
1153
- return "|";
1154
- }
1155
- throw new Error("Unknown namespace type: ".concat(namespace.type, "."));
1156
- }
1157
- function renderSubstitution(sub) {
1158
- return "$".concat((0, utils_1.escapeIdentifier)(sub.name));
1159
- }
1160
- function renderFormula(a, b) {
1161
- if (a) {
1162
- var result = "".concat(a === 1 ? "" : a, "n");
1163
- if (b) {
1164
- result += "".concat(b > 0 ? "+" : "").concat(b);
1165
- }
1166
- return result;
1167
- } else {
1168
- return String(b);
1169
- }
1170
- }
1171
- function render(entity) {
1172
- if (entity.type === "Selector") {
1173
- return entity.rules.map(render).join(", ");
1174
- }
1175
- if (entity.type === "Rule") {
1176
- var result = "";
1177
- var tag = entity.tag, ids = entity.ids, classNames = entity.classNames, attributes = entity.attributes, pseudoClasses = entity.pseudoClasses, pseudoElement = entity.pseudoElement, nestedRule = entity.nestedRule;
1178
- if (tag) {
1179
- var namespace = tag.namespace;
1180
- if (namespace) {
1181
- result += renderNamespace(namespace);
1182
- }
1183
- if (tag.type === "TagName") {
1184
- result += (0, utils_1.escapeIdentifier)(tag.name);
1185
- } else if (tag.type === "WildcardTag") {
1186
- result += "*";
1187
- } else {
1188
- throw new Error("Unknown tagName type: ".concat(tag.type, "."));
1189
- }
1190
- }
1191
- if (ids) {
1192
- for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
1193
- var id = ids_1[_i];
1194
- result += "#".concat((0, utils_1.escapeIdentifier)(id));
1195
- }
1196
- }
1197
- if (classNames) {
1198
- for (var _a = 0, classNames_1 = classNames; _a < classNames_1.length; _a++) {
1199
- var className = classNames_1[_a];
1200
- result += ".".concat((0, utils_1.escapeIdentifier)(className));
1201
- }
1202
- }
1203
- if (attributes) {
1204
- for (var _b = 0, attributes_1 = attributes; _b < attributes_1.length; _b++) {
1205
- var _c = attributes_1[_b], name_1 = _c.name, namespace = _c.namespace, operator = _c.operator, value = _c.value, caseSensitivityModifier = _c.caseSensitivityModifier;
1206
- result += "[";
1207
- if (namespace) {
1208
- result += renderNamespace(namespace);
1209
- }
1210
- result += (0, utils_1.escapeIdentifier)(name_1);
1211
- if (operator && value) {
1212
- result += operator;
1213
- if (value.type === "String") {
1214
- result += (0, utils_1.escapeStr)(value.value);
1215
- } else if (value.type === "Substitution") {
1216
- result += renderSubstitution(value);
1217
- } else {
1218
- throw new Error("Unknown attribute value type: ".concat(value.type, "."));
1219
- }
1220
- if (caseSensitivityModifier) {
1221
- result += " ".concat((0, utils_1.escapeIdentifier)(caseSensitivityModifier));
1222
- }
1223
- }
1224
- result += "]";
1225
- }
1226
- }
1227
- if (pseudoClasses) {
1228
- for (var _d = 0, pseudoClasses_1 = pseudoClasses; _d < pseudoClasses_1.length; _d++) {
1229
- var _e = pseudoClasses_1[_d], name_2 = _e.name, argument = _e.argument;
1230
- result += ":".concat((0, utils_1.escapeIdentifier)(name_2));
1231
- if (argument) {
1232
- result += "(";
1233
- if (argument.type === "Selector") {
1234
- result += render(argument);
1235
- } else if (argument.type === "String") {
1236
- result += (0, utils_1.escapePseudoClassString)(argument.value);
1237
- } else if (argument.type === "Formula") {
1238
- result += renderFormula(argument.a, argument.b);
1239
- } else if (argument.type === "FormulaOfSelector") {
1240
- result += renderFormula(argument.a, argument.b);
1241
- result += " of ";
1242
- result += render(argument.selector);
1243
- } else if (argument.type === "Substitution") {
1244
- result += renderSubstitution(argument);
1245
- } else {
1246
- throw new Error("Unknown pseudo-class argument type: ".concat(argument.type, "."));
1247
- }
1248
- result += ")";
1249
- }
1250
- }
1251
- }
1252
- if (pseudoElement) {
1253
- result += "::".concat((0, utils_1.escapeIdentifier)(pseudoElement));
1254
- }
1255
- if (nestedRule) {
1256
- if (nestedRule.combinator) {
1257
- result += " ".concat(nestedRule.combinator);
1258
- }
1259
- result += " ".concat(render(nestedRule));
1260
- }
1261
- return result;
1262
- }
1263
- throw new Error("Render method accepts only Selector, Rule and RuleList.");
1264
- }
1265
- exports.render = render;
1266
- }
1267
- });
1268
-
1269
- // node_modules/css-selector-parser/lib/ast.js
1270
- var require_ast = __commonJS({
1271
- "node_modules/css-selector-parser/lib/ast.js"(exports) {
1272
- "use strict";
1273
- var __assign = exports && exports.__assign || function() {
1274
- __assign = Object.assign || function(t) {
1275
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1276
- s = arguments[i];
1277
- for (var p in s)
1278
- if (Object.prototype.hasOwnProperty.call(s, p))
1279
- t[p] = s[p];
1280
- }
1281
- return t;
1282
- };
1283
- return __assign.apply(this, arguments);
1284
- };
1285
- Object.defineProperty(exports, "__esModule", { value: true });
1286
- exports.ast = void 0;
1287
- function astMethods(type) {
1288
- return function(generatorName, checkerName) {
1289
- var _a;
1290
- return _a = {}, _a[generatorName] = function(props) {
1291
- return __assign({ type }, props);
1292
- }, _a[checkerName] = function(entity) {
1293
- return typeof entity === "object" && entity !== null && entity.type === type;
1294
- }, _a;
1295
- };
1296
- }
1297
- exports.ast = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, astMethods("Selector")("selector", "isSelector")), astMethods("Rule")("rule", "isRule")), astMethods("TagName")("tagName", "isTagName")), astMethods("WildcardTag")("wildcardTag", "isWildcardTag")), astMethods("NamespaceName")("namespaceName", "isNamespaceName")), astMethods("WildcardNamespace")("wildcardNamespace", "isWildcardNamespace")), astMethods("NoNamespace")("noNamespace", "isNoNamespace")), astMethods("Attribute")("attribute", "isAttribute")), astMethods("PseudoClass")("pseudoClass", "isPseudoClass")), astMethods("String")("string", "isString")), astMethods("Formula")("formula", "isFormula")), astMethods("FormulaOfSelector")("formulaOfSelector", "isFormulaOfSelector")), astMethods("Substitution")("substitution", "isSubstitution"));
1298
- }
1299
- });
1300
-
1301
- // node_modules/css-selector-parser/lib/index.js
1302
- var require_lib = __commonJS({
1303
- "node_modules/css-selector-parser/lib/index.js"(exports) {
1304
- "use strict";
1305
- Object.defineProperty(exports, "__esModule", { value: true });
1306
- exports.ast = exports.render = exports.createParser = void 0;
1307
- var parser_1 = require_parser();
1308
- Object.defineProperty(exports, "createParser", { enumerable: true, get: function() {
1309
- return parser_1.createParser;
1310
- } });
1311
- var render_1 = require_render();
1312
- Object.defineProperty(exports, "render", { enumerable: true, get: function() {
1313
- return render_1.render;
1314
- } });
1315
- var ast_1 = require_ast();
1316
- Object.defineProperty(exports, "ast", { enumerable: true, get: function() {
1317
- return ast_1.ast;
1318
- } });
1319
- }
1320
- });
1321
-
1322
- // node_modules/throw-expression/index.js
1323
- var require_throw_expression = __commonJS({
1324
- "node_modules/throw-expression/index.js"(exports) {
1325
- "use strict";
1326
- Object.defineProperty(exports, "__esModule", { value: true });
1327
- exports.throwIfFalsy = exports.throwIfUndefined = exports.throwIfNull = exports.Throw = void 0;
1328
- exports.Throw = function(error) {
1329
- if (typeof error === "string") {
1330
- throw new Error(error);
1331
- }
1332
- throw error;
1333
- };
1334
- exports.throwIfNull = function(value, error) {
1335
- if (error === void 0) {
1336
- error = "value is null";
1337
- }
1338
- return value === null ? exports.Throw(error) : value;
1339
- };
1340
- exports.throwIfUndefined = function(value, error) {
1341
- if (error === void 0) {
1342
- error = "value is undefined";
1343
- }
1344
- return value === void 0 ? exports.Throw(error) : value;
1345
- };
1346
- exports.throwIfFalsy = function(value, error) {
1347
- if (error === void 0) {
1348
- error = "value is undefined";
1349
- }
1350
- return value === void 0 || value === null ? exports.Throw(error) : value;
1351
- };
1352
- }
1353
- });
1354
-
1355
- // src/browser/main.ts
1356
- var main_exports = {};
1357
- __export(main_exports, {
1358
- default: () => main_default
1359
- });
1360
- module.exports = __toCommonJS(main_exports);
1361
- var import_css_selector_parser = __toESM(require_lib());
1362
- var import_throw_expression = __toESM(require_throw_expression());
1363
- var getAllParents = (element) => {
1364
- const getParents = (class_) => {
1365
- const parent = class_.getParent();
1366
- if (parent !== void 0) {
1367
- return [class_, ...getParents(parent)];
1368
- }
1369
- return [class_];
1370
- };
1371
- return getParents(element.getMetadata()).map((parent) => parent.getName());
1372
- };
1373
- var parseSelector = (selector) => {
1374
- if (selector === "") {
1375
- throw new Error("ui5 selector is empty");
1376
- }
1377
- const parsedSelector = parse(selector);
1378
- parsedSelector.rules.forEach((rule) => {
1379
- var _a;
1380
- if (rule.ids && rule.ids.length > 1) {
1381
- throw new Error("multiple ids are not supported");
1382
- }
1383
- if (rule.pseudoElement === "subclass" && ((_a = rule.tag) == null ? void 0 : _a.type) !== "TagName") {
1384
- throw new Error(
1385
- "subclass pseudo-selector cannot be used without specifying a control type"
1386
- );
1387
- }
1388
- });
1389
- return parsedSelector;
1390
- };
1391
- var parse = (0, import_css_selector_parser.createParser)({
1392
- syntax: {
1393
- combinators: [],
1394
- namespace: false,
1395
- attributes: { operators: ["=", "^=", "$=", "*=", "~=", "|="] },
1396
- pseudoElements: { definitions: ["subclass"] },
1397
- pseudoClasses: { definitions: { Selector: ["has"] } },
1398
- tag: { wildcard: true },
1399
- ids: true,
1400
- classNames: true
1401
- }
1402
- });
1403
- var querySelector = (root, selector) => selector.rules.flatMap((rule) => {
1404
- var _a;
1405
- if (((_a = rule.tag) == null ? void 0 : _a.type) === "TagName" && rule.classNames) {
1406
- const sapNamespace = "sap";
1407
- if (rule.tag.name !== sapNamespace) {
1408
- rule.tag.name = `${sapNamespace}.${rule.tag.name}`;
1409
- }
1410
- rule.tag.name = [rule.tag.name, ...rule.classNames].join(".");
1411
- delete rule.classNames;
1412
- }
1413
- const controls = sap.ui.core.Element.registry.filter((element) => {
1414
- var _a2, _b;
1415
- if (((_a2 = rule.tag) == null ? void 0 : _a2.type) === "TagName" && rule.tag.name !== element.getMetadata().getName() && (rule.pseudoElement !== "subclass" || !getAllParents(element).includes(rule.tag.name)) || rule.ids && rule.ids[0] !== element.getId()) {
1416
- return false;
1417
- }
1418
- return ((_b = rule.attributes) != null ? _b : []).every((attr) => {
1419
- let actualValue;
1420
- try {
1421
- actualValue = String(element.getProperty(attr.name));
1422
- } catch {
1423
- return false;
1424
- }
1425
- if (!("value" in attr)) {
1426
- return true;
1427
- }
1428
- const expectedValue = attr.value.value;
1429
- return {
1430
- "=": actualValue === expectedValue,
1431
- "^=": actualValue.startsWith(expectedValue),
1432
- "$=": actualValue.endsWith(expectedValue),
1433
- "*=": actualValue.includes(expectedValue),
1434
- "~=": actualValue.trim() === expectedValue,
1435
- "|=": actualValue.split("-")[0] === expectedValue
1436
- }[(0, import_throw_expression.throwIfUndefined)(
1437
- attr.operator,
1438
- "attribute operator was undefined when value was set (this should NEVER happen)"
1439
- )];
1440
- });
1441
- });
1442
- return controls.map((control) => control.getDomRef()).filter((element) => {
1443
- if (element === null || root.querySelector(`[id='${element.id}']`) === null) {
1444
- return false;
1445
- }
1446
- if (rule.pseudoClasses && querySelector(
1447
- element,
1448
- (0, import_throw_expression.throwIfUndefined)(
1449
- rule.pseudoClasses[0],
1450
- '":has" pseudo-class was specified without an argument'
1451
- ).argument
1452
- ).length === 0) {
1453
- return false;
1454
- }
1455
- return true;
1456
- });
1457
- });
1458
- var queryAll = (root, selector) => {
1459
- try {
1460
- const parsedSelector = parseSelector(selector);
1461
- if (typeof sap === "undefined" || typeof sap.ui === "undefined") {
1462
- return [];
1463
- }
1464
- return querySelector(root, parsedSelector);
1465
- } catch (e) {
1466
- throw new Error(`ui5 selector engine failed on selector: "${selector}"
1467
-
1468
- ${String(e)}`);
1469
- }
1470
- };
1471
- var main_default = {
1472
- queryAll,
1473
- query: (root, selector) => queryAll(root, selector)[0]
1474
- };