Skip to content

Commit 3702e36

Browse files
Release build 4.2.3 [ci release]
1 parent b48a927 commit 3702e36

File tree

23 files changed

+401
-104
lines changed

23 files changed

+401
-104
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-20.04
88
steps:
99
- uses: actions/checkout@v2
10-
- name: Use Node.js 16
10+
- name: Use Node.js 18
1111
uses: actions/setup-node@v1
1212
with:
13-
node-version: 16.x
13+
node-version: 18.x
1414
- uses: actions/cache@v2
1515
with:
1616
path: ~/.npm
@@ -28,10 +28,10 @@ jobs:
2828
timeout-minutes: 10
2929
steps:
3030
- uses: actions/checkout@v2
31-
- name: Use Node.js 16
31+
- name: Use Node.js 18
3232
uses: actions/setup-node@v1
3333
with:
34-
node-version: 16.x
34+
node-version: 18.x
3535
- uses: actions/cache@v2
3636
with:
3737
path: ~/.npm

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
node_modules/
33
.swiftpm
44
.env
5+
build/
6+
Sources/ContentScopeScripts/dist/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
18

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,8 +4657,8 @@
46574657

46584658
var cookie = /*#__PURE__*/Object.freeze({
46594659
__proto__: null,
4660-
load: load$1,
46614660
init: init$e,
4661+
load: load$1,
46624662
update: update
46634663
});
46644664

@@ -6786,6 +6786,20 @@
67866786
let matchAllStackDomains = false;
67876787
let taintCheck = false;
67886788
let initialCreateElement;
6789+
let tagModifiers = {};
6790+
6791+
/**
6792+
* @param {string} tagName
6793+
* @param {'property' | 'attribute' | 'handler' | 'listener'} filterName
6794+
* @param {string} key
6795+
* @returns {boolean}
6796+
*/
6797+
function shouldFilterKey (tagName, filterName, key) {
6798+
if (filterName === 'attribute') {
6799+
key = key.toLowerCase();
6800+
}
6801+
return tagModifiers?.[tagName]?.filters?.[filterName]?.includes(key)
6802+
}
67896803

67906804
let elementRemovalTimeout;
67916805
const featureName = 'runtimeChecks';
@@ -6819,12 +6833,15 @@
68196833
monitorProperties (el) {
68206834
// Mutation oberver and observedAttributes don't work on property accessors
68216835
// So instead we need to monitor all properties on the prototypes and forward them to the real element
6822-
const propertyNames = [];
6836+
let propertyNames = [];
68236837
let proto = Object.getPrototypeOf(el);
68246838
while (proto && proto !== Object.prototype) {
68256839
propertyNames.push(...Object.getOwnPropertyNames(proto));
68266840
proto = Object.getPrototypeOf(proto);
68276841
}
6842+
const classMethods = Object.getOwnPropertyNames(Object.getPrototypeOf(this));
6843+
// Filter away the methods we don't want to monitor from our own class
6844+
propertyNames = propertyNames.filter(prop => !classMethods.includes(prop));
68286845
propertyNames.forEach(prop => {
68296846
if (prop === 'constructor') return
68306847
// May throw, but this is best effort monitoring.
@@ -6834,6 +6851,7 @@
68346851
return el[prop]
68356852
},
68366853
set (value) {
6854+
if (shouldFilterKey(this.#tagName, 'property', prop)) return
68376855
el[prop] = value;
68386856
}
68396857
});
@@ -6856,23 +6874,27 @@
68566874

68576875
// Reflect all attrs to the new element
68586876
for (const attribute of this.getAttributeNames()) {
6877+
if (shouldFilterKey(this.#tagName, 'attribute', attribute)) continue
68596878
el.setAttribute(attribute, this.getAttribute(attribute));
68606879
}
68616880

68626881
// Reflect all props to the new element
68636882
for (const param of Object.keys(this)) {
6883+
if (shouldFilterKey(this.#tagName, 'property', param)) continue
68646884
el[param] = this[param];
68656885
}
68666886

68676887
// Reflect all listeners to the new element
68686888
for (const [...args] of this.#listeners) {
6889+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) continue
68696890
el.addEventListener(...args);
68706891
}
68716892
this.#listeners = [];
68726893

68736894
// Reflect all 'on' event handlers to the new element
68746895
for (const propName in this) {
68756896
if (propName.startsWith('on')) {
6897+
if (shouldFilterKey(this.#tagName, 'handler', propName)) continue
68766898
const prop = this[propName];
68776899
if (typeof prop === 'function') {
68786900
el[propName] = prop;
@@ -6905,6 +6927,7 @@
69056927
}
69066928

69076929
setAttribute (name, value) {
6930+
if (shouldFilterKey(this.#tagName, 'attribute', name)) return
69086931
const el = this.getElement();
69096932
if (el) {
69106933
return el.setAttribute(name, value)
@@ -6913,6 +6936,7 @@
69136936
}
69146937

69156938
removeAttribute (name) {
6939+
if (shouldFilterKey(this.#tagName, 'attribute', name)) return
69166940
const el = this.getElement();
69176941
if (el) {
69186942
return el.removeAttribute(name)
@@ -6921,6 +6945,7 @@
69216945
}
69226946

69236947
addEventListener (...args) {
6948+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) return
69246949
const el = this.getElement();
69256950
if (el) {
69266951
return el.addEventListener(...args)
@@ -6929,6 +6954,7 @@
69296954
}
69306955

69316956
removeEventListener (...args) {
6957+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) return
69326958
const el = this.getElement();
69336959
if (el) {
69346960
return el.removeEventListener(...args)
@@ -7054,6 +7080,7 @@
70547080
matchAllStackDomains = getFeatureSettingEnabled(featureName, args, 'matchAllStackDomains');
70557081
stackDomains = getFeatureSetting(featureName, args, 'stackDomains') || [];
70567082
elementRemovalTimeout = getFeatureSetting(featureName, args, 'elementRemovalTimeout') || 1000;
7083+
tagModifiers = getFeatureSetting(featureName, args, 'tagModifiers') || {};
70577084

70587085
overrideCreateElement();
70597086

@@ -7064,8 +7091,8 @@
70647091

70657092
var runtimeChecks = /*#__PURE__*/Object.freeze({
70667093
__proto__: null,
7067-
load: load,
7068-
init: init$2
7094+
init: init$2,
7095+
load: load
70697096
});
70707097

70717098
/**
@@ -7265,6 +7292,7 @@
72657292
const videoTracks = new Set();
72667293
const audioTracks = new Set();
72677294

7295+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
72687296
function getTracks (permission) {
72697297
switch (permission) {
72707298
case Permission.Camera:
@@ -7592,11 +7620,11 @@
75927620
if (isGloballyDisabled(processedConfig)) {
75937621
return
75947622
}
7595-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7623+
75967624
contentScopeFeatures.load({
75977625
platform: processedConfig.platform
75987626
});
7599-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7627+
76007628
contentScopeFeatures.init(processedConfig);
76017629

76027630
// Not supported:

build/android/contentScope.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,8 +4657,8 @@
46574657

46584658
var cookie = /*#__PURE__*/Object.freeze({
46594659
__proto__: null,
4660-
load: load$1,
46614660
init: init$e,
4661+
load: load$1,
46624662
update: update
46634663
});
46644664

@@ -6786,6 +6786,20 @@
67866786
let matchAllStackDomains = false;
67876787
let taintCheck = false;
67886788
let initialCreateElement;
6789+
let tagModifiers = {};
6790+
6791+
/**
6792+
* @param {string} tagName
6793+
* @param {'property' | 'attribute' | 'handler' | 'listener'} filterName
6794+
* @param {string} key
6795+
* @returns {boolean}
6796+
*/
6797+
function shouldFilterKey (tagName, filterName, key) {
6798+
if (filterName === 'attribute') {
6799+
key = key.toLowerCase();
6800+
}
6801+
return tagModifiers?.[tagName]?.filters?.[filterName]?.includes(key)
6802+
}
67896803

67906804
let elementRemovalTimeout;
67916805
const featureName = 'runtimeChecks';
@@ -6819,12 +6833,15 @@
68196833
monitorProperties (el) {
68206834
// Mutation oberver and observedAttributes don't work on property accessors
68216835
// So instead we need to monitor all properties on the prototypes and forward them to the real element
6822-
const propertyNames = [];
6836+
let propertyNames = [];
68236837
let proto = Object.getPrototypeOf(el);
68246838
while (proto && proto !== Object.prototype) {
68256839
propertyNames.push(...Object.getOwnPropertyNames(proto));
68266840
proto = Object.getPrototypeOf(proto);
68276841
}
6842+
const classMethods = Object.getOwnPropertyNames(Object.getPrototypeOf(this));
6843+
// Filter away the methods we don't want to monitor from our own class
6844+
propertyNames = propertyNames.filter(prop => !classMethods.includes(prop));
68286845
propertyNames.forEach(prop => {
68296846
if (prop === 'constructor') return
68306847
// May throw, but this is best effort monitoring.
@@ -6834,6 +6851,7 @@
68346851
return el[prop]
68356852
},
68366853
set (value) {
6854+
if (shouldFilterKey(this.#tagName, 'property', prop)) return
68376855
el[prop] = value;
68386856
}
68396857
});
@@ -6856,23 +6874,27 @@
68566874

68576875
// Reflect all attrs to the new element
68586876
for (const attribute of this.getAttributeNames()) {
6877+
if (shouldFilterKey(this.#tagName, 'attribute', attribute)) continue
68596878
el.setAttribute(attribute, this.getAttribute(attribute));
68606879
}
68616880

68626881
// Reflect all props to the new element
68636882
for (const param of Object.keys(this)) {
6883+
if (shouldFilterKey(this.#tagName, 'property', param)) continue
68646884
el[param] = this[param];
68656885
}
68666886

68676887
// Reflect all listeners to the new element
68686888
for (const [...args] of this.#listeners) {
6889+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) continue
68696890
el.addEventListener(...args);
68706891
}
68716892
this.#listeners = [];
68726893

68736894
// Reflect all 'on' event handlers to the new element
68746895
for (const propName in this) {
68756896
if (propName.startsWith('on')) {
6897+
if (shouldFilterKey(this.#tagName, 'handler', propName)) continue
68766898
const prop = this[propName];
68776899
if (typeof prop === 'function') {
68786900
el[propName] = prop;
@@ -6905,6 +6927,7 @@
69056927
}
69066928

69076929
setAttribute (name, value) {
6930+
if (shouldFilterKey(this.#tagName, 'attribute', name)) return
69086931
const el = this.getElement();
69096932
if (el) {
69106933
return el.setAttribute(name, value)
@@ -6913,6 +6936,7 @@
69136936
}
69146937

69156938
removeAttribute (name) {
6939+
if (shouldFilterKey(this.#tagName, 'attribute', name)) return
69166940
const el = this.getElement();
69176941
if (el) {
69186942
return el.removeAttribute(name)
@@ -6921,6 +6945,7 @@
69216945
}
69226946

69236947
addEventListener (...args) {
6948+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) return
69246949
const el = this.getElement();
69256950
if (el) {
69266951
return el.addEventListener(...args)
@@ -6929,6 +6954,7 @@
69296954
}
69306955

69316956
removeEventListener (...args) {
6957+
if (shouldFilterKey(this.#tagName, 'listener', args[0])) return
69326958
const el = this.getElement();
69336959
if (el) {
69346960
return el.removeEventListener(...args)
@@ -7054,6 +7080,7 @@
70547080
matchAllStackDomains = getFeatureSettingEnabled(featureName, args, 'matchAllStackDomains');
70557081
stackDomains = getFeatureSetting(featureName, args, 'stackDomains') || [];
70567082
elementRemovalTimeout = getFeatureSetting(featureName, args, 'elementRemovalTimeout') || 1000;
7083+
tagModifiers = getFeatureSetting(featureName, args, 'tagModifiers') || {};
70577084

70587085
overrideCreateElement();
70597086

@@ -7064,8 +7091,8 @@
70647091

70657092
var runtimeChecks = /*#__PURE__*/Object.freeze({
70667093
__proto__: null,
7067-
load: load,
7068-
init: init$2
7094+
init: init$2,
7095+
load: load
70697096
});
70707097

70717098
/**
@@ -7265,6 +7292,7 @@
72657292
const videoTracks = new Set();
72667293
const audioTracks = new Set();
72677294

7295+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
72687296
function getTracks (permission) {
72697297
switch (permission) {
72707298
case Permission.Camera:
@@ -7592,11 +7620,11 @@
75927620
if (isGloballyDisabled(processedConfig)) {
75937621
return
75947622
}
7595-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7623+
75967624
contentScopeFeatures.load({
75977625
platform: processedConfig.platform
75987626
});
7599-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7627+
76007628
contentScopeFeatures.init(processedConfig);
76017629

76027630
// Not supported:

0 commit comments

Comments
 (0)