tldts-utils 7.0.32 → 7.1.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/dist/cjs/index.js CHANGED
@@ -525,155 +525,134 @@ var buildHashes = (body) => {
525
525
  };
526
526
 
527
527
  /**
528
- * This builder implements a fast and compact DAWG data-structure (a.k.a.:
529
- * direct acyclic word graph, with suffix and prefix compression of the
530
- * top-level domains) using JavaScript Objects. It is a good trade-off between
531
- * correctness, speed and space. This is much faster then using a linear scan
532
- * over all the rules, but slightly slower than the probabilistic
533
- * data-structure implemented in `bin/builders/hashes.js`.
528
+ * Builds a flat, allocation-free public-suffix trie.
534
529
  *
535
- * Here is a simple example:
530
+ * The rules are inserted into an in-memory trie, identical sub-trees are shared
531
+ * (DAWG compression), and the result is emitted as a handful of flat typed
532
+ * arrays plus one `text` string holding every edge label:
536
533
  *
537
- * co.uk
538
- * gov.uk
539
- * fr
534
+ * nodeFlags[node] -> 0 (none) | 1 (ICANN) | 2 (PRIVATE)
535
+ * edgeStart[node] -> first edge index of `node` (edges of a node are a
536
+ * contiguous, hash-sorted slice [edgeStart[node], edgeStart[node+1]))
537
+ * edgeLength[edge] -> label length
538
+ * edgeChild[edge] -> destination node
539
+ * labelText -> all edge labels concatenated in edge order
540
540
  *
541
- * <root>
542
- * |_ uk
543
- * |_ co *
544
- * |_ gov *
545
- * |_ fr *
541
+ * The per-edge label offsets (prefix-sum of `edgeLength`) and label hashes
542
+ * (djb2 over `labelText`) are NOT shipped — they are derived once at load in
543
+ * `suffix-trie.ts`. This keeps the bundle small (only compressible text +
544
+ * structure) while the lookup binary-searches integer hashes at runtime.
546
545
  *
547
- * Finding a match is then a matter of iterating on labels of a hostname
548
- * backward and following the branches of the Trie. Whenever we find a terminal
549
- * node (indicated with a '*' above), we consider this a match.
546
+ * Lookup walks a hostname's labels right-to-left following edges; a flagged
547
+ * node is a public-suffix match. See `suffix-trie.ts`.
550
548
  */
551
- function convertToCompactTrie(trie) {
552
- return [
553
- trie.$,
554
- Object.fromEntries(Object.entries(trie.succ).map(([label, succ]) => [
555
- label,
556
- typeof succ === 'string' ? succ : convertToCompactTrie(succ),
557
- ])),
558
- ];
559
- }
560
549
  /**
561
- * Insert a public suffix rule in the `trie`.
550
+ * Insert a public suffix rule (its labels, already reversed) into the `trie`.
562
551
  */
