Skip to content

Commit

Permalink
Merge branch 'dbajpeyi/fix/supported-paths' of github.com:duckduckgo/…
Browse files Browse the repository at this point in the history
…content-scope-scripts into dbajpeyi/fix/supported-paths
  • Loading branch information
dbajpeyi committed Nov 5, 2024
2 parents 05f8244 + e19c1a9 commit 8ad828f
Show file tree
Hide file tree
Showing 73 changed files with 864 additions and 319 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default tseslint.config(
"playwright-report",
"test-results",
"injected/src/types",
".idea"
],
},
{
Expand Down
8 changes: 4 additions & 4 deletions injected/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"@types/chrome": "^0.0.279",
"@types/chrome": "^0.0.280",
"@types/jasmine": "^5.1.4",
"@types/node": "^22.8.6",
"@types/node": "^22.8.7",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"config-builder": "github:duckduckgo/privacy-configuration#1729260354597",
"fast-check": "^3.22.0",
"fast-check": "^3.23.1",
"jasmine": "^5.4.0",
"minimist": "^1.2.8",
"rollup": "^4.24.3",
"rollup": "^4.24.4",
"rollup-plugin-import-css": "^3.5.6",
"rollup-plugin-svg-import": "^3.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion injected/src/features/autofill-password-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ export default class AutofillPasswordImport extends ContentFeature {
* @param {string} path
*/
async handleElementForPath (path) {
this.removeOverlayIfNeeded()
const supportedPaths = [
this.#exportButtonSettings?.path,
this.#settingsButtonSettings?.path,
this.#signInButtonSettings?.path
]
this.removeOverlayIfNeeded()
if (supportedPaths.includes(path)) {
try {
const { element, style, shouldTap, shouldWatchForRemoval } = await this.getElementAndStyleFromPath(path) ?? {}
Expand Down
379 changes: 189 additions & 190 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"stylelint": "^15.11.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-csstree-validator": "^3.0.0",
"typedoc": "^0.26.10",
"typedoc": "^0.26.11",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2",
"@playwright/test": "^1.48.2"
Expand Down
3 changes: 2 additions & 1 deletion special-pages/messages/new-tab/examples/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const privacyStatsData = {
* @type {import("../../../types/new-tab").StatsConfig}
*/
const minimumConfig = {
expansion: "expanded"
expansion: "expanded",
animation: { kind: "none" }
}

/**
Expand Down
3 changes: 3 additions & 0 deletions special-pages/messages/new-tab/favorites_add.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json-schema.org/draft-07/schema#"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json-schema.org/draft-07/schema#"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "./types/favorites-config.json"
}
]
}
3 changes: 3 additions & 0 deletions special-pages/messages/new-tab/favorites_getData.request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json-schema.org/draft-07/schema#"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "types/favorites-data.json"
}
]
}
19 changes: 19 additions & 0 deletions special-pages/messages/new-tab/favorites_move.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Favorites Move Action",
"type": "object",
"required": [
"id",
"targetIndex"
],
"properties": {
"id": {
"description": "Entity ID",
"type": "string"
},
"targetIndex": {
"description": "zero-indexed target",
"type": "number"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "./types/favorites-config.json"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "types/favorites-data.json"
}
]
}
19 changes: 19 additions & 0 deletions special-pages/messages/new-tab/favorites_open.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Favorites Open Action",
"type": "object",
"required": [
"id",
"target"
],
"properties": {
"id": {
"description": "Entity ID",
"type": "string"
},
"target": {
"type": "string",
"enum": ["same-tab", "new-tab", "new-window"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Favorites Open Context Menu Action",
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"description": "Entity ID",
"type": "string"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "./types/favorites-config.json"
}
]
}
10 changes: 10 additions & 0 deletions special-pages/messages/new-tab/types/favorites-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "FavoritesConfig",
"type": "object",
"required": ["expansion"],
"properties": {
"expansion": { "$ref": "./expansion.json" },
"animation": { "$ref": "./animation.json" }
}
}
47 changes: 47 additions & 0 deletions special-pages/messages/new-tab/types/favorites-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Favorites Data",
"type": "object",
"required": ["favorites"],
"properties": {
"favorites": {
"type": "array",
"items": {
"type": "object",
"title": "Favorite",
"required": ["url", "id", "title", "favicon"],
"properties": {
"url": {
"type": "string"
},
"id": {
"type": "string"
},
"title": {
"type": "string"
},
"favicon": {
"oneOf": [
{
"type": "null"
},
{
"type": "object",
"title": "Favorite Favicon",
"required": ["src", "maxAvailableSize"],
"properties": {
"src": {
"type": "string"
},
"maxAvailableSize": {
"type": "number"
}
}
}
]
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion special-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"esbuild": "^0.24.0",
"http-server": "^14.1.1",
"web-resource-inliner": "^6.0.1",
"fast-check": "^3.22.0"
"fast-check": "^3.23.1"
},
"dependencies": {
"preact": "^10.24.3",
Expand Down
10 changes: 10 additions & 0 deletions special-pages/pages/new-tab/app/components/App.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ body {
margin-right: auto;
}

body:has([data-reset-layout="true"]) .layout {
padding-top: 0;
}

:global(.layout-centered) {
margin-inline: auto;
width: 100%;
max-width: calc(504 * var(--px-in-rem));
}

/** Don't affect layout if empty (eg: if a widget was toggled) **/
:global(.layout-centered:empty) {
display: contents;
}
12 changes: 10 additions & 2 deletions special-pages/pages/new-tab/app/components/Components.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { Fragment, h } from "preact";
import styles from "./Components.module.css";
import { mainExamples, otherExamples } from "./Examples.jsx";
import { updateNotificationExamples } from "../update-notification/UpdateNotification.examples.js";
const url = new URL(window.location.href);

const list = {
...mainExamples,
...otherExamples,
...updateNotificationExamples
}

const entries = Object.entries(list);

export function Components() {
const ids = url.searchParams.getAll("id");
const isolated = url.searchParams.has("isolate");
const e2e = url.searchParams.has("e2e");
const entries = Object.entries(mainExamples).concat(Object.entries(otherExamples));
const entryIds = entries.map(([id]) => id);

const validIds = ids.filter(id => entryIds.includes(id));

const filtered = validIds.length
? validIds.map((id) => /** @type {const} */([id, mainExamples[id] || otherExamples[id]]))
? validIds.map((id) => /** @type {const} */([id, list[id]]))
: entries

if (isolated) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/* nested styles to avoid global side-effects */
[data-display="components"] {
a {
color: var(--ntp-text-normal);
}
}

body[data-display="components"] {
padding-left: 0;
Expand Down Expand Up @@ -35,7 +30,9 @@ body[data-display="components"] {
align-items: center;
gap: 1em;
}

.itemLink {
color: var(--ntp-text-normal);
padding: 0.2em 0.3em;
border: 1px solid var(--color-gray-60);
border-radius: 4px;
Expand Down
9 changes: 9 additions & 0 deletions special-pages/pages/new-tab/app/components/Layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { h } from 'preact'

export function Centered ({ children }) {
return (
<div class="layout-centered">
{children}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
justify-content: center;
align-items: center;
color: var(--ntp-text-normal);
background: var(--ntp-background-color);
height: 32px;
width: 32px;
line-height: 32px;
Expand Down
14 changes: 8 additions & 6 deletions special-pages/pages/new-tab/app/customizer/Customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ export function useContextMenu () {
e.stopImmediatePropagation()
const items = getItems()
/** @type {VisibilityMenuItem[]} */
const simplified = items.map(item => {
return {
id: item.id,
title: item.title
}
})
const simplified = items
.filter(x => x.id !== 'debug')
.map(item => {
return {
id: item.id,
title: item.title
}
})
messaging.contextMenu({ visibilityMenuItems: simplified })
}
document.body.addEventListener('contextmenu', handler)
Expand Down
Loading

0 comments on commit 8ad828f

Please sign in to comment.