-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ContentFeature] de-decouple build specific code from content-features #1545
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for content-scope-scripts ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Temporary Branch UpdateThe temporary branch has been updated with the latest changes. Below are the details:
Please use the above install command to update to the latest version. |
[Beta] Generated file diffTime updated: Fri, 07 Mar 2025 11:31:42 GMT Android
File has changed Chrome
File has changed Chrome-mv3
File has changed Firefox
File has changed Integration
File has changed Windows
File has changed Apple
File has changed |
f87255a
to
c5e86a4
Compare
894cce5
to
512b303
Compare
512b303
to
e7e6721
Compare
injected/entry-points/android.js
Outdated
@@ -31,10 +30,14 @@ function initCode() { | |||
debug: processedConfig.debug, | |||
}); | |||
|
|||
const importConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this into content-scope-features to remove the need for it being in all files?
@@ -463,7 +463,7 @@ export class WebCompat extends ContentFeature { | |||
|
|||
mediaSessionFix() { | |||
try { | |||
if (window.navigator.mediaSession && import.meta.injectName !== 'integration') { | |||
if (window.navigator.mediaSession && this.injectName !== 'integration') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be this.importConfig.injectName
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a getter in the base class.
@@ -39,7 +37,7 @@ export function load(args) { | |||
return; | |||
} | |||
|
|||
const featureNames = typeof import.meta.injectName === 'string' ? platformSupport[import.meta.injectName] : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the for loop below I think you'll need to pass in importConfig into the ContentFeature, probably to the constructor.
…uckduckgo/content-scope-scripts into dbajpeyi/refactor/decouple-import-meta
917f4f8
to
db3cdf8
Compare
injected/src/content-feature.js
Outdated
this.#args = null; | ||
constructor(featureName, importConfig) { | ||
super(featureName); | ||
this.args = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.args = null; | |
this.#args = null; |
d309b19
to
85dfc98
Compare
const featureInstance = new ContentFeature(featureName, importConfig); | ||
featureInstance.callLoad(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const featureInstance = new ContentFeature(featureName, importConfig); | |
featureInstance.callLoad(args); | |
const featureInstance = new ContentFeature(featureName, importConfig, args); | |
featureInstance.callLoad(); |
Later on:
featureInstance.callInit(args);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would allow us to move the initLoadArgs it super constructor.
injected/entry-points/chrome.js
Outdated
@@ -54,7 +54,6 @@ function init() { | |||
platform: { | |||
name: 'extension' | |||
}, | |||
trackerLookup: ${JSON.stringify(trackerLookup)}, | |||
site: ${JSON.stringify(siteObject)}, | |||
documentOriginIsTracker: ${documentOriginIsTracker}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documentOriginIsTracker: ${documentOriginIsTracker}, |
85dfc98
to
363da49
Compare
injected/src/content-feature.js
Outdated
constructor(featureName, importConfig) { | ||
super(featureName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor(featureName, importConfig) { | |
super(featureName); | |
constructor(featureName, importConfig, args) { | |
super(featureName, args); |
injected/src/config-feature.js
Outdated
initLoadArgs(loadArgs) { | ||
const { bundledConfig, site, platform } = loadArgs; | ||
this.#bundledConfig = bundledConfig; | ||
this.#args = loadArgs; | ||
// If we have a bundled config, treat it as a regular config | ||
// This will be overriden by the remote config if it is available | ||
if (this.#bundledConfig && this.#args) { | ||
const enabledFeatures = computeEnabledFeatures(bundledConfig, site.domain, platform.version); | ||
this.#args.featureSettings = parseFeatureSettings(bundledConfig, enabledFeatures); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this moves into the constructor.
injected/src/config-feature.js
Outdated
/** | ||
* @param {any} name | ||
*/ | ||
constructor(name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor(name) { | |
constructor(name, args) { |
injected/src/content-feature.js
Outdated
init(args) {} | ||
|
||
callInit(args) { | ||
const mark = this.monitor.mark(this.name + 'CallInit'); | ||
this.#args = args; | ||
this.args = args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes a method called setArgs
. That we call from the constructor and callInit
. We remove these two lines from callLoad
.
injected/src/content-feature.js
Outdated
} | ||
this.#trackerLookup = args.trackerLookup; | ||
this.#documentOriginIsTracker = args.documentOriginIsTracker; | ||
this.initLoadArgs(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initLoadArgs becomes part of the constructor (just calling super with the args).
injected/src/content-feature.js
Outdated
} | ||
this.#trackerLookup = args.trackerLookup; | ||
this.#documentOriginIsTracker = args.documentOriginIsTracker; | ||
this.initLoadArgs(args); | ||
this.load(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.load(args); | |
this.load(this.#args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this passing in is legacy btw, I think there's very few uses of it).
3ac99d4
to
3239109
Compare
83024d3
to
2562c00
Compare
Asana Task/Github Issue:
Description
Testing Steps
Checklist
Please tick all that apply: