Skip to content
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

Switch to using ts direct from privacy config #1211

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion injected/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"devDependencies": {
"@canvas/image-data": "^1.0.0",
"@duckduckgo/privacy-configuration": "github:duckduckgo/privacy-configuration#main",
jonathanKingston marked this conversation as resolved.
Show resolved Hide resolved
"@fingerprintjs/fingerprintjs": "^4.5.1",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
Expand All @@ -46,7 +47,6 @@
"@types/jasmine": "^5.1.4",
"@types/node": "^22.8.7",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"config-builder": "github:duckduckgo/privacy-configuration#1729260354597",
"fast-check": "^3.23.1",
"jasmine": "^5.4.0",
"minimist": "^1.2.8",
Expand Down
4 changes: 4 additions & 0 deletions injected/scripts/bundleTrackers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { parseArgs, write } from '../../scripts/script-utils.js';

const tdsUrl = 'https://staticcdn.duckduckgo.com/trackerblocking/v4/tds.json';
const resp = await fetch(tdsUrl);
/**
* Ignore 'unknown' type for now.
* @type any
*/
const tds = await resp.json();
jonathanKingston marked this conversation as resolved.
Show resolved Hide resolved

// Build a trie of tracker domains, starting with the broadest subdomain. Leaves are set to 1 to indicate success
Expand Down
21 changes: 1 addition & 20 deletions injected/scripts/types.mjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import { cwd, isLaunchFile } from '../../scripts/script-utils.js';
import { dirname, join } from 'node:path';
import { createRequire } from 'node:module';
import { join } from 'node:path';
import { buildTypes } from '../../types-generator/build-types.mjs';

const injectRoot = join(cwd(import.meta.url), '..');

// eslint-disable-next-line no-redeclare
const require = createRequire(import.meta.url);
const configBuilderRoot = dirname(require.resolve('config-builder'));

/** @type {Record<string, import('../../types-generator/build-types.mjs').Mapping>} */
const injectSchemaMapping = {
/**
* Add more mappings here
* - `schema` should be an absolute path to a valid JSON Schema document
* - `types` should be an absolute path to the output file
*/
'Webcompat Settings': {
schema: join(configBuilderRoot, 'tests/schemas/webcompat-settings.json'),
types: join(injectRoot, 'src/types/webcompat-settings.d.ts'),
// todo: fix this on windows.
exclude: process.platform === 'win32',
kind: 'settings',
},
'Duckplayer Settings': {
schema: join(configBuilderRoot, 'tests/schemas/duckplayer-settings.json'),
types: join(injectRoot, 'src/types/duckplayer-settings.d.ts'),
// todo: fix this on windows.
exclude: process.platform === 'win32',
kind: 'settings',
},
'Schema Messages': {
schemaDir: join(injectRoot, 'src/messages'),
typesDir: join(injectRoot, 'src/types'),
Expand Down
4 changes: 2 additions & 2 deletions injected/src/features/duck-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class DuckPlayerFeature extends ContentFeature {

/**
* Just the 'overlays' part of the settings object.
* @type {import("../types/duckplayer-settings.js").DuckPlayerSettings['overlays']}
* @type {import("@duckduckgo/privacy-configuration/schema/features/duckplayer").DuckPlayerSettings['overlays']}
*/
const overlaySettings = this.getFeatureSetting('overlays');
const overlaysEnabled = overlaySettings?.youtube?.state === 'enabled';
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class DuckPlayerFeature extends ContentFeature {
}

/**
* @typedef {Omit<import("../types/duckplayer-settings").YouTubeOverlay, "state">} OverlaysFeatureSettings
* @typedef {Omit<import("@duckduckgo/privacy-configuration/schema/features/duckplayer").DuckPlayerSettings['overlays']['youtube'], "state">} OverlaysFeatureSettings
*/

// for docs generation
Expand Down
4 changes: 2 additions & 2 deletions injected/src/features/web-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ export class WebCompat extends ContentFeature {
* Support for modifying localStorage entries
*/
modifyLocalStorage() {
/** @type {import('../types//webcompat-settings').WebCompatSettings['modifyLocalStorage']} */
/** @type {import('@duckduckgo/privacy-configuration/schema/features/webcompat').WebCompatSettings['modifyLocalStorage']} */
const settings = this.getFeatureSetting('modifyLocalStorage');

if (!settings || !settings.changes) return;
Expand All @@ -587,7 +587,7 @@ export class WebCompat extends ContentFeature {
* Support for proxying `window.webkit.messageHandlers`
*/
messageHandlersFix() {
/** @type {import('../types//webcompat-settings').WebCompatSettings['messageHandlers']} */
/** @type {import('@duckduckgo/privacy-configuration/schema/features/webcompat').WebCompatSettings['messageHandlers']} */
const settings = this.getFeatureSetting('messageHandlers');

// Do nothing if `messageHandlers` is absent
Expand Down
133 changes: 66 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading