@adguard/agtree
Version:
Tool set for working with adblock filter lists
60 lines (58 loc) • 2.02 kB
JavaScript
/*
* AGTree v3.2.2 (build date: Tue, 08 Jul 2025 13:39:47 GMT)
* (c) 2025 Adguard Software Ltd.
* Released under the MIT license
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
*/
/**
* Property map for binary serialization. This helps to reduce the size of the serialized data,
* as it allows us to use a single byte to represent a property.
*
* ! IMPORTANT: If you change values here, please update the {@link BINARY_SCHEMA_VERSION}!
*
* @note Only 256 values can be represented this way.
*/
const PreProcessorRuleMarshallingMap = {
Name: 1,
Params: 2,
Syntax: 3,
Start: 4,
End: 5,
};
/**
* Value map for binary serialization. This helps to reduce the size of the serialized data,
* as it allows us to use a single byte to represent frequently used values.
*
* ! IMPORTANT: If you change values here, please update the {@link BINARY_SCHEMA_VERSION}!
*
* @note Only 256 values can be represented this way.
*
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#preprocessor-directives}
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
*/
const FREQUENT_DIRECTIVES_SERIALIZATION_MAP = new Map([
['if', 0],
['else', 1],
['endif', 2],
['include', 3],
['safari_cb_affinity', 4],
]);
/**
* Value map for binary serialization. This helps to reduce the size of the serialized data,
* as it allows us to use a single byte to represent frequently used values.
*
* ! IMPORTANT: If you change values here, please update the {@link BINARY_SCHEMA_VERSION}!
*
* @note Only 256 values can be represented this way.
*/
const FREQUENT_PARAMS_SERIALIZATION_MAP = new Map([
// safari_cb_affinity parameters
['general', 0],
['privacy', 1],
['social', 2],
['security', 3],
['other', 4],
['custom', 5],
['all', 6],
]);
export { FREQUENT_DIRECTIVES_SERIALIZATION_MAP, FREQUENT_PARAMS_SERIALIZATION_MAP, PreProcessorRuleMarshallingMap };