@adguard/agtree 1.1.7 → 2.0.0-alpha.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.
- package/README.md +25 -45
- package/dist/agtree.cjs +22681 -8979
- package/dist/agtree.d.ts +1965 -801
- package/dist/agtree.esm.js +22650 -8963
- package/dist/agtree.iife.min.js +11 -11
- package/dist/agtree.umd.min.js +11 -11
- package/dist/build.txt +1 -1
- package/dist/compatibility-tables.json +12367 -0
- package/package.json +127 -108
- package/CHANGELOG.md +0 -106
package/dist/agtree.d.ts
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v2.0.0-alpha.0 (build date: Mon, 29 Jul 2024 13:43:09 GMT)
|
|
3
|
+
* (c) 2024 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import zod from 'zod';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @file Common options for all parsers.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Common options for all parsers.
|
|
14
|
+
*/
|
|
15
|
+
interface ParserOptions {
|
|
16
|
+
/**
|
|
17
|
+
* If `true`, then the parser will not throw an error if the rule is syntactically invalid, instead it will
|
|
18
|
+
* return an `InvalidRule` object with the error attached to it.
|
|
19
|
+
*/
|
|
20
|
+
tolerant?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to include location information in the AST nodes.
|
|
23
|
+
*/
|
|
24
|
+
isLocIncluded?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to parse AdBlock-specific rules.
|
|
27
|
+
*/
|
|
28
|
+
parseAbpSpecificRules?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to parse uBlock Origin-specific rules.
|
|
31
|
+
*/
|
|
32
|
+
parseUboSpecificRules?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to parse raw parts.
|
|
35
|
+
*/
|
|
36
|
+
includeRaws?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to ignore comment-rules.
|
|
39
|
+
*/
|
|
40
|
+
ignoreComments?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to parse host rules.
|
|
43
|
+
*/
|
|
44
|
+
parseHostRules?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Default parser options.
|
|
48
|
+
*/
|
|
49
|
+
declare const defaultParserOptions: ParserOptions;
|
|
10
50
|
|
|
11
51
|
/**
|
|
12
52
|
* @file Possible adblock syntaxes are listed here.
|
|
@@ -14,7 +54,7 @@ export { ecssTree as ECSSTree };
|
|
|
14
54
|
/**
|
|
15
55
|
* Possible adblock syntaxes (supported by this library)
|
|
16
56
|
*/
|
|
17
|
-
declare
|
|
57
|
+
declare enum AdblockSyntax {
|
|
18
58
|
/**
|
|
19
59
|
* Common syntax, which is supported by more than one adblocker (or by all adblockers).
|
|
20
60
|
*
|
|
@@ -58,7 +98,7 @@ declare const enum AdblockSyntax {
|
|
|
58
98
|
}
|
|
59
99
|
|
|
60
100
|
declare const ADG_SCRIPTLET_MASK = "//scriptlet";
|
|
61
|
-
declare const UBO_SCRIPTLET_MASK = "js";
|
|
101
|
+
declare const UBO_SCRIPTLET_MASK = "+js";
|
|
62
102
|
declare const MODIFIERS_SEPARATOR = ",";
|
|
63
103
|
declare const MODIFIER_ASSIGN_OPERATOR = "=";
|
|
64
104
|
declare const NEGATION_MARKER = "~";
|
|
@@ -106,7 +146,7 @@ type AnyExpressionNode = ExpressionVariableNode | ExpressionOperatorNode | Expre
|
|
|
106
146
|
/**
|
|
107
147
|
* Represents any kind of adblock rule.
|
|
108
148
|
*/
|
|
109
|
-
type AnyRule = EmptyRule | AnyCommentRule | AnyCosmeticRule |
|
|
149
|
+
type AnyRule = EmptyRule | AnyCommentRule | AnyCosmeticRule | AnyNetworkRule | InvalidRule;
|
|
110
150
|
/**
|
|
111
151
|
* Represents any comment-like adblock rule.
|
|
112
152
|
*/
|
|
@@ -115,6 +155,10 @@ type AnyCommentRule = AgentCommentRule | CommentRule | ConfigCommentRule | HintC
|
|
|
115
155
|
* Represents any cosmetic adblock rule.
|
|
116
156
|
*/
|
|
117
157
|
type AnyCosmeticRule = CssInjectionRule | ElementHidingRule | ScriptletInjectionRule | HtmlFilteringRule | JsInjectionRule;
|
|
158
|
+
/**
|
|
159
|
+
* Represents any network adblock rule.
|
|
160
|
+
*/
|
|
161
|
+
type AnyNetworkRule = NetworkRule | HostRule;
|
|
118
162
|
/**
|
|
119
163
|
* Represents the different comment markers that can be used in an adblock rule.
|
|
120
164
|
*
|
|
@@ -137,7 +181,7 @@ declare const enum CommentMarker {
|
|
|
137
181
|
* Represents the main categories that an adblock rule can belong to.
|
|
138
182
|
* Of course, these include additional subcategories.
|
|
139
183
|
*/
|
|
140
|
-
declare
|
|
184
|
+
declare enum RuleCategory {
|
|
141
185
|
/**
|
|
142
186
|
* Empty "rules" that are only containing whitespaces. These rules are handled just for convenience.
|
|
143
187
|
*/
|
|
@@ -165,6 +209,7 @@ declare const enum RuleCategory {
|
|
|
165
209
|
* which may be separated by a comma `,` (only for DomainList) or a pipe `|`.
|
|
166
210
|
*/
|
|
167
211
|
declare const enum ListNodeType {
|
|
212
|
+
Unknown = "Unknown",
|
|
168
213
|
AppList = "AppList",
|
|
169
214
|
DomainList = "DomainList",
|
|
170
215
|
MethodList = "MethodList",
|
|
@@ -173,7 +218,8 @@ declare const enum ListNodeType {
|
|
|
173
218
|
/**
|
|
174
219
|
* Represents child items for {@link ListNodeType}.
|
|
175
220
|
*/
|
|
176
|
-
declare
|
|
221
|
+
declare enum ListItemNodeType {
|
|
222
|
+
Unknown = "Unknown",
|
|
177
223
|
App = "App",
|
|
178
224
|
Domain = "Domain",
|
|
179
225
|
Method = "Method",
|
|
@@ -182,7 +228,7 @@ declare const enum ListItemNodeType {
|
|
|
182
228
|
/**
|
|
183
229
|
* Represents possible comment types.
|
|
184
230
|
*/
|
|
185
|
-
declare
|
|
231
|
+
declare enum CommentRuleType {
|
|
186
232
|
AgentCommentRule = "AgentCommentRule",
|
|
187
233
|
CommentRule = "CommentRule",
|
|
188
234
|
ConfigCommentRule = "ConfigCommentRule",
|
|
@@ -193,7 +239,7 @@ declare const enum CommentRuleType {
|
|
|
193
239
|
/**
|
|
194
240
|
* Represents possible cosmetic rule types.
|
|
195
241
|
*/
|
|
196
|
-
declare
|
|
242
|
+
declare enum CosmeticRuleType {
|
|
197
243
|
ElementHidingRule = "ElementHidingRule",
|
|
198
244
|
CssInjectionRule = "CssInjectionRule",
|
|
199
245
|
ScriptletInjectionRule = "ScriptletInjectionRule",
|
|
@@ -259,23 +305,7 @@ declare const enum CosmeticRuleSeparator {
|
|
|
259
305
|
/**
|
|
260
306
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#html-filtering-rules}
|
|
261
307
|
*/
|
|
262
|
-
AdgHtmlFilteringException = "$@$"
|
|
263
|
-
/**
|
|
264
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#scriptlet-injection}
|
|
265
|
-
*/
|
|
266
|
-
UboScriptletInjection = "##+",
|
|
267
|
-
/**
|
|
268
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#scriptlet-injection}
|
|
269
|
-
*/
|
|
270
|
-
UboScriptletInjectionException = "#@#+",
|
|
271
|
-
/**
|
|
272
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
273
|
-
*/
|
|
274
|
-
UboHtmlFiltering = "##^",
|
|
275
|
-
/**
|
|
276
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
277
|
-
*/
|
|
278
|
-
UboHtmlFilteringException = "#@#^"
|
|
308
|
+
AdgHtmlFilteringException = "$@$"
|
|
279
309
|
}
|
|
280
310
|
/**
|
|
281
311
|
* Represents a basic node in the AST.
|
|
@@ -285,27 +315,18 @@ interface Node {
|
|
|
285
315
|
* The type of the node. Every node should have a type.
|
|
286
316
|
*/
|
|
287
317
|
type: string;
|
|
288
|
-
/**
|
|
289
|
-
* Every node should support a loc property, which refers to the location of the node in the source code.
|
|
290
|
-
*/
|
|
291
|
-
loc?: LocationRange;
|
|
292
318
|
/**
|
|
293
319
|
* Optionally the raw representation of the node in the source code.
|
|
294
320
|
*/
|
|
295
321
|
raw?: string;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Represents a location range in the source code.
|
|
299
|
-
*/
|
|
300
|
-
interface LocationRange {
|
|
301
322
|
/**
|
|
302
|
-
*
|
|
323
|
+
* Start offset of the node.
|
|
303
324
|
*/
|
|
304
|
-
start
|
|
325
|
+
start?: number;
|
|
305
326
|
/**
|
|
306
|
-
*
|
|
327
|
+
* End offset of the node.
|
|
307
328
|
*/
|
|
308
|
-
end
|
|
329
|
+
end?: number;
|
|
309
330
|
}
|
|
310
331
|
/**
|
|
311
332
|
* Represents a location in the source code.
|
|
@@ -325,24 +346,27 @@ interface Location {
|
|
|
325
346
|
column: number;
|
|
326
347
|
}
|
|
327
348
|
/**
|
|
328
|
-
* Represents a
|
|
349
|
+
* Represents a location range in the source code.
|
|
329
350
|
*/
|
|
330
|
-
interface
|
|
331
|
-
type: 'Value';
|
|
351
|
+
interface LocationRange {
|
|
332
352
|
/**
|
|
333
|
-
*
|
|
353
|
+
* The start location of the node.
|
|
334
354
|
*/
|
|
335
|
-
|
|
355
|
+
start: Location;
|
|
356
|
+
/**
|
|
357
|
+
* The end location of the node.
|
|
358
|
+
*/
|
|
359
|
+
end: Location;
|
|
336
360
|
}
|
|
337
361
|
/**
|
|
338
|
-
* Represents a basic
|
|
362
|
+
* Represents a basic value node in the AST.
|
|
339
363
|
*/
|
|
340
|
-
interface
|
|
341
|
-
type: '
|
|
364
|
+
interface Value<T = string> extends Node {
|
|
365
|
+
type: 'Value';
|
|
342
366
|
/**
|
|
343
367
|
* Value of the node.
|
|
344
368
|
*/
|
|
345
|
-
value:
|
|
369
|
+
value: T;
|
|
346
370
|
}
|
|
347
371
|
/**
|
|
348
372
|
* Represents a list of parameters.
|
|
@@ -351,8 +375,10 @@ interface ParameterList extends Node {
|
|
|
351
375
|
type: 'ParameterList';
|
|
352
376
|
/**
|
|
353
377
|
* List of values
|
|
378
|
+
*
|
|
379
|
+
* @note `null` values are allowed in the list, they represent empty parameters.
|
|
354
380
|
*/
|
|
355
|
-
children:
|
|
381
|
+
children: (Value | null)[];
|
|
356
382
|
}
|
|
357
383
|
/**
|
|
358
384
|
* Represents a logical expression variable node in the AST.
|
|
@@ -415,6 +441,17 @@ interface RuleBase extends Node {
|
|
|
415
441
|
nl?: NewLine;
|
|
416
442
|
};
|
|
417
443
|
}
|
|
444
|
+
interface InvalidRuleError extends Node {
|
|
445
|
+
type: 'InvalidRuleError';
|
|
446
|
+
/**
|
|
447
|
+
* Error name
|
|
448
|
+
*/
|
|
449
|
+
name: string;
|
|
450
|
+
/**
|
|
451
|
+
* Error message
|
|
452
|
+
*/
|
|
453
|
+
message: string;
|
|
454
|
+
}
|
|
418
455
|
/**
|
|
419
456
|
* Represents an invalid rule (used by tolerant mode).
|
|
420
457
|
*/
|
|
@@ -431,20 +468,7 @@ interface InvalidRule extends RuleBase {
|
|
|
431
468
|
/**
|
|
432
469
|
* Error details
|
|
433
470
|
*/
|
|
434
|
-
error:
|
|
435
|
-
/**
|
|
436
|
-
* Error name
|
|
437
|
-
*/
|
|
438
|
-
name: string;
|
|
439
|
-
/**
|
|
440
|
-
* Error message
|
|
441
|
-
*/
|
|
442
|
-
message: string;
|
|
443
|
-
/**
|
|
444
|
-
* Error location (if any)
|
|
445
|
-
*/
|
|
446
|
-
loc?: LocationRange;
|
|
447
|
-
};
|
|
471
|
+
error: InvalidRuleError;
|
|
448
472
|
}
|
|
449
473
|
/**
|
|
450
474
|
* Represents an "empty rule" (practically an empty line)
|
|
@@ -487,7 +511,7 @@ interface CommentRule extends CommentBase {
|
|
|
487
511
|
* - If the rule is `! This is just a comment`, then the marker will be `!`.
|
|
488
512
|
* - If the rule is `# This is just a comment`, then the marker will be `#`.
|
|
489
513
|
*/
|
|
490
|
-
marker: Value
|
|
514
|
+
marker: Value;
|
|
491
515
|
/**
|
|
492
516
|
* Comment text.
|
|
493
517
|
*
|
|
@@ -512,7 +536,7 @@ interface MetadataCommentRule extends CommentBase {
|
|
|
512
536
|
/**
|
|
513
537
|
* Comment marker.
|
|
514
538
|
*/
|
|
515
|
-
marker: Value
|
|
539
|
+
marker: Value;
|
|
516
540
|
/**
|
|
517
541
|
* Metadata header name.
|
|
518
542
|
*/
|
|
@@ -522,6 +546,21 @@ interface MetadataCommentRule extends CommentBase {
|
|
|
522
546
|
*/
|
|
523
547
|
value: Value;
|
|
524
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Represents an AGLint configuration node.
|
|
551
|
+
*
|
|
552
|
+
* Used within config comments.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```adblock
|
|
556
|
+
* ! aglint "rule-1": ["warn", { "option1": "value1" }], "rule-2": "off"
|
|
557
|
+
* ! ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
interface ConfigNode extends Node {
|
|
561
|
+
type: 'ConfigNode';
|
|
562
|
+
value: object;
|
|
563
|
+
}
|
|
525
564
|
/**
|
|
526
565
|
* Represents an inline linter configuration comment.
|
|
527
566
|
*
|
|
@@ -538,7 +577,7 @@ interface ConfigCommentRule extends CommentBase {
|
|
|
538
577
|
/**
|
|
539
578
|
* The marker for the comment. It can be `!` or `#`. It is always the first non-whitespace character in the comment.
|
|
540
579
|
*/
|
|
541
|
-
marker: Value
|
|
580
|
+
marker: Value;
|
|
542
581
|
/**
|
|
543
582
|
* The command for the comment. It is always begins with the `aglint` prefix.
|
|
544
583
|
*
|
|
@@ -558,7 +597,7 @@ interface ConfigCommentRule extends CommentBase {
|
|
|
558
597
|
* ```
|
|
559
598
|
* the params would be `["some-rule", "another-rule"]`.
|
|
560
599
|
*/
|
|
561
|
-
params?:
|
|
600
|
+
params?: ConfigNode | ParameterList;
|
|
562
601
|
/**
|
|
563
602
|
* Config comment text. The idea is generally the same as in ESLint.
|
|
564
603
|
*
|
|
@@ -605,7 +644,7 @@ interface Agent extends Node {
|
|
|
605
644
|
/**
|
|
606
645
|
* Adblock version (if specified).
|
|
607
646
|
*/
|
|
608
|
-
version
|
|
647
|
+
version?: Value;
|
|
609
648
|
/**
|
|
610
649
|
* Needed for network rules modifier validation.
|
|
611
650
|
*/
|
|
@@ -674,7 +713,7 @@ interface HintCommentRule extends RuleBase {
|
|
|
674
713
|
/**
|
|
675
714
|
* Currently only AdGuard supports hints.
|
|
676
715
|
*/
|
|
677
|
-
syntax: AdblockSyntax
|
|
716
|
+
syntax: AdblockSyntax;
|
|
678
717
|
/**
|
|
679
718
|
* List of hints.
|
|
680
719
|
*/
|
|
@@ -711,7 +750,7 @@ interface Modifier extends Node {
|
|
|
711
750
|
/**
|
|
712
751
|
* Modifier name
|
|
713
752
|
*/
|
|
714
|
-
|
|
753
|
+
name: Value;
|
|
715
754
|
/**
|
|
716
755
|
* Is this modifier an exception? For example, `~third-party` is an exception
|
|
717
756
|
*/
|
|
@@ -747,8 +786,8 @@ type DomainListSeparator = CommaSeparator | PipeSeparator;
|
|
|
747
786
|
* Common interface for a list item of $app, $denyallow, $domain, $method
|
|
748
787
|
* which have similar syntax.
|
|
749
788
|
*/
|
|
750
|
-
interface ListItem extends Node {
|
|
751
|
-
type:
|
|
789
|
+
interface ListItem<T extends ListItemNodeType> extends Node {
|
|
790
|
+
type: T;
|
|
752
791
|
/**
|
|
753
792
|
* Value of the node.
|
|
754
793
|
*/
|
|
@@ -764,27 +803,19 @@ interface ListItem extends Node {
|
|
|
764
803
|
/**
|
|
765
804
|
* Represents an element of the app list — $app.
|
|
766
805
|
*/
|
|
767
|
-
|
|
768
|
-
type: ListItemNodeType.App;
|
|
769
|
-
}
|
|
806
|
+
type App = ListItem<ListItemNodeType.App>;
|
|
770
807
|
/**
|
|
771
808
|
* Represents an element of the domain list — $domain, $denyallow.
|
|
772
809
|
*/
|
|
773
|
-
|
|
774
|
-
type: ListItemNodeType.Domain;
|
|
775
|
-
}
|
|
810
|
+
type Domain = ListItem<ListItemNodeType.Domain>;
|
|
776
811
|
/**
|
|
777
812
|
* Represents an element of the method list — $method.
|
|
778
813
|
*/
|
|
779
|
-
|
|
780
|
-
type: ListItemNodeType.Method;
|
|
781
|
-
}
|
|
814
|
+
type Method = ListItem<ListItemNodeType.Method>;
|
|
782
815
|
/**
|
|
783
816
|
* Represents an element of the stealth option list — $stealth.
|
|
784
817
|
*/
|
|
785
|
-
|
|
786
|
-
type: ListItemNodeType.StealthOption;
|
|
787
|
-
}
|
|
818
|
+
type StealthOption = ListItem<ListItemNodeType.StealthOption>;
|
|
788
819
|
/**
|
|
789
820
|
* Represents a list of domains.
|
|
790
821
|
* Needed for $domain and $denyallow.
|
|
@@ -875,17 +906,38 @@ interface StealthOptionList extends Node {
|
|
|
875
906
|
interface CssInjectionRuleBody extends Node {
|
|
876
907
|
type: 'CssInjectionRuleBody';
|
|
877
908
|
/**
|
|
878
|
-
* Media query
|
|
909
|
+
* Media query, if any.
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
*
|
|
913
|
+
* ```text
|
|
914
|
+
* @media (max-width: 768px) { ... }
|
|
915
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
916
|
+
* ```
|
|
879
917
|
*/
|
|
880
|
-
mediaQueryList?:
|
|
918
|
+
mediaQueryList?: Value;
|
|
881
919
|
/**
|
|
882
|
-
*
|
|
920
|
+
* CSS selector list.
|
|
921
|
+
*
|
|
922
|
+
* @example
|
|
923
|
+
* section:has(> .ad) { display: none; }
|
|
924
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
925
|
+
* section:has(> .ad), article > p[advert] { display: none; }
|
|
926
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
883
927
|
*/
|
|
884
|
-
selectorList:
|
|
928
|
+
selectorList: Value;
|
|
885
929
|
/**
|
|
886
|
-
* Declaration
|
|
930
|
+
* Declaration list.
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* section:has(> .ad) { display: none; }
|
|
934
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
935
|
+
* section:has(> .ad), article > p[advert] { display: none; }
|
|
936
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
937
|
+
* div[ad] { padding-top: 10px; padding-bottom: 10px; }
|
|
938
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
887
939
|
*/
|
|
888
|
-
declarationList?:
|
|
940
|
+
declarationList?: Value;
|
|
889
941
|
/**
|
|
890
942
|
* Remove flag
|
|
891
943
|
*/
|
|
@@ -900,7 +952,7 @@ interface ElementHidingRuleBody extends Node {
|
|
|
900
952
|
/**
|
|
901
953
|
* Element hiding rule selector(s).
|
|
902
954
|
*/
|
|
903
|
-
selectorList:
|
|
955
|
+
selectorList: Value;
|
|
904
956
|
}
|
|
905
957
|
/**
|
|
906
958
|
* Represents a scriptlet injection rule body.
|
|
@@ -920,7 +972,7 @@ interface HtmlFilteringRuleBody extends Node {
|
|
|
920
972
|
/**
|
|
921
973
|
* HTML rule selector(s).
|
|
922
974
|
*/
|
|
923
|
-
body:
|
|
975
|
+
body: Value;
|
|
924
976
|
}
|
|
925
977
|
/**
|
|
926
978
|
* A generic representation of a cosmetic rule.
|
|
@@ -1065,7 +1117,7 @@ interface ScriptletInjectionRule extends CosmeticRule {
|
|
|
1065
1117
|
*/
|
|
1066
1118
|
interface HtmlFilteringRule extends CosmeticRule {
|
|
1067
1119
|
type: CosmeticRuleType.HtmlFilteringRule;
|
|
1068
|
-
body:
|
|
1120
|
+
body: Value;
|
|
1069
1121
|
}
|
|
1070
1122
|
/**
|
|
1071
1123
|
* Representation of a JS injection rule.
|
|
@@ -1082,13 +1134,39 @@ interface JsInjectionRule extends CosmeticRule {
|
|
|
1082
1134
|
type: CosmeticRuleType.JsInjectionRule;
|
|
1083
1135
|
body: Value;
|
|
1084
1136
|
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Represents the different types of network rules.
|
|
1139
|
+
*/
|
|
1140
|
+
declare enum NetworkRuleType {
|
|
1141
|
+
NetworkRule = "NetworkRule",
|
|
1142
|
+
HostRule = "HostRule"
|
|
1143
|
+
}
|
|
1085
1144
|
/**
|
|
1086
1145
|
* Represents the common properties of network rules
|
|
1087
1146
|
*/
|
|
1088
|
-
interface
|
|
1147
|
+
interface NetworkRuleBase extends RuleBase {
|
|
1148
|
+
/**
|
|
1149
|
+
* Category of the adblock rule.
|
|
1150
|
+
*/
|
|
1089
1151
|
category: RuleCategory.Network;
|
|
1090
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* Type of the network rule.
|
|
1154
|
+
*/
|
|
1155
|
+
type: NetworkRuleType;
|
|
1156
|
+
/**
|
|
1157
|
+
* Syntax of the adblock rule. If we are not able to determine the syntax of the rule,
|
|
1158
|
+
* we should use `AdblockSyntax.Common` as the value.
|
|
1159
|
+
*/
|
|
1091
1160
|
syntax: AdblockSyntax;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Represents the common properties of network rules
|
|
1164
|
+
*/
|
|
1165
|
+
interface NetworkRule extends NetworkRuleBase {
|
|
1166
|
+
/**
|
|
1167
|
+
* Type of the node.
|
|
1168
|
+
*/
|
|
1169
|
+
type: NetworkRuleType.NetworkRule;
|
|
1092
1170
|
/**
|
|
1093
1171
|
* If the rule is an exception rule. If the rule begins with `@@`, it means that it is an exception rule.
|
|
1094
1172
|
*
|
|
@@ -1134,197 +1212,726 @@ interface NetworkRule extends RuleBase {
|
|
|
1134
1212
|
*/
|
|
1135
1213
|
modifiers?: ModifierList;
|
|
1136
1214
|
}
|
|
1137
|
-
|
|
1138
1215
|
/**
|
|
1139
|
-
*
|
|
1216
|
+
* Represents a list of hostnames.
|
|
1217
|
+
*/
|
|
1218
|
+
interface HostnameList extends Node {
|
|
1219
|
+
/**
|
|
1220
|
+
* Type of the node.
|
|
1221
|
+
*/
|
|
1222
|
+
type: 'HostnameList';
|
|
1223
|
+
/**
|
|
1224
|
+
* List of hostnames.
|
|
1225
|
+
*/
|
|
1226
|
+
children: Value[];
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Represents the common properties of host rules.
|
|
1140
1230
|
*
|
|
1141
|
-
*
|
|
1231
|
+
* @see https://adguard-dns.io/kb/general/dns-filtering-syntax/#etc-hosts-syntax
|
|
1142
1232
|
*/
|
|
1143
|
-
|
|
1233
|
+
interface HostRule extends NetworkRuleBase {
|
|
1144
1234
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
*
|
|
1150
|
-
* For example, let's have this network rule:
|
|
1151
|
-
* ```adblock
|
|
1152
|
-
* ||example.org^$important
|
|
1153
|
-
* ```
|
|
1154
|
-
* The `syntax` property will be `Common`, since the rule is syntactically correct in every adblockers, but we
|
|
1155
|
-
* cannot determine at parsing level whether `important` is an existing option or not, nor if it exists, then
|
|
1156
|
-
* which adblocker supports it. This is why the `syntax` property is simply `Common` at this point.
|
|
1157
|
-
* The concrete COMPATIBILITY of the rule will be determined later, in a different, higher-level layer, called
|
|
1158
|
-
* "Compatibility table".
|
|
1235
|
+
* Type of the node.
|
|
1236
|
+
*/
|
|
1237
|
+
type: NetworkRuleType.HostRule;
|
|
1238
|
+
/**
|
|
1239
|
+
* IP address. It can be an IPv4 or IPv6 address.
|
|
1159
1240
|
*
|
|
1160
|
-
*
|
|
1161
|
-
* ```
|
|
1162
|
-
* example.org
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```text
|
|
1243
|
+
* 127.0.0.1 example.com example.org
|
|
1244
|
+
* ↑↑↑↑↑↑↑↑↑
|
|
1163
1245
|
* ```
|
|
1164
|
-
*
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1246
|
+
* @note If IP is not specified in the rule, it parsed as null IP: `0.0.0.0`.
|
|
1247
|
+
*/
|
|
1248
|
+
ip: Value;
|
|
1249
|
+
/**
|
|
1250
|
+
* Hostnames.
|
|
1168
1251
|
*
|
|
1169
|
-
* @param raw Raw adblock rule
|
|
1170
|
-
* @param tolerant If `true`, then the parser will not throw if the rule is syntactically invalid, instead it will
|
|
1171
|
-
* return an `InvalidRule` object with the error attached to it. Default is `false`.
|
|
1172
|
-
* @param loc Base location of the rule
|
|
1173
|
-
* @returns Adblock rule AST
|
|
1174
|
-
* @throws If the input matches a pattern but syntactically invalid
|
|
1175
1252
|
* @example
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1179
|
-
* const ast1 = RuleParser.parse("||example.org^$important");
|
|
1180
|
-
*
|
|
1181
|
-
* // Parse another network rule
|
|
1182
|
-
* const ast2 = RuleParser.parse("/ads.js^$important,third-party,domain=example.org|~example.com");
|
|
1183
|
-
*
|
|
1184
|
-
* // Parse a cosmetic rule
|
|
1185
|
-
* const ast2 = RuleParser.parse("example.org##.banner");
|
|
1186
|
-
*
|
|
1187
|
-
* // Parse another cosmetic rule
|
|
1188
|
-
* const ast3 = RuleParser.parse("example.org#?#.banner:-abp-has(.ad)");
|
|
1189
|
-
*
|
|
1190
|
-
* // Parse a comment rule
|
|
1191
|
-
* const ast4 = RuleParser.parse("! Comment");
|
|
1192
|
-
*
|
|
1193
|
-
* // Parse an empty rule
|
|
1194
|
-
* const ast5 = RuleParser.parse("");
|
|
1195
|
-
*
|
|
1196
|
-
* // Parse a comment rule (with metadata)
|
|
1197
|
-
* const ast6 = RuleParser.parse("! Title: Example");
|
|
1198
|
-
*
|
|
1199
|
-
* // Parse a pre-processor rule
|
|
1200
|
-
* const ast7 = RuleParser.parse("!#if (adguard)");
|
|
1253
|
+
* ```text
|
|
1254
|
+
* 127.0.0.1 example.com example.org
|
|
1255
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
1201
1256
|
* ```
|
|
1202
1257
|
*/
|
|
1203
|
-
|
|
1258
|
+
hostnames: HostnameList;
|
|
1204
1259
|
/**
|
|
1205
|
-
*
|
|
1260
|
+
* Comment (optional).
|
|
1206
1261
|
*
|
|
1207
|
-
* @param ast - Adblock rule AST
|
|
1208
|
-
* @returns Raw string
|
|
1209
1262
|
* @example
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1213
|
-
* const ast = RuleParser.parse("example.org##.banner");
|
|
1214
|
-
* // Generate the rule from the AST
|
|
1215
|
-
* const raw = RuleParser.generate(ast);
|
|
1216
|
-
* // Print the generated rule
|
|
1217
|
-
* console.log(raw); // "example.org##.banner"
|
|
1263
|
+
* ```text
|
|
1264
|
+
* 127.0.0.1 localhost # This is just a comment
|
|
1265
|
+
* ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
|
1218
1266
|
* ```
|
|
1219
1267
|
*/
|
|
1220
|
-
|
|
1268
|
+
comment?: Value;
|
|
1221
1269
|
}
|
|
1222
1270
|
|
|
1223
1271
|
/**
|
|
1224
|
-
* @file
|
|
1272
|
+
* @file Core ByteBuffer implementation for handling binary data in chunks.
|
|
1225
1273
|
*/
|
|
1226
|
-
|
|
1227
1274
|
/**
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1275
|
+
* Core ByteBuffer implementation for handling binary data in chunks.
|
|
1276
|
+
* This class allows for efficient byte storage and manipulation by organizing data into chunks
|
|
1277
|
+
* and providing methods to read and write bytes.
|
|
1230
1278
|
*/
|
|
1231
|
-
declare class
|
|
1279
|
+
declare class ByteBuffer {
|
|
1232
1280
|
/**
|
|
1233
|
-
*
|
|
1281
|
+
* The size of each chunk in bytes (32 KB).
|
|
1234
1282
|
*/
|
|
1235
|
-
|
|
1283
|
+
static readonly CHUNK_SIZE = 32768;
|
|
1236
1284
|
/**
|
|
1237
|
-
*
|
|
1285
|
+
* An array of Uint8Array chunks that make up the buffer.
|
|
1286
|
+
*/
|
|
1287
|
+
protected chunks: Uint8Array[];
|
|
1288
|
+
/**
|
|
1289
|
+
* The total number of chunks in the buffer.
|
|
1290
|
+
*/
|
|
1291
|
+
protected chunksLength: number;
|
|
1292
|
+
/**
|
|
1293
|
+
* Constructs a new ByteBuffer instance.
|
|
1238
1294
|
*
|
|
1239
|
-
* @param
|
|
1240
|
-
* @param
|
|
1295
|
+
* @param chunks Optional array of chunks to initialize the ByteBuffer with.
|
|
1296
|
+
* @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
|
|
1297
|
+
* its default value is `false`. If the original chunks are guaranteed not to change,
|
|
1298
|
+
* leave this flag as `false` to avoid unnecessary copying.
|
|
1241
1299
|
*/
|
|
1242
|
-
constructor(
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* `AgentParser` is responsible for parsing an Adblock agent rules.
|
|
1247
|
-
* Adblock agent comment marks that the filter list is supposed to
|
|
1248
|
-
* be used by the specified ad blockers.
|
|
1249
|
-
*
|
|
1250
|
-
* @example
|
|
1251
|
-
* - ```adblock
|
|
1252
|
-
* [AdGuard]
|
|
1253
|
-
* ```
|
|
1254
|
-
* - ```adblock
|
|
1255
|
-
* [Adblock Plus 2.0]
|
|
1256
|
-
* ```
|
|
1257
|
-
* - ```adblock
|
|
1258
|
-
* [uBlock Origin]
|
|
1259
|
-
* ```
|
|
1260
|
-
* - ```adblock
|
|
1261
|
-
* [uBlock Origin 1.45.3]
|
|
1262
|
-
* ```
|
|
1263
|
-
* - ```adblock
|
|
1264
|
-
* [Adblock Plus 2.0; AdGuard]
|
|
1265
|
-
* ```
|
|
1266
|
-
*/
|
|
1267
|
-
declare class AgentCommentRuleParser {
|
|
1300
|
+
constructor(chunks?: Uint8Array[], cloneChunks?: boolean);
|
|
1268
1301
|
/**
|
|
1269
|
-
*
|
|
1302
|
+
* Ensures that the buffer has enough capacity to accommodate a given position.
|
|
1303
|
+
* This method adjusts the `chunks` array size to ensure it can hold the specified position.
|
|
1270
1304
|
*
|
|
1271
|
-
* @param
|
|
1272
|
-
* @returns `true` if the rule is an adblock agent, `false` otherwise
|
|
1305
|
+
* @param position The position to ensure capacity for.
|
|
1273
1306
|
*/
|
|
1274
|
-
|
|
1307
|
+
protected ensureCapacity(position: number): void;
|
|
1275
1308
|
/**
|
|
1276
|
-
*
|
|
1309
|
+
* Writes a byte to the buffer at the specified position.
|
|
1310
|
+
* If the position is outside of the buffer's current size, the buffer is resized to accommodate it.
|
|
1277
1311
|
*
|
|
1278
|
-
* @param
|
|
1279
|
-
* @param
|
|
1280
|
-
* @returns Agent rule AST or null (if the raw rule cannot be parsed as an adblock agent comment)
|
|
1312
|
+
* @param position The position at which to write the byte.
|
|
1313
|
+
* @param value The byte value to write (0-255).
|
|
1281
1314
|
*/
|
|
1282
|
-
|
|
1315
|
+
protected writeByte(position: number, value: number): void;
|
|
1283
1316
|
/**
|
|
1284
|
-
*
|
|
1317
|
+
* Reads a byte from the specified position in the buffer.
|
|
1318
|
+
* Returns `undefined` if the position is outside of the buffer's current size.
|
|
1285
1319
|
*
|
|
1286
|
-
* @param
|
|
1287
|
-
* @returns
|
|
1320
|
+
* @param position The position from which to read the byte.
|
|
1321
|
+
* @returns The read byte value, or `undefined` if the position is out of bounds.
|
|
1288
1322
|
*/
|
|
1289
|
-
|
|
1323
|
+
protected readByte(position: number): number | undefined;
|
|
1290
1324
|
}
|
|
1291
1325
|
|
|
1292
1326
|
/**
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
* @example
|
|
1296
|
-
* If the adblock agent rule is
|
|
1297
|
-
* ```adblock
|
|
1298
|
-
* [Adblock Plus 2.0; AdGuard]
|
|
1299
|
-
* ```
|
|
1300
|
-
* then the adblock agents are `Adblock Plus 2.0` and `AdGuard`, and this
|
|
1301
|
-
* class is responsible for parsing them. The rule itself is parsed by
|
|
1302
|
-
* `AgentCommentRuleParser`, which uses this class to parse single agents.
|
|
1327
|
+
* @file Represents a storage interface for reading and writing data.
|
|
1303
1328
|
*/
|
|
1304
|
-
|
|
1329
|
+
/**
|
|
1330
|
+
* Represents a storage interface for reading and writing data.
|
|
1331
|
+
*/
|
|
1332
|
+
interface Storage<K = string, V = unknown> {
|
|
1305
1333
|
/**
|
|
1306
|
-
*
|
|
1334
|
+
* Writes the given data to the storage with the specified key.
|
|
1307
1335
|
*
|
|
1308
|
-
* @param
|
|
1309
|
-
* @
|
|
1336
|
+
* @param key The key to identify the data in the storage.
|
|
1337
|
+
* @param chunks The data to write to the storage.
|
|
1338
|
+
* @returns A promise that resolves when the write operation is complete.
|
|
1310
1339
|
*/
|
|
1311
|
-
|
|
1340
|
+
set(key: K, data: V): Promise<void>;
|
|
1312
1341
|
/**
|
|
1313
|
-
*
|
|
1342
|
+
* Reads the data from the storage with the specified key.
|
|
1314
1343
|
*
|
|
1315
|
-
* @param
|
|
1316
|
-
* @
|
|
1344
|
+
* @param key The key to identify the data in the storage.
|
|
1345
|
+
* @returns A promise that resolves with the data read from the storage.
|
|
1346
|
+
*/
|
|
1347
|
+
get(key: K): Promise<V | undefined>;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* @file Input byte buffer for reading binary data.
|
|
1352
|
+
*/
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Input byte buffer for reading binary data.
|
|
1356
|
+
*
|
|
1357
|
+
* @note Internally, this class uses a {@link ByteBuffer} instance, just providing a convenient API for reading data.
|
|
1358
|
+
*/
|
|
1359
|
+
declare class InputByteBuffer extends ByteBuffer {
|
|
1360
|
+
/**
|
|
1361
|
+
* Current offset in the buffer for reading.
|
|
1362
|
+
*/
|
|
1363
|
+
private offset;
|
|
1364
|
+
/**
|
|
1365
|
+
* Shared native decoder for decoding strings.
|
|
1366
|
+
*/
|
|
1367
|
+
private readonly sharedNativeDecoder;
|
|
1368
|
+
/**
|
|
1369
|
+
* Flag indicating if the current environment is Chromium.
|
|
1370
|
+
* This is used for performance optimizations, because Chromium's TextEncoder/TextDecoder has a relatively
|
|
1371
|
+
* large marshalling overhead for small strings.
|
|
1372
|
+
*/
|
|
1373
|
+
private readonly isChromium;
|
|
1374
|
+
/**
|
|
1375
|
+
* Constructs a new `InputByteBuffer` instance.
|
|
1376
|
+
*
|
|
1377
|
+
* @param chunks Array of chunks to initialize the ByteBuffer with.
|
|
1378
|
+
* @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
|
|
1379
|
+
* its default value is `false`. If the original chunks are guaranteed not to change,
|
|
1380
|
+
* leave this flag as `false` to avoid unnecessary copying.
|
|
1381
|
+
* @param initialOffset Initial offset in the buffer for reading.
|
|
1382
|
+
*
|
|
1383
|
+
* @throws If the specified chunks array is empty.
|
|
1384
|
+
* @throws If the binary schema version in the buffer is not equal to the expected version.
|
|
1385
|
+
* @throws If the initial offset is out of bounds.
|
|
1386
|
+
*/
|
|
1387
|
+
constructor(chunks: Uint8Array[], cloneChunks?: boolean, initialOffset?: number);
|
|
1388
|
+
/**
|
|
1389
|
+
* Creates a new InputByteBuffer instance from a Storage instance by reading chunks from the storage.
|
|
1390
|
+
*
|
|
1391
|
+
* @param storage Storage instance.
|
|
1392
|
+
* @param key Key to read from the storage.
|
|
1393
|
+
* @returns New InputByteBuffer instance.
|
|
1394
|
+
* @note For performance reasons, chunks are passed by reference and not copied.
|
|
1395
|
+
*/
|
|
1396
|
+
static createFromStorage(storage: Storage, key: string): Promise<InputByteBuffer>;
|
|
1397
|
+
/**
|
|
1398
|
+
* Reads a 8-bit unsigned integer from the buffer.
|
|
1399
|
+
*
|
|
1400
|
+
* @returns 8-bit unsigned integer from the buffer.
|
|
1401
|
+
*/
|
|
1402
|
+
readUint8(): number;
|
|
1403
|
+
/**
|
|
1404
|
+
* Reads a 16-bit unsigned integer from the buffer.
|
|
1405
|
+
*
|
|
1406
|
+
* @returns 16-bit unsigned integer from the buffer.
|
|
1407
|
+
*/
|
|
1408
|
+
readUint16(): number;
|
|
1409
|
+
/**
|
|
1410
|
+
* Reads a 32-bit unsigned integer from the buffer at the specified index.
|
|
1411
|
+
*
|
|
1412
|
+
* @param index Index to read the 32-bit unsigned integer from.
|
|
1413
|
+
*
|
|
1414
|
+
* @returns 32-bit unsigned integer from the buffer.
|
|
1415
|
+
*/
|
|
1416
|
+
private readUint32FromIndex;
|
|
1417
|
+
/**
|
|
1418
|
+
* Reads a 32-bit unsigned integer from the buffer.
|
|
1419
|
+
*
|
|
1420
|
+
* @returns 32-bit unsigned integer from the buffer.
|
|
1421
|
+
*/
|
|
1422
|
+
readUint32(): number;
|
|
1423
|
+
/**
|
|
1424
|
+
* Reads schema version from the buffer.
|
|
1425
|
+
*
|
|
1426
|
+
* @returns 32-bit unsigned integer from the buffer.
|
|
1427
|
+
* @note Schema version is always stored at the beginning of the buffer.
|
|
1428
|
+
*/
|
|
1429
|
+
readSchemaVersion(): number;
|
|
1430
|
+
/**
|
|
1431
|
+
* Reads a 32-bit signed integer from the buffer.
|
|
1432
|
+
*
|
|
1433
|
+
* @returns 32-bit signed integer from the buffer.
|
|
1434
|
+
*/
|
|
1435
|
+
readInt32(): number;
|
|
1436
|
+
/**
|
|
1437
|
+
* Reads an optimized unsigned integer from the buffer.
|
|
1438
|
+
* 'Optimized' means that the integer is stored in a variable number of bytes, depending on its value,
|
|
1439
|
+
* so that smaller numbers occupy less space.
|
|
1440
|
+
*
|
|
1441
|
+
* @returns Decoded unsigned integer from the buffer.
|
|
1442
|
+
*/
|
|
1443
|
+
readOptimizedUint(): number;
|
|
1444
|
+
/**
|
|
1445
|
+
* Reads a string from the buffer.
|
|
1446
|
+
*
|
|
1447
|
+
* @returns Decoded string from the buffer.
|
|
1448
|
+
*/
|
|
1449
|
+
readString(): string;
|
|
1450
|
+
/**
|
|
1451
|
+
* Reads a 8-bit unsigned integer from the buffer without advancing the offset.
|
|
1452
|
+
*
|
|
1453
|
+
* @returns 8-bit unsigned integer from the buffer.
|
|
1454
|
+
*/
|
|
1455
|
+
peekUint8(): number;
|
|
1456
|
+
/**
|
|
1457
|
+
* Helper method for asserting the next 8-bit unsigned integer in the buffer.
|
|
1458
|
+
*
|
|
1459
|
+
* @param value Expected value.
|
|
1460
|
+
* @throws If the next value in the buffer is not equal to the expected value.
|
|
1461
|
+
*/
|
|
1462
|
+
assertUint8(value: number): void;
|
|
1463
|
+
/**
|
|
1464
|
+
* Creates a new `InputByteBuffer` instance with the given initial offset.
|
|
1465
|
+
*
|
|
1466
|
+
* @param initialOffset Initial offset for the new buffer.
|
|
1467
|
+
* @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
|
|
1468
|
+
* its default value is `false`. If the original chunks are guaranteed not to change,
|
|
1469
|
+
* leave this flag as `false` to avoid unnecessary copying.
|
|
1470
|
+
*
|
|
1471
|
+
* @returns New `InputByteBuffer` instance with the given initial offset.
|
|
1472
|
+
*
|
|
1473
|
+
* @note This method is useful if you want to read some data from a specific index.
|
|
1474
|
+
*/
|
|
1475
|
+
createCopyWithOffset(initialOffset: number, cloneChunks?: boolean): InputByteBuffer;
|
|
1476
|
+
/**
|
|
1477
|
+
* Gets the current offset in the buffer for reading.
|
|
1478
|
+
*
|
|
1479
|
+
* @returns Current offset in the buffer for reading.
|
|
1480
|
+
*/
|
|
1481
|
+
get currentOffset(): number;
|
|
1482
|
+
/**
|
|
1483
|
+
* Gets the capacity of the buffer.
|
|
1484
|
+
*
|
|
1485
|
+
* @returns Capacity of the buffer.
|
|
1486
|
+
*/
|
|
1487
|
+
get capacity(): number;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Output byte buffer for writing binary data.
|
|
1492
|
+
*
|
|
1493
|
+
* @note Internally, this class uses a {@link ByteBuffer} instance, just providing a convenient API for reading data.
|
|
1494
|
+
*/
|
|
1495
|
+
declare class OutputByteBuffer extends ByteBuffer {
|
|
1496
|
+
/**
|
|
1497
|
+
* Current offset in the buffer for writing.
|
|
1498
|
+
*/
|
|
1499
|
+
private offset;
|
|
1500
|
+
/**
|
|
1501
|
+
* Size of the shared buffer for encoding strings.
|
|
1502
|
+
*/
|
|
1503
|
+
private static readonly ENCODER_BUFFER_SIZE;
|
|
1504
|
+
/**
|
|
1505
|
+
* Threshold for using a shared buffer for encoding strings.
|
|
1506
|
+
*/
|
|
1507
|
+
private static readonly SHORT_STRING_THRESHOLD;
|
|
1508
|
+
/**
|
|
1509
|
+
* Represents the maximum value that can be written as a 'storage optimized' unsigned integer.
|
|
1510
|
+
* 0x1FFFFFFF means 32 bits minus 3 bits, because the last bit in each byte is a flag indicating
|
|
1511
|
+
* if there are more bytes (except for the last byte).
|
|
1512
|
+
*/
|
|
1513
|
+
static MAX_OPTIMIZED_UINT: number;
|
|
1514
|
+
/**
|
|
1515
|
+
* Shared buffer for encoding strings.
|
|
1516
|
+
*/
|
|
1517
|
+
private readonly sharedBuffer;
|
|
1518
|
+
/**
|
|
1519
|
+
* Shared native encoder for encoding strings.
|
|
1520
|
+
*/
|
|
1521
|
+
private readonly sharedNativeEncoder;
|
|
1522
|
+
/**
|
|
1523
|
+
* Flag indicating if the current environment is Chromium.
|
|
1524
|
+
* This is used for performance optimizations, because Chromium's TextEncoder/TextDecoder has a relatively
|
|
1525
|
+
* large marshalling overhead for small strings.
|
|
1526
|
+
*/
|
|
1527
|
+
private readonly isChromium;
|
|
1528
|
+
/**
|
|
1529
|
+
* Constructs a new OutputByteBuffer instance.
|
|
1530
|
+
*/
|
|
1531
|
+
constructor();
|
|
1532
|
+
/**
|
|
1533
|
+
* Writes a 8-bit unsigned integer to the buffer.
|
|
1534
|
+
*
|
|
1535
|
+
* @param value Value to write.
|
|
1536
|
+
* @returns Number of bytes written to the buffer.
|
|
1537
|
+
*/
|
|
1538
|
+
writeUint8(value: number): number;
|
|
1539
|
+
/**
|
|
1540
|
+
* Writes a 16-bit unsigned integer to the buffer.
|
|
1541
|
+
*
|
|
1542
|
+
* @param value Value to write.
|
|
1543
|
+
* @returns Number of bytes written to the buffer.
|
|
1544
|
+
*/
|
|
1545
|
+
writeUint16(value: number): number;
|
|
1546
|
+
/**
|
|
1547
|
+
* Writes a 32-bit unsigned integer to the buffer at a specific index.
|
|
1548
|
+
*
|
|
1549
|
+
* @param value Value to write.
|
|
1550
|
+
* @param index Index to write the value to.
|
|
1551
|
+
* @returns Number of bytes written to the buffer.
|
|
1552
|
+
*/
|
|
1553
|
+
private writeUint32ToIndex;
|
|
1554
|
+
/**
|
|
1555
|
+
* Writes a 32-bit unsigned integer to the buffer.
|
|
1556
|
+
*
|
|
1557
|
+
* @param value Value to write.
|
|
1558
|
+
* @returns Number of bytes written to the buffer.
|
|
1559
|
+
*/
|
|
1560
|
+
writeUint32(value: number): number;
|
|
1561
|
+
/**
|
|
1562
|
+
* Writes a 32-bit signed integer to the buffer.
|
|
1563
|
+
*
|
|
1564
|
+
* @param value Value to write.
|
|
1565
|
+
* @returns Number of bytes written to the buffer.
|
|
1566
|
+
*/
|
|
1567
|
+
writeInt32(value: number): number;
|
|
1568
|
+
/**
|
|
1569
|
+
* Writes a Uint8Array to the byte buffer.
|
|
1570
|
+
*
|
|
1571
|
+
* @param buffer Buffer to write.
|
|
1572
|
+
*/
|
|
1573
|
+
private writeBuffer;
|
|
1574
|
+
/**
|
|
1575
|
+
* Writes a string to the buffer.
|
|
1576
|
+
*
|
|
1577
|
+
* @param value Value to write.
|
|
1578
|
+
* @returns Number of bytes written to the buffer.
|
|
1579
|
+
*/
|
|
1580
|
+
writeString(value: string): number;
|
|
1581
|
+
/**
|
|
1582
|
+
* Writes chunks to the storage.
|
|
1583
|
+
*
|
|
1584
|
+
* @param storage Storage to write the chunks to.
|
|
1585
|
+
* @param key Key to write the chunks to.
|
|
1586
|
+
* @note For performance reasons, chunks are passed by reference and not copied.
|
|
1587
|
+
* @throws If the storage write operation throws.
|
|
1588
|
+
*/
|
|
1589
|
+
writeChunksToStorage(storage: Storage, key: string): Promise<void>;
|
|
1590
|
+
/**
|
|
1591
|
+
* Writes an 'optimized' unsigned integer to the buffer.
|
|
1592
|
+
* 'Optimized' means smaller storage usage for smaller numbers.
|
|
1593
|
+
* Except for the last byte, each byte's most significant bit is a flag indicating if there are more bytes.
|
|
1594
|
+
*
|
|
1595
|
+
* @param value Value to write.
|
|
1596
|
+
* @returns Number of bytes written to the buffer.
|
|
1597
|
+
* @throws If the value exceeds the 29-bit limit.
|
|
1598
|
+
*/
|
|
1599
|
+
writeOptimizedUint(value: number): number;
|
|
1600
|
+
/**
|
|
1601
|
+
* Gets the current offset in the buffer for writing.
|
|
1602
|
+
*
|
|
1603
|
+
* @returns Current offset in the buffer for writing.
|
|
1604
|
+
*/
|
|
1605
|
+
get currentOffset(): number;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* Base class for parsers. Each parser should extend this class.
|
|
1610
|
+
*/
|
|
1611
|
+
declare class ParserBase {
|
|
1612
|
+
/**
|
|
1613
|
+
* Parses the input string and returns the AST node.
|
|
1614
|
+
*
|
|
1615
|
+
* @param input Input string to parse.
|
|
1616
|
+
* @param options Parser options, see {@link ParserOptions}.
|
|
1617
|
+
* @param baseOffset Base offset. Locations in the AST node will be relative to this offset.
|
|
1618
|
+
* @param args Additional, parser-specific arguments, if needed.
|
|
1619
|
+
*/
|
|
1620
|
+
static parse(input: string, options: ParserOptions, baseOffset: number, ...args: unknown[]): Node | null;
|
|
1621
|
+
/**
|
|
1622
|
+
* Generates a string from the AST node.
|
|
1623
|
+
*
|
|
1624
|
+
* @param node AST node to generate a string from.
|
|
1625
|
+
*/
|
|
1626
|
+
static generate(node: Node): string;
|
|
1627
|
+
/**
|
|
1628
|
+
* Serializes the AST node to a byte buffer.
|
|
1629
|
+
*
|
|
1630
|
+
* @param node AST node to serialize.
|
|
1631
|
+
* @param buffer Output byte buffer to write to.
|
|
1632
|
+
* @param args Additional, parser-specific arguments, if needed.
|
|
1633
|
+
*/
|
|
1634
|
+
static serialize(node: Node, buffer: OutputByteBuffer, ...args: unknown[]): void;
|
|
1635
|
+
/**
|
|
1636
|
+
* Deserializes the AST node from a byte buffer.
|
|
1637
|
+
*
|
|
1638
|
+
* @param buffer Input byte buffer to read from.
|
|
1639
|
+
* @param node Destination node to write to.
|
|
1640
|
+
* @param args Additional, parser-specific arguments, if needed.
|
|
1641
|
+
*/
|
|
1642
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<Node>, ...args: unknown[]): void;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* `RuleParser` is responsible for parsing the rules.
|
|
1647
|
+
*
|
|
1648
|
+
* It automatically determines the category and syntax of the rule, so you can pass any kind of rule to it.
|
|
1649
|
+
*/
|
|
1650
|
+
declare class RuleParser extends ParserBase {
|
|
1651
|
+
/**
|
|
1652
|
+
* Helper method to parse host rules if the `parseHostRules` option is enabled, otherwise it will
|
|
1653
|
+
* parse network rules.
|
|
1654
|
+
*
|
|
1655
|
+
* @param raw Raw input to parse.
|
|
1656
|
+
* @param options Global parser options.
|
|
1657
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1658
|
+
* @returns Host rule or network rule node.
|
|
1659
|
+
*/
|
|
1660
|
+
private static parseHostOrNetworkRule;
|
|
1661
|
+
/**
|
|
1662
|
+
* Parse an adblock rule. You can pass any kind of rule to this method, since it will automatically determine
|
|
1663
|
+
* the category and syntax. If the rule is syntactically invalid, then an error will be thrown. If the
|
|
1664
|
+
* syntax / compatibility cannot be determined clearly, then the value of the `syntax` property will be
|
|
1665
|
+
* `Common`.
|
|
1666
|
+
*
|
|
1667
|
+
* For example, let's have this network rule:
|
|
1668
|
+
* ```adblock
|
|
1669
|
+
* ||example.org^$important
|
|
1670
|
+
* ```
|
|
1671
|
+
* The `syntax` property will be `Common`, since the rule is syntactically correct in every adblockers, but we
|
|
1672
|
+
* cannot determine at parsing level whether `important` is an existing option or not, nor if it exists, then
|
|
1673
|
+
* which adblocker supports it. This is why the `syntax` property is simply `Common` at this point.
|
|
1674
|
+
* The concrete COMPATIBILITY of the rule will be determined later, in a different, higher-level layer, called
|
|
1675
|
+
* "Compatibility table".
|
|
1676
|
+
*
|
|
1677
|
+
* But we can determinate the concrete syntax of this rule:
|
|
1678
|
+
* ```adblock
|
|
1679
|
+
* example.org#%#//scriptlet("scriptlet0", "arg0")
|
|
1680
|
+
* ```
|
|
1681
|
+
* since it is clearly an AdGuard-specific rule and no other adblockers uses this syntax natively. However, we also
|
|
1682
|
+
* cannot determine the COMPATIBILITY of this rule, as it is not clear at this point whether the `scriptlet0`
|
|
1683
|
+
* scriptlet is supported by AdGuard or not. This is also the task of the "Compatibility table". Here, we simply
|
|
1684
|
+
* mark the rule with the `AdGuard` syntax in this case.
|
|
1685
|
+
*
|
|
1686
|
+
* @param raw Raw input to parse.
|
|
1687
|
+
* @param options Global parser options.
|
|
1688
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1689
|
+
* @returns Adblock rule node
|
|
1690
|
+
* @throws If the input matches a pattern but syntactically invalid
|
|
1691
|
+
* @example
|
|
1692
|
+
* Take a look at the following example:
|
|
1693
|
+
* ```js
|
|
1694
|
+
* // Parse a network rule
|
|
1695
|
+
* const ast1 = RuleParser.parse("||example.org^$important");
|
|
1696
|
+
*
|
|
1697
|
+
* // Parse another network rule
|
|
1698
|
+
* const ast2 = RuleParser.parse("/ads.js^$important,third-party,domain=example.org|~example.com");
|
|
1699
|
+
*
|
|
1700
|
+
* // Parse a cosmetic rule
|
|
1701
|
+
* const ast2 = RuleParser.parse("example.org##.banner");
|
|
1702
|
+
*
|
|
1703
|
+
* // Parse another cosmetic rule
|
|
1704
|
+
* const ast3 = RuleParser.parse("example.org#?#.banner:-abp-has(.ad)");
|
|
1705
|
+
*
|
|
1706
|
+
* // Parse a comment rule
|
|
1707
|
+
* const ast4 = RuleParser.parse("! Comment");
|
|
1708
|
+
*
|
|
1709
|
+
* // Parse an empty rule
|
|
1710
|
+
* const ast5 = RuleParser.parse("");
|
|
1711
|
+
*
|
|
1712
|
+
* // Parse a comment rule (with metadata)
|
|
1713
|
+
* const ast6 = RuleParser.parse("! Title: Example");
|
|
1714
|
+
*
|
|
1715
|
+
* // Parse a pre-processor rule
|
|
1716
|
+
* const ast7 = RuleParser.parse("!#if (adguard)");
|
|
1717
|
+
* ```
|
|
1718
|
+
*/
|
|
1719
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AnyRule;
|
|
1720
|
+
/**
|
|
1721
|
+
* Converts a rule AST to a string.
|
|
1722
|
+
*
|
|
1723
|
+
* @param ast - Adblock rule AST
|
|
1724
|
+
* @returns Raw string
|
|
1725
|
+
* @example
|
|
1726
|
+
* Take a look at the following example:
|
|
1727
|
+
* ```js
|
|
1728
|
+
* // Parse the rule to the AST
|
|
1729
|
+
* const ast = RuleParser.parse("example.org##.banner");
|
|
1730
|
+
* // Generate the rule from the AST
|
|
1731
|
+
* const raw = RuleParser.generate(ast);
|
|
1732
|
+
* // Print the generated rule
|
|
1733
|
+
* console.log(raw); // "example.org##.banner"
|
|
1734
|
+
* ```
|
|
1735
|
+
*/
|
|
1736
|
+
static generate(ast: AnyRule): string;
|
|
1737
|
+
/**
|
|
1738
|
+
* Serializes an empty rule node to binary format.
|
|
1739
|
+
*
|
|
1740
|
+
* @param node Node to serialize.
|
|
1741
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1742
|
+
*/
|
|
1743
|
+
static serializeEmptyRule(node: EmptyRule, buffer: OutputByteBuffer): void;
|
|
1744
|
+
/**
|
|
1745
|
+
* Deserializes an empty rule node from binary format.
|
|
1746
|
+
*
|
|
1747
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1748
|
+
* @param node Destination node.
|
|
1749
|
+
*/
|
|
1750
|
+
static deserializeEmptyRule(buffer: InputByteBuffer, node: EmptyRule): void;
|
|
1751
|
+
/**
|
|
1752
|
+
* Serializes an invalid rule error node to binary format.
|
|
1753
|
+
*
|
|
1754
|
+
* @param node Node to serialize.
|
|
1755
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1756
|
+
*/
|
|
1757
|
+
static serializeInvalidRuleErrorNode(node: InvalidRuleError, buffer: OutputByteBuffer): void;
|
|
1758
|
+
/**
|
|
1759
|
+
* Deserializes an invalid rule error node from binary format.
|
|
1760
|
+
*
|
|
1761
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1762
|
+
* @param node Destination node.
|
|
1763
|
+
*/
|
|
1764
|
+
static deserializeInvalidRuleErrorNode(buffer: InputByteBuffer, node: Partial<InvalidRuleError>): void;
|
|
1765
|
+
/**
|
|
1766
|
+
* Serializes an invalid rule node to binary format.
|
|
1767
|
+
*
|
|
1768
|
+
* @param node Node to serialize.
|
|
1769
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1770
|
+
*/
|
|
1771
|
+
static serializeInvalidRule(node: InvalidRule, buffer: OutputByteBuffer): void;
|
|
1772
|
+
/**
|
|
1773
|
+
* Deserializes an invalid rule node from binary format.
|
|
1774
|
+
*
|
|
1775
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1776
|
+
* @param node Destination node.
|
|
1777
|
+
*/
|
|
1778
|
+
static deserializeInvalidRule(buffer: InputByteBuffer, node: InvalidRule): void;
|
|
1779
|
+
/**
|
|
1780
|
+
* Serializes a rule node to binary format.
|
|
1781
|
+
*
|
|
1782
|
+
* @param node Node to serialize.
|
|
1783
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1784
|
+
*/
|
|
1785
|
+
static serialize(node: AnyRule, buffer: OutputByteBuffer): void;
|
|
1786
|
+
/**
|
|
1787
|
+
* Deserializes a rule node from binary format.
|
|
1788
|
+
*
|
|
1789
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1790
|
+
* @param node Destination node.
|
|
1791
|
+
*/
|
|
1792
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<AnyRule>): void;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* @file Customized syntax error class for Adblock Filter Parser.
|
|
1797
|
+
*/
|
|
1798
|
+
/**
|
|
1799
|
+
* Customized syntax error class for Adblock Filter Parser,
|
|
1800
|
+
* which contains the location range of the error.
|
|
1801
|
+
*/
|
|
1802
|
+
declare class AdblockSyntaxError extends SyntaxError {
|
|
1803
|
+
/**
|
|
1804
|
+
* Start offset of the error.
|
|
1805
|
+
*/
|
|
1806
|
+
start: number;
|
|
1807
|
+
/**
|
|
1808
|
+
* End offset of the error.
|
|
1809
|
+
*/
|
|
1810
|
+
end: number;
|
|
1811
|
+
/**
|
|
1812
|
+
* Constructs a new `AdblockSyntaxError` instance.
|
|
1813
|
+
*
|
|
1814
|
+
* @param message Error message.
|
|
1815
|
+
* @param start Start offset of the error.
|
|
1816
|
+
* @param end End offset of the error.
|
|
1817
|
+
*/
|
|
1818
|
+
constructor(message: string, start: number, end: number);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* `AgentParser` is responsible for parsing an Adblock agent rules.
|
|
1823
|
+
* Adblock agent comment marks that the filter list is supposed to
|
|
1824
|
+
* be used by the specified ad blockers.
|
|
1825
|
+
*
|
|
1826
|
+
* @example
|
|
1827
|
+
* - ```adblock
|
|
1828
|
+
* [AdGuard]
|
|
1829
|
+
* ```
|
|
1830
|
+
* - ```adblock
|
|
1831
|
+
* [Adblock Plus 2.0]
|
|
1832
|
+
* ```
|
|
1833
|
+
* - ```adblock
|
|
1834
|
+
* [uBlock Origin]
|
|
1835
|
+
* ```
|
|
1836
|
+
* - ```adblock
|
|
1837
|
+
* [uBlock Origin 1.45.3]
|
|
1838
|
+
* ```
|
|
1839
|
+
* - ```adblock
|
|
1840
|
+
* [Adblock Plus 2.0; AdGuard]
|
|
1841
|
+
* ```
|
|
1842
|
+
*/
|
|
1843
|
+
declare class AgentCommentRuleParser extends ParserBase {
|
|
1844
|
+
/**
|
|
1845
|
+
* Checks if the raw rule is an adblock agent comment.
|
|
1846
|
+
*
|
|
1847
|
+
* @param raw Raw rule
|
|
1848
|
+
* @returns `true` if the rule is an adblock agent, `false` otherwise
|
|
1849
|
+
*/
|
|
1850
|
+
static isAgentRule(raw: string): boolean;
|
|
1851
|
+
/**
|
|
1852
|
+
* Parses a raw rule as an adblock agent comment.
|
|
1853
|
+
*
|
|
1854
|
+
* @param raw Raw input to parse.
|
|
1855
|
+
* @param options Global parser options.
|
|
1856
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1857
|
+
* @returns Agent rule AST or null (if the raw rule cannot be parsed as an adblock agent comment)
|
|
1858
|
+
*/
|
|
1859
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AgentCommentRule | null;
|
|
1860
|
+
/**
|
|
1861
|
+
* Converts an adblock agent AST to a string.
|
|
1862
|
+
*
|
|
1863
|
+
* @param ast Agent rule AST
|
|
1864
|
+
* @returns Raw string
|
|
1865
|
+
*/
|
|
1866
|
+
static generate(ast: AgentCommentRule): string;
|
|
1867
|
+
/**
|
|
1868
|
+
* Serializes an adblock agent list node to binary format.
|
|
1869
|
+
*
|
|
1870
|
+
* @param node Node to serialize.
|
|
1871
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1872
|
+
*/
|
|
1873
|
+
static serialize(node: AgentCommentRule, buffer: OutputByteBuffer): void;
|
|
1874
|
+
/**
|
|
1875
|
+
* Deserializes an agent list node from binary format.
|
|
1876
|
+
*
|
|
1877
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1878
|
+
* @param node Destination node.
|
|
1879
|
+
*/
|
|
1880
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<AgentCommentRule>): void;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* `AgentParser` is responsible for parsing single adblock agent elements.
|
|
1885
|
+
*
|
|
1886
|
+
* @example
|
|
1887
|
+
* If the adblock agent rule is
|
|
1888
|
+
* ```adblock
|
|
1889
|
+
* [Adblock Plus 2.0; AdGuard]
|
|
1890
|
+
* ```
|
|
1891
|
+
* then the adblock agents are `Adblock Plus 2.0` and `AdGuard`, and this
|
|
1892
|
+
* class is responsible for parsing them. The rule itself is parsed by
|
|
1893
|
+
* `AgentCommentRuleParser`, which uses this class to parse single agents.
|
|
1894
|
+
*/
|
|
1895
|
+
declare class AgentParser extends ParserBase {
|
|
1896
|
+
/**
|
|
1897
|
+
* Checks if the string is a valid version.
|
|
1898
|
+
*
|
|
1899
|
+
* @param str String to check
|
|
1900
|
+
* @returns `true` if the string is a valid version, `false` otherwise
|
|
1901
|
+
*/
|
|
1902
|
+
private static isValidVersion;
|
|
1903
|
+
/**
|
|
1904
|
+
* Parses a raw rule as an adblock agent comment.
|
|
1905
|
+
*
|
|
1906
|
+
* @param raw Raw input to parse.
|
|
1907
|
+
* @param options Global parser options.
|
|
1908
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1317
1909
|
* @returns Agent rule AST
|
|
1318
1910
|
* @throws {AdblockSyntaxError} If the raw rule cannot be parsed as an adblock agent
|
|
1319
1911
|
*/
|
|
1320
|
-
static parse(raw: string,
|
|
1912
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): Agent;
|
|
1321
1913
|
/**
|
|
1322
|
-
* Converts an adblock agent
|
|
1914
|
+
* Converts an adblock agent node to a string.
|
|
1323
1915
|
*
|
|
1324
|
-
* @param
|
|
1916
|
+
* @param value Agent node
|
|
1325
1917
|
* @returns Raw string
|
|
1326
1918
|
*/
|
|
1327
|
-
static generate(
|
|
1919
|
+
static generate(value: Agent): string;
|
|
1920
|
+
/**
|
|
1921
|
+
* Serializes an agent node to binary format.
|
|
1922
|
+
*
|
|
1923
|
+
* @param node Node to serialize.
|
|
1924
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1925
|
+
*/
|
|
1926
|
+
static serialize(node: Agent, buffer: OutputByteBuffer): void;
|
|
1927
|
+
/**
|
|
1928
|
+
* Deserializes an agent node from binary format.
|
|
1929
|
+
*
|
|
1930
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
1931
|
+
* @param node Destination node.
|
|
1932
|
+
* @throws If the binary data is malformed.
|
|
1933
|
+
*/
|
|
1934
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<Agent>): void;
|
|
1328
1935
|
}
|
|
1329
1936
|
|
|
1330
1937
|
/**
|
|
@@ -1383,15 +1990,7 @@ declare class AgentParser {
|
|
|
1383
1990
|
* ```
|
|
1384
1991
|
* - etc.
|
|
1385
1992
|
*/
|
|
1386
|
-
declare class CommentRuleParser {
|
|
1387
|
-
/**
|
|
1388
|
-
* Checks whether a rule is a regular comment. Regular comments are the ones that start with
|
|
1389
|
-
* an exclamation mark (`!`).
|
|
1390
|
-
*
|
|
1391
|
-
* @param raw Raw rule
|
|
1392
|
-
* @returns `true` if the rule is a regular comment, `false` otherwise
|
|
1393
|
-
*/
|
|
1394
|
-
static isRegularComment(raw: string): boolean;
|
|
1993
|
+
declare class CommentRuleParser extends ParserBase {
|
|
1395
1994
|
/**
|
|
1396
1995
|
* Checks whether a rule is a comment.
|
|
1397
1996
|
*
|
|
@@ -1402,32 +2001,43 @@ declare class CommentRuleParser {
|
|
|
1402
2001
|
/**
|
|
1403
2002
|
* Parses a raw rule as comment.
|
|
1404
2003
|
*
|
|
1405
|
-
* @param raw Raw
|
|
1406
|
-
* @param
|
|
2004
|
+
* @param raw Raw input to parse.
|
|
2005
|
+
* @param options Global parser options.
|
|
2006
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1407
2007
|
* @returns Comment AST or null (if the raw rule cannot be parsed as comment)
|
|
1408
2008
|
*/
|
|
1409
|
-
static parse(raw: string,
|
|
2009
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AnyCommentRule | null;
|
|
1410
2010
|
/**
|
|
1411
|
-
* Converts a comment
|
|
2011
|
+
* Converts a comment rule node to a string.
|
|
1412
2012
|
*
|
|
1413
|
-
* @param
|
|
2013
|
+
* @param node Comment rule node
|
|
1414
2014
|
* @returns Raw string
|
|
1415
2015
|
*/
|
|
1416
|
-
static generate(
|
|
2016
|
+
static generate(node: AnyCommentRule): string;
|
|
2017
|
+
/**
|
|
2018
|
+
* Serializes a comment rule node to binary format.
|
|
2019
|
+
*
|
|
2020
|
+
* @param node Node to serialize.
|
|
2021
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2022
|
+
*/
|
|
2023
|
+
static serialize(node: AnyCommentRule, buffer: OutputByteBuffer): void;
|
|
2024
|
+
/**
|
|
2025
|
+
* Deserializes a comment rule node from binary format.
|
|
2026
|
+
*
|
|
2027
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2028
|
+
* @param node Destination node.
|
|
2029
|
+
* @throws If the binary data is malformed.
|
|
2030
|
+
*/
|
|
2031
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<AnyCommentRule>): void;
|
|
1417
2032
|
}
|
|
1418
2033
|
|
|
1419
|
-
/**
|
|
1420
|
-
* @file AGLint configuration comments. Inspired by ESLint inline configuration comments.
|
|
1421
|
-
* @see {@link https://eslint.org/docs/latest/user-guide/configuring/rules#using-configuration-comments}
|
|
1422
|
-
*/
|
|
1423
|
-
|
|
1424
2034
|
/**
|
|
1425
2035
|
* `ConfigCommentParser` is responsible for parsing inline AGLint configuration rules.
|
|
1426
2036
|
* Generally, the idea is inspired by ESLint inline configuration comments.
|
|
1427
2037
|
*
|
|
1428
2038
|
* @see {@link https://eslint.org/docs/latest/user-guide/configuring/rules#using-configuration-comments}
|
|
1429
2039
|
*/
|
|
1430
|
-
declare class ConfigCommentRuleParser {
|
|
2040
|
+
declare class ConfigCommentRuleParser extends ParserBase {
|
|
1431
2041
|
/**
|
|
1432
2042
|
* Checks if the raw rule is an inline configuration comment rule.
|
|
1433
2043
|
*
|
|
@@ -1438,19 +2048,50 @@ declare class ConfigCommentRuleParser {
|
|
|
1438
2048
|
/**
|
|
1439
2049
|
* Parses a raw rule as an inline configuration comment.
|
|
1440
2050
|
*
|
|
1441
|
-
* @param raw Raw
|
|
1442
|
-
* @param
|
|
2051
|
+
* @param raw Raw input to parse.
|
|
2052
|
+
* @param options Global parser options.
|
|
2053
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1443
2054
|
* @returns
|
|
1444
2055
|
* Inline configuration comment AST or null (if the raw rule cannot be parsed as configuration comment)
|
|
1445
2056
|
*/
|
|
1446
|
-
static parse(raw: string,
|
|
2057
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): ConfigCommentRule | null;
|
|
1447
2058
|
/**
|
|
1448
|
-
* Converts an inline configuration comment
|
|
2059
|
+
* Converts an inline configuration comment node to a string.
|
|
1449
2060
|
*
|
|
1450
|
-
* @param
|
|
2061
|
+
* @param node Inline configuration comment node
|
|
1451
2062
|
* @returns Raw string
|
|
1452
2063
|
*/
|
|
1453
|
-
static generate(
|
|
2064
|
+
static generate(node: ConfigCommentRule): string;
|
|
2065
|
+
/**
|
|
2066
|
+
* Serializes a config node to binary format.
|
|
2067
|
+
*
|
|
2068
|
+
* @param node Node to serialize.
|
|
2069
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2070
|
+
*/
|
|
2071
|
+
private static serializeConfigNode;
|
|
2072
|
+
/**
|
|
2073
|
+
* Deserializes a metadata comment node from binary format.
|
|
2074
|
+
*
|
|
2075
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2076
|
+
* @param node Destination node.
|
|
2077
|
+
* @throws If the binary data is malformed.
|
|
2078
|
+
*/
|
|
2079
|
+
private static deserializeConfigNode;
|
|
2080
|
+
/**
|
|
2081
|
+
* Serializes a metadata comment node to binary format.
|
|
2082
|
+
*
|
|
2083
|
+
* @param node Node to serialize.
|
|
2084
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2085
|
+
*/
|
|
2086
|
+
static serialize(node: ConfigCommentRule, buffer: OutputByteBuffer): void;
|
|
2087
|
+
/**
|
|
2088
|
+
* Deserializes a metadata comment node from binary format.
|
|
2089
|
+
*
|
|
2090
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2091
|
+
* @param node Destination node.
|
|
2092
|
+
* @throws If the binary data is malformed.
|
|
2093
|
+
*/
|
|
2094
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<ConfigCommentRule>): void;
|
|
1454
2095
|
}
|
|
1455
2096
|
|
|
1456
2097
|
/**
|
|
@@ -1467,7 +2108,7 @@ declare class ConfigCommentRuleParser {
|
|
|
1467
2108
|
* compatible with the given adblocker. This is a completely natural behavior, meaningful
|
|
1468
2109
|
* checking of compatibility is not done at the parser level.
|
|
1469
2110
|
*/
|
|
1470
|
-
declare class CosmeticRuleParser {
|
|
2111
|
+
declare class CosmeticRuleParser extends ParserBase {
|
|
1471
2112
|
/**
|
|
1472
2113
|
* Determines whether a rule is a cosmetic rule. The rule is considered cosmetic if it
|
|
1473
2114
|
* contains a cosmetic rule separator.
|
|
@@ -1482,42 +2123,85 @@ declare class CosmeticRuleParser {
|
|
|
1482
2123
|
* - separator
|
|
1483
2124
|
* - body
|
|
1484
2125
|
*
|
|
1485
|
-
* @param raw Raw
|
|
1486
|
-
* @param
|
|
2126
|
+
* @param raw Raw input to parse.
|
|
2127
|
+
* @param options Global parser options.
|
|
2128
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1487
2129
|
* @returns
|
|
1488
2130
|
* Parsed cosmetic rule AST or null if it failed to parse based on the known cosmetic rules
|
|
1489
2131
|
* @throws If the input matches the cosmetic rule pattern but syntactically invalid
|
|
1490
2132
|
*/
|
|
1491
|
-
static parse(raw: string,
|
|
2133
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AnyCosmeticRule | null;
|
|
1492
2134
|
/**
|
|
1493
2135
|
* Generates the rule pattern from the AST.
|
|
1494
2136
|
*
|
|
1495
|
-
* @param
|
|
2137
|
+
* @param node Cosmetic rule node
|
|
1496
2138
|
* @returns Raw rule pattern
|
|
1497
2139
|
* @example
|
|
1498
2140
|
* - '##.foo' → ''
|
|
1499
2141
|
* - 'example.com,example.org##.foo' → 'example.com,example.org'
|
|
1500
2142
|
* - '[$path=/foo/bar]example.com##.foo' → '[$path=/foo/bar]example.com'
|
|
1501
2143
|
*/
|
|
1502
|
-
static generatePattern(
|
|
2144
|
+
static generatePattern(node: AnyCosmeticRule): string;
|
|
1503
2145
|
/**
|
|
1504
|
-
* Generates the rule body from the
|
|
2146
|
+
* Generates the rule body from the node.
|
|
1505
2147
|
*
|
|
1506
|
-
* @param
|
|
2148
|
+
* @param node Cosmetic rule node
|
|
1507
2149
|
* @returns Raw rule body
|
|
1508
2150
|
* @example
|
|
1509
2151
|
* - '##.foo' → '.foo'
|
|
1510
2152
|
* - 'example.com,example.org##.foo' → '.foo'
|
|
1511
2153
|
* - 'example.com#%#//scriptlet('foo')' → '//scriptlet('foo')'
|
|
1512
2154
|
*/
|
|
1513
|
-
static generateBody(
|
|
2155
|
+
static generateBody(node: AnyCosmeticRule): string;
|
|
1514
2156
|
/**
|
|
1515
2157
|
* Converts a cosmetic rule AST into a string.
|
|
1516
2158
|
*
|
|
1517
|
-
* @param
|
|
2159
|
+
* @param node Cosmetic rule AST
|
|
1518
2160
|
* @returns Raw string
|
|
1519
2161
|
*/
|
|
1520
|
-
static generate(
|
|
2162
|
+
static generate(node: AnyCosmeticRule): string;
|
|
2163
|
+
/**
|
|
2164
|
+
* Serializes an element hiding rule body node to binary format.
|
|
2165
|
+
*
|
|
2166
|
+
* @param node Node to serialize.
|
|
2167
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2168
|
+
*/
|
|
2169
|
+
private static serializeElementHidingBody;
|
|
2170
|
+
/**
|
|
2171
|
+
* Deserializes an element hiding rule body node from binary format.
|
|
2172
|
+
*
|
|
2173
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2174
|
+
* @param node Destination node.
|
|
2175
|
+
*/
|
|
2176
|
+
private static deserializeElementHidingBody;
|
|
2177
|
+
/**
|
|
2178
|
+
* Serializes a CSS injection rule body node to binary format.
|
|
2179
|
+
*
|
|
2180
|
+
* @param node Node to serialize.
|
|
2181
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2182
|
+
*/
|
|
2183
|
+
private static serializeCssInjectionBody;
|
|
2184
|
+
/**
|
|
2185
|
+
* Deserializes CSS injection rule body node from binary format.
|
|
2186
|
+
*
|
|
2187
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2188
|
+
* @param node Destination node.
|
|
2189
|
+
*/
|
|
2190
|
+
private static deserializeCssInjectionBody;
|
|
2191
|
+
/**
|
|
2192
|
+
* Serializes a cosmetic rule node to binary format.
|
|
2193
|
+
*
|
|
2194
|
+
* @param node Node to serialize.
|
|
2195
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2196
|
+
*/
|
|
2197
|
+
static serialize(node: AnyCosmeticRule, buffer: OutputByteBuffer): void;
|
|
2198
|
+
/**
|
|
2199
|
+
* Deserializes a cosmetic rule node from binary format.
|
|
2200
|
+
*
|
|
2201
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2202
|
+
* @param node Destination node.
|
|
2203
|
+
*/
|
|
2204
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<AnyCosmeticRule>): void;
|
|
1521
2205
|
}
|
|
1522
2206
|
|
|
1523
2207
|
/**
|
|
@@ -1525,18 +2209,20 @@ declare class CosmeticRuleParser {
|
|
|
1525
2209
|
*
|
|
1526
2210
|
* @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#app-modifier}
|
|
1527
2211
|
*/
|
|
1528
|
-
declare class AppListParser {
|
|
2212
|
+
declare class AppListParser extends ParserBase {
|
|
1529
2213
|
/**
|
|
1530
2214
|
* Parses an app list which items are separated by `|`,
|
|
1531
2215
|
* e.g. `Example.exe|com.example.osx`.
|
|
1532
2216
|
*
|
|
1533
|
-
* @param raw Raw
|
|
1534
|
-
* @param
|
|
2217
|
+
* @param raw Raw input to parse.
|
|
2218
|
+
* @param options Global parser options.
|
|
2219
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1535
2220
|
*
|
|
1536
2221
|
* @returns App list AST.
|
|
1537
2222
|
* @throws An {@link AdblockSyntaxError} if the app list is syntactically invalid.
|
|
2223
|
+
* @throws An {@link Error} if the options are invalid.
|
|
1538
2224
|
*/
|
|
1539
|
-
static parse(raw: string,
|
|
2225
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AppList;
|
|
1540
2226
|
}
|
|
1541
2227
|
|
|
1542
2228
|
/**
|
|
@@ -1548,26 +2234,42 @@ declare class AppListParser {
|
|
|
1548
2234
|
* This parser is responsible for parsing these domain lists.
|
|
1549
2235
|
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_domains}
|
|
1550
2236
|
*/
|
|
1551
|
-
declare class DomainListParser {
|
|
2237
|
+
declare class DomainListParser extends ParserBase {
|
|
1552
2238
|
/**
|
|
1553
2239
|
* Parses a domain list, eg. `example.com,example.org,~example.org`
|
|
1554
2240
|
*
|
|
1555
|
-
* @param raw Raw
|
|
1556
|
-
* @param
|
|
1557
|
-
* @param
|
|
2241
|
+
* @param raw Raw input to parse.
|
|
2242
|
+
* @param options Global parser options.
|
|
2243
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
2244
|
+
* @param separator Separator character (default: comma)
|
|
1558
2245
|
*
|
|
1559
2246
|
* @returns Domain list AST.
|
|
1560
2247
|
* @throws An {@link AdblockSyntaxError} if the domain list is syntactically invalid.
|
|
2248
|
+
* @throws An {@link Error} if the options are invalid.
|
|
1561
2249
|
*/
|
|
1562
|
-
static parse(raw: string,
|
|
2250
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number, separator?: string): DomainList;
|
|
1563
2251
|
/**
|
|
1564
|
-
* Converts a domain list
|
|
2252
|
+
* Converts a domain list node to a string.
|
|
1565
2253
|
*
|
|
1566
|
-
* @param
|
|
2254
|
+
* @param node Domain list node.
|
|
1567
2255
|
*
|
|
1568
2256
|
* @returns Raw string.
|
|
1569
2257
|
*/
|
|
1570
|
-
static generate(
|
|
2258
|
+
static generate(node: DomainList): string;
|
|
2259
|
+
/**
|
|
2260
|
+
* Serializes a domain list node to binary format.
|
|
2261
|
+
*
|
|
2262
|
+
* @param node Node to serialize.
|
|
2263
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2264
|
+
*/
|
|
2265
|
+
static serialize(node: DomainList, buffer: OutputByteBuffer): void;
|
|
2266
|
+
/**
|
|
2267
|
+
* Deserializes a modifier list node from binary format.
|
|
2268
|
+
*
|
|
2269
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2270
|
+
* @param node Destination node.
|
|
2271
|
+
*/
|
|
2272
|
+
static deserialize(buffer: InputByteBuffer, node: DomainList): void;
|
|
1571
2273
|
}
|
|
1572
2274
|
|
|
1573
2275
|
/**
|
|
@@ -1575,18 +2277,20 @@ declare class DomainListParser {
|
|
|
1575
2277
|
*
|
|
1576
2278
|
* @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#method-modifier}
|
|
1577
2279
|
*/
|
|
1578
|
-
declare class MethodListParser {
|
|
2280
|
+
declare class MethodListParser extends ParserBase {
|
|
1579
2281
|
/**
|
|
1580
2282
|
* Parses a method list which items are separated by `|`,
|
|
1581
2283
|
* e.g. `get|post|put`.
|
|
1582
2284
|
*
|
|
1583
|
-
* @param raw Raw
|
|
1584
|
-
* @param
|
|
2285
|
+
* @param raw Raw input to parse.
|
|
2286
|
+
* @param options Global parser options.
|
|
2287
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1585
2288
|
*
|
|
1586
2289
|
* @returns Method list AST.
|
|
1587
2290
|
* @throws An {@link AdblockSyntaxError} if the method list is syntactically invalid.
|
|
2291
|
+
* @throws An {@link Error} if the options are invalid.
|
|
1588
2292
|
*/
|
|
1589
|
-
static parse(raw: string,
|
|
2293
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): MethodList;
|
|
1590
2294
|
}
|
|
1591
2295
|
|
|
1592
2296
|
/**
|
|
@@ -1594,33 +2298,33 @@ declare class MethodListParser {
|
|
|
1594
2298
|
*
|
|
1595
2299
|
* @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#stealth-modifier}
|
|
1596
2300
|
*/
|
|
1597
|
-
declare class StealthOptionListParser {
|
|
2301
|
+
declare class StealthOptionListParser extends ParserBase {
|
|
1598
2302
|
/**
|
|
1599
2303
|
* Parses a stealth option list which items are separated by `|`,
|
|
1600
2304
|
* e.g. `dpi|ip`.
|
|
1601
2305
|
*
|
|
1602
|
-
* @param raw Raw
|
|
1603
|
-
* @param
|
|
2306
|
+
* @param raw Raw input to parse.
|
|
2307
|
+
* @param options Global parser options.
|
|
2308
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1604
2309
|
*
|
|
1605
2310
|
* @returns Stealth option list AST.
|
|
1606
2311
|
* @throws An {@link AdblockSyntaxError} if the stealth option list is syntactically invalid.
|
|
2312
|
+
* @throws An {@link Error} if the options are invalid.
|
|
1607
2313
|
*/
|
|
1608
|
-
static parse(raw: string,
|
|
2314
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): StealthOptionList;
|
|
1609
2315
|
}
|
|
1610
2316
|
|
|
1611
2317
|
/**
|
|
1612
2318
|
* `FilterListParser` is responsible for parsing a whole adblock filter list (list of rules).
|
|
1613
2319
|
* It is a wrapper around `RuleParser` which parses each line separately.
|
|
1614
2320
|
*/
|
|
1615
|
-
declare class FilterListParser {
|
|
2321
|
+
declare class FilterListParser extends ParserBase {
|
|
1616
2322
|
/**
|
|
1617
2323
|
* Parses a whole adblock filter list (list of rules).
|
|
1618
2324
|
*
|
|
1619
|
-
* @param raw
|
|
1620
|
-
* @param
|
|
1621
|
-
*
|
|
1622
|
-
* It is useful for parsing filter lists with invalid rules, because most of the rules are valid,
|
|
1623
|
-
* and some invalid rules can't break the whole filter list parsing.
|
|
2325
|
+
* @param raw Raw input to parse.
|
|
2326
|
+
* @param options Global parser options.
|
|
2327
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1624
2328
|
* @returns AST of the source code (list of rules)
|
|
1625
2329
|
* @example
|
|
1626
2330
|
* ```js
|
|
@@ -1635,7 +2339,7 @@ declare class FilterListParser {
|
|
|
1635
2339
|
* ```
|
|
1636
2340
|
* @throws If one of the rules is syntactically invalid (if `tolerant` is `false`)
|
|
1637
2341
|
*/
|
|
1638
|
-
static parse(raw: string,
|
|
2342
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): FilterList;
|
|
1639
2343
|
/**
|
|
1640
2344
|
* Serializes a whole adblock filter list (list of rules).
|
|
1641
2345
|
*
|
|
@@ -1645,6 +2349,38 @@ declare class FilterListParser {
|
|
|
1645
2349
|
* @returns Serialized filter list
|
|
1646
2350
|
*/
|
|
1647
2351
|
static generate(ast: FilterList, preferRaw?: boolean): string;
|
|
2352
|
+
/**
|
|
2353
|
+
* Serializes a filter list node to binary format.
|
|
2354
|
+
*
|
|
2355
|
+
* @param node Node to serialize.
|
|
2356
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2357
|
+
*/
|
|
2358
|
+
static serialize(node: FilterList, buffer: OutputByteBuffer): void;
|
|
2359
|
+
/**
|
|
2360
|
+
* Deserializes a filter list node from binary format.
|
|
2361
|
+
*
|
|
2362
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2363
|
+
* @param node Destination node.
|
|
2364
|
+
*/
|
|
2365
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<FilterList>): void;
|
|
2366
|
+
/**
|
|
2367
|
+
* Helper method to jump to the children of the filter list node.
|
|
2368
|
+
*
|
|
2369
|
+
* Filter lists serialized in binary format are structured as follows:
|
|
2370
|
+
* - `FilterListNode` filter list node indicator (1 byte)
|
|
2371
|
+
* - Properties:
|
|
2372
|
+
* - `Children` (1 byte) - children count, followed by children nodes
|
|
2373
|
+
* - `Start` (1 byte) - start offset, if present, followed by the value
|
|
2374
|
+
* - `End` (1 byte) - end offset, if present, followed by the value
|
|
2375
|
+
* - `NULL` (1 byte) - closing indicator
|
|
2376
|
+
*
|
|
2377
|
+
* This method skips indicators, reads the children count and returns it.
|
|
2378
|
+
* This way the buffer is positioned at the beginning of the children nodes.
|
|
2379
|
+
*
|
|
2380
|
+
* @param buffer Reference to the input byte buffer.
|
|
2381
|
+
* @returns Number of children nodes.
|
|
2382
|
+
*/
|
|
2383
|
+
static jumpToChildren(buffer: InputByteBuffer): number;
|
|
1648
2384
|
}
|
|
1649
2385
|
|
|
1650
2386
|
/**
|
|
@@ -1658,7 +2394,7 @@ declare class FilterListParser {
|
|
|
1658
2394
|
* contains two hints: `NOT_OPTIMIZED` and `PLATFORM`.
|
|
1659
2395
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
|
|
1660
2396
|
*/
|
|
1661
|
-
declare class HintCommentRuleParser {
|
|
2397
|
+
declare class HintCommentRuleParser extends ParserBase {
|
|
1662
2398
|
/**
|
|
1663
2399
|
* Checks if the raw rule is a hint rule.
|
|
1664
2400
|
*
|
|
@@ -1669,27 +2405,38 @@ declare class HintCommentRuleParser {
|
|
|
1669
2405
|
/**
|
|
1670
2406
|
* Parses a raw rule as a hint comment.
|
|
1671
2407
|
*
|
|
1672
|
-
* @param raw Raw
|
|
1673
|
-
* @param
|
|
2408
|
+
* @param raw Raw input to parse.
|
|
2409
|
+
* @param options Global parser options.
|
|
2410
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1674
2411
|
* @returns Hint AST or null (if the raw rule cannot be parsed as a hint comment)
|
|
1675
2412
|
* @throws If the input matches the HINT pattern but syntactically invalid
|
|
1676
2413
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints-1}
|
|
1677
2414
|
*/
|
|
1678
|
-
static parse(raw: string,
|
|
2415
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): HintCommentRule | null;
|
|
1679
2416
|
/**
|
|
1680
|
-
* Converts a hint rule
|
|
2417
|
+
* Converts a hint rule node to a raw string.
|
|
1681
2418
|
*
|
|
1682
|
-
* @param
|
|
2419
|
+
* @param node Hint rule node
|
|
1683
2420
|
* @returns Raw string
|
|
1684
2421
|
*/
|
|
1685
|
-
static generate(
|
|
2422
|
+
static generate(node: HintCommentRule): string;
|
|
2423
|
+
/**
|
|
2424
|
+
* Serializes a hint rule node to binary format.
|
|
2425
|
+
*
|
|
2426
|
+
* @param node Node to serialize.
|
|
2427
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2428
|
+
*/
|
|
2429
|
+
static serialize(node: HintCommentRule, buffer: OutputByteBuffer): void;
|
|
2430
|
+
/**
|
|
2431
|
+
* Deserializes a hint rule node from binary format.
|
|
2432
|
+
*
|
|
2433
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2434
|
+
* @param node Destination node.
|
|
2435
|
+
* @throws If the binary data is malformed.
|
|
2436
|
+
*/
|
|
2437
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<HintCommentRule>): void;
|
|
1686
2438
|
}
|
|
1687
2439
|
|
|
1688
|
-
/**
|
|
1689
|
-
* @file AdGuard Hints
|
|
1690
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
|
|
1691
|
-
*/
|
|
1692
|
-
|
|
1693
2440
|
/**
|
|
1694
2441
|
* `HintParser` is responsible for parsing AdGuard hints.
|
|
1695
2442
|
*
|
|
@@ -1702,16 +2449,17 @@ declare class HintCommentRuleParser {
|
|
|
1702
2449
|
* class is responsible for parsing them. The rule itself is parsed by
|
|
1703
2450
|
* the `HintRuleParser`, which uses this class to parse single hints.
|
|
1704
2451
|
*/
|
|
1705
|
-
declare class HintParser {
|
|
2452
|
+
declare class HintParser extends ParserBase {
|
|
1706
2453
|
/**
|
|
1707
2454
|
* Parses a raw rule as a hint.
|
|
1708
2455
|
*
|
|
1709
|
-
* @param raw Raw
|
|
1710
|
-
* @param
|
|
2456
|
+
* @param raw Raw input to parse.
|
|
2457
|
+
* @param options Global parser options.
|
|
2458
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1711
2459
|
* @returns Hint rule AST or null
|
|
1712
2460
|
* @throws If the syntax is invalid
|
|
1713
2461
|
*/
|
|
1714
|
-
static parse(raw: string,
|
|
2462
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): Hint;
|
|
1715
2463
|
/**
|
|
1716
2464
|
* Converts a single hint AST to a string.
|
|
1717
2465
|
*
|
|
@@ -1719,6 +2467,21 @@ declare class HintParser {
|
|
|
1719
2467
|
* @returns Hint string
|
|
1720
2468
|
*/
|
|
1721
2469
|
static generate(hint: Hint): string;
|
|
2470
|
+
/**
|
|
2471
|
+
* Serializes a hint node to binary format.
|
|
2472
|
+
*
|
|
2473
|
+
* @param node Node to serialize.
|
|
2474
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2475
|
+
*/
|
|
2476
|
+
static serialize(node: Hint, buffer: OutputByteBuffer): void;
|
|
2477
|
+
/**
|
|
2478
|
+
* Deserializes a hint node from binary format.
|
|
2479
|
+
*
|
|
2480
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2481
|
+
* @param node Destination node.
|
|
2482
|
+
* @throws If the binary data is malformed.
|
|
2483
|
+
*/
|
|
2484
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<Hint>): void;
|
|
1722
2485
|
}
|
|
1723
2486
|
|
|
1724
2487
|
/**
|
|
@@ -1731,38 +2494,99 @@ declare class HintParser {
|
|
|
1731
2494
|
* ```
|
|
1732
2495
|
* this parser will parse the expression `(adguard_ext_android_cb || adguard_ext_safari)`.
|
|
1733
2496
|
*/
|
|
1734
|
-
declare class LogicalExpressionParser {
|
|
2497
|
+
declare class LogicalExpressionParser extends ParserBase {
|
|
2498
|
+
/**
|
|
2499
|
+
* Split the expression into tokens.
|
|
2500
|
+
*
|
|
2501
|
+
* @param raw Source code of the expression
|
|
2502
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
2503
|
+
* @returns Token list
|
|
2504
|
+
* @throws {AdblockSyntaxError} If the expression is invalid
|
|
2505
|
+
*/
|
|
2506
|
+
private static tokenize;
|
|
2507
|
+
/**
|
|
2508
|
+
* Parses a logical expression.
|
|
2509
|
+
*
|
|
2510
|
+
* @param raw Raw input to parse.
|
|
2511
|
+
* @param options Global parser options.
|
|
2512
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
2513
|
+
* @returns Parsed expression
|
|
2514
|
+
* @throws {AdblockSyntaxError} If the expression is invalid
|
|
2515
|
+
*/
|
|
2516
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): AnyExpressionNode;
|
|
2517
|
+
/**
|
|
2518
|
+
* Generates a string representation of the logical expression (serialization).
|
|
2519
|
+
*
|
|
2520
|
+
* @param node Expression node
|
|
2521
|
+
* @returns String representation of the logical expression
|
|
2522
|
+
*/
|
|
2523
|
+
static generate(node: AnyExpressionNode): string;
|
|
2524
|
+
/**
|
|
2525
|
+
* Serializes a variable node to binary format.
|
|
2526
|
+
*
|
|
2527
|
+
* @param node Node to serialize.
|
|
2528
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2529
|
+
*/
|
|
2530
|
+
private static serializeVariableNode;
|
|
2531
|
+
/**
|
|
2532
|
+
* Serializes a parenthesis node to binary format.
|
|
2533
|
+
*
|
|
2534
|
+
* @param node Node to serialize.
|
|
2535
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2536
|
+
*/
|
|
2537
|
+
private static serializeParenthesisNode;
|
|
2538
|
+
/**
|
|
2539
|
+
* Serializes an operator node to binary format.
|
|
2540
|
+
*
|
|
2541
|
+
* @param node Node to serialize.
|
|
2542
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2543
|
+
*/
|
|
2544
|
+
private static serializeOperatorNode;
|
|
1735
2545
|
/**
|
|
1736
|
-
*
|
|
2546
|
+
* Serializes a logical expression node to binary format.
|
|
1737
2547
|
*
|
|
1738
|
-
* @param
|
|
1739
|
-
* @param
|
|
1740
|
-
* @returns Token list
|
|
1741
|
-
* @throws {AdblockSyntaxError} If the expression is invalid
|
|
2548
|
+
* @param node Node to serialize.
|
|
2549
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
1742
2550
|
*/
|
|
1743
|
-
|
|
2551
|
+
static serialize(node: AnyExpressionNode, buffer: OutputByteBuffer): void;
|
|
1744
2552
|
/**
|
|
1745
|
-
*
|
|
2553
|
+
* Deserializes a variable node from binary format.
|
|
1746
2554
|
*
|
|
1747
|
-
* @param
|
|
1748
|
-
* @param
|
|
1749
|
-
* @
|
|
1750
|
-
* @throws {AdblockSyntaxError} If the expression is invalid
|
|
2555
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2556
|
+
* @param node Destination node.
|
|
2557
|
+
* @throws If the binary data is malformed.
|
|
1751
2558
|
*/
|
|
1752
|
-
static
|
|
2559
|
+
private static deserializeVariableNode;
|
|
1753
2560
|
/**
|
|
1754
|
-
*
|
|
2561
|
+
* Deserializes a parenthesis node from binary format.
|
|
1755
2562
|
*
|
|
1756
|
-
* @param
|
|
1757
|
-
* @
|
|
2563
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2564
|
+
* @param node Destination node.
|
|
2565
|
+
* @throws If the binary data is malformed.
|
|
2566
|
+
*/
|
|
2567
|
+
private static deserializeParenthesisNode;
|
|
2568
|
+
/**
|
|
2569
|
+
* Deserializes an operator node from binary format.
|
|
2570
|
+
*
|
|
2571
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2572
|
+
* @param node Destination node.
|
|
2573
|
+
* @throws If the binary data is malformed.
|
|
2574
|
+
*/
|
|
2575
|
+
private static deserializeOperatorNode;
|
|
2576
|
+
/**
|
|
2577
|
+
* Deserializes a logical expression node from binary format.
|
|
2578
|
+
*
|
|
2579
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2580
|
+
* @param node Destination node.
|
|
2581
|
+
* @throws If the binary data is malformed.
|
|
1758
2582
|
*/
|
|
1759
|
-
static
|
|
2583
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<AnyExpressionNode>): void;
|
|
1760
2584
|
}
|
|
1761
2585
|
|
|
1762
2586
|
/**
|
|
1763
|
-
*
|
|
2587
|
+
* Known metadata headers.
|
|
1764
2588
|
*/
|
|
1765
|
-
|
|
2589
|
+
declare const KNOWN_METADATA_HEADERS: string[];
|
|
1766
2590
|
/**
|
|
1767
2591
|
* `MetadataParser` is responsible for parsing metadata comments.
|
|
1768
2592
|
* Metadata comments are special comments that specify some properties of the list.
|
|
@@ -1776,22 +2600,38 @@ declare class LogicalExpressionParser {
|
|
|
1776
2600
|
* the list title is `My List`, and it can be used in the adblocker UI.
|
|
1777
2601
|
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#special-comments}
|
|
1778
2602
|
*/
|
|
1779
|
-
declare class MetadataCommentRuleParser {
|
|
2603
|
+
declare class MetadataCommentRuleParser extends ParserBase {
|
|
1780
2604
|
/**
|
|
1781
2605
|
* Parses a raw rule as a metadata comment.
|
|
1782
2606
|
*
|
|
1783
|
-
* @param raw Raw
|
|
1784
|
-
* @param
|
|
2607
|
+
* @param raw Raw input to parse.
|
|
2608
|
+
* @param options Global parser options.
|
|
2609
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1785
2610
|
* @returns Metadata comment AST or null (if the raw rule cannot be parsed as a metadata comment)
|
|
1786
2611
|
*/
|
|
1787
|
-
static parse(raw: string,
|
|
2612
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): MetadataCommentRule | null;
|
|
1788
2613
|
/**
|
|
1789
|
-
* Converts a metadata comment
|
|
2614
|
+
* Converts a metadata comment rule node to a string.
|
|
1790
2615
|
*
|
|
1791
|
-
* @param
|
|
1792
|
-
* @returns Raw string
|
|
2616
|
+
* @param node Metadata comment rule node.
|
|
2617
|
+
* @returns Raw string.
|
|
2618
|
+
*/
|
|
2619
|
+
static generate(node: MetadataCommentRule): string;
|
|
2620
|
+
/**
|
|
2621
|
+
* Serializes a metadata comment node to binary format.
|
|
2622
|
+
*
|
|
2623
|
+
* @param node Node to serialize.
|
|
2624
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2625
|
+
*/
|
|
2626
|
+
static serialize(node: MetadataCommentRule, buffer: OutputByteBuffer): void;
|
|
2627
|
+
/**
|
|
2628
|
+
* Deserializes a metadata comment node from binary format.
|
|
2629
|
+
*
|
|
2630
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2631
|
+
* @param node Destination node.
|
|
2632
|
+
* @throws If the binary data is malformed.
|
|
1793
2633
|
*/
|
|
1794
|
-
static
|
|
2634
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<MetadataCommentRule>): void;
|
|
1795
2635
|
}
|
|
1796
2636
|
|
|
1797
2637
|
/**
|
|
@@ -1802,18 +2642,19 @@ declare class MetadataCommentRuleParser {
|
|
|
1802
2642
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#non-basic-rules-modifiers}
|
|
1803
2643
|
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#options}
|
|
1804
2644
|
*/
|
|
1805
|
-
declare class ModifierListParser {
|
|
2645
|
+
declare class ModifierListParser extends ParserBase {
|
|
1806
2646
|
/**
|
|
1807
2647
|
* Parses the cosmetic rule modifiers, eg. `third-party,domain=example.com|~example.org`.
|
|
1808
2648
|
*
|
|
1809
2649
|
* _Note:_ you should remove `$` separator before passing the raw modifiers to this function,
|
|
1810
2650
|
* or it will be parsed in the first modifier.
|
|
1811
2651
|
*
|
|
1812
|
-
* @param raw Raw
|
|
1813
|
-
* @param
|
|
2652
|
+
* @param raw Raw input to parse.
|
|
2653
|
+
* @param options Global parser options.
|
|
2654
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1814
2655
|
* @returns Parsed modifiers interface
|
|
1815
2656
|
*/
|
|
1816
|
-
static parse(raw: string,
|
|
2657
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): ModifierList;
|
|
1817
2658
|
/**
|
|
1818
2659
|
* Converts a modifier list AST to a string.
|
|
1819
2660
|
*
|
|
@@ -1821,6 +2662,20 @@ declare class ModifierListParser {
|
|
|
1821
2662
|
* @returns Raw string
|
|
1822
2663
|
*/
|
|
1823
2664
|
static generate(ast: ModifierList): string;
|
|
2665
|
+
/**
|
|
2666
|
+
* Serializes a modifier list node to binary format.
|
|
2667
|
+
*
|
|
2668
|
+
* @param node Node to serialize.
|
|
2669
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2670
|
+
*/
|
|
2671
|
+
static serialize(node: ModifierList, buffer: OutputByteBuffer): void;
|
|
2672
|
+
/**
|
|
2673
|
+
* Deserializes a modifier list node from binary format.
|
|
2674
|
+
*
|
|
2675
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2676
|
+
* @param node Destination node.
|
|
2677
|
+
*/
|
|
2678
|
+
static deserialize(buffer: InputByteBuffer, node: ModifierList): void;
|
|
1824
2679
|
}
|
|
1825
2680
|
|
|
1826
2681
|
/**
|
|
@@ -1829,17 +2684,18 @@ declare class ModifierListParser {
|
|
|
1829
2684
|
* @example
|
|
1830
2685
|
* `match-case`, `~third-party`, `domain=example.com|~example.org`
|
|
1831
2686
|
*/
|
|
1832
|
-
declare class ModifierParser {
|
|
2687
|
+
declare class ModifierParser extends ParserBase {
|
|
1833
2688
|
/**
|
|
1834
2689
|
* Parses a modifier.
|
|
1835
2690
|
*
|
|
1836
|
-
* @param raw Raw
|
|
1837
|
-
* @param
|
|
2691
|
+
* @param raw Raw input to parse.
|
|
2692
|
+
* @param options Global parser options.
|
|
2693
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1838
2694
|
*
|
|
1839
2695
|
* @returns Parsed modifier
|
|
1840
2696
|
* @throws An error if modifier name or value is empty.
|
|
1841
2697
|
*/
|
|
1842
|
-
static parse(raw: string,
|
|
2698
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): Modifier;
|
|
1843
2699
|
/**
|
|
1844
2700
|
* Generates a string from a modifier (serializes it).
|
|
1845
2701
|
*
|
|
@@ -1847,6 +2703,20 @@ declare class ModifierParser {
|
|
|
1847
2703
|
* @returns String representation of the modifier
|
|
1848
2704
|
*/
|
|
1849
2705
|
static generate(modifier: Modifier): string;
|
|
2706
|
+
/**
|
|
2707
|
+
* Serializes a modifier node to binary format.
|
|
2708
|
+
*
|
|
2709
|
+
* @param node Node to serialize.
|
|
2710
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2711
|
+
*/
|
|
2712
|
+
static serialize(node: Modifier, buffer: OutputByteBuffer): void;
|
|
2713
|
+
/**
|
|
2714
|
+
* Deserializes a modifier node from binary format.
|
|
2715
|
+
*
|
|
2716
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2717
|
+
* @param node Destination node.
|
|
2718
|
+
*/
|
|
2719
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<Modifier>): void;
|
|
1850
2720
|
}
|
|
1851
2721
|
|
|
1852
2722
|
/**
|
|
@@ -1858,15 +2728,18 @@ declare class ModifierParser {
|
|
|
1858
2728
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#basic-rules}
|
|
1859
2729
|
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#basic}
|
|
1860
2730
|
*/
|
|
1861
|
-
declare class NetworkRuleParser {
|
|
2731
|
+
declare class NetworkRuleParser extends ParserBase {
|
|
1862
2732
|
/**
|
|
1863
2733
|
* Parses a network rule (also known as basic rule).
|
|
1864
2734
|
*
|
|
1865
|
-
* @param raw Raw
|
|
1866
|
-
* @param
|
|
2735
|
+
* @param raw Raw input to parse.
|
|
2736
|
+
* @param options Global parser options.
|
|
2737
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1867
2738
|
* @returns Network rule AST
|
|
2739
|
+
*
|
|
2740
|
+
* @throws If the rule is syntactically incorrect.
|
|
1868
2741
|
*/
|
|
1869
|
-
static parse(raw: string,
|
|
2742
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): NetworkRule;
|
|
1870
2743
|
/**
|
|
1871
2744
|
* Finds the index of the separator character in a network rule.
|
|
1872
2745
|
*
|
|
@@ -1877,10 +2750,24 @@ declare class NetworkRuleParser {
|
|
|
1877
2750
|
/**
|
|
1878
2751
|
* Converts a network rule (basic rule) AST to a string.
|
|
1879
2752
|
*
|
|
1880
|
-
* @param
|
|
2753
|
+
* @param node Network rule node
|
|
1881
2754
|
* @returns Raw string
|
|
1882
2755
|
*/
|
|
1883
|
-
static generate(
|
|
2756
|
+
static generate(node: NetworkRule): string;
|
|
2757
|
+
/**
|
|
2758
|
+
* Serializes a network rule node to binary format.
|
|
2759
|
+
*
|
|
2760
|
+
* @param node Node to serialize.
|
|
2761
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2762
|
+
*/
|
|
2763
|
+
static serialize(node: NetworkRule, buffer: OutputByteBuffer): void;
|
|
2764
|
+
/**
|
|
2765
|
+
* Deserializes a modifier node from binary format.
|
|
2766
|
+
*
|
|
2767
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2768
|
+
* @param node Destination node.
|
|
2769
|
+
*/
|
|
2770
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<NetworkRule>): void;
|
|
1884
2771
|
}
|
|
1885
2772
|
|
|
1886
2773
|
/**
|
|
@@ -1898,16 +2785,17 @@ declare class NotImplementedError extends Error {
|
|
|
1898
2785
|
constructor(message?: string | undefined);
|
|
1899
2786
|
}
|
|
1900
2787
|
|
|
1901
|
-
declare class ParameterListParser {
|
|
2788
|
+
declare class ParameterListParser extends ParserBase {
|
|
1902
2789
|
/**
|
|
1903
2790
|
* Parses a raw parameter list.
|
|
1904
2791
|
*
|
|
1905
|
-
* @param raw Raw
|
|
2792
|
+
* @param raw Raw input to parse.
|
|
2793
|
+
* @param options Global parser options.
|
|
2794
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1906
2795
|
* @param separator Separator character (default: comma)
|
|
1907
|
-
* @param loc Base location
|
|
1908
2796
|
* @returns Parameter list AST
|
|
1909
2797
|
*/
|
|
1910
|
-
static parse(raw: string,
|
|
2798
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number, separator?: string): ParameterList;
|
|
1911
2799
|
/**
|
|
1912
2800
|
* Converts a parameter list AST to a string.
|
|
1913
2801
|
*
|
|
@@ -1916,14 +2804,94 @@ declare class ParameterListParser {
|
|
|
1916
2804
|
* @returns String representation of the parameter list
|
|
1917
2805
|
*/
|
|
1918
2806
|
static generate(params: ParameterList, separator?: string): string;
|
|
2807
|
+
/**
|
|
2808
|
+
* Serializes a parameter list node to binary format.
|
|
2809
|
+
*
|
|
2810
|
+
* @param node Node to serialize.
|
|
2811
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2812
|
+
* @param frequentValuesMap Optional map of frequent values.
|
|
2813
|
+
* @param toLower Whether to lowercase the value before the frequent value match (defaults to `false`).
|
|
2814
|
+
*/
|
|
2815
|
+
static serialize(node: ParameterList, buffer: OutputByteBuffer, frequentValuesMap?: Map<string, number>, toLower?: boolean): void;
|
|
2816
|
+
/**
|
|
2817
|
+
* Deserializes a parameter list node from binary format.
|
|
2818
|
+
*
|
|
2819
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2820
|
+
* @param node Destination node.
|
|
2821
|
+
* @param frequentValuesMap Optional map of frequent values.
|
|
2822
|
+
* @throws If the binary data is malformed.
|
|
2823
|
+
*/
|
|
2824
|
+
static deserialize(buffer: InputByteBuffer, node: ParameterList, frequentValuesMap?: Map<number, string>): void;
|
|
1919
2825
|
}
|
|
1920
2826
|
|
|
1921
2827
|
/**
|
|
1922
|
-
*
|
|
2828
|
+
* `HostRuleParser` is responsible for parsing hosts-like rules.
|
|
1923
2829
|
*
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
2830
|
+
* HostRule is a structure for simple host-level rules (i.e. /etc/hosts syntax).
|
|
2831
|
+
* It also supports "just domain" syntax. In this case, the IP will be set to 0.0.0.0.
|
|
2832
|
+
*
|
|
2833
|
+
* Rules syntax looks like this:
|
|
2834
|
+
* ```text
|
|
2835
|
+
* IP_address canonical_hostname [aliases...]
|
|
2836
|
+
* ```
|
|
2837
|
+
*
|
|
2838
|
+
* @example
|
|
2839
|
+
* `192.168.1.13 bar.mydomain.org bar` -- ipv4
|
|
2840
|
+
* `ff02::1 ip6-allnodes` -- ipv6
|
|
2841
|
+
* `::1 localhost ip6-localhost ip6-loopback` -- ipv6 aliases
|
|
2842
|
+
* `example.org` -- "just domain" syntax
|
|
2843
|
+
* @see {@link http://man7.org/linux/man-pages/man5/hosts.5.html}
|
|
1926
2844
|
*/
|
|
2845
|
+
declare class HostRuleParser extends ParserBase {
|
|
2846
|
+
static readonly NULL_IP = "0.0.0.0";
|
|
2847
|
+
static readonly COMMENT_MARKER = "#";
|
|
2848
|
+
/**
|
|
2849
|
+
* Parses an etc/hosts-like rule.
|
|
2850
|
+
*
|
|
2851
|
+
* @param raw Raw input to parse.
|
|
2852
|
+
* @param options Global parser options.
|
|
2853
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
2854
|
+
* @returns Host rule node.
|
|
2855
|
+
*
|
|
2856
|
+
* @throws If the input contains invalid data.
|
|
2857
|
+
*/
|
|
2858
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): HostRule;
|
|
2859
|
+
/**
|
|
2860
|
+
* Converts a host rule node to a raw string.
|
|
2861
|
+
*
|
|
2862
|
+
* @param node Host rule node.
|
|
2863
|
+
* @returns Raw string.
|
|
2864
|
+
*/
|
|
2865
|
+
static generate(node: HostRule): string;
|
|
2866
|
+
/**
|
|
2867
|
+
* Serializes a hostname list node to binary format.
|
|
2868
|
+
*
|
|
2869
|
+
* @param node Node to serialize.
|
|
2870
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2871
|
+
*/
|
|
2872
|
+
private static serializeHostnameList;
|
|
2873
|
+
/**
|
|
2874
|
+
* Deserializes a hostname list node from binary format.
|
|
2875
|
+
*
|
|
2876
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2877
|
+
* @param node Destination node.
|
|
2878
|
+
*/
|
|
2879
|
+
private static deserializeHostnameList;
|
|
2880
|
+
/**
|
|
2881
|
+
* Serializes a host rule node to binary format.
|
|
2882
|
+
*
|
|
2883
|
+
* @param node Node to serialize.
|
|
2884
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2885
|
+
*/
|
|
2886
|
+
static serialize(node: HostRule, buffer: OutputByteBuffer): void;
|
|
2887
|
+
/**
|
|
2888
|
+
* Deserializes a modifier node from binary format.
|
|
2889
|
+
*
|
|
2890
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2891
|
+
* @param node Destination node.
|
|
2892
|
+
*/
|
|
2893
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<HostRule>): void;
|
|
2894
|
+
}
|
|
1927
2895
|
|
|
1928
2896
|
/**
|
|
1929
2897
|
* `PreProcessorParser` is responsible for parsing preprocessor rules.
|
|
@@ -1941,7 +2909,7 @@ declare class ParameterListParser {
|
|
|
1941
2909
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
1942
2910
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
1943
2911
|
*/
|
|
1944
|
-
declare class PreProcessorCommentRuleParser {
|
|
2912
|
+
declare class PreProcessorCommentRuleParser extends ParserBase {
|
|
1945
2913
|
/**
|
|
1946
2914
|
* Determines whether the rule is a pre-processor rule.
|
|
1947
2915
|
*
|
|
@@ -1952,19 +2920,35 @@ declare class PreProcessorCommentRuleParser {
|
|
|
1952
2920
|
/**
|
|
1953
2921
|
* Parses a raw rule as a pre-processor comment.
|
|
1954
2922
|
*
|
|
1955
|
-
* @param raw Raw
|
|
1956
|
-
* @param
|
|
2923
|
+
* @param raw Raw input to parse.
|
|
2924
|
+
* @param options Global parser options.
|
|
2925
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
1957
2926
|
* @returns
|
|
1958
2927
|
* Pre-processor comment AST or null (if the raw rule cannot be parsed as a pre-processor comment)
|
|
1959
2928
|
*/
|
|
1960
|
-
static parse(raw: string,
|
|
2929
|
+
static parse(raw: string, options?: ParserOptions, baseOffset?: number): PreProcessorCommentRule | null;
|
|
1961
2930
|
/**
|
|
1962
|
-
* Converts a pre-processor comment
|
|
2931
|
+
* Converts a pre-processor comment node to a string.
|
|
1963
2932
|
*
|
|
1964
|
-
* @param
|
|
2933
|
+
* @param node Pre-processor comment node
|
|
1965
2934
|
* @returns Raw string
|
|
1966
2935
|
*/
|
|
1967
|
-
static generate(
|
|
2936
|
+
static generate(node: PreProcessorCommentRule): string;
|
|
2937
|
+
/**
|
|
2938
|
+
* Serializes a pre-processor comment node to binary format.
|
|
2939
|
+
*
|
|
2940
|
+
* @param node Node to serialize.
|
|
2941
|
+
* @param buffer ByteBuffer for writing binary data.
|
|
2942
|
+
*/
|
|
2943
|
+
static serialize(node: PreProcessorCommentRule, buffer: OutputByteBuffer): void;
|
|
2944
|
+
/**
|
|
2945
|
+
* Deserializes a pre-processor comment node from binary format.
|
|
2946
|
+
*
|
|
2947
|
+
* @param buffer ByteBuffer for reading binary data.
|
|
2948
|
+
* @param node Destination node.
|
|
2949
|
+
* @throws If the binary data is malformed.
|
|
2950
|
+
*/
|
|
2951
|
+
static deserialize(buffer: InputByteBuffer, node: Partial<PreProcessorCommentRule>): void;
|
|
1968
2952
|
}
|
|
1969
2953
|
|
|
1970
2954
|
/**
|
|
@@ -1982,6 +2966,30 @@ declare class RuleConversionError extends Error {
|
|
|
1982
2966
|
constructor(message: string);
|
|
1983
2967
|
}
|
|
1984
2968
|
|
|
2969
|
+
/**
|
|
2970
|
+
* @file Customized error for binary schema mismatch.
|
|
2971
|
+
*/
|
|
2972
|
+
/**
|
|
2973
|
+
* Customized error for binary schema mismatch.
|
|
2974
|
+
*/
|
|
2975
|
+
declare class BinarySchemaMismatchError extends Error {
|
|
2976
|
+
/**
|
|
2977
|
+
* Expected schema version.
|
|
2978
|
+
*/
|
|
2979
|
+
expectedVersion: number;
|
|
2980
|
+
/**
|
|
2981
|
+
* Actual schema version.
|
|
2982
|
+
*/
|
|
2983
|
+
actualVersion: number;
|
|
2984
|
+
/**
|
|
2985
|
+
* Constructs a new `BinarySchemaMismatchError` instance.
|
|
2986
|
+
*
|
|
2987
|
+
* @param expectedVersion Expected schema version.
|
|
2988
|
+
* @param actualVersion Actual schema version.
|
|
2989
|
+
*/
|
|
2990
|
+
constructor(expectedVersion: number, actualVersion: number);
|
|
2991
|
+
}
|
|
2992
|
+
|
|
1985
2993
|
/**
|
|
1986
2994
|
* Result of modifier validation:
|
|
1987
2995
|
* - `{ valid: true }` for valid and _fully supported_ modifier;
|
|
@@ -2003,17 +3011,6 @@ type ValidationResult = {
|
|
|
2003
3011
|
* Modifier validator class.
|
|
2004
3012
|
*/
|
|
2005
3013
|
declare class ModifierValidator {
|
|
2006
|
-
/**
|
|
2007
|
-
* Map of all modifiers data parsed from yaml files.
|
|
2008
|
-
*/
|
|
2009
|
-
private modifiersData;
|
|
2010
|
-
/**
|
|
2011
|
-
* List of all modifier names for any adblocker.
|
|
2012
|
-
*
|
|
2013
|
-
* Please note that **deprecated** modifiers are **included** as well.
|
|
2014
|
-
*/
|
|
2015
|
-
private allModifierNames;
|
|
2016
|
-
constructor();
|
|
2017
3014
|
/**
|
|
2018
3015
|
* Simply checks whether the modifier exists in any adblocker.
|
|
2019
3016
|
*
|
|
@@ -2039,30 +3036,6 @@ declare class ModifierValidator {
|
|
|
2039
3036
|
* @returns Result of modifier validation.
|
|
2040
3037
|
*/
|
|
2041
3038
|
validate: (syntax: AdblockSyntax, rawModifier: Modifier, isException?: boolean) => ValidationResult;
|
|
2042
|
-
/**
|
|
2043
|
-
* Returns AdGuard documentation URL for given modifier.
|
|
2044
|
-
*
|
|
2045
|
-
* @param modifier Parsed modifier AST node.
|
|
2046
|
-
*
|
|
2047
|
-
* @returns AdGuard documentation URL or `null` if not found.
|
|
2048
|
-
*/
|
|
2049
|
-
getAdgDocumentationLink: (modifier: Modifier) => string | null;
|
|
2050
|
-
/**
|
|
2051
|
-
* Returns Ublock Origin documentation URL for given modifier.
|
|
2052
|
-
*
|
|
2053
|
-
* @param modifier Parsed modifier AST node.
|
|
2054
|
-
*
|
|
2055
|
-
* @returns Ublock Origin documentation URL or `null` if not found.
|
|
2056
|
-
*/
|
|
2057
|
-
getUboDocumentationLink: (modifier: Modifier) => string | null;
|
|
2058
|
-
/**
|
|
2059
|
-
* Returns AdBlock Plus documentation URL for given modifier.
|
|
2060
|
-
*
|
|
2061
|
-
* @param modifier Parsed modifier AST node.
|
|
2062
|
-
*
|
|
2063
|
-
* @returns AdBlock Plus documentation URL or `null` if not found.
|
|
2064
|
-
*/
|
|
2065
|
-
getAbpDocumentationLink: (modifier: Modifier) => string | null;
|
|
2066
3039
|
}
|
|
2067
3040
|
declare const modifierValidator: ModifierValidator;
|
|
2068
3041
|
|
|
@@ -2292,6 +3265,16 @@ declare class RuleConverter extends RuleConverterBase {
|
|
|
2292
3265
|
static convertToAdg(rule: AnyRule): NodeConversionResult<AnyRule>;
|
|
2293
3266
|
}
|
|
2294
3267
|
|
|
3268
|
+
/**
|
|
3269
|
+
* @file Binary schema version.
|
|
3270
|
+
*/
|
|
3271
|
+
/**
|
|
3272
|
+
* Binary schema version.
|
|
3273
|
+
* This version number is used to ensure that the binary format is compatible with the current library version.
|
|
3274
|
+
* We increment this number if the serialized format changes in a way that is not backwards-compatible.
|
|
3275
|
+
*/
|
|
3276
|
+
declare const BINARY_SCHEMA_VERSION = 1;
|
|
3277
|
+
|
|
2295
3278
|
/**
|
|
2296
3279
|
* @file Cosmetic rule separator finder and categorizer
|
|
2297
3280
|
*/
|
|
@@ -2312,371 +3295,30 @@ interface CosmeticRuleSeparatorFinderResult {
|
|
|
2312
3295
|
}
|
|
2313
3296
|
/**
|
|
2314
3297
|
* Utility class for cosmetic rule separators.
|
|
2315
|
-
*/
|
|
2316
|
-
declare class CosmeticRuleSeparatorUtils {
|
|
2317
|
-
/**
|
|
2318
|
-
* Checks whether the specified separator is an exception.
|
|
2319
|
-
*
|
|
2320
|
-
* @param separator Separator to check
|
|
2321
|
-
* @returns `true` if the separator is an exception, `false` otherwise
|
|
2322
|
-
*/
|
|
2323
|
-
static isException(separator: CosmeticRuleSeparator): boolean;
|
|
2324
|
-
/**
|
|
2325
|
-
* Checks whether the specified separator is marks an Extended CSS cosmetic rule.
|
|
2326
|
-
*
|
|
2327
|
-
* @param separator Separator to check
|
|
2328
|
-
* @returns `true` if the separator is marks an Extended CSS cosmetic rule, `false` otherwise
|
|
2329
|
-
*/
|
|
2330
|
-
static isExtendedCssMarker(separator: CosmeticRuleSeparator): boolean;
|
|
2331
|
-
/**
|
|
2332
|
-
* Looks for the cosmetic rule separator in the rule. This is a simplified version that
|
|
2333
|
-
* masks the recursive function.
|
|
2334
|
-
*
|
|
2335
|
-
* @param rule Raw rule
|
|
2336
|
-
* @returns Separator result or null if no separator was found
|
|
2337
|
-
*/
|
|
2338
|
-
static find(rule: string): CosmeticRuleSeparatorFinderResult | null;
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
/**
|
|
2342
|
-
* @file Helper file for CSSTree to provide better compatibility with TypeScript.
|
|
2343
|
-
* @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/62536}
|
|
2344
|
-
*/
|
|
2345
|
-
/**
|
|
2346
|
-
* CSSTree node types.
|
|
2347
|
-
*
|
|
2348
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/ast.md#node-types}
|
|
2349
|
-
*/
|
|
2350
|
-
declare const enum CssTreeNodeType {
|
|
2351
|
-
AnPlusB = "AnPlusB",
|
|
2352
|
-
Atrule = "Atrule",
|
|
2353
|
-
AtrulePrelude = "AtrulePrelude",
|
|
2354
|
-
AttributeSelector = "AttributeSelector",
|
|
2355
|
-
Block = "Block",
|
|
2356
|
-
Brackets = "Brackets",
|
|
2357
|
-
CDC = "CDC",
|
|
2358
|
-
CDO = "CDO",
|
|
2359
|
-
ClassSelector = "ClassSelector",
|
|
2360
|
-
Combinator = "Combinator",
|
|
2361
|
-
Comment = "Comment",
|
|
2362
|
-
Declaration = "Declaration",
|
|
2363
|
-
DeclarationList = "DeclarationList",
|
|
2364
|
-
Dimension = "Dimension",
|
|
2365
|
-
Function = "Function",
|
|
2366
|
-
Hash = "Hash",
|
|
2367
|
-
Identifier = "Identifier",
|
|
2368
|
-
IdSelector = "IdSelector",
|
|
2369
|
-
MediaFeature = "MediaFeature",
|
|
2370
|
-
MediaQuery = "MediaQuery",
|
|
2371
|
-
MediaQueryList = "MediaQueryList",
|
|
2372
|
-
NestingSelector = "NestingSelector",
|
|
2373
|
-
Nth = "Nth",
|
|
2374
|
-
Number = "Number",
|
|
2375
|
-
Operator = "Operator",
|
|
2376
|
-
Parentheses = "Parentheses",
|
|
2377
|
-
Percentage = "Percentage",
|
|
2378
|
-
PseudoClassSelector = "PseudoClassSelector",
|
|
2379
|
-
PseudoElementSelector = "PseudoElementSelector",
|
|
2380
|
-
Ratio = "Ratio",
|
|
2381
|
-
Raw = "Raw",
|
|
2382
|
-
Rule = "Rule",
|
|
2383
|
-
Selector = "Selector",
|
|
2384
|
-
SelectorList = "SelectorList",
|
|
2385
|
-
String = "String",
|
|
2386
|
-
StyleSheet = "StyleSheet",
|
|
2387
|
-
TypeSelector = "TypeSelector",
|
|
2388
|
-
UnicodeRange = "UnicodeRange",
|
|
2389
|
-
Url = "Url",
|
|
2390
|
-
Value = "Value",
|
|
2391
|
-
WhiteSpace = "WhiteSpace"
|
|
2392
|
-
}
|
|
2393
|
-
/**
|
|
2394
|
-
* Parser context for CSSTree.
|
|
2395
|
-
*
|
|
2396
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/parsing.md#context}
|
|
2397
|
-
*/
|
|
2398
|
-
declare const enum CssTreeParserContext {
|
|
2399
|
-
/**
|
|
2400
|
-
* Regular stylesheet, should be suitable in most cases (default)
|
|
2401
|
-
*/
|
|
2402
|
-
stylesheet = "stylesheet",
|
|
2403
|
-
/**
|
|
2404
|
-
* at-rule (e.g. `@media screen`, `print { ... }`)
|
|
2405
|
-
*/
|
|
2406
|
-
atrule = "atrule",
|
|
2407
|
-
/**
|
|
2408
|
-
* at-rule prelude (screen, print for example above)
|
|
2409
|
-
*/
|
|
2410
|
-
atrulePrelude = "atrulePrelude",
|
|
2411
|
-
/**
|
|
2412
|
-
* used to parse comma separated media query list
|
|
2413
|
-
*/
|
|
2414
|
-
mediaQueryList = "mediaQueryList",
|
|
2415
|
-
/**
|
|
2416
|
-
* used to parse media query
|
|
2417
|
-
*/
|
|
2418
|
-
mediaQuery = "mediaQuery",
|
|
2419
|
-
/**
|
|
2420
|
-
* rule (e.g. `.foo`, `.bar:hover { color: red; border: 1px solid black; }`)
|
|
2421
|
-
*/
|
|
2422
|
-
rule = "rule",
|
|
2423
|
-
/**
|
|
2424
|
-
* selector group (`.foo`, `.bar:hover` for rule example)
|
|
2425
|
-
*/
|
|
2426
|
-
selectorList = "selectorList",
|
|
2427
|
-
/**
|
|
2428
|
-
* selector (`.foo` or `.bar:hover` for rule example)
|
|
2429
|
-
*/
|
|
2430
|
-
selector = "selector",
|
|
2431
|
-
/**
|
|
2432
|
-
* block with curly braces ({ color: red; border: 1px solid black; } for rule example)
|
|
2433
|
-
*/
|
|
2434
|
-
block = "block",
|
|
2435
|
-
/**
|
|
2436
|
-
* block content w/o curly braces (`color: red; border: 1px solid black;` for rule example),
|
|
2437
|
-
* useful for parsing HTML style attribute value
|
|
2438
|
-
*/
|
|
2439
|
-
declarationList = "declarationList",
|
|
2440
|
-
/**
|
|
2441
|
-
* declaration (`color: red` or `border: 1px solid black` for rule example)
|
|
2442
|
-
*/
|
|
2443
|
-
declaration = "declaration",
|
|
2444
|
-
/**
|
|
2445
|
-
* declaration value (`red` or `1px solid black` for rule example)
|
|
2446
|
-
*/
|
|
2447
|
-
value = "value"
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
/**
|
|
2451
|
-
* Additional / helper functions for CSSTree.
|
|
2452
|
-
*/
|
|
2453
|
-
declare class CssTree {
|
|
2454
|
-
/**
|
|
2455
|
-
* Shifts location of the CSSTree node. Temporary workaround for CSSTree issue:
|
|
2456
|
-
* https://github.com/csstree/csstree/issues/251
|
|
2457
|
-
*
|
|
2458
|
-
* @param root Root CSSTree node
|
|
2459
|
-
* @param loc Location to shift
|
|
2460
|
-
* @returns Root CSSTree node with shifted location
|
|
2461
|
-
*/
|
|
2462
|
-
static shiftNodePosition(root: CssNode, loc?: Location): CssNode;
|
|
2463
|
-
/**
|
|
2464
|
-
* Helper function for parsing CSS parts.
|
|
2465
|
-
*
|
|
2466
|
-
* @param raw Raw CSS input
|
|
2467
|
-
* @param context CSSTree context for parsing
|
|
2468
|
-
* @param tolerant If `true`, then the parser will not throw an error on parsing fallbacks. Default is `false`
|
|
2469
|
-
* @param loc Base location for the parsed node
|
|
2470
|
-
* @returns CSSTree node (AST)
|
|
2471
|
-
*/
|
|
2472
|
-
static parse(raw: string, context: CssTreeParserContext, tolerant?: boolean, loc?: Location): CssNode;
|
|
2473
|
-
/**
|
|
2474
|
-
* Helper function for parsing CSS parts.
|
|
2475
|
-
*
|
|
2476
|
-
* @param raw Raw CSS input
|
|
2477
|
-
* @param context CSSTree context
|
|
2478
|
-
* @param tolerant If `true`, then the parser will not throw an error on parsing fallbacks. Default is `false`
|
|
2479
|
-
* @param loc Base location for the parsed node
|
|
2480
|
-
* @returns CSSTree node (AST)
|
|
2481
|
-
*/
|
|
2482
|
-
static parsePlain(raw: string, context: CssTreeParserContext, tolerant?: boolean, loc?: Location): CssNodePlain;
|
|
2483
|
-
/**
|
|
2484
|
-
* Checks if the CSSTree node is an ExtendedCSS node.
|
|
2485
|
-
*
|
|
2486
|
-
* @param node Node to check
|
|
2487
|
-
* @param pseudoClasses List of the names of the pseudo classes to check
|
|
2488
|
-
* @param attributeSelectors List of the names of the attribute selectors to check
|
|
2489
|
-
* @returns `true` if the node is an ExtendedCSS node, otherwise `false`
|
|
2490
|
-
*/
|
|
2491
|
-
static isExtendedCssNode(node: CssNode | CssNodePlain, pseudoClasses: Set<string>, attributeSelectors: Set<string>): boolean;
|
|
2492
|
-
/**
|
|
2493
|
-
* Walks through the CSSTree node and returns all ExtendedCSS nodes.
|
|
2494
|
-
*
|
|
2495
|
-
* @param selectorList Selector list (can be a string or a CSSTree node)
|
|
2496
|
-
* @param pseudoClasses List of the names of the pseudo classes to check
|
|
2497
|
-
* @param attributeSelectors List of the names of the attribute selectors to check
|
|
2498
|
-
* @returns Extended CSS nodes (pseudos and attributes)
|
|
2499
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/ast.md#selectorlist}
|
|
2500
|
-
*/
|
|
2501
|
-
static getSelectorExtendedCssNodes(selectorList: string | SelectorList | SelectorListPlain, pseudoClasses?: Set<string>, attributeSelectors?: Set<string>): CssNode[];
|
|
2502
|
-
/**
|
|
2503
|
-
* Checks if the selector contains any ExtendedCSS nodes. It is a faster alternative to
|
|
2504
|
-
* `getSelectorExtendedCssNodes` if you only need to know if the selector contains any ExtendedCSS nodes,
|
|
2505
|
-
* because it stops the search on the first ExtendedCSS node instead of going through the whole selector
|
|
2506
|
-
* and collecting all ExtendedCSS nodes.
|
|
2507
|
-
*
|
|
2508
|
-
* @param selectorList Selector list (can be a string or a CSSTree node)
|
|
2509
|
-
* @param pseudoClasses List of the names of the pseudo classes to check
|
|
2510
|
-
* @param attributeSelectors List of the names of the attribute selectors to check
|
|
2511
|
-
* @returns `true` if the selector contains any ExtendedCSS nodes
|
|
2512
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/ast.md#selectorlist}
|
|
2513
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/traversal.md#findast-fn}
|
|
2514
|
-
*/
|
|
2515
|
-
static hasAnySelectorExtendedCssNode(selectorList: string | SelectorList | SelectorListPlain, pseudoClasses?: Set<string>, attributeSelectors?: Set<string>): boolean;
|
|
2516
|
-
/**
|
|
2517
|
-
* Checks if the node is a forbidden function (unsafe resource loading). Typically it is used to check
|
|
2518
|
-
* if the node is a `url()` function, which is a security risk when using filter lists from untrusted
|
|
2519
|
-
* sources.
|
|
2520
|
-
*
|
|
2521
|
-
* @param node Node to check
|
|
2522
|
-
* @param forbiddenFunctions Set of the names of the functions to check
|
|
2523
|
-
* @returns `true` if the node is a forbidden function
|
|
2524
|
-
*/
|
|
2525
|
-
static isForbiddenFunction(node: CssNode | CssNodePlain, forbiddenFunctions?: Set<string>): boolean;
|
|
2526
|
-
/**
|
|
2527
|
-
* Gets the list of the forbidden function nodes in the declaration block. Typically it is used to get
|
|
2528
|
-
* the list of the functions that can be used to load external resources, which is a security risk
|
|
2529
|
-
* when using filter lists from untrusted sources.
|
|
2530
|
-
*
|
|
2531
|
-
* @param declarationList Declaration list to check (can be a string or a CSSTree node)
|
|
2532
|
-
* @param forbiddenFunctions Set of the names of the functions to check
|
|
2533
|
-
* @returns List of the forbidden function nodes in the declaration block (can be empty)
|
|
2534
|
-
*/
|
|
2535
|
-
static getForbiddenFunctionNodes(declarationList: string | DeclarationList | DeclarationListPlain, forbiddenFunctions?: Set<string>): CssNode[];
|
|
2536
|
-
/**
|
|
2537
|
-
* Checks if the declaration block contains any forbidden functions. Typically it is used to check
|
|
2538
|
-
* if the declaration block contains any functions that can be used to load external resources,
|
|
2539
|
-
* which is a security risk when using filter lists from untrusted sources.
|
|
2540
|
-
*
|
|
2541
|
-
* @param declarationList Declaration list to check (can be a string or a CSSTree node)
|
|
2542
|
-
* @param forbiddenFunctions Set of the names of the functions to check
|
|
2543
|
-
* @returns `true` if the declaration block contains any forbidden functions
|
|
2544
|
-
* @throws If you pass a string, but it is not a valid CSS
|
|
2545
|
-
* @throws If you pass an invalid CSSTree node / AST
|
|
2546
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/ast.md#declarationlist}
|
|
2547
|
-
* @see {@link https://github.com/AdguardTeam/AdguardBrowserExtension/issues/1196}
|
|
2548
|
-
* @see {@link https://github.com/AdguardTeam/AdguardBrowserExtension/issues/1920}
|
|
2549
|
-
*/
|
|
2550
|
-
static hasAnyForbiddenFunction(declarationList: string | DeclarationList | DeclarationListPlain, forbiddenFunctions?: Set<string>): boolean;
|
|
2551
|
-
/**
|
|
2552
|
-
* Generates string representation of the media query list.
|
|
2553
|
-
*
|
|
2554
|
-
* @param ast Media query list AST
|
|
2555
|
-
* @returns String representation of the media query list
|
|
2556
|
-
*/
|
|
2557
|
-
static generateMediaQueryList(ast: MediaQueryList): string;
|
|
2558
|
-
/**
|
|
2559
|
-
* Generates string representation of the media query.
|
|
2560
|
-
*
|
|
2561
|
-
* @param ast Media query AST
|
|
2562
|
-
* @returns String representation of the media query
|
|
2563
|
-
*/
|
|
2564
|
-
static generateMediaQuery(ast: MediaQuery): string;
|
|
2565
|
-
/**
|
|
2566
|
-
* Generates string representation of the selector list.
|
|
2567
|
-
*
|
|
2568
|
-
* @param ast SelectorList AST
|
|
2569
|
-
* @returns String representation of the selector list
|
|
2570
|
-
*/
|
|
2571
|
-
static generateSelectorList(ast: SelectorList): string;
|
|
2572
|
-
/**
|
|
2573
|
-
* Selector generation based on CSSTree's AST. This is necessary because CSSTree
|
|
2574
|
-
* only adds spaces in some edge cases.
|
|
2575
|
-
*
|
|
2576
|
-
* @param ast CSS Tree AST
|
|
2577
|
-
* @returns CSS selector as string
|
|
2578
|
-
*/
|
|
2579
|
-
static generateSelector(ast: Selector): string;
|
|
2580
|
-
/**
|
|
2581
|
-
* Generates string representation of the selector list.
|
|
2582
|
-
*
|
|
2583
|
-
* @param ast SelectorList AST
|
|
2584
|
-
* @returns String representation of the selector list
|
|
2585
|
-
*/
|
|
2586
|
-
static generateSelectorListPlain(ast: SelectorListPlain): string;
|
|
2587
|
-
/**
|
|
2588
|
-
* Selector generation based on CSSTree's AST. This is necessary because CSSTree
|
|
2589
|
-
* only adds spaces in some edge cases.
|
|
2590
|
-
*
|
|
2591
|
-
* @param ast CSS Tree AST
|
|
2592
|
-
* @returns CSS selector as string
|
|
2593
|
-
*/
|
|
2594
|
-
static generateSelectorPlain(ast: SelectorPlain): string;
|
|
2595
|
-
/**
|
|
2596
|
-
* Block generation based on CSSTree's AST. This is necessary because CSSTree only adds spaces in some edge cases.
|
|
2597
|
-
*
|
|
2598
|
-
* @param ast CSS Tree AST
|
|
2599
|
-
* @returns CSS selector as string
|
|
2600
|
-
*/
|
|
2601
|
-
static generateDeclarationList(ast: DeclarationList): string;
|
|
2602
|
-
/**
|
|
2603
|
-
* Helper method to assert that the attribute selector has a value
|
|
2604
|
-
*
|
|
2605
|
-
* @param node Attribute selector node
|
|
2606
|
-
*/
|
|
2607
|
-
static assertAttributeSelectorHasStringValue(node: AttributeSelector): asserts node is AttributeSelector & {
|
|
2608
|
-
value: {
|
|
2609
|
-
type: 'String';
|
|
2610
|
-
};
|
|
2611
|
-
};
|
|
2612
|
-
/**
|
|
2613
|
-
* Helper method to assert that the pseudo-class selector has at least one argument
|
|
2614
|
-
*
|
|
2615
|
-
* @param node Pseudo-class selector node
|
|
2616
|
-
*/
|
|
2617
|
-
static assertPseudoClassHasAnyArgument(node: PseudoClassSelectorPlain): asserts node is PseudoClassSelectorPlain & {
|
|
2618
|
-
children: CssNodePlain[];
|
|
2619
|
-
};
|
|
2620
|
-
/**
|
|
2621
|
-
* Helper method to parse an attribute selector value as a number
|
|
2622
|
-
*
|
|
2623
|
-
* @param node Attribute selector node
|
|
2624
|
-
* @returns Parsed attribute selector value as a number
|
|
2625
|
-
* @throws If the attribute selector hasn't a string value or the string value is can't be parsed as a number
|
|
2626
|
-
*/
|
|
2627
|
-
static parseAttributeSelectorValueAsNumber(node: AttributeSelector): number;
|
|
2628
|
-
/**
|
|
2629
|
-
* Helper method to parse a pseudo-class argument as a number
|
|
2630
|
-
*
|
|
2631
|
-
* @param node Pseudo-class selector node to parse
|
|
2632
|
-
* @returns Parsed pseudo-class argument as a number
|
|
2633
|
-
*/
|
|
2634
|
-
static parsePseudoClassArgumentAsNumber(node: PseudoClassSelectorPlain): number;
|
|
2635
|
-
/**
|
|
2636
|
-
* Helper method to create an attribute selector node
|
|
2637
|
-
*
|
|
2638
|
-
* @param name Name of the attribute
|
|
2639
|
-
* @param value Value of the attribute
|
|
2640
|
-
* @param matcher Matcher of the attribute
|
|
2641
|
-
* @param flags Flags of the attribute
|
|
2642
|
-
* @returns Attribute selector node
|
|
2643
|
-
* @see {@link https://github.com/csstree/csstree/blob/master/docs/ast.md#attributeselector}
|
|
2644
|
-
*/
|
|
2645
|
-
static createAttributeSelectorNode(name: string, value: string, matcher?: string, flags?: string | null): AttributeSelector;
|
|
2646
|
-
/**
|
|
2647
|
-
* Helper function to rename a CSSTree pseudo-class node
|
|
2648
|
-
*
|
|
2649
|
-
* @param node Node to rename
|
|
2650
|
-
* @param name New name
|
|
2651
|
-
*/
|
|
2652
|
-
static renamePseudoClass(node: PseudoClassSelector, name: string): void;
|
|
3298
|
+
*/
|
|
3299
|
+
declare class CosmeticRuleSeparatorUtils {
|
|
2653
3300
|
/**
|
|
2654
|
-
*
|
|
2655
|
-
* selector's children
|
|
3301
|
+
* Checks whether the specified separator is an exception.
|
|
2656
3302
|
*
|
|
2657
|
-
* @param
|
|
2658
|
-
* @returns
|
|
2659
|
-
* @example
|
|
2660
|
-
* - `:nth-child(2n+1)` -> `2n+1`
|
|
2661
|
-
* - `:matches-path(/foo/bar)` -> `/foo/bar`
|
|
3303
|
+
* @param separator Separator to check
|
|
3304
|
+
* @returns `true` if the separator is an exception, `false` otherwise
|
|
2662
3305
|
*/
|
|
2663
|
-
static
|
|
3306
|
+
static isException(separator: CosmeticRuleSeparator): boolean;
|
|
2664
3307
|
/**
|
|
2665
|
-
*
|
|
3308
|
+
* Checks whether the specified separator is marks an Extended CSS cosmetic rule.
|
|
2666
3309
|
*
|
|
2667
|
-
* @param
|
|
2668
|
-
* @returns
|
|
2669
|
-
* @example `responseheader(name)` -> `name`
|
|
3310
|
+
* @param separator Separator to check
|
|
3311
|
+
* @returns `true` if the separator is marks an Extended CSS cosmetic rule, `false` otherwise
|
|
2670
3312
|
*/
|
|
2671
|
-
static
|
|
3313
|
+
static isExtendedCssMarker(separator: CosmeticRuleSeparator): boolean;
|
|
2672
3314
|
/**
|
|
2673
|
-
*
|
|
3315
|
+
* Looks for the cosmetic rule separator in the rule. This is a simplified version that
|
|
3316
|
+
* masks the recursive function.
|
|
2674
3317
|
*
|
|
2675
|
-
* @param
|
|
2676
|
-
* @returns
|
|
2677
|
-
* @example `responseheader(name)` -> `name`
|
|
3318
|
+
* @param rule Raw rule
|
|
3319
|
+
* @returns Separator result or null if no separator was found
|
|
2678
3320
|
*/
|
|
2679
|
-
static
|
|
3321
|
+
static find(rule: string): CosmeticRuleSeparatorFinderResult | null;
|
|
2680
3322
|
}
|
|
2681
3323
|
|
|
2682
3324
|
declare class DomainUtils {
|
|
@@ -2690,7 +3332,7 @@ declare class DomainUtils {
|
|
|
2690
3332
|
}
|
|
2691
3333
|
|
|
2692
3334
|
/**
|
|
2693
|
-
* @file Utility functions for logical expression
|
|
3335
|
+
* @file Utility functions for logical expression node.
|
|
2694
3336
|
*/
|
|
2695
3337
|
|
|
2696
3338
|
/**
|
|
@@ -2700,24 +3342,24 @@ type VariableTable = {
|
|
|
2700
3342
|
[key: string]: boolean;
|
|
2701
3343
|
};
|
|
2702
3344
|
/**
|
|
2703
|
-
* Utility functions for logical expression
|
|
3345
|
+
* Utility functions for logical expression node.
|
|
2704
3346
|
*/
|
|
2705
3347
|
declare class LogicalExpressionUtils {
|
|
2706
3348
|
/**
|
|
2707
3349
|
* Get all variables in the expression.
|
|
2708
3350
|
*
|
|
2709
|
-
* @param
|
|
3351
|
+
* @param node Logical expression node
|
|
2710
3352
|
* @returns List of variables in the expression (nodes)
|
|
2711
3353
|
* @example
|
|
2712
3354
|
* If the expression is `a && b || c`, the returned list will be
|
|
2713
3355
|
* nodes for `a`, `b`, and `c`.
|
|
2714
3356
|
*/
|
|
2715
|
-
static getVariables(
|
|
3357
|
+
static getVariables(node: AnyExpressionNode): ExpressionVariableNode[];
|
|
2716
3358
|
/**
|
|
2717
3359
|
* Evaluate the parsed logical expression. You'll need to provide a
|
|
2718
3360
|
* variable table.
|
|
2719
3361
|
*
|
|
2720
|
-
* @param
|
|
3362
|
+
* @param node Logical expression node
|
|
2721
3363
|
* @param table Variable table (key: variable name, value: boolean)
|
|
2722
3364
|
* @returns Evaluation result
|
|
2723
3365
|
* @example
|
|
@@ -2732,34 +3374,9 @@ declare class LogicalExpressionUtils {
|
|
|
2732
3374
|
* );
|
|
2733
3375
|
* ```
|
|
2734
3376
|
*/
|
|
2735
|
-
static evaluate(
|
|
3377
|
+
static evaluate(node: AnyExpressionNode, table: VariableTable): boolean;
|
|
2736
3378
|
}
|
|
2737
3379
|
|
|
2738
|
-
/**
|
|
2739
|
-
* @file Utility functions for location and location range management.
|
|
2740
|
-
*/
|
|
2741
|
-
|
|
2742
|
-
/**
|
|
2743
|
-
* Shifts the specified location by the specified offset.
|
|
2744
|
-
*
|
|
2745
|
-
* @param loc Location to shift
|
|
2746
|
-
* @param offset Offset to shift by
|
|
2747
|
-
* @returns Location shifted by the specified offset
|
|
2748
|
-
*/
|
|
2749
|
-
declare function shiftLoc(loc: Location, offset: number): Location;
|
|
2750
|
-
/**
|
|
2751
|
-
* Calculates a location range from the specified base location and offsets.
|
|
2752
|
-
*
|
|
2753
|
-
* Since every adblock rule is a single line, the start and end locations
|
|
2754
|
-
* of the range will have the same line, no need to calculate it here.
|
|
2755
|
-
*
|
|
2756
|
-
* @param loc Base location
|
|
2757
|
-
* @param startOffset Start offset
|
|
2758
|
-
* @param endOffset End offset
|
|
2759
|
-
* @returns Calculated location range
|
|
2760
|
-
*/
|
|
2761
|
-
declare function locRange(loc: Location, startOffset: number, endOffset: number): LocationRange;
|
|
2762
|
-
|
|
2763
3380
|
declare const ADBLOCK_URL_START: string;
|
|
2764
3381
|
declare const ADBLOCK_URL_START_REGEX = "^(http|https|ws|wss)://([a-z0-9-_.]+\\.)?";
|
|
2765
3382
|
declare const ADBLOCK_URL_SEPARATOR = "^";
|
|
@@ -2866,6 +3483,14 @@ declare class QuoteUtils {
|
|
|
2866
3483
|
* @returns String without quotes
|
|
2867
3484
|
*/
|
|
2868
3485
|
static removeQuotes(string: string): string;
|
|
3486
|
+
/**
|
|
3487
|
+
* Removes bounding quotes from a string, if any, and unescapes the escaped quotes,
|
|
3488
|
+
* like transforming `'abc\'def'` to `abc'def`.
|
|
3489
|
+
*
|
|
3490
|
+
* @param string Input string
|
|
3491
|
+
* @returns String without quotes
|
|
3492
|
+
*/
|
|
3493
|
+
static removeQuotesAndUnescape(string: string): string;
|
|
2869
3494
|
/**
|
|
2870
3495
|
* Wraps given `strings` with `quote` (defaults to single quote `'`)
|
|
2871
3496
|
* and joins them with `separator` (defaults to comma+space `, `).
|
|
@@ -2883,12 +3508,104 @@ declare class QuoteUtils {
|
|
|
2883
3508
|
}
|
|
2884
3509
|
|
|
2885
3510
|
/**
|
|
2886
|
-
*
|
|
3511
|
+
* @file Position provider class.
|
|
3512
|
+
*/
|
|
3513
|
+
/**
|
|
3514
|
+
* Represents a position in the source code.
|
|
3515
|
+
*/
|
|
3516
|
+
interface Position {
|
|
3517
|
+
/**
|
|
3518
|
+
* 1-based line number
|
|
3519
|
+
*/
|
|
3520
|
+
line: number;
|
|
3521
|
+
/**
|
|
3522
|
+
* 1-based column number
|
|
3523
|
+
*/
|
|
3524
|
+
column: number;
|
|
3525
|
+
}
|
|
3526
|
+
/**
|
|
3527
|
+
* Class responsible for converting a character offset in source code into a line and column position.
|
|
3528
|
+
* This conversion is particularly needed in linters and VSCode extensions,
|
|
3529
|
+
* where line and column numbers are more human-friendly and intuitive than character offsets.
|
|
3530
|
+
* Moreover, the VSCode diagnostics API does not directly support character offsets,
|
|
3531
|
+
* it also requires line and column numbers.
|
|
3532
|
+
*/
|
|
3533
|
+
declare class PositionProvider {
|
|
3534
|
+
/**
|
|
3535
|
+
* Maps a character offset to a line number.
|
|
3536
|
+
*/
|
|
3537
|
+
private offsetToLine;
|
|
3538
|
+
/**
|
|
3539
|
+
* Maps a line number to the starting character offset of that line.
|
|
3540
|
+
*/
|
|
3541
|
+
private lineStartOffsets;
|
|
3542
|
+
/**
|
|
3543
|
+
* Constructs a new PositionProvider instance.
|
|
3544
|
+
*
|
|
3545
|
+
* @param sourceCode The source code as a string.
|
|
3546
|
+
*/
|
|
3547
|
+
constructor(sourceCode: string);
|
|
3548
|
+
/**
|
|
3549
|
+
* Converts a character offset to a line and column position.
|
|
3550
|
+
*
|
|
3551
|
+
* @param offset The zero-based character offset in the source code.
|
|
3552
|
+
* @returns A Position object containing the 1-based line and column number, or null if the offset is out of range.
|
|
3553
|
+
*/
|
|
3554
|
+
convertOffsetToPosition(offset: number): Position | null;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
/**
|
|
3558
|
+
* @file Utility for encoding strings to byte sequences.
|
|
3559
|
+
*/
|
|
3560
|
+
interface TextEncoderPolyfillResult {
|
|
3561
|
+
readonly written: number;
|
|
3562
|
+
readonly read: number;
|
|
3563
|
+
}
|
|
3564
|
+
/**
|
|
3565
|
+
* Encodes an UTF-8 string into a byte sequence according to the WHATWG spec.
|
|
3566
|
+
*
|
|
3567
|
+
* @param str String to encode.
|
|
3568
|
+
* @param buffer Buffer to write the encoded bytes to.
|
|
3569
|
+
* @returns Number of bytes written to the buffer.
|
|
3570
|
+
* @see {@link https://encoding.spec.whatwg.org/#utf-8-encoder}
|
|
3571
|
+
* @note Bytes written maybe larger than the string length, but never smaller.
|
|
3572
|
+
* For example, the string '你好' has a length of 2, but its byte representation has a length of 6.
|
|
3573
|
+
*/
|
|
3574
|
+
declare const encodeIntoPolyfill: (str: string, buffer: Uint8Array) => TextEncoderPolyfillResult;
|
|
3575
|
+
|
|
3576
|
+
/**
|
|
3577
|
+
* @file Optimized utility for decoding strings from byte sequences.
|
|
2887
3578
|
*/
|
|
2888
|
-
|
|
3579
|
+
/**
|
|
3580
|
+
* Decodes a byte sequence into an UTF-8 string according to the WHATWG spec.
|
|
3581
|
+
* Optimized for performance.
|
|
3582
|
+
*
|
|
3583
|
+
* @param buffer Buffer to read the bytes from.
|
|
3584
|
+
* @param start Start offset in the buffer.
|
|
3585
|
+
* @param end End offset in the buffer.
|
|
3586
|
+
* @returns Decoded string.
|
|
3587
|
+
* @see {@link https://encoding.spec.whatwg.org/#utf-8-decoder}
|
|
3588
|
+
*/
|
|
3589
|
+
declare const decodeTextPolyfill: (buffer: Uint8Array, start?: number, end?: number) => string;
|
|
3590
|
+
|
|
3591
|
+
/**
|
|
3592
|
+
* Utility functions for categorizing rules.
|
|
3593
|
+
*/
|
|
3594
|
+
declare class RuleCategorizer {
|
|
3595
|
+
/**
|
|
3596
|
+
* Determines the type of a given raw cosmetic rule.
|
|
3597
|
+
*
|
|
3598
|
+
* @param rawRule Raw rule to check.
|
|
3599
|
+
*
|
|
3600
|
+
* @returns Type of the cosmetic rule or `null` if the rule is cannot be parsed as a cosmetic rule.
|
|
3601
|
+
*/
|
|
3602
|
+
static getCosmeticRuleType(rawRule: string): CosmeticRuleType | null;
|
|
3603
|
+
}
|
|
2889
3604
|
|
|
2890
3605
|
/**
|
|
2891
|
-
*
|
|
3606
|
+
* _ALL_ known Extended CSS pseudo-classes. Please, keep this list sorted.
|
|
3607
|
+
* It includes strict pseudo-classes and additional pseudo-classes that may be
|
|
3608
|
+
* supported by some browsers natively.
|
|
2892
3609
|
*/
|
|
2893
3610
|
declare const EXT_CSS_PSEUDO_CLASSES: Set<string>;
|
|
2894
3611
|
/**
|
|
@@ -2905,9 +3622,456 @@ declare const EXT_CSS_LEGACY_ATTRIBUTES: Set<string>;
|
|
|
2905
3622
|
*/
|
|
2906
3623
|
declare const FORBIDDEN_CSS_FUNCTIONS: Set<string>;
|
|
2907
3624
|
|
|
3625
|
+
/**
|
|
3626
|
+
* @file Base compatibility data schema, which is commonly used in compatibility tables.
|
|
3627
|
+
*/
|
|
3628
|
+
|
|
3629
|
+
/**
|
|
3630
|
+
* Zod schema for base compatibility data with camelCase properties.
|
|
3631
|
+
*/
|
|
3632
|
+
declare const baseCompatibilityDataSchemaCamelCase: zod.ZodEffects<zod.ZodTypeAny, {
|
|
3633
|
+
name: string;
|
|
3634
|
+
description: string | null;
|
|
3635
|
+
aliases: string[] | null;
|
|
3636
|
+
docs: string | null;
|
|
3637
|
+
versionAdded: string | null;
|
|
3638
|
+
versionRemoved: string | null;
|
|
3639
|
+
deprecated: boolean;
|
|
3640
|
+
deprecationMessage: string | null;
|
|
3641
|
+
removed: boolean;
|
|
3642
|
+
removalMessage: string | null;
|
|
3643
|
+
}, any>;
|
|
3644
|
+
/**
|
|
3645
|
+
* Type of the base compatibility data schema.
|
|
3646
|
+
*/
|
|
3647
|
+
type BaseCompatibilityDataSchema = zod.infer<typeof baseCompatibilityDataSchemaCamelCase>;
|
|
3648
|
+
|
|
3649
|
+
/**
|
|
3650
|
+
* @file Schema for modifier data.
|
|
3651
|
+
*/
|
|
3652
|
+
|
|
3653
|
+
/**
|
|
3654
|
+
* Zod schema for modifier data.
|
|
3655
|
+
*/
|
|
3656
|
+
declare const modifierDataSchema: zod.ZodEffects<zod.ZodTypeAny, {
|
|
3657
|
+
name: string;
|
|
3658
|
+
description: string | null;
|
|
3659
|
+
aliases: string[] | null;
|
|
3660
|
+
docs: string | null;
|
|
3661
|
+
versionAdded: string | null;
|
|
3662
|
+
versionRemoved: string | null;
|
|
3663
|
+
deprecated: boolean;
|
|
3664
|
+
deprecationMessage: string | null;
|
|
3665
|
+
removed: boolean;
|
|
3666
|
+
removalMessage: string | null;
|
|
3667
|
+
conflicts: string[] | null;
|
|
3668
|
+
inverseConflicts: boolean;
|
|
3669
|
+
assignable: boolean;
|
|
3670
|
+
negatable: boolean;
|
|
3671
|
+
blockOnly: boolean;
|
|
3672
|
+
exceptionOnly: boolean;
|
|
3673
|
+
valueOptional: boolean;
|
|
3674
|
+
valueFormat: string | null;
|
|
3675
|
+
}, any>;
|
|
3676
|
+
/**
|
|
3677
|
+
* Type of the modifier data schema.
|
|
3678
|
+
*/
|
|
3679
|
+
type ModifierDataSchema = zod.infer<typeof modifierDataSchema>;
|
|
3680
|
+
|
|
3681
|
+
/**
|
|
3682
|
+
* @file Schema for redirect data.
|
|
3683
|
+
*/
|
|
3684
|
+
|
|
3685
|
+
/**
|
|
3686
|
+
* Zod schema for redirect data.
|
|
3687
|
+
*/
|
|
3688
|
+
declare const redirectDataSchema: zod.ZodEffects<zod.ZodTypeAny, {
|
|
3689
|
+
name: string;
|
|
3690
|
+
description: string | null;
|
|
3691
|
+
aliases: string[] | null;
|
|
3692
|
+
docs: string | null;
|
|
3693
|
+
versionAdded: string | null;
|
|
3694
|
+
versionRemoved: string | null;
|
|
3695
|
+
deprecated: boolean;
|
|
3696
|
+
deprecationMessage: string | null;
|
|
3697
|
+
removed: boolean;
|
|
3698
|
+
removalMessage: string | null;
|
|
3699
|
+
isBlocking: boolean;
|
|
3700
|
+
}, any>;
|
|
3701
|
+
/**
|
|
3702
|
+
* Type of the redirect data schema.
|
|
3703
|
+
*/
|
|
3704
|
+
type RedirectDataSchema = zod.infer<typeof redirectDataSchema>;
|
|
3705
|
+
|
|
3706
|
+
/**
|
|
3707
|
+
* @file Schema for scriptlet data.
|
|
3708
|
+
*/
|
|
3709
|
+
|
|
3710
|
+
/**
|
|
3711
|
+
* Zod schema for scriptlet data.
|
|
3712
|
+
*/
|
|
3713
|
+
declare const scriptletDataSchema: zod.ZodEffects<zod.ZodTypeAny, {
|
|
3714
|
+
name: string;
|
|
3715
|
+
description: string | null;
|
|
3716
|
+
aliases: string[] | null;
|
|
3717
|
+
docs: string | null;
|
|
3718
|
+
versionAdded: string | null;
|
|
3719
|
+
versionRemoved: string | null;
|
|
3720
|
+
deprecated: boolean;
|
|
3721
|
+
deprecationMessage: string | null;
|
|
3722
|
+
removed: boolean;
|
|
3723
|
+
removalMessage: string | null;
|
|
3724
|
+
parameters?: {
|
|
3725
|
+
name: string;
|
|
3726
|
+
debug: boolean;
|
|
3727
|
+
pattern: string | null;
|
|
3728
|
+
description: string | null;
|
|
3729
|
+
default: string | null;
|
|
3730
|
+
required: boolean;
|
|
3731
|
+
}[] | undefined;
|
|
3732
|
+
}, any>;
|
|
3733
|
+
/**
|
|
3734
|
+
* Type of the scriptlet data schema.
|
|
3735
|
+
*/
|
|
3736
|
+
type ScriptletDataSchema = zod.infer<typeof scriptletDataSchema>;
|
|
3737
|
+
|
|
3738
|
+
/**
|
|
3739
|
+
* @file Platform schema.
|
|
3740
|
+
*/
|
|
3741
|
+
|
|
3742
|
+
/**
|
|
3743
|
+
* Parses a raw platform string into a platform bitmask.
|
|
3744
|
+
*
|
|
3745
|
+
* @param rawPlatforms Raw platform string, e.g. 'adg_safari_any|adg_os_any'.
|
|
3746
|
+
*
|
|
3747
|
+
* @returns Platform bitmask.
|
|
3748
|
+
*/
|
|
3749
|
+
declare const parseRawPlatforms: (rawPlatforms: string) => number;
|
|
3750
|
+
|
|
3751
|
+
/**
|
|
3752
|
+
* @file Provides platform enums.
|
|
3753
|
+
* The difference between specific and generic platforms is that specific platforms are individual platforms
|
|
3754
|
+
* (e.g. AdGuard for Windows, AdGuard for Android, etc.),
|
|
3755
|
+
* while generic platforms are groups of specific platforms
|
|
3756
|
+
* (e.g. AdGuard for any OS, AdGuard for any Chromium-based extension, etc.).
|
|
3757
|
+
*/
|
|
3758
|
+
/**
|
|
3759
|
+
* List of specific platforms.
|
|
3760
|
+
*/
|
|
3761
|
+
declare enum SpecificPlatform {
|
|
3762
|
+
AdgOsWindows = 1,
|
|
3763
|
+
AdgOsMac = 2,
|
|
3764
|
+
AdgOsAndroid = 4,
|
|
3765
|
+
AdgExtChrome = 8,
|
|
3766
|
+
AdgExtOpera = 16,
|
|
3767
|
+
AdgExtEdge = 32,
|
|
3768
|
+
AdgExtFirefox = 64,
|
|
3769
|
+
AdgCbAndroid = 128,
|
|
3770
|
+
AdgCbIos = 256,
|
|
3771
|
+
AdgCbSafari = 512,
|
|
3772
|
+
UboExtChrome = 1024,
|
|
3773
|
+
UboExtOpera = 2048,
|
|
3774
|
+
UboExtEdge = 4096,
|
|
3775
|
+
UboExtFirefox = 8192,
|
|
3776
|
+
AbpExtChrome = 16384,
|
|
3777
|
+
AbpExtOpera = 32768,
|
|
3778
|
+
AbpExtEdge = 65536,
|
|
3779
|
+
AbpExtFirefox = 131072
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* List of generic platforms (combinations of specific platforms).
|
|
3783
|
+
*/
|
|
3784
|
+
declare enum GenericPlatform {
|
|
3785
|
+
AdgOsAny = 7,
|
|
3786
|
+
AdgSafariAny = 768,
|
|
3787
|
+
AdgExtChromium = 56,
|
|
3788
|
+
AdgExtAny = 120,
|
|
3789
|
+
AdgAny = 1023,
|
|
3790
|
+
UboExtChromium = 7168,
|
|
3791
|
+
UboExtAny = 15360,
|
|
3792
|
+
UboAny = 15360,
|
|
3793
|
+
AbpExtChromium = 114688,
|
|
3794
|
+
AbpExtAny = 245760,
|
|
3795
|
+
AbpAny = 245760,
|
|
3796
|
+
Any = 262143
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
/**
|
|
3800
|
+
* @file Compatibility tables types.
|
|
3801
|
+
*/
|
|
3802
|
+
/**
|
|
3803
|
+
* Map with shared storage.
|
|
3804
|
+
* The idea is to avoid storing the same value multiple times in the map,
|
|
3805
|
+
* so the value is stored in the `shared` array and the map refers to the index in the `shared` array.
|
|
3806
|
+
*
|
|
3807
|
+
* @template K Type of the map keys.
|
|
3808
|
+
* @template V Type of the map values.
|
|
3809
|
+
*/
|
|
3810
|
+
interface MapWithSharedStorage<K extends string | number | symbol, V> {
|
|
3811
|
+
/**
|
|
3812
|
+
* Shared storage.
|
|
3813
|
+
*/
|
|
3814
|
+
shared: V[];
|
|
3815
|
+
/**
|
|
3816
|
+
* Map of the values where the value is a pointer to the shared storage (refers to the index in the `shared` array).
|
|
3817
|
+
*/
|
|
3818
|
+
map: Record<K, number>;
|
|
3819
|
+
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Compatibility table row.
|
|
3822
|
+
*
|
|
3823
|
+
* @template T Type of the compatibility data.
|
|
3824
|
+
*/
|
|
3825
|
+
type CompatibilityTableRow<T> = MapWithSharedStorage<number, T>;
|
|
3826
|
+
/**
|
|
3827
|
+
* Compatibility table.
|
|
3828
|
+
*
|
|
3829
|
+
* @template T Type of the compatibility data.
|
|
3830
|
+
*/
|
|
3831
|
+
type CompatibilityTable<T> = MapWithSharedStorage<string, CompatibilityTableRow<T>>;
|
|
3832
|
+
|
|
3833
|
+
/**
|
|
3834
|
+
* @file Provides common compatibility table methods.
|
|
3835
|
+
*/
|
|
3836
|
+
|
|
3837
|
+
/**
|
|
3838
|
+
* Lists all supported entity records by a product.
|
|
3839
|
+
*
|
|
3840
|
+
* Keys are compatibility flags, values are compatibility data records.
|
|
3841
|
+
*
|
|
3842
|
+
* @template T Compatibility data schema.
|
|
3843
|
+
*/
|
|
3844
|
+
type ProductRecords<T> = {
|
|
3845
|
+
[key: string]: T;
|
|
3846
|
+
};
|
|
3847
|
+
/**
|
|
3848
|
+
* Defines a compatibility table row by product.
|
|
3849
|
+
*
|
|
3850
|
+
* Keys are Adblock syntaxes, values are product records.
|
|
3851
|
+
*
|
|
3852
|
+
* @template T Compatibility data schema.
|
|
3853
|
+
*/
|
|
3854
|
+
type RowByProduct<T> = {
|
|
3855
|
+
[AdblockSyntax.Adg]: ProductRecords<T>;
|
|
3856
|
+
[AdblockSyntax.Ubo]: ProductRecords<T>;
|
|
3857
|
+
[AdblockSyntax.Abp]: ProductRecords<T>;
|
|
3858
|
+
};
|
|
3859
|
+
/**
|
|
3860
|
+
* Defines multiple compatibility table rows by product.
|
|
3861
|
+
*
|
|
3862
|
+
* @template T Compatibility data schema.
|
|
3863
|
+
*/
|
|
3864
|
+
type RowsByProduct<T> = RowByProduct<T>[];
|
|
3865
|
+
/**
|
|
3866
|
+
* Single platform records type.
|
|
3867
|
+
*
|
|
3868
|
+
* Keys are platform enums values, values are compatibility data records.
|
|
3869
|
+
*
|
|
3870
|
+
* @template T Compatibility data schema.
|
|
3871
|
+
*/
|
|
3872
|
+
type SinglePlatformRecords<T> = {
|
|
3873
|
+
[key: string]: T;
|
|
3874
|
+
};
|
|
3875
|
+
/**
|
|
3876
|
+
* Name transformer function type. This function is used to normalize compatibility data names before processing them,
|
|
3877
|
+
* e.g. converting to lowercase, remove unnecessary prefixes, etc.
|
|
3878
|
+
*
|
|
3879
|
+
* @param name Compatibility data name.
|
|
3880
|
+
*
|
|
3881
|
+
* @returns Normalized name.
|
|
3882
|
+
*/
|
|
3883
|
+
type NameTransformer = (name: string) => string;
|
|
3884
|
+
/**
|
|
3885
|
+
* Base compatibility table class which provides common methods to work with compatibility data.
|
|
3886
|
+
*
|
|
3887
|
+
* @template T Compatibility data schema.
|
|
3888
|
+
*/
|
|
3889
|
+
declare abstract class CompatibilityTableBase<T extends BaseCompatibilityDataSchema> {
|
|
3890
|
+
/**
|
|
3891
|
+
* Compatibility table data.
|
|
3892
|
+
*/
|
|
3893
|
+
private data;
|
|
3894
|
+
/**
|
|
3895
|
+
* Optional name transformer function. If provided,
|
|
3896
|
+
* it will be called in all methods before processing compatibility data names.
|
|
3897
|
+
*/
|
|
3898
|
+
private readonly nameTransformer;
|
|
3899
|
+
/**
|
|
3900
|
+
* Creates a new instance of the common compatibility table.
|
|
3901
|
+
*
|
|
3902
|
+
* @param data Compatibility table data.
|
|
3903
|
+
* @param nameTransformer Optional name transformer function.
|
|
3904
|
+
*/
|
|
3905
|
+
constructor(data: CompatibilityTable<T>, nameTransformer?: NameTransformer | null);
|
|
3906
|
+
/**
|
|
3907
|
+
* Helper method to get a 'row' from the compatibility table data by name.
|
|
3908
|
+
*
|
|
3909
|
+
* @param name Compatibility data name.
|
|
3910
|
+
* @returns Compatibility table row storage or `null` if not found.
|
|
3911
|
+
*/
|
|
3912
|
+
private getRowStorage;
|
|
3913
|
+
/**
|
|
3914
|
+
* Checks whether a compatibility data `name` exists for any platform.
|
|
3915
|
+
*
|
|
3916
|
+
* @note Technically, do the same as `exists()` method with generic platform _any_
|
|
3917
|
+
* but it is faster because it does not apply complex logic.
|
|
3918
|
+
*
|
|
3919
|
+
* @param name Compatibility data name.
|
|
3920
|
+
*
|
|
3921
|
+
* @returns True if the compatibility data exists, false otherwise.
|
|
3922
|
+
*/
|
|
3923
|
+
existsAny(name: string): boolean;
|
|
3924
|
+
/**
|
|
3925
|
+
* Checks whether a compatibility data `name` exists for a specified platform.
|
|
3926
|
+
*
|
|
3927
|
+
* @param name Compatibility data name.
|
|
3928
|
+
* @param platform Specific or generic platform.
|
|
3929
|
+
*
|
|
3930
|
+
* @returns True if the compatibility data exists, false otherwise.
|
|
3931
|
+
*/
|
|
3932
|
+
exists(name: string, platform: SpecificPlatform | GenericPlatform): boolean;
|
|
3933
|
+
/**
|
|
3934
|
+
* Returns a compatibility data by name and specific platform.
|
|
3935
|
+
*
|
|
3936
|
+
* @param name The name of the compatibility data.
|
|
3937
|
+
* @param platform The specific platform.
|
|
3938
|
+
*
|
|
3939
|
+
* @returns A single compatibility data or `null` if not found.
|
|
3940
|
+
*/
|
|
3941
|
+
getSingle(name: string, platform: SpecificPlatform): T | null;
|
|
3942
|
+
/**
|
|
3943
|
+
* Returns all compatibility data records for name and specified platform.
|
|
3944
|
+
*
|
|
3945
|
+
* @param name Compatibility data name.
|
|
3946
|
+
* @param platform Specific or generic platform.
|
|
3947
|
+
*
|
|
3948
|
+
* @returns Multiple records grouped by platforms.
|
|
3949
|
+
* Technically, it is an object where keys are platform enums values and values are compatibility data records.
|
|
3950
|
+
*
|
|
3951
|
+
* @note Platform enum values can be converted to string names using {@link getSpecificPlatformName} on demand.
|
|
3952
|
+
*/
|
|
3953
|
+
getMultiple(name: string, platform: SpecificPlatform | GenericPlatform): SinglePlatformRecords<T> | null;
|
|
3954
|
+
/**
|
|
3955
|
+
* Returns all compatibility data records for the specified platform.
|
|
3956
|
+
*
|
|
3957
|
+
* @param platform Specific or generic platform.
|
|
3958
|
+
*
|
|
3959
|
+
* @returns Array of multiple records grouped by platforms.
|
|
3960
|
+
*/
|
|
3961
|
+
getAllMultiple(platform: SpecificPlatform | GenericPlatform): SinglePlatformRecords<T>[];
|
|
3962
|
+
/**
|
|
3963
|
+
* Returns the first compatibility data record for name and specified platform.
|
|
3964
|
+
*
|
|
3965
|
+
* @param name Compatibility data name.
|
|
3966
|
+
* @param platform Specific or generic platform.
|
|
3967
|
+
*
|
|
3968
|
+
* @returns First found compatibility data record or `null` if not found.
|
|
3969
|
+
*/
|
|
3970
|
+
getFirst(name: string, platform: SpecificPlatform | GenericPlatform): T | null;
|
|
3971
|
+
/**
|
|
3972
|
+
* Returns all compatibility data records for the specified name.
|
|
3973
|
+
*
|
|
3974
|
+
* @param name Compatibility data name.
|
|
3975
|
+
*
|
|
3976
|
+
* @returns Array of multiple records grouped by platforms.
|
|
3977
|
+
*/
|
|
3978
|
+
getRow(name: string): T[];
|
|
3979
|
+
/**
|
|
3980
|
+
* Returns all compatibility data grouped by products.
|
|
3981
|
+
*
|
|
3982
|
+
* @returns Array of multiple records grouped by products.
|
|
3983
|
+
*/
|
|
3984
|
+
getRowsByProduct(): RowsByProduct<T>;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3987
|
+
/**
|
|
3988
|
+
* @file Compatibility tables for modifiers.
|
|
3989
|
+
*/
|
|
3990
|
+
|
|
3991
|
+
/**
|
|
3992
|
+
* Compatibility table for modifiers.
|
|
3993
|
+
*/
|
|
3994
|
+
declare class ModifiersCompatibilityTable extends CompatibilityTableBase<ModifierDataSchema> {
|
|
3995
|
+
/**
|
|
3996
|
+
* Creates a new instance of the compatibility table for modifiers.
|
|
3997
|
+
*
|
|
3998
|
+
* @param data Compatibility table data.
|
|
3999
|
+
*/
|
|
4000
|
+
constructor(data: CompatibilityTable<ModifierDataSchema>);
|
|
4001
|
+
}
|
|
4002
|
+
/**
|
|
4003
|
+
* Compatibility table instance for modifiers.
|
|
4004
|
+
*/
|
|
4005
|
+
declare const modifiersCompatibilityTable: ModifiersCompatibilityTable;
|
|
4006
|
+
|
|
4007
|
+
/**
|
|
4008
|
+
* @file Compatibility tables for redirects.
|
|
4009
|
+
*/
|
|
4010
|
+
|
|
4011
|
+
/**
|
|
4012
|
+
* Compatibility table for redirects.
|
|
4013
|
+
*/
|
|
4014
|
+
declare class RedirectsCompatibilityTable extends CompatibilityTableBase<RedirectDataSchema> {
|
|
4015
|
+
/**
|
|
4016
|
+
* Creates a new instance of the compatibility table for redirects.
|
|
4017
|
+
*
|
|
4018
|
+
* @param data Compatibility table data.
|
|
4019
|
+
*/
|
|
4020
|
+
constructor(data: CompatibilityTable<RedirectDataSchema>);
|
|
4021
|
+
}
|
|
4022
|
+
/**
|
|
4023
|
+
* Compatibility table instance for redirects.
|
|
4024
|
+
*/
|
|
4025
|
+
declare const redirectsCompatibilityTable: RedirectsCompatibilityTable;
|
|
4026
|
+
|
|
4027
|
+
/**
|
|
4028
|
+
* @file Compatibility tables for scriptlets.
|
|
4029
|
+
*/
|
|
4030
|
+
|
|
4031
|
+
/**
|
|
4032
|
+
* Compatibility table for scriptlets.
|
|
4033
|
+
*/
|
|
4034
|
+
declare class ScriptletsCompatibilityTable extends CompatibilityTableBase<ScriptletDataSchema> {
|
|
4035
|
+
}
|
|
4036
|
+
/**
|
|
4037
|
+
* Compatibility table instance for scriptlets.
|
|
4038
|
+
*/
|
|
4039
|
+
declare const scriptletsCompatibilityTable: ScriptletsCompatibilityTable;
|
|
4040
|
+
|
|
4041
|
+
/**
|
|
4042
|
+
* @file Provides platform mapping and helper functions.
|
|
4043
|
+
*/
|
|
4044
|
+
|
|
4045
|
+
/**
|
|
4046
|
+
* Check if the platform is a generic platform.
|
|
4047
|
+
*
|
|
4048
|
+
* @param platform Platform to check.
|
|
4049
|
+
*
|
|
4050
|
+
* @returns True if the platform is a generic platform, false otherwise.
|
|
4051
|
+
*/
|
|
4052
|
+
declare const isGenericPlatform: (platform: number) => boolean;
|
|
4053
|
+
/**
|
|
4054
|
+
* Returns the platform enum value for the given platform string name.
|
|
4055
|
+
*
|
|
4056
|
+
* @param platform Platform string name, e.g., 'adg_os_windows'.
|
|
4057
|
+
*
|
|
4058
|
+
* @returns Specific or generic platform enum value.
|
|
4059
|
+
* @throws Error if the platform is unknown.
|
|
4060
|
+
*/
|
|
4061
|
+
declare const getPlatformId: (platform: string) => SpecificPlatform | GenericPlatform;
|
|
4062
|
+
/**
|
|
4063
|
+
* Returns the specific platform string name for the given platform enum value.
|
|
4064
|
+
*
|
|
4065
|
+
* @param platform Specific platform enum value.
|
|
4066
|
+
*
|
|
4067
|
+
* @returns Specific platform string name, e.g., 'adg_os_windows'.
|
|
4068
|
+
* @throws Error if the platform is unknown.
|
|
4069
|
+
*/
|
|
4070
|
+
declare const getSpecificPlatformName: (platform: SpecificPlatform) => string;
|
|
4071
|
+
|
|
2908
4072
|
/**
|
|
2909
4073
|
* @file AGTree version
|
|
2910
4074
|
*/
|
|
2911
|
-
declare const
|
|
4075
|
+
declare const AGTREE_VERSION: string;
|
|
2912
4076
|
|
|
2913
|
-
export { ADBLOCK_URL_SEPARATOR, ADBLOCK_URL_SEPARATOR_REGEX, ADBLOCK_URL_START, ADBLOCK_URL_START_REGEX, ADBLOCK_WILDCARD, ADBLOCK_WILDCARD_REGEX, ADG_SCRIPTLET_MASK, AGLINT_COMMAND_PREFIX, AdblockSyntax, AdblockSyntaxError, Agent, AgentCommentRule, AgentCommentRuleParser, AgentParser, AnyCommentRule, AnyCosmeticRule, AnyExpressionNode, AnyOperator, AnyRule, AppListParser, COMMA_DOMAIN_LIST_SEPARATOR, CommentBase, CommentMarker, CommentRule, CommentRuleParser, CommentRuleType, ConfigCommentRule, ConfigCommentRuleParser, CosmeticRule, CosmeticRuleParser, CosmeticRuleSeparator, CosmeticRuleSeparatorFinderResult, CosmeticRuleSeparatorUtils, CosmeticRuleType, CssInjectionRule, CssInjectionRuleBody,
|
|
4077
|
+
export { ADBLOCK_URL_SEPARATOR, ADBLOCK_URL_SEPARATOR_REGEX, ADBLOCK_URL_START, ADBLOCK_URL_START_REGEX, ADBLOCK_WILDCARD, ADBLOCK_WILDCARD_REGEX, ADG_SCRIPTLET_MASK, AGLINT_COMMAND_PREFIX, AGTREE_VERSION, AdblockSyntax, AdblockSyntaxError, Agent, AgentCommentRule, AgentCommentRuleParser, AgentParser, AnyCommentRule, AnyCosmeticRule, AnyExpressionNode, AnyNetworkRule, AnyOperator, AnyRule, AppListParser, BINARY_SCHEMA_VERSION, BinarySchemaMismatchError, ByteBuffer, COMMA_DOMAIN_LIST_SEPARATOR, CommentBase, CommentMarker, CommentRule, CommentRuleParser, CommentRuleType, CompatibilityTable, CompatibilityTableRow, ConfigCommentRule, ConfigCommentRuleParser, CosmeticRule, CosmeticRuleParser, CosmeticRuleSeparator, CosmeticRuleSeparatorFinderResult, CosmeticRuleSeparatorUtils, CosmeticRuleType, CssInjectionRule, CssInjectionRuleBody, Domain, DomainList, DomainListParser, DomainListSeparator, DomainUtils, EXT_CSS_LEGACY_ATTRIBUTES, EXT_CSS_PSEUDO_CLASSES, ElementHidingRule, ElementHidingRuleBody, EmptyRule, ExpressionOperatorNode, ExpressionParenthesisNode, ExpressionVariableNode, FORBIDDEN_CSS_FUNCTIONS, FilterList, FilterListConverter, FilterListParser, GenericPlatform, HINT_MARKER, Hint, HintCommentRule, HintCommentRuleParser, HintParser, HostRule, HostRuleParser, HostnameList, HtmlFilteringRule, HtmlFilteringRuleBody, IF, INCLUDE, InputByteBuffer, JsInjectionRule, KNOWN_METADATA_HEADERS, Location, LocationRange, LogicalExpressionParser, LogicalExpressionUtils, MODIFIERS_SEPARATOR, MODIFIER_ASSIGN_OPERATOR, MetadataCommentRule, MetadataCommentRuleParser, MethodListParser, Modifier, ModifierList, ModifierListParser, ModifierParser, NEGATION_MARKER, NETWORK_RULE_EXCEPTION_MARKER, NETWORK_RULE_SEPARATOR, NetworkRule, NetworkRuleParser, NetworkRuleType, Node, NotImplementedError, OutputByteBuffer, PIPE_MODIFIER_SEPARATOR, PREPROCESSOR_MARKER, ParameterList, ParameterListParser, ParserOptions, Position, PositionProvider, PreProcessorCommentRule, PreProcessorCommentRuleParser, ProductRecords, QuoteType, QuoteUtils, RawFilterListConverter, RawRuleConverter, RegExpUtils, RowByProduct, RowsByProduct, RuleBase, RuleCategorizer, RuleCategory, RuleConversionError, RuleConverter, RuleParser, SAFARI_CB_AFFINITY, SPECIAL_REGEX_SYMBOLS, ScriptletInjectionRule, ScriptletInjectionRuleBody, SpecificPlatform, StealthOptionListParser, TextEncoderPolyfillResult, UBO_SCRIPTLET_MASK, Value, VariableTable, decodeTextPolyfill, defaultParserOptions, encodeIntoPolyfill, getPlatformId, getSpecificPlatformName, isGenericPlatform, modifierValidator, modifiersCompatibilityTable, parseRawPlatforms, redirectsCompatibilityTable, scriptletsCompatibilityTable };
|