563
- function insertInTrie({ parts, isIcann, }, trie) {
552
+ function insertInTrie({ parts, isIcann }, trie) {
564
553
  let node = trie;
565
554
  for (const part of parts) {
566
- let nextNode = node.succ[part];
567
- if (nextNode === undefined) {
568
- nextNode = { $: 0, succ: {} };
569
- node.succ[part] = nextNode;
555
+ let next = node.children[part];
556
+ if (next === undefined) {
557
+ next = { flag: 0, children: {} };
558
+ node.children[part] = next;
570
559
  }
571
- node = nextNode;
560
+ node = next;
572
561
  }
573
- node.$ = isIcann ? 1 : 2;
574
- return trie;
562
+ node.flag = isIcann ? 1 : 2;
575
563
  }
576
- let nextId = 0;
577
564
  /**
578
- * Compress the given `trie` into a DAWG (by compressing common suffixes as
579
- * well as prefixes). This form is very efficient but cannot be dumped as a
580
- * simple JSON into the file. The solution is to create intermediary variables
581
- * for each shared sub-tree, which are then used in the main DAWG.
565
+ * djb2 hash over `label`, computed backward. MUST stay identical to the
566
+ * load-time recomputation in `suffix-trie.ts` so edges remain hash-sorted.
582
567
  */
583
- function compressToDAWG(trie, name) {
584
- const nodesByHash = new Map();
585
- const replaceNodes = new Map();
586
- (function groupNodesByHash(node) {
587
- // Get a sorted list of next labels from this node
588
- const nexts = Object.entries(node.succ)
589
- .filter(([n]) => n !== '$')
590
- .sort();
591
- // Create a setter which can be used later to replace the value of a node.
592
- // Each node is associated with a lambda function accepting one argument:
593
- // the new value of the node. Because the context of the node (parent and
594
- // label) is captured in the closure, it allows to just call it later, in a
595
- // different context, to change the value of a given node in-place.
596
- nexts.forEach(([n, succ]) => {
597
- replaceNodes.set(succ, (newNode) => {
598
- node.succ[n] = newNode;
599
- });
600
- });
601
- // Compute a unique hash for this node recursively.
602
- const hash = `(${node.$},${[
603
- ...nexts.map(([c, succ]) => `${c},${groupNodesByHash(succ)}`),
604
- ].join('|')})`;
605
- // Keep track of all node's hashes
606
- let nodes = nodesByHash.get(hash);
607
- if (nodes === undefined) {
608
- nodes = [];
609
- nodesByHash.set(hash, nodes);
610
- }
611
- nodes.push(node);
612
- return hash;
613
- })(trie);
614
- // Given `nodesByHash`, which associates a list of nodes to each hash
615
- // encountered in the previous step, we will detect all the sub-trees being
616
- // seen more than once and store them in a variable to allow sharing with
617
- // different parts in the DAWG.
618
- const variables = [];
619
- nodesByHash.forEach((nodes) => {
620
- if (nodes.length > 1) {
621
- // Dump one of the nodes (they are all the same so it does not matter which one)
622
- variables.push(`_${nextId}: ITrie = ${JSON.stringify(convertToCompactTrie(nodes[0]))}`);
623
- // Replace all the other ones by the name of this new variable
624
- nodes.forEach((node) => {
625
- var _a;
626
- // @ts-expect-error replaceNodes callback expects ITrie, we pass string ref
627
- (_a = replaceNodes.get(node)) === null || _a === void 0 ? void 0 : _a(`_${nextId}`);
628
- });
629
- nextId += 1;
630
- }
631
- });
632
- const output = [];
633
- // Create TypeScript source code to declare all of these variables. Because
634
- // the value of nodes has been set to a value of the form '"_id"', we need to
635
- // replace this on the fly to '_id'. We use a RegExp for this.
636
- if (variables.length !== 0) {
637
- let variablesSourceCode = `const ${variables.join(',')};`;
638
- for (let i = 0; i < nextId; i += 1) {
639
- variablesSourceCode = variablesSourceCode.replace(new RegExp(`"_${i}"`, 'g'), `_${i}`);
640
- }
641
- output.push(variablesSourceCode);
642
- }
643
- // Dump the root of the DAWG as well, and perform the same replacement of _id
644
- // parts than for the variables above.
645
- let serializedTrie = JSON.stringify(convertToCompactTrie(trie));
646
- for (let i = 0; i < nextId; i += 1) {
647
- serializedTrie = serializedTrie.replace(new RegExp(`"_${i}"`, 'g'), `_${i}`);
568
+ function labelHash(label) {
569
+ let hash = 5381;
570
+ for (let i = label.length - 1; i >= 0; i -= 1) {
571
+ hash = (hash * 33) ^ label.charCodeAt(i);
648
572
  }
649
- output.push(`const ${name}: ITrie = ${serializedTrie};`);
650
- return output.join('\n');
573
+ return hash >>> 0;
651
574
  }
652
- function convertToTypeScriptSource(rules, exceptions, { includePrivate }) {
653
- return `
654
- export type ITrie = [${includePrivate ? '0 | 1 | 2' : '0 | 1'}, { [label: string]: ITrie}];
655
-
656
- export const exceptions: ITrie = (function() {
657
- ${compressToDAWG(exceptions, 'exceptions')}
658
- return exceptions;
659
- })();
660
-
661
- export const rules: ITrie = (function() {
662
- ${compressToDAWG(rules, 'rules')}
663
- return rules;
664
- })();
665
- `;
575
+ /**
576
+ * Flatten the given tries into a shared pool of nodes (identical sub-trees get
577
+ * the same id => DAWG compression). Returns the node pool and each root's id.
578
+ */
579
+ function flatten(roots) {
580
+ const idByKey = new Map();
581
+ const nodes = [];
582
+ const visit = (node) => {
583
+ const edges = Object.keys(node.children)
584
+ .sort()
585
+ .map((label) => ({ label, child: visit(node.children[label]) }));
586
+ // Identity key for DAWG dedup: same flag + same (label -> child) set. Built
587
+ // from the alpha-sorted edges so it is canonical; the stored copy is then
588
+ // re-sorted by hash because the lookup binary-searches edge hashes.
589
+ const key = `${node.flag}|${edges.map((e) => `${e.label}>${e.child}`).join(',')}`;
590
+ let id = idByKey.get(key);
591
+ if (id === undefined) {
592
+ edges.sort((a, b) => labelHash(a.label) - labelHash(b.label));
593
+ id = nodes.length;
594
+ nodes.push({ flag: node.flag, edges });
595
+ idByKey.set(key, id);
596
+ }
597
+ return id;
598
+ };
599
+ return { nodes, rootIds: roots.map(visit) };
666
600
  }
667
601
  var buildTrie = (body, { includePrivate }) => {
668
- const exceptions = { $: 0, succ: {} };
669
- const rules = { $: 0, succ: {} };
670
- // Iterate on public suffix rules
602
+ const rules = { flag: 0, children: {} };
603
+ const exceptions = { flag: 0, children: {} };
671
604
  parse(body, ({ rule, isIcann, isException }) => {
672
605
  if (isIcann || includePrivate) {
673
606
  insertInTrie({ isIcann, parts: rule.split('.').reverse() }, isException ? exceptions : rules);
674
607
  }
675
608
  });
676
- return convertToTypeScriptSource(rules, exceptions, { includePrivate });
609
+ const { nodes, rootIds } = flatten([rules, exceptions]);
610
+ const nodeFlags = [];
611
+ const edgeStart = [0];
612
+ const edgeLength = [];
613
+ const edgeChild = [];
614
+ let labelText = '';
615
+ for (const node of nodes) {
616
+ nodeFlags.push(node.flag);
617
+ for (const edge of node.edges) {
618
+ edgeLength.push(edge.label.length);
619
+ edgeChild.push(edge.child);
620
+ labelText += edge.label;
621
+ }
622
+ edgeStart.push(edgeLength.length);
623
+ }
624
+ // The serialized arrays ship as typed arrays (see the emitted code below):
625
+ // edgeChild/edgeStart as Uint16Array, edgeLength as Uint8Array. If the PSL
626
+ // ever outgrows those ranges the values would silently wrap and corrupt every
627
+ // lookup, so fail the build loudly instead. Headroom is large today (~600
628
+ // nodes / ~10k edges / max label 31 vs the 65535/255 ceilings). If this trips,
629
+ // widen the array(s) here AND in the two suffix-trie.ts loaders.
630
+ let maxEdgeLength = 0;
631
+ for (const length of edgeLength) {
632
+ if (length > maxEdgeLength) {
633
+ maxEdgeLength = length;
634
+ }
635
+ }
636
+ if (nodes.length > 65536) {
637
+ // edgeChild stores node ids in [0, nodes.length); max id must fit Uint16.
638
+ throw new Error(`trie builder: ${nodes.length} nodes exceeds the Uint16 edgeChild range (max 65536). Widen edgeChild + edgeStart to Uint32Array here and in suffix-trie.ts.`);
639
+ }
640
+ if (edgeLength.length > 65535) {
641
+ // edgeStart stores edge indices up to the edge count; must fit Uint16.
642
+ throw new Error(`trie builder: ${edgeLength.length} edges exceeds the Uint16 edgeStart range (max 65535). Widen edgeStart + edgeChild to Uint32Array here and in suffix-trie.ts.`);
643
+ }
644
+ if (maxEdgeLength > 255) {
645
+ throw new Error(`trie builder: label length ${maxEdgeLength} exceeds the Uint8 edgeLength range (max 255). Widen edgeLength to Uint16Array here and in suffix-trie.ts.`);
646
+ }
647
+ return `// Auto-generated flat public-suffix trie. Do not edit.
648
+ export const nodeFlags = /*#__PURE__*/ new Uint8Array([${nodeFlags.join(',')}]);
649
+ export const edgeStart = /*#__PURE__*/ new Uint16Array([${edgeStart.join(',')}]);
650
+ export const edgeLength = /*#__PURE__*/ new Uint8Array([${edgeLength.join(',')}]);
651
+ export const edgeChild = /*#__PURE__*/ new Uint16Array([${edgeChild.join(',')}]);
652
+ export const labelText = ${JSON.stringify(labelText)};
653
+ export const rulesRoot = ${rootIds[0]};
654
+ export const exceptionsRoot = ${rootIds[1]};
655
+ `;
677
656
  };
678
657
 
679
658
  function update () {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../node_modules/punycode/punycode.es6.js","../../src/parser.ts","../../src/find-base-dir.ts","../../src/list.ts","../../src/builders/hashes.ts","../../src/builders/trie.ts","../../src/update.ts"],"sourcesContent":["'use strict';\n\n/** Highest positive signed 32-bit float value */\nconst maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\n\n/** Bootstring parameters */\nconst base = 36;\nconst tMin = 1;\nconst tMax = 26;\nconst skew = 38;\nconst damp = 700;\nconst initialBias = 72;\nconst initialN = 128; // 0x80\nconst delimiter = '-'; // '\\x2D'\n\n/** Regular expressions */\nconst regexPunycode = /^xn--/;\nconst regexNonASCII = /[^\\0-\\x7F]/; // Note: U+007F DEL is excluded too.\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\n\n/** Error messages */\nconst errors = {\n\t'overflow': 'Overflow: input needs wider integers to process',\n\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t'invalid-input': 'Invalid input'\n};\n\n/** Convenience shortcuts */\nconst baseMinusTMin = base - tMin;\nconst floor = Math.floor;\nconst stringFromCharCode = String.fromCharCode;\n\n/*--------------------------------------------------------------------------*/\n\n/**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\nfunction error(type) {\n\tthrow new RangeError(errors[type]);\n}\n\n/**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\nfunction map(array, callback) {\n\tconst result = [];\n\tlet length = array.length;\n\twhile (length--) {\n\t\tresult[length] = callback(array[length]);\n\t}\n\treturn result;\n}\n\n/**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {String} A new string of characters returned by the callback\n * function.\n */\nfunction mapDomain(domain, callback) {\n\tconst parts = domain.split('@');\n\tlet result = '';\n\tif (parts.length > 1) {\n\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t// the local part (i.e. everything up to `@`) intact.\n\t\tresult = parts[0] + '@';\n\t\tdomain = parts[1];\n\t}\n\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\tdomain = domain.replace(regexSeparators, '\\x2E');\n\tconst labels = domain.split('.');\n\tconst encoded = map(labels, callback).join('.');\n\treturn result + encoded;\n}\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see <https://mathiasbynens.be/notes/javascript-encoding>\n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\nfunction ucs2decode(string) {\n\tconst output = [];\n\tlet counter = 0;\n\tconst length = string.length;\n\twhile (counter < length) {\n\t\tconst value = string.charCodeAt(counter++);\n\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t// It's a high surrogate, and there is a next character.\n\t\t\tconst extra = string.charCodeAt(counter++);\n\t\t\tif ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t} else {\n\t\t\t\t// It's an unmatched surrogate; only append this code unit, in case the\n\t\t\t\t// next code unit is the high surrogate of a surrogate pair.\n\t\t\t\toutput.push(value);\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t} else {\n\t\t\toutput.push(value);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\nconst ucs2encode = codePoints => String.fromCodePoint(...codePoints);\n\n/**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\nconst basicToDigit = function(codePoint) {\n\tif (codePoint >= 0x30 && codePoint < 0x3A) {\n\t\treturn 26 + (codePoint - 0x30);\n\t}\n\tif (codePoint >= 0x41 && codePoint < 0x5B) {\n\t\treturn codePoint - 0x41;\n\t}\n\tif (codePoint >= 0x61 && codePoint < 0x7B) {\n\t\treturn codePoint - 0x61;\n\t}\n\treturn base;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\nconst digitToBasic = function(digit, flag) {\n\t// 0..25 map to ASCII a..z or A..Z\n\t// 26..35 map to ASCII 0..9\n\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\nconst adapt = function(delta, numPoints, firstTime) {\n\tlet k = 0;\n\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\tdelta += floor(delta / numPoints);\n\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\tdelta = floor(delta / baseMinusTMin);\n\t}\n\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\nconst decode = function(input) {\n\t// Don't use UCS-2.\n\tconst output = [];\n\tconst inputLength = input.length;\n\tlet i = 0;\n\tlet n = initialN;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points: let `basic` be the number of input code\n\t// points before the last delimiter, or `0` if there is none, then copy\n\t// the first basic code points to the output.\n\n\tlet basic = input.lastIndexOf(delimiter);\n\tif (basic < 0) {\n\t\tbasic = 0;\n\t}\n\n\tfor (let j = 0; j < basic; ++j) {\n\t\t// if it's not a basic code point\n\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\terror('not-basic');\n\t\t}\n\t\toutput.push(input.charCodeAt(j));\n\t}\n\n\t// Main decoding loop: start just after the last delimiter if any basic code\n\t// points were copied; start at the beginning otherwise.\n\n\tfor (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t// `index` is the index of the next character to be consumed.\n\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t// which gets added to `i`. The overflow checking is easier\n\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t// value at the end to obtain `delta`.\n\t\tconst oldi = i;\n\t\tfor (let w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\tif (index >= inputLength) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\n\t\t\tconst digit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\tif (digit >= base) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\t\t\tif (digit > floor((maxInt - i) / w)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\tif (digit < t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst baseMinusT = base - t;\n\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tw *= baseMinusT;\n\n\t\t}\n\n\t\tconst out = output.length + 1;\n\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t// incrementing `n` each time, so we'll fix that now:\n\t\tif (floor(i / out) > maxInt - n) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tn += floor(i / out);\n\t\ti %= out;\n\n\t\t// Insert `n` at position `i` of the output.\n\t\toutput.splice(i++, 0, n);\n\n\t}\n\n\treturn String.fromCodePoint(...output);\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\nconst encode = function(input) {\n\tconst output = [];\n\n\t// Convert the input in UCS-2 to an array of Unicode code points.\n\tinput = ucs2decode(input);\n\n\t// Cache the length.\n\tconst inputLength = input.length;\n\n\t// Initialize the state.\n\tlet n = initialN;\n\tlet delta = 0;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points.\n\tfor (const currentValue of input) {\n\t\tif (currentValue < 0x80) {\n\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t}\n\t}\n\n\tconst basicLength = output.length;\n\tlet handledCPCount = basicLength;\n\n\t// `handledCPCount` is the number of code points that have been handled;\n\t// `basicLength` is the number of basic code points.\n\n\t// Finish the basic string with a delimiter unless it's empty.\n\tif (basicLength) {\n\t\toutput.push(delimiter);\n\t}\n\n\t// Main encoding loop:\n\twhile (handledCPCount < inputLength) {\n\n\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t// larger one:\n\t\tlet m = maxInt;\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\tm = currentValue;\n\t\t\t}\n\t\t}\n\n\t\t// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,\n\t\t// but guard against overflow.\n\t\tconst handledCPCountPlusOne = handledCPCount + 1;\n\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\tn = m;\n\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\t\t\tif (currentValue === n) {\n\t\t\t\t// Represent delta as a generalized variable-length integer.\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = base; /* no condition */; k += base) {\n\t\t\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst qMinusT = q - t;\n\t\t\t\t\tconst baseMinusT = base - t;\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t);\n\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t}\n\n\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\t++handledCPCount;\n\t\t\t}\n\t\t}\n\n\t\t++delta;\n\t\t++n;\n\n\t}\n\treturn output.join('');\n};\n\n/**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\nconst toUnicode = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexPunycode.test(string)\n\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t: string;\n\t});\n};\n\n/**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\nconst toASCII = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexNonASCII.test(string)\n\t\t\t? 'xn--' + encode(string)\n\t\t\t: string;\n\t});\n};\n\n/*--------------------------------------------------------------------------*/\n\n/** Define the public API */\nconst punycode = {\n\t/**\n\t * A string representing the current Punycode.js version number.\n\t * @memberOf punycode\n\t * @type String\n\t */\n\t'version': '2.3.1',\n\t/**\n\t * An object of methods to convert from JavaScript's internal character\n\t * representation (UCS-2) to Unicode code points, and back.\n\t * @see <https://mathiasbynens.be/notes/javascript-encoding>\n\t * @memberOf punycode\n\t * @type Object\n\t */\n\t'ucs2': {\n\t\t'decode': ucs2decode,\n\t\t'encode': ucs2encode\n\t},\n\t'decode': decode,\n\t'encode': encode,\n\t'toASCII': toASCII,\n\t'toUnicode': toUnicode\n};\n\nexport { ucs2decode, ucs2encode, decode, encode, toASCII, toUnicode };\nexport default punycode;\n","import { toASCII } from 'punycode/';\n\nexport interface IRule {\n isException: boolean;\n isIcann: boolean;\n isNormal: boolean;\n isWildcard: boolean;\n rule: string;\n}\n\n/**\n * Parse public suffix list and invoke callback on each rule.\n */\nexport default (body: string, cb: (_: IRule) => void) => {\n const beginPrivateDomains = '// ===begin private domains===';\n let isIcann = true;\n\n // Iterate on lines and extract public suffix rules\n const lines: string[] = body.split('\\n');\n for (let line of lines) {\n line = line.trim().toLowerCase();\n\n // Ignore comments\n if (line.length === 0 || line.startsWith('//')) {\n if (line.startsWith(beginPrivateDomains)) {\n isIcann = false;\n }\n\n continue;\n }\n\n let isException = false;\n let isWildcard = false;\n let isNormal = false;\n\n // Select correct section to insert the rule\n if (line.startsWith('!')) {\n isException = true;\n line = line.slice(1);\n } else if (line.startsWith('*.')) {\n isWildcard = true;\n } else {\n isNormal = true;\n }\n\n // Specification says that we should only consider the content of a line up\n // to the first whitespace encountered.\n const spaceIndex = line.indexOf(' ');\n if (spaceIndex !== -1) {\n line = line.slice(0, spaceIndex);\n }\n\n // If suffix is not ascii, we index the suffix twice so that we support IDNA\n // labels as well. This allows to not have to perform the conversion at\n // runtime.\n const encoded = toASCII(line);\n if (line !== encoded) {\n cb({\n isException,\n isIcann,\n isNormal,\n isWildcard,\n rule: encoded,\n });\n }\n\n cb({\n isException,\n isIcann,\n isNormal,\n isWildcard,\n rule: line,\n });\n }\n};\n","import { existsSync } from 'fs';\nimport { resolve } from 'path';\n\nexport default function (target: string): string {\n let baseDir = __dirname;\n while (!existsSync(resolve(baseDir, target))) {\n baseDir = resolve(baseDir, '../');\n }\n\n return resolve(baseDir, target);\n}\n","import findBaseDir from './find-base-dir';\nimport { readFileSync } from 'fs';\n\nexport default function (): string {\n return readFileSync(findBaseDir('./publicsuffix/public_suffix_list.dat'), {\n encoding: 'utf-8',\n });\n}\n","/**\n * This builder implements a probabilistic data-structure to store the public\n * suffixes from Mozilla's 'publicsuffix' project. The goals are:\n *\n * 1. Allow storing the parsed rules in a very compact form (<30KB)\n * 2. Allow super fast load time with no parsing required (typed array)\n * 2. Super fast lookup times (~2M+ per second)\n *\n * These are achieved by hashing each available suffix as a 32bits number and\n * storing them in a typed array which is bundled in the library itself. This\n * way the only cost of loading the rules is paid by the JavaScript engine\n * loading the source and the size of the rules is ~29KB. Matching is also\n * extremely fast, at around 2M+ lookups per second.\n *\n * **WARNING**: The drawback of this structure is that, because we use hashes of\n * suffixes instead of their initial values, there can be collisions (think\n * bloom filters). Some future work involves estimating the probability of\n * collisions. Only use this structure if you are fine with this limitation and\n * need the most compact/fast data structure available.\n *\n * Data Structure\n * ==============\n *\n * The basic idea behind the packed hashes structure is that suffixes will be\n * grouped by number of labels then hashed to 32bits integers using a fast\n * hashing function. For examples:\n *\n * 1 label:\n * com -> hash(com)\n * fr -> hash(fr)\n * gov -> hash(gov)\n * 2 labels:\n * co.uk -> hash(co.uk)\n *\n * Then the hashes are organized in a typed array from least number of labels to\n * most number of labels, and in each section, hashes are sorted so that we can\n * perform lookups using a binary search:\n *\n * |#1 length|suffix 1|suffix 2|...|#2 length|suffix 1|suffix 2|...|...\n * ^ ^ number of suffixes with 2 labels\n * | number of suffix with 1 label\n *\n * In the example above:\n *\n * 3|hash(com)|hash(fr)|hash(gov)|1|hash(co.uk)\n * ^ ^ we have on suffix with 2 labels (co.uk)\n * | we have 3 suffixes with one label\n *\n * In practice, the data-structure is slightly more complex as we have to handle\n * the ICANN and PRIVATE sections of the list separately (which allows to pick\n * one or the other at runtime; or both, which is the default) as well as\n * wildcards and exceptions rules. The structure looks more like:\n *\n * |icann exceptions|private exceptions|icann wildcards|private wildcards|icann rules|private rules\n *\n * Still ordered from least number of labels to most number of labels. This\n * allows the matching to be a forward progression from beginning to end,\n * potentially skipping some sections (e.g.: private) by just incrementing the\n * index.\n *\n * Finding a Match\n * ===============\n *\n * Finding a match can be done efficiently, without any string copy and by a\n * single pass over the input (from end to beginning). The algorithm is as\n * follows:\n *\n * - For each character `c` in hostname, from end to start:\n * 1. If `c` is '.' then we reached the end of a label:\n * * Use a binary search in the section containing suffixes of the same\n * size as our current label to check if our hash is there.\n * * Move forward to the next section by incrementing the index by the\n * number of suffixes in this section.\n * 2. Update the hash with the current character\n *\n * This does not account for wildcards and exceptions, but explains the general\n * idea of the matching algorithm. Have a look at the source bellow for more\n * details.\n *\n * Some nice properties of this algorithm:\n * 1. Pretty straight-forward implementation\n * 2. Matching is always going forward in the array\n * 3. Sections can be skipped by just incrementing the index\n * 4. Hash can be computed on-the-fly from end to start without any string copy\n */\n\nimport parse from '../parser';\n\n/**\n * Compute 32 bits hash of `str` backward.\n */\nfunction fastHash(str: string): number {\n let hash = 5381;\n for (let j = str.length - 1; j >= 0; j -= 1) {\n hash = (hash * 33) ^ str.charCodeAt(j);\n }\n return hash >>> 0;\n}\n\ninterface IRules {\n icann: number[][];\n priv: number[][];\n}\n\n/**\n * Build packed typed array given the raw public list as a string.\n */\nexport default (body: string) => {\n const rules: IRules = {\n icann: [],\n priv: [],\n };\n const wildcards: IRules = {\n icann: [],\n priv: [],\n };\n const exceptions: IRules = {\n icann: [],\n priv: [],\n };\n\n // Keep track of maximum number of labels seen in a given rule. This allows us\n // to make sure that all sections of the typed array (wildcards, exceptions\n // and normal rules) have the same size and we do not need to check that while\n // matching.\n let maximumNumberOfLabels = 0;\n\n // Iterate on public suffix rules\n parse(body, ({ rule, isIcann, isException, isWildcard, isNormal }) => {\n // Select correct section to insert the rule\n let hashesPerLabels = null;\n if (isException) {\n hashesPerLabels = isIcann ? exceptions.icann : exceptions.priv;\n } else if (isWildcard) {\n hashesPerLabels = isIcann ? wildcards.icann : wildcards.priv;\n rule = rule.slice(2);\n } else if (isNormal) {\n hashesPerLabels = isIcann ? rules.icann : rules.priv;\n }\n\n if (hashesPerLabels === null) {\n return;\n }\n\n // Count number of labels in this suffix\n const numberOfLabels = rule.split('.').length;\n\n // Experimentally, we start ignoring suffixes with only one label since the\n // fallback to '*' will yield the same result. This helps reduce the size of\n // the bundle further and speed-up matching. One potential side-effect is\n // that we might not accurately return the information about if a suffix is\n // from the ICANN or PRIVATE section.\n if (\n numberOfLabels === 1 &&\n (hashesPerLabels === rules.icann || hashesPerLabels === rules.priv)\n ) {\n return;\n }\n\n maximumNumberOfLabels = Math.max(maximumNumberOfLabels, numberOfLabels);\n let hashesForLabel = hashesPerLabels[numberOfLabels];\n if (hashesForLabel === undefined) {\n hashesForLabel = [];\n hashesPerLabels[numberOfLabels] = hashesForLabel;\n }\n\n hashesForLabel.push(fastHash(rule));\n });\n\n // Pack everything together\n const chunks: number[][] = [];\n const pushHashes = (hashes: number[] = []) => {\n chunks.push([\n hashes.length,\n ...hashes.sort((a, b) => {\n if (a < b) {\n return -1;\n }\n if (a > b) {\n return 1;\n }\n return 0;\n }),\n ]);\n };\n\n for (let label = 1; label <= maximumNumberOfLabels; label += 1) {\n pushHashes(exceptions.icann[label]);\n pushHashes(exceptions.priv[label]);\n pushHashes(wildcards.icann[label]);\n pushHashes(wildcards.priv[label]);\n pushHashes(rules.icann[label]);\n pushHashes(rules.priv[label]);\n }\n\n return new Uint32Array([\n maximumNumberOfLabels,\n ...([] as number[]).concat(...chunks),\n ]);\n};\n","/**\n * This builder implements a fast and compact DAWG data-structure (a.k.a.:\n * direct acyclic word graph, with suffix and prefix compression of the\n * top-level domains) using JavaScript Objects. It is a good trade-off between\n * correctness, speed and space. This is much faster then using a linear scan\n * over all the rules, but slightly slower than the probabilistic\n * data-structure implemented in `bin/builders/hashes.js`.\n *\n * Here is a simple example:\n *\n * co.uk\n * gov.uk\n * fr\n *\n * <root>\n * |_ uk\n * |_ co *\n * |_ gov *\n * |_ fr *\n *\n * Finding a match is then a matter of iterating on labels of a hostname\n * backward and following the branches of the Trie. Whenever we find a terminal\n * node (indicated with a '*' above), we consider this a match.\n */\n\nimport parse from '../parser';\n\ninterface ITrie {\n $: 0 | 1 | 2;\n succ: Record<string, ITrie>;\n}\n\ntype CompactTrie = [0 | 1 | 2, Record<string, CompactTrie>];\n\nfunction convertToCompactTrie(trie: ITrie): CompactTrie {\n return [\n trie.$,\n Object.fromEntries(\n Object.entries(trie.succ).map(([label, succ]) => [\n label,\n typeof succ === 'string' ? succ : convertToCompactTrie(succ),\n ]),\n ),\n ];\n}\n\n/**\n * Insert a public suffix rule in the `trie`.\n */\nfunction insertInTrie(\n {\n parts,\n isIcann,\n }: {\n parts: string[];\n isIcann: boolean;\n },\n trie: ITrie,\n): ITrie {\n let node: ITrie = trie;\n\n for (const part of parts) {\n let nextNode = node.succ[part];\n if (nextNode === undefined) {\n nextNode = { $: 0, succ: {} };\n node.succ[part] = nextNode;\n }\n\n node = nextNode;\n }\n\n node.$ = isIcann ? 1 : 2;\n\n return trie;\n}\n\nlet nextId = 0;\n\n/**\n * Compress the given `trie` into a DAWG (by compressing common suffixes as\n * well as prefixes). This form is very efficient but cannot be dumped as a\n * simple JSON into the file. The solution is to create intermediary variables\n * for each shared sub-tree, which are then used in the main DAWG.\n */\nfunction compressToDAWG(trie: ITrie, name: string): string {\n const nodesByHash = new Map<string, ITrie[]>();\n const replaceNodes = new Map<ITrie, (newNode: ITrie) => void>();\n\n (function groupNodesByHash(node: ITrie): string {\n // Get a sorted list of next labels from this node\n const nexts = Object.entries(node.succ)\n .filter(([n]) => n !== '$')\n .sort();\n\n // Create a setter which can be used later to replace the value of a node.\n // Each node is associated with a lambda function accepting one argument:\n // the new value of the node. Because the context of the node (parent and\n // label) is captured in the closure, it allows to just call it later, in a\n // different context, to change the value of a given node in-place.\n nexts.forEach(([n, succ]) => {\n replaceNodes.set(succ, (newNode: ITrie) => {\n node.succ[n] = newNode;\n });\n });\n\n // Compute a unique hash for this node recursively.\n const hash = `(${node.$},${[\n ...nexts.map(([c, succ]) => `${c},${groupNodesByHash(succ)}`),\n ].join('|')})`;\n\n // Keep track of all node's hashes\n let nodes: undefined | ITrie[] = nodesByHash.get(hash);\n if (nodes === undefined) {\n nodes = [];\n nodesByHash.set(hash, nodes);\n }\n nodes.push(node);\n\n return hash;\n })(trie);\n\n // Given `nodesByHash`, which associates a list of nodes to each hash\n // encountered in the previous step, we will detect all the sub-trees being\n // seen more than once and store them in a variable to allow sharing with\n // different parts in the DAWG.\n const variables: string[] = [];\n nodesByHash.forEach((nodes) => {\n if (nodes.length > 1) {\n // Dump one of the nodes (they are all the same so it does not matter which one)\n variables.push(\n `_${nextId}: ITrie = ${JSON.stringify(\n convertToCompactTrie(nodes[0]!),\n )}`,\n );\n\n // Replace all the other ones by the name of this new variable\n nodes.forEach((node) => {\n // @ts-expect-error replaceNodes callback expects ITrie, we pass string ref\n replaceNodes.get(node)?.(`_${nextId}`);\n });\n\n nextId += 1;\n }\n });\n\n const output = [];\n\n // Create TypeScript source code to declare all of these variables. Because\n // the value of nodes has been set to a value of the form '\"_id\"', we need to\n // replace this on the fly to '_id'. We use a RegExp for this.\n if (variables.length !== 0) {\n let variablesSourceCode = `const ${variables.join(',')};`;\n for (let i = 0; i < nextId; i += 1) {\n variablesSourceCode = variablesSourceCode.replace(\n new RegExp(`\"_${i}\"`, 'g'),\n `_${i}`,\n );\n }\n output.push(variablesSourceCode);\n }\n\n // Dump the root of the DAWG as well, and perform the same replacement of _id\n // parts than for the variables above.\n let serializedTrie = JSON.stringify(convertToCompactTrie(trie));\n for (let i = 0; i < nextId; i += 1) {\n serializedTrie = serializedTrie.replace(\n new RegExp(`\"_${i}\"`, 'g'),\n `_${i}`,\n );\n }\n output.push(`const ${name}: ITrie = ${serializedTrie};`);\n\n return output.join('\\n');\n}\n\nfunction convertToTypeScriptSource(\n rules: ITrie,\n exceptions: ITrie,\n { includePrivate }: { includePrivate: boolean },\n): string {\n return `\nexport type ITrie = [${\n includePrivate ? '0 | 1 | 2' : '0 | 1'\n }, { [label: string]: ITrie}];\n\nexport const exceptions: ITrie = (function() {\n ${compressToDAWG(exceptions, 'exceptions')}\n return exceptions;\n})();\n\nexport const rules: ITrie = (function() {\n ${compressToDAWG(rules, 'rules')}\n return rules;\n})();\n`;\n}\n\nexport default (\n body: string,\n { includePrivate }: { includePrivate: boolean },\n) => {\n const exceptions: ITrie = { $: 0, succ: {} };\n const rules: ITrie = { $: 0, succ: {} };\n\n // Iterate on public suffix rules\n parse(body, ({ rule, isIcann, isException }) => {\n if (isIcann || includePrivate) {\n insertInTrie(\n { isIcann, parts: rule.split('.').reverse() },\n isException ? exceptions : rules,\n );\n }\n });\n\n return convertToTypeScriptSource(rules, exceptions, { includePrivate });\n};\n","import { writeFileSync } from 'fs';\n\nimport findBaseDir from './find-base-dir';\nimport loadPublicSuffixList from './list';\nimport buildHashes from './builders/hashes';\nimport buildTrie from './builders/trie';\n\nexport default function () {\n console.log('Updating rules...');\n const publicSuffixList = loadPublicSuffixList();\n\n // Build trie and update TypeScript file\n writeFileSync(\n findBaseDir('./tldts/src/data/trie.ts'),\n buildTrie(publicSuffixList, { includePrivate: true }),\n 'utf-8',\n );\n\n // Build trie and update TypeScript file (ICANN only)\n writeFileSync(\n findBaseDir('./tldts-icann/src/data/trie.ts'),\n buildTrie(publicSuffixList, { includePrivate: false }),\n 'utf-8',\n );\n\n // Build hashes and update TypeScript file\n const packed = buildHashes(publicSuffixList);\n writeFileSync(\n findBaseDir('./tldts-experimental/src/data/hashes.ts'),\n `\n// Code automatically generated using ./bin/builders/hashes.ts\nexport default new Uint32Array([${Array.from(packed).toString()}]);\n`,\n 'utf-8',\n );\n}\n"],"names":["existsSync","resolve","readFileSync","writeFileSync"],"mappings":";;;;;AAEA;AACA,MAAM,MAAM,GAAG,UAAU,CAAC;;AAE1B;AACA,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,GAAG;AAChB,MAAM,WAAW,GAAG,EAAE;AACtB,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,SAAS,GAAG,GAAG,CAAC;AAItB,MAAM,aAAa,GAAG,YAAY,CAAC;AACnC,MAAM,eAAe,GAAG,2BAA2B,CAAC;;AAEpD;AACA,MAAM,MAAM,GAAG;AACf,CAAC,UAAU,EAAE,iDAAiD;AAC9D,CAAC,WAAW,EAAE,gDAAgD;AAC9D,CAAC,eAAe,EAAE;AAClB,CAAC;;AAED;AACA,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI;AACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;AACxB,MAAM,kBAAkB,GAAG,MAAM,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AAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;;AAGvC,IAAA,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,KAAI;AAC7C,QAAA,IAAI,OAAO,IAAI,cAAc,EAAE;YAC7B,YAAY,CACV,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,EAC7C,WAAW,GAAG,UAAU,GAAG,KAAK,CACjC;QACH;AACF,IAAA,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,cAAc,EAAE,CAAC;AACzE,CAAC;;AChNa,eAAA,IAAA;AACZ,IAAA,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAChC,IAAA,MAAM,gBAAgB,GAAG,oBAAoB,EAAE;;AAG/C,IAAAC,gBAAa,CACX,WAAW,CAAC,0BAA0B,CAAC,EACvC,SAAS,CAAC,gBAAgB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EACrD,OAAO,CACR;;AAGD,IAAAA,gBAAa,CACX,WAAW,CAAC,gCAAgC,CAAC,EAC7C,SAAS,CAAC,gBAAgB,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EACtD,OAAO,CACR;;AAGD,IAAA,MAAM,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC;AAC5C,IAAAA,gBAAa,CACX,WAAW,CAAC,yCAAyC,CAAC,EACtD;;AAE8B,gCAAA,EAAA,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;CAC9D,EACG,OAAO,CACR;AACH;;;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.js","sources":["../../../../node_modules/punycode/punycode.es6.js","../../src/parser.ts","../../src/find-base-dir.ts","../../src/list.ts","../../src/builders/hashes.ts","../../src/builders/trie.ts","../../src/update.ts"],"sourcesContent":["'use strict';\n\n/** Highest positive signed 32-bit float value */\nconst maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\n\n/** Bootstring parameters */\nconst base = 36;\nconst tMin = 1;\nconst tMax = 26;\nconst skew = 38;\nconst damp = 700;\nconst initialBias = 72;\nconst initialN = 128; // 0x80\nconst delimiter = '-'; // '\\x2D'\n\n/** Regular expressions */\nconst regexPunycode = /^xn--/;\nconst regexNonASCII = /[^\\0-\\x7F]/; // Note: U+007F DEL is excluded too.\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\n\n/** Error messages */\nconst errors = {\n\t'overflow': 'Overflow: input needs wider integers to process',\n\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t'invalid-input': 'Invalid input'\n};\n\n/** Convenience shortcuts */\nconst baseMinusTMin = base - tMin;\nconst floor = Math.floor;\nconst stringFromCharCode = String.fromCharCode;\n\n/*--------------------------------------------------------------------------*/\n\n/**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\nfunction error(type) {\n\tthrow new RangeError(errors[type]);\n}\n\n/**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\nfunction map(array, callback) {\n\tconst result = [];\n\tlet length = array.length;\n\twhile (length--) {\n\t\tresult[length] = callback(array[length]);\n\t}\n\treturn result;\n}\n\n/**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {String} A new string of characters returned by the callback\n * function.\n */\nfunction mapDomain(domain, callback) {\n\tconst parts = domain.split('@');\n\tlet result = '';\n\tif (parts.length > 1) {\n\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t// the local part (i.e. everything up to `@`) intact.\n\t\tresult = parts[0] + '@';\n\t\tdomain = parts[1];\n\t}\n\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\tdomain = domain.replace(regexSeparators, '\\x2E');\n\tconst labels = domain.split('.');\n\tconst encoded = map(labels, callback).join('.');\n\treturn result + encoded;\n}\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see <https://mathiasbynens.be/notes/javascript-encoding>\n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\nfunction ucs2decode(string) {\n\tconst output = [];\n\tlet counter = 0;\n\tconst length = string.length;\n\twhile (counter < length) {\n\t\tconst value = string.charCodeAt(counter++);\n\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t// It's a high surrogate, and there is a next character.\n\t\t\tconst extra = string.charCodeAt(counter++);\n\t\t\tif ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t} else {\n\t\t\t\t// It's an unmatched surrogate; only append this code unit, in case the\n\t\t\t\t// next code unit is the high surrogate of a surrogate pair.\n\t\t\t\toutput.push(value);\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t} else {\n\t\t\toutput.push(value);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\nconst ucs2encode = codePoints => String.fromCodePoint(...codePoints);\n\n/**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\nconst basicToDigit = function(codePoint) {\n\tif (codePoint >= 0x30 && codePoint < 0x3A) {\n\t\treturn 26 + (codePoint - 0x30);\n\t}\n\tif (codePoint >= 0x41 && codePoint < 0x5B) {\n\t\treturn codePoint - 0x41;\n\t}\n\tif (codePoint >= 0x61 && codePoint < 0x7B) {\n\t\treturn codePoint - 0x61;\n\t}\n\treturn base;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\nconst digitToBasic = function(digit, flag) {\n\t// 0..25 map to ASCII a..z or A..Z\n\t// 26..35 map to ASCII 0..9\n\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\nconst adapt = function(delta, numPoints, firstTime) {\n\tlet k = 0;\n\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\tdelta += floor(delta / numPoints);\n\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\tdelta = floor(delta / baseMinusTMin);\n\t}\n\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\nconst decode = function(input) {\n\t// Don't use UCS-2.\n\tconst output = [];\n\tconst inputLength = input.length;\n\tlet i = 0;\n\tlet n = initialN;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points: let `basic` be the number of input code\n\t// points before the last delimiter, or `0` if there is none, then copy\n\t// the first basic code points to the output.\n\n\tlet basic = input.lastIndexOf(delimiter);\n\tif (basic < 0) {\n\t\tbasic = 0;\n\t}\n\n\tfor (let j = 0; j < basic; ++j) {\n\t\t// if it's not a basic code point\n\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\terror('not-basic');\n\t\t}\n\t\toutput.push(input.charCodeAt(j));\n\t}\n\n\t// Main decoding loop: start just after the last delimiter if any basic code\n\t// points were copied; start at the beginning otherwise.\n\n\tfor (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t// `index` is the index of the next character to be consumed.\n\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t// which gets added to `i`. The overflow checking is easier\n\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t// value at the end to obtain `delta`.\n\t\tconst oldi = i;\n\t\tfor (let w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\tif (index >= inputLength) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\n\t\t\tconst digit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\tif (digit >= base) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\t\t\tif (digit > floor((maxInt - i) / w)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\tif (digit < t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst baseMinusT = base - t;\n\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tw *= baseMinusT;\n\n\t\t}\n\n\t\tconst out = output.length + 1;\n\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t// incrementing `n` each time, so we'll fix that now:\n\t\tif (floor(i / out) > maxInt - n) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tn += floor(i / out);\n\t\ti %= out;\n\n\t\t// Insert `n` at position `i` of the output.\n\t\toutput.splice(i++, 0, n);\n\n\t}\n\n\treturn String.fromCodePoint(...output);\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\nconst encode = function(input) {\n\tconst output = [];\n\n\t// Convert the input in UCS-2 to an array of Unicode code points.\n\tinput = ucs2decode(input);\n\n\t// Cache the length.\n\tconst inputLength = input.length;\n\n\t// Initialize the state.\n\tlet n = initialN;\n\tlet delta = 0;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points.\n\tfor (const currentValue of input) {\n\t\tif (currentValue < 0x80) {\n\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t}\n\t}\n\n\tconst basicLength = output.length;\n\tlet handledCPCount = basicLength;\n\n\t// `handledCPCount` is the number of code points that have been handled;\n\t// `basicLength` is the number of basic code points.\n\n\t// Finish the basic string with a delimiter unless it's empty.\n\tif (basicLength) {\n\t\toutput.push(delimiter);\n\t}\n\n\t// Main encoding loop:\n\twhile (handledCPCount < inputLength) {\n\n\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t// larger one:\n\t\tlet m = maxInt;\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\tm = currentValue;\n\t\t\t}\n\t\t}\n\n\t\t// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,\n\t\t// but guard against overflow.\n\t\tconst handledCPCountPlusOne = handledCPCount + 1;\n\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\tn = m;\n\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\t\t\tif (currentValue === n) {\n\t\t\t\t// Represent delta as a generalized variable-length integer.\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = base; /* no condition */; k += base) {\n\t\t\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst qMinusT = q - t;\n\t\t\t\t\tconst baseMinusT = base - t;\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t);\n\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t}\n\n\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\t++handledCPCount;\n\t\t\t}\n\t\t}\n\n\t\t++delta;\n\t\t++n;\n\n\t}\n\treturn output.join('');\n};\n\n/**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\nconst toUnicode = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexPunycode.test(string)\n\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t: string;\n\t});\n};\n\n/**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\nconst toASCII = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexNonASCII.test(string)\n\t\t\t? 'xn--' + encode(string)\n\t\t\t: string;\n\t});\n};\n\n/*--------------------------------------------------------------------------*/\n\n/** Define the public API */\nconst punycode = {\n\t/**\n\t * A string representing the current Punycode.js version number.\n\t * @memberOf punycode\n\t * @type String\n\t */\n\t'version': '2.3.1',\n\t/**\n\t * An object of methods to convert from JavaScript's internal character\n\t * representation (UCS-2) to Unicode code points, and back.\n\t * @see <https://mathiasbynens.be/notes/javascript-encoding>\n\t * @memberOf punycode\n\t * @type Object\n\t */\n\t'ucs2': {\n\t\t'decode': ucs2decode,\n\t\t'encode': ucs2encode\n\t},\n\t'decode': decode,\n\t'encode': encode,\n\t'toASCII': toASCII,\n\t'toUnicode': toUnicode\n};\n\nexport { ucs2decode, ucs2encode, decode, encode, toASCII, toUnicode };\nexport default punycode;\n","import { toASCII } from 'punycode/';\n\nexport interface IRule {\n isException: boolean;\n isIcann: boolean;\n isNormal: boolean;\n isWildcard: boolean;\n rule: string;\n}\n\n/**\n * Parse public suffix list and invoke callback on each rule.\n */\nexport default (body: string, cb: (_: IRule) => void) => {\n const beginPrivateDomains = '// ===begin private domains===';\n let isIcann = true;\n\n // Iterate on lines and extract public suffix rules\n const lines: string[] = body.split('\\n');\n for (let line of lines) {\n line = line.trim().toLowerCase();\n\n // Ignore comments\n if (line.length === 0 || line.startsWith('//')) {\n if (line.startsWith(beginPrivateDomains)) {\n isIcann = false;\n }\n\n continue;\n }\n\n let isException = false;\n let isWildcard = false;\n let isNormal = false;\n\n // Select correct section to insert the rule\n if (line.startsWith('!')) {\n isException = true;\n line = line.slice(1);\n } else if (line.startsWith('*.')) {\n isWildcard = true;\n } else {\n isNormal = true;\n }\n\n // Specification says that we should only consider the content of a line up\n // to the first whitespace encountered.\n const spaceIndex = line.indexOf(' ');\n if (spaceIndex !== -1) {\n line = line.slice(0, spaceIndex);\n }\n\n // If suffix is not ascii, we index the suffix twice so that we support IDNA\n // labels as well. This allows to not have to perform the conversion at\n // runtime.\n const encoded = toASCII(line);\n if (line !== encoded) {\n cb({\n isException,\n isIcann,\n isNormal,\n isWildcard,\n rule: encoded,\n });\n }\n\n cb({\n isException,\n isIcann,\n isNormal,\n isWildcard,\n rule: line,\n });\n }\n};\n","import { existsSync } from 'fs';\nimport { resolve } from 'path';\n\nexport default function (target: string): string {\n let baseDir = __dirname;\n while (!existsSync(resolve(baseDir, target))) {\n baseDir = resolve(baseDir, '../');\n }\n\n return resolve(baseDir, target);\n}\n","import findBaseDir from './find-base-dir';\nimport { readFileSync } from 'fs';\n\nexport default function (): string {\n return readFileSync(findBaseDir('./publicsuffix/public_suffix_list.dat'), {\n encoding: 'utf-8',\n });\n}\n","/**\n * This builder implements a probabilistic data-structure to store the public\n * suffixes from Mozilla's 'publicsuffix' project. The goals are:\n *\n * 1. Allow storing the parsed rules in a very compact form (<30KB)\n * 2. Allow super fast load time with no parsing required (typed array)\n * 2. Super fast lookup times (~2M+ per second)\n *\n * These are achieved by hashing each available suffix as a 32bits number and\n * storing them in a typed array which is bundled in the library itself. This\n * way the only cost of loading the rules is paid by the JavaScript engine\n * loading the source and the size of the rules is ~29KB. Matching is also\n * extremely fast, at around 2M+ lookups per second.\n *\n * **WARNING**: The drawback of this structure is that, because we use hashes of\n * suffixes instead of their initial values, there can be collisions (think\n * bloom filters). Some future work involves estimating the probability of\n * collisions. Only use this structure if you are fine with this limitation and\n * need the most compact/fast data structure available.\n *\n * Data Structure\n * ==============\n *\n * The basic idea behind the packed hashes structure is that suffixes will be\n * grouped by number of labels then hashed to 32bits integers using a fast\n * hashing function. For examples:\n *\n * 1 label:\n * com -> hash(com)\n * fr -> hash(fr)\n * gov -> hash(gov)\n * 2 labels:\n * co.uk -> hash(co.uk)\n *\n * Then the hashes are organized in a typed array from least number of labels to\n * most number of labels, and in each section, hashes are sorted so that we can\n * perform lookups using a binary search:\n *\n * |#1 length|suffix 1|suffix 2|...|#2 length|suffix 1|suffix 2|...|...\n * ^ ^ number of suffixes with 2 labels\n * | number of suffix with 1 label\n *\n * In the example above:\n *\n * 3|hash(com)|hash(fr)|hash(gov)|1|hash(co.uk)\n * ^ ^ we have on suffix with 2 labels (co.uk)\n * | we have 3 suffixes with one label\n *\n * In practice, the data-structure is slightly more complex as we have to handle\n * the ICANN and PRIVATE sections of the list separately (which allows to pick\n * one or the other at runtime; or both, which is the default) as well as\n * wildcards and exceptions rules. The structure looks more like:\n *\n * |icann exceptions|private exceptions|icann wildcards|private wildcards|icann rules|private rules\n *\n * Still ordered from least number of labels to most number of labels. This\n * allows the matching to be a forward progression from beginning to end,\n * potentially skipping some sections (e.g.: private) by just incrementing the\n * index.\n *\n * Finding a Match\n * ===============\n *\n * Finding a match can be done efficiently, without any string copy and by a\n * single pass over the input (from end to beginning). The algorithm is as\n * follows:\n *\n * - For each character `c` in hostname, from end to start:\n * 1. If `c` is '.' then we reached the end of a label:\n * * Use a binary search in the section containing suffixes of the same\n * size as our current label to check if our hash is there.\n * * Move forward to the next section by incrementing the index by the\n * number of suffixes in this section.\n * 2. Update the hash with the current character\n *\n * This does not account for wildcards and exceptions, but explains the general\n * idea of the matching algorithm. Have a look at the source bellow for more\n * details.\n *\n * Some nice properties of this algorithm:\n * 1. Pretty straight-forward implementation\n * 2. Matching is always going forward in the array\n * 3. Sections can be skipped by just incrementing the index\n * 4. Hash can be computed on-the-fly from end to start without any string copy\n */\n\nimport parse from '../parser';\n\n/**\n * Compute 32 bits hash of `str` backward.\n */\nfunction fastHash(str: string): number {\n let hash = 5381;\n for (let j = str.length - 1; j >= 0; j -= 1) {\n hash = (hash * 33) ^ str.charCodeAt(j);\n }\n return hash >>> 0;\n}\n\ninterface IRules {\n icann: number[][];\n priv: number[][];\n}\n\n/**\n * Build packed typed array given the raw public list as a string.\n */\nexport default (body: string) => {\n const rules: IRules = {\n icann: [],\n priv: [],\n };\n const wildcards: IRules = {\n icann: [],\n priv: [],\n };\n const exceptions: IRules = {\n icann: [],\n priv: [],\n };\n\n // Keep track of maximum number of labels seen in a given rule. This allows us\n // to make sure that all sections of the typed array (wildcards, exceptions\n // and normal rules) have the same size and we do not need to check that while\n // matching.\n let maximumNumberOfLabels = 0;\n\n // Iterate on public suffix rules\n parse(body, ({ rule, isIcann, isException, isWildcard, isNormal }) => {\n // Select correct section to insert the rule\n let hashesPerLabels = null;\n if (isException) {\n hashesPerLabels = isIcann ? exceptions.icann : exceptions.priv;\n } else if (isWildcard) {\n hashesPerLabels = isIcann ? wildcards.icann : wildcards.priv;\n rule = rule.slice(2);\n } else if (isNormal) {\n hashesPerLabels = isIcann ? rules.icann : rules.priv;\n }\n\n if (hashesPerLabels === null) {\n return;\n }\n\n // Count number of labels in this suffix\n const numberOfLabels = rule.split('.').length;\n\n // Experimentally, we start ignoring suffixes with only one label since the\n // fallback to '*' will yield the same result. This helps reduce the size of\n // the bundle further and speed-up matching. One potential side-effect is\n // that we might not accurately return the information about if a suffix is\n // from the ICANN or PRIVATE section.\n if (\n numberOfLabels === 1 &&\n (hashesPerLabels === rules.icann || hashesPerLabels === rules.priv)\n ) {\n return;\n }\n\n maximumNumberOfLabels = Math.max(maximumNumberOfLabels, numberOfLabels);\n let hashesForLabel = hashesPerLabels[numberOfLabels];\n if (hashesForLabel === undefined) {\n hashesForLabel = [];\n hashesPerLabels[numberOfLabels] = hashesForLabel;\n }\n\n hashesForLabel.push(fastHash(rule));\n });\n\n // Pack everything together\n const chunks: number[][] = [];\n const pushHashes = (hashes: number[] = []) => {\n chunks.push([\n hashes.length,\n ...hashes.sort((a, b) => {\n if (a < b) {\n return -1;\n }\n if (a > b) {\n return 1;\n }\n return 0;\n }),\n ]);\n };\n\n for (let label = 1; label <= maximumNumberOfLabels; label += 1) {\n pushHashes(exceptions.icann[label]);\n pushHashes(exceptions.priv[label]);\n pushHashes(wildcards.icann[label]);\n pushHashes(wildcards.priv[label]);\n pushHashes(rules.icann[label]);\n pushHashes(rules.priv[label]);\n }\n\n return new Uint32Array([\n maximumNumberOfLabels,\n ...([] as number[]).concat(...chunks),\n ]);\n};\n","/**\n * Builds a flat, allocation-free public-suffix trie.\n *\n * The rules are inserted into an in-memory trie, identical sub-trees are shared\n * (DAWG compression), and the result is emitted as a handful of flat typed\n * arrays plus one `text` string holding every edge label:\n *\n * nodeFlags[node] -> 0 (none) | 1 (ICANN) | 2 (PRIVATE)\n * edgeStart[node] -> first edge index of `node` (edges of a node are a\n * contiguous, hash-sorted slice [edgeStart[node], edgeStart[node+1]))\n * edgeLength[edge] -> label length\n * edgeChild[edge] -> destination node\n * labelText -> all edge labels concatenated in edge order\n *\n * The per-edge label offsets (prefix-sum of `edgeLength`) and label hashes\n * (djb2 over `labelText`) are NOT shipped — they are derived once at load in\n * `suffix-trie.ts`. This keeps the bundle small (only compressible text +\n * structure) while the lookup binary-searches integer hashes at runtime.\n *\n * Lookup walks a hostname's labels right-to-left following edges; a flagged\n * node is a public-suffix match. See `suffix-trie.ts`.\n */\n\nimport parse from '../parser';\n\ninterface ITrie {\n flag: 0 | 1 | 2;\n children: Record<string, ITrie>;\n}\n\n/**\n * Insert a public suffix rule (its labels, already reversed) into the `trie`.\n */\nfunction insertInTrie(\n { parts, isIcann }: { parts: string[]; isIcann: boolean },\n trie: ITrie,\n): void {\n let node = trie;\n for (const part of parts) {\n let next = node.children[part];\n if (next === undefined) {\n next = { flag: 0, children: {} };\n node.children[part] = next;\n }\n node = next;\n }\n node.flag = isIcann ? 1 : 2;\n}\n\n/**\n * djb2 hash over `label`, computed backward. MUST stay identical to the\n * load-time recomputation in `suffix-trie.ts` so edges remain hash-sorted.\n */\nfunction labelHash(label: string): number {\n let hash = 5381;\n for (let i = label.length - 1; i >= 0; i -= 1) {\n hash = (hash * 33) ^ label.charCodeAt(i);\n }\n return hash >>> 0;\n}\n\ninterface FlatNode {\n flag: 0 | 1 | 2;\n edges: { label: string; child: number }[];\n}\n\n/**\n * Flatten the given tries into a shared pool of nodes (identical sub-trees get\n * the same id => DAWG compression). Returns the node pool and each root's id.\n */\nfunction flatten(roots: ITrie[]): { nodes: FlatNode[]; rootIds: number[] } {\n const idByKey = new Map<string, number>();\n const nodes: FlatNode[] = [];\n\n const visit = (node: ITrie): number => {\n const edges = Object.keys(node.children)\n .sort()\n .map((label) => ({ label, child: visit(node.children[label]!) }));\n\n // Identity key for DAWG dedup: same flag + same (label -> child) set. Built\n // from the alpha-sorted edges so it is canonical; the stored copy is then\n // re-sorted by hash because the lookup binary-searches edge hashes.\n const key = `${node.flag}|${edges.map((e) => `${e.label}>${e.child}`).join(',')}`;\n let id = idByKey.get(key);\n if (id === undefined) {\n edges.sort((a, b) => labelHash(a.label) - labelHash(b.label));\n id = nodes.length;\n nodes.push({ flag: node.flag, edges });\n idByKey.set(key, id);\n }\n return id;\n };\n\n return { nodes, rootIds: roots.map(visit) };\n}\n\nexport default (\n body: string,\n { includePrivate }: { includePrivate: boolean },\n): string => {\n const rules: ITrie = { flag: 0, children: {} };\n const exceptions: ITrie = { flag: 0, children: {} };\n\n parse(body, ({ rule, isIcann, isException }) => {\n if (isIcann || includePrivate) {\n insertInTrie(\n { isIcann, parts: rule.split('.').reverse() },\n isException ? exceptions : rules,\n );\n }\n });\n\n const { nodes, rootIds } = flatten([rules, exceptions]);\n\n const nodeFlags: number[] = [];\n const edgeStart: number[] = [0];\n const edgeLength: number[] = [];\n const edgeChild: number[] = [];\n let labelText = '';\n for (const node of nodes) {\n nodeFlags.push(node.flag);\n for (const edge of node.edges) {\n edgeLength.push(edge.label.length);\n edgeChild.push(edge.child);\n labelText += edge.label;\n }\n edgeStart.push(edgeLength.length);\n }\n\n // The serialized arrays ship as typed arrays (see the emitted code below):\n // edgeChild/edgeStart as Uint16Array, edgeLength as Uint8Array. If the PSL\n // ever outgrows those ranges the values would silently wrap and corrupt every\n // lookup, so fail the build loudly instead. Headroom is large today (~600\n // nodes / ~10k edges / max label 31 vs the 65535/255 ceilings). If this trips,\n // widen the array(s) here AND in the two suffix-trie.ts loaders.\n let maxEdgeLength = 0;\n for (const length of edgeLength) {\n if (length > maxEdgeLength) {\n maxEdgeLength = length;\n }\n }\n if (nodes.length > 65536) {\n // edgeChild stores node ids in [0, nodes.length); max id must fit Uint16.\n throw new Error(\n `trie builder: ${nodes.length} nodes exceeds the Uint16 edgeChild range (max 65536). Widen edgeChild + edgeStart to Uint32Array here and in suffix-trie.ts.`,\n );\n }\n if (edgeLength.length > 65535) {\n // edgeStart stores edge indices up to the edge count; must fit Uint16.\n throw new Error(\n `trie builder: ${edgeLength.length} edges exceeds the Uint16 edgeStart range (max 65535). Widen edgeStart + edgeChild to Uint32Array here and in suffix-trie.ts.`,\n );\n }\n if (maxEdgeLength > 255) {\n throw new Error(\n `trie builder: label length ${maxEdgeLength} exceeds the Uint8 edgeLength range (max 255). Widen edgeLength to Uint16Array here and in suffix-trie.ts.`,\n );\n }\n\n return `// Auto-generated flat public-suffix trie. Do not edit.\nexport const nodeFlags = /*#__PURE__*/ new Uint8Array([${nodeFlags.join(',')}]);\nexport const edgeStart = /*#__PURE__*/ new Uint16Array([${edgeStart.join(',')}]);\nexport const edgeLength = /*#__PURE__*/ new Uint8Array([${edgeLength.join(',')}]);\nexport const edgeChild = /*#__PURE__*/ new Uint16Array([${edgeChild.join(',')}]);\nexport const labelText = ${JSON.stringify(labelText)};\nexport const rulesRoot = ${rootIds[0]};\nexport const exceptionsRoot = ${rootIds[1]};\n`;\n};\n","import { writeFileSync } from 'fs';\n\nimport findBaseDir from './find-base-dir';\nimport loadPublicSuffixList from './list';\nimport buildHashes from './builders/hashes';\nimport buildTrie from './builders/trie';\n\nexport default function () {\n console.log('Updating rules...');\n const publicSuffixList = loadPublicSuffixList();\n\n // Build trie and update TypeScript file\n writeFileSync(\n findBaseDir('./tldts/src/data/trie.ts'),\n buildTrie(publicSuffixList, { includePrivate: true }),\n 'utf-8',\n );\n\n // Build trie and update TypeScript file (ICANN only)\n writeFileSync(\n findBaseDir('./tldts-icann/src/data/trie.ts'),\n buildTrie(publicSuffixList, { includePrivate: false }),\n 'utf-8',\n );\n\n // Build hashes and update TypeScript file\n const packed = buildHashes(publicSuffixList);\n writeFileSync(\n findBaseDir('./tldts-experimental/src/data/hashes.ts'),\n `\n// Code automatically generated using ./bin/builders/hashes.ts\nexport default new Uint32Array([${Array.from(packed).toString()}]);\n`,\n 'utf-8',\n );\n}\n"],"names":["existsSync","resolve","readFileSync","writeFileSync"],"mappings":";;;;;AAEA;AACA,MAAM,MAAM,GAAG,UAAU,CAAC;;AAE1B;AACA,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,EAAE;AACf,MAAM,IAAI,GAAG,GAAG;AAChB,MAAM,WAAW,GAAG,EAAE;AACtB,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,SAAS,GAAG,GAAG,CAAC;AAItB,MAAM,aAAa,GAAG,YAAY,CAAC;AACnC,MAAM,eAAe,GAAG,2BAA2B,CAAC;;AAEpD;AACA,MAAM,MAAM,GAAG;AACf,CAAC,UAAU,EAAE,iDAAiD;AAC9D,CAAC,WAAW,EAAE,gDAAgD;AAC9D,CAAC,eAAe,EAAE;AAClB,CAAC;;AAED;AACA,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI;AACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;AACxB,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY;;AAE9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,KAAK,CAAC,IAAI,EAAE;AACrB,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE;AAC9B,CAAC,MAAM,MAAM,GAAG,EAAE;AAClB,CAAC,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM;AAC1B,CAAC,OAAO,MAAM,EAAE,EAAE;AAClB,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,C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