@duckduckgo/autoconsent 14.48.0 → 14.49.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/CHANGELOG.md +13 -0
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/autoconsent.cjs.js +88 -2
- package/dist/autoconsent.esm.js +86 -1
- package/lib/web.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# v14.49.0 (Tue Jan 13 2026)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- Export filterCompactRules from main module [#1120](https://github.com/duckduckgo/autoconsent/pull/1120) ([@rafaelr-hub](https://github.com/rafaelr-hub) [@Ezhik-777](https://github.com/Ezhik-777))
|
|
6
|
+
|
|
7
|
+
#### Authors: 2
|
|
8
|
+
|
|
9
|
+
- [@rafaelr-hub](https://github.com/rafaelr-hub)
|
|
10
|
+
- Evgenij Eliseew ([@Ezhik-777](https://github.com/Ezhik-777))
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
1
14
|
# v14.48.0 (Sat Jan 10 2026)
|
|
2
15
|
|
|
3
16
|
#### 🚀 Enhancement
|
package/dist/autoconsent.cjs.js
CHANGED
|
@@ -28,7 +28,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
28
28
|
var web_exports = {};
|
|
29
29
|
__export(web_exports, {
|
|
30
30
|
default: () => AutoConsent,
|
|
31
|
-
evalSnippets: () => snippets
|
|
31
|
+
evalSnippets: () => snippets,
|
|
32
|
+
filterCompactRules: () => filterCompactRules
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(web_exports);
|
|
34
35
|
|
|
@@ -3187,6 +3188,90 @@ var CompactedCMPRule = class {
|
|
|
3187
3188
|
return this.r[9].map(this._decodeRuleStep.bind(this));
|
|
3188
3189
|
}
|
|
3189
3190
|
};
|
|
3191
|
+
function clearUnusedStrings(ruleset, ignoreBeforeIndex = 0) {
|
|
3192
|
+
const { v, s, r } = ruleset;
|
|
3193
|
+
const usedStringIds = /* @__PURE__ */ new Set();
|
|
3194
|
+
function addStringIdsFromRuleSteps(steps) {
|
|
3195
|
+
steps.forEach((step) => {
|
|
3196
|
+
for (const [, shortKey] of compactedRuleSteps) {
|
|
3197
|
+
if (step[shortKey] !== void 0) {
|
|
3198
|
+
usedStringIds.add(step[shortKey]);
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
if (step.if) {
|
|
3202
|
+
addStringIdsFromRuleSteps([step.if]);
|
|
3203
|
+
}
|
|
3204
|
+
if (step.then) {
|
|
3205
|
+
addStringIdsFromRuleSteps(step.then);
|
|
3206
|
+
}
|
|
3207
|
+
if (step.else) {
|
|
3208
|
+
addStringIdsFromRuleSteps(step.else);
|
|
3209
|
+
}
|
|
3210
|
+
if (step.any) {
|
|
3211
|
+
addStringIdsFromRuleSteps(step.any);
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
}
|
|
3215
|
+
ruleset.r.forEach((rule) => {
|
|
3216
|
+
addStringIdsFromRuleSteps(rule[6]);
|
|
3217
|
+
addStringIdsFromRuleSteps(rule[7]);
|
|
3218
|
+
addStringIdsFromRuleSteps(rule[8]);
|
|
3219
|
+
addStringIdsFromRuleSteps(rule[9]);
|
|
3220
|
+
rule[5].forEach((id) => usedStringIds.add(id));
|
|
3221
|
+
});
|
|
3222
|
+
return {
|
|
3223
|
+
v,
|
|
3224
|
+
r,
|
|
3225
|
+
s: s.slice(0, Math.max(...usedStringIds) + 1).map((str, idx) => {
|
|
3226
|
+
if (idx < ignoreBeforeIndex || usedStringIds.has(idx)) {
|
|
3227
|
+
return str;
|
|
3228
|
+
}
|
|
3229
|
+
return "";
|
|
3230
|
+
})
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
function shouldRunRuleInContext(rule, mainFrame, url) {
|
|
3234
|
+
const runContext = rule[4];
|
|
3235
|
+
if (mainFrame && runContext === 1) {
|
|
3236
|
+
return false;
|
|
3237
|
+
}
|
|
3238
|
+
if (!mainFrame && [20, 22, 10, 12].includes(runContext)) {
|
|
3239
|
+
return false;
|
|
3240
|
+
}
|
|
3241
|
+
const urlPattern = rule[3];
|
|
3242
|
+
if (urlPattern && urlPattern !== "" && url.match(urlPattern) === null) {
|
|
3243
|
+
return false;
|
|
3244
|
+
}
|
|
3245
|
+
return true;
|
|
3246
|
+
}
|
|
3247
|
+
function filterCompactRules(rules, context) {
|
|
3248
|
+
const { v, s, r, index } = rules;
|
|
3249
|
+
const { url, mainFrame } = context;
|
|
3250
|
+
const shouldRunInContext = (rule) => shouldRunRuleInContext(rule, mainFrame, url);
|
|
3251
|
+
if (!mainFrame) {
|
|
3252
|
+
const ruleset = {
|
|
3253
|
+
v,
|
|
3254
|
+
s: s.slice(0, index.frameStringEnd),
|
|
3255
|
+
r: r.slice(index.frameRuleRange[0], index.frameRuleRange[1]).filter(shouldRunInContext)
|
|
3256
|
+
};
|
|
3257
|
+
return clearUnusedStrings(ruleset);
|
|
3258
|
+
}
|
|
3259
|
+
const genericRules = r.slice(index.genericRuleRange[0], index.genericRuleRange[1]);
|
|
3260
|
+
const specificRules = r.slice(index.specificRuleRange[0], index.specificRuleRange[1]).filter(shouldRunInContext);
|
|
3261
|
+
if (specificRules.length > 0) {
|
|
3262
|
+
const ruleset = {
|
|
3263
|
+
v,
|
|
3264
|
+
s,
|
|
3265
|
+
r: [...genericRules, ...specificRules]
|
|
3266
|
+
};
|
|
3267
|
+
return clearUnusedStrings(ruleset);
|
|
3268
|
+
}
|
|
3269
|
+
return {
|
|
3270
|
+
v,
|
|
3271
|
+
s: s.slice(0, index.genericStringEnd),
|
|
3272
|
+
r: genericRules
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3190
3275
|
|
|
3191
3276
|
// lib/web.ts
|
|
3192
3277
|
function filterCMPs(rules, config) {
|
|
@@ -3715,5 +3800,6 @@ var AutoConsent = class {
|
|
|
3715
3800
|
_config = new WeakMap();
|
|
3716
3801
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3717
3802
|
0 && (module.exports = {
|
|
3718
|
-
evalSnippets
|
|
3803
|
+
evalSnippets,
|
|
3804
|
+
filterCompactRules
|
|
3719
3805
|
});
|
package/dist/autoconsent.esm.js
CHANGED
|
@@ -3161,6 +3161,90 @@ var CompactedCMPRule = class {
|
|
|
3161
3161
|
return this.r[9].map(this._decodeRuleStep.bind(this));
|
|
3162
3162
|
}
|
|
3163
3163
|
};
|
|
3164
|
+
function clearUnusedStrings(ruleset, ignoreBeforeIndex = 0) {
|
|
3165
|
+
const { v, s, r } = ruleset;
|
|
3166
|
+
const usedStringIds = /* @__PURE__ */ new Set();
|
|
3167
|
+
function addStringIdsFromRuleSteps(steps) {
|
|
3168
|
+
steps.forEach((step) => {
|
|
3169
|
+
for (const [, shortKey] of compactedRuleSteps) {
|
|
3170
|
+
if (step[shortKey] !== void 0) {
|
|
3171
|
+
usedStringIds.add(step[shortKey]);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
if (step.if) {
|
|
3175
|
+
addStringIdsFromRuleSteps([step.if]);
|
|
3176
|
+
}
|
|
3177
|
+
if (step.then) {
|
|
3178
|
+
addStringIdsFromRuleSteps(step.then);
|
|
3179
|
+
}
|
|
3180
|
+
if (step.else) {
|
|
3181
|
+
addStringIdsFromRuleSteps(step.else);
|
|
3182
|
+
}
|
|
3183
|
+
if (step.any) {
|
|
3184
|
+
addStringIdsFromRuleSteps(step.any);
|
|
3185
|
+
}
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
ruleset.r.forEach((rule) => {
|
|
3189
|
+
addStringIdsFromRuleSteps(rule[6]);
|
|
3190
|
+
addStringIdsFromRuleSteps(rule[7]);
|
|
3191
|
+
addStringIdsFromRuleSteps(rule[8]);
|
|
3192
|
+
addStringIdsFromRuleSteps(rule[9]);
|
|
3193
|
+
rule[5].forEach((id) => usedStringIds.add(id));
|
|
3194
|
+
});
|
|
3195
|
+
return {
|
|
3196
|
+
v,
|
|
3197
|
+
r,
|
|
3198
|
+
s: s.slice(0, Math.max(...usedStringIds) + 1).map((str, idx) => {
|
|
3199
|
+
if (idx < ignoreBeforeIndex || usedStringIds.has(idx)) {
|
|
3200
|
+
return str;
|
|
3201
|
+
}
|
|
3202
|
+
return "";
|
|
3203
|
+
})
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
function shouldRunRuleInContext(rule, mainFrame, url) {
|
|
3207
|
+
const runContext = rule[4];
|
|
3208
|
+
if (mainFrame && runContext === 1) {
|
|
3209
|
+
return false;
|
|
3210
|
+
}
|
|
3211
|
+
if (!mainFrame && [20, 22, 10, 12].includes(runContext)) {
|
|
3212
|
+
return false;
|
|
3213
|
+
}
|
|
3214
|
+
const urlPattern = rule[3];
|
|
3215
|
+
if (urlPattern && urlPattern !== "" && url.match(urlPattern) === null) {
|
|
3216
|
+
return false;
|
|
3217
|
+
}
|
|
3218
|
+
return true;
|
|
3219
|
+
}
|
|
3220
|
+
function filterCompactRules(rules, context) {
|
|
3221
|
+
const { v, s, r, index } = rules;
|
|
3222
|
+
const { url, mainFrame } = context;
|
|
3223
|
+
const shouldRunInContext = (rule) => shouldRunRuleInContext(rule, mainFrame, url);
|
|
3224
|
+
if (!mainFrame) {
|
|
3225
|
+
const ruleset = {
|
|
3226
|
+
v,
|
|
3227
|
+
s: s.slice(0, index.frameStringEnd),
|
|
3228
|
+
r: r.slice(index.frameRuleRange[0], index.frameRuleRange[1]).filter(shouldRunInContext)
|
|
3229
|
+
};
|
|
3230
|
+
return clearUnusedStrings(ruleset);
|
|
3231
|
+
}
|
|
3232
|
+
const genericRules = r.slice(index.genericRuleRange[0], index.genericRuleRange[1]);
|
|
3233
|
+
const specificRules = r.slice(index.specificRuleRange[0], index.specificRuleRange[1]).filter(shouldRunInContext);
|
|
3234
|
+
if (specificRules.length > 0) {
|
|
3235
|
+
const ruleset = {
|
|
3236
|
+
v,
|
|
3237
|
+
s,
|
|
3238
|
+
r: [...genericRules, ...specificRules]
|
|
3239
|
+
};
|
|
3240
|
+
return clearUnusedStrings(ruleset);
|
|
3241
|
+
}
|
|
3242
|
+
return {
|
|
3243
|
+
v,
|
|
3244
|
+
s: s.slice(0, index.genericStringEnd),
|
|
3245
|
+
r: genericRules
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3164
3248
|
|
|
3165
3249
|
// lib/web.ts
|
|
3166
3250
|
function filterCMPs(rules, config) {
|
|
@@ -3689,5 +3773,6 @@ var AutoConsent = class {
|
|
|
3689
3773
|
_config = new WeakMap();
|
|
3690
3774
|
export {
|
|
3691
3775
|
AutoConsent as default,
|
|
3692
|
-
snippets as evalSnippets
|
|
3776
|
+
snippets as evalSnippets,
|
|
3777
|
+
filterCompactRules
|
|
3693
3778
|
};
|
package/lib/web.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { checkHeuristicPatterns } from './heuristics';
|
|
|
13
13
|
import { decodeRules } from './encoding';
|
|
14
14
|
|
|
15
15
|
export { snippets as evalSnippets } from './eval-snippets';
|
|
16
|
+
export { filterCompactRules } from './encoding';
|
|
17
|
+
export type { IndexedCMPRuleset, CompactCMPRuleset } from './encoding';
|
|
16
18
|
|
|
17
19
|
function filterCMPs(rules: AutoCMP[], config: Config) {
|
|
18
20
|
return rules.filter((cmp) => {
|