From 275cff284ec1af9076735645165887887382d92d Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Wed, 9 Jul 2025 15:00:04 +0100 Subject: [PATCH 1/3] Move Apple dir PoC --- Package.swift | 29 ------------------- .../ContentScopeScripts.swift | 5 ---- .../ContentScopeScripts/dist/pages/.gitignore | 1 - eslint.config.js | 1 - injected/docs/development-utilities.md | 2 +- injected/integration-test/type-helpers.mjs | 4 +-- injected/scripts/entry-points.js | 4 +-- injected/unit-test/verify-artifacts.js | 7 ++--- package.json | 5 ++-- special-pages/README.md | 1 + special-pages/index.mjs | 2 +- .../integration-tests/duck-player.js | 2 +- special-pages/pages/errorpage/readme.md | 3 +- .../integration-tests/onboarding.js | 2 +- .../integration-tests/release-notes.js | 2 +- .../integration-tests/special-error.js | 2 +- 16 files changed, 17 insertions(+), 55 deletions(-) delete mode 100644 Package.swift delete mode 100644 Sources/ContentScopeScripts/ContentScopeScripts.swift delete mode 100644 Sources/ContentScopeScripts/dist/pages/.gitignore diff --git a/Package.swift b/Package.swift deleted file mode 100644 index 5c7881c216..0000000000 --- a/Package.swift +++ /dev/null @@ -1,29 +0,0 @@ -// swift-tools-version:5.5 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "ContentScopeScripts", - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "ContentScopeScripts", - targets: ["ContentScopeScripts"]), - ], - dependencies: [ - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "ContentScopeScripts", - dependencies: [], - resources: [ - .process("dist/contentScope.js"), - .process("dist/contentScopeIsolated.js"), - .copy("dist/pages"), - ] - ), - ] -) diff --git a/Sources/ContentScopeScripts/ContentScopeScripts.swift b/Sources/ContentScopeScripts/ContentScopeScripts.swift deleted file mode 100644 index c220f4f98d..0000000000 --- a/Sources/ContentScopeScripts/ContentScopeScripts.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -public struct ContentScopeScripts { - public static var Bundle: Bundle = .module -} diff --git a/Sources/ContentScopeScripts/dist/pages/.gitignore b/Sources/ContentScopeScripts/dist/pages/.gitignore deleted file mode 100644 index 72e8ffc0db..0000000000 --- a/Sources/ContentScopeScripts/dist/pages/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/eslint.config.js b/eslint.config.js index c6b6583c37..313092a5d0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,7 +12,6 @@ export default tseslint.config( '**/docs/', 'injected/lib', 'injected/playwright-report/', - 'Sources/ContentScopeScripts/dist/', 'injected/integration-test/extension/contentScope.js', 'injected/integration-test/test-pages/duckplayer/scripts/dist', 'special-pages/pages/**/public', diff --git a/injected/docs/development-utilities.md b/injected/docs/development-utilities.md index 6d5586954d..2ef6230ca3 100644 --- a/injected/docs/development-utilities.md +++ b/injected/docs/development-utilities.md @@ -161,4 +161,4 @@ historyMethodProxy.overload(); ### `DDGReflect` -Calls into `wrappedJSObject.Reflect` for Firefox but otherwise exactly the same as [window.Reflect](../../Sources/ContentScopeScripts/ContentScopeScripts.swift) +Calls into `wrappedJSObject.Reflect` for Firefox but otherwise exactly the same as `window.Reflect` diff --git a/injected/integration-test/type-helpers.mjs b/injected/integration-test/type-helpers.mjs index e74ea75127..5b348a85d4 100644 --- a/injected/integration-test/type-helpers.mjs +++ b/injected/integration-test/type-helpers.mjs @@ -59,8 +59,8 @@ export class Build { const path = this.switch({ windows: () => '../build/windows/contentScope.js', android: () => '../build/android/contentScope.js', - apple: () => '../Sources/ContentScopeScripts/dist/contentScope.js', - 'apple-isolated': () => '../Sources/ContentScopeScripts/dist/contentScopeIsolated.js', + apple: () => '../build/apple/contentScope.js', + 'apple-isolated': () => '../build/apple/contentScopeIsolated.js', 'android-autofill-password-import': () => '../build/android/autofillPasswordImport.js', 'android-broker-protection': () => '../build/android/brokerProtection.js', }); diff --git a/injected/scripts/entry-points.js b/injected/scripts/entry-points.js index 4ad12fb63a..f85aecc3f3 100644 --- a/injected/scripts/entry-points.js +++ b/injected/scripts/entry-points.js @@ -17,11 +17,11 @@ const builds = { }, apple: { input: 'entry-points/apple.js', - output: ['../Sources/ContentScopeScripts/dist/contentScope.js'], + output: ['../build/apple/contentScope.js'], }, 'apple-isolated': { input: 'entry-points/apple.js', - output: ['../Sources/ContentScopeScripts/dist/contentScopeIsolated.js'], + output: ['../build/apple/contentScopeIsolated.js'], }, android: { input: 'entry-points/android.js', diff --git a/injected/unit-test/verify-artifacts.js b/injected/unit-test/verify-artifacts.js index 196968b754..484228c184 100644 --- a/injected/unit-test/verify-artifacts.js +++ b/injected/unit-test/verify-artifacts.js @@ -6,8 +6,7 @@ import { cwd } from '../../scripts/script-utils.js'; const ROOT = join(cwd(import.meta.url), '..', '..'); console.log(ROOT); const BUILD = join(ROOT, 'build'); -const APPLE_BUILD = join(ROOT, 'Sources/ContentScopeScripts/dist'); -console.log(APPLE_BUILD); + let CSS_OUTPUT_SIZE = 770_000; if (process.platform === 'win32') { CSS_OUTPUT_SIZE = CSS_OUTPUT_SIZE * 1.1; // 10% larger for Windows due to line endings @@ -43,14 +42,14 @@ const checks = { tests: [{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE }], }, apple: { - file: join(APPLE_BUILD, 'contentScope.js'), + file: join(BUILD, 'apple/contentScope.js'), tests: [ { kind: 'maxFileSize', value: CSS_OUTPUT_SIZE }, { kind: 'containsString', text: '#bundledConfig', includes: false }, ], }, 'apple-isolated': { - file: join(APPLE_BUILD, 'contentScopeIsolated.js'), + file: join(BUILD, 'apple/contentScopeIsolated.js'), tests: [ { kind: 'maxFileSize', value: CSS_OUTPUT_SIZE }, { kind: 'containsString', text: 'Copyright (c) 2014-2015, hassansin', includes: true }, diff --git a/package.json b/package.json index 2f959beaf0..d1d2b093e3 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "injected", "special-pages", "messaging", - "build", - "Sources/ContentScopeScripts/dist" + "build" ], "scripts": { "build": "npm run build --workspaces --if-present", @@ -22,7 +21,7 @@ "tsc": "tsc", "tsc-watch": "tsc --watch", "lint": "eslint . && npm run tsc && npm run lint-no-output-globals && npx prettier . --check", - "lint-no-output-globals": "eslint --no-inline-config --config build-output.eslint.config.js Sources/ContentScopeScripts/dist/contentScope.js", + "lint-no-output-globals": "eslint --no-inline-config --config build-output.eslint.config.js build/apple/contentScope.js", "postlint": "npm run lint --workspaces --if-present", "lint-fix": "eslint . --fix && npx prettier . --write && npm run tsc", "stylelint": "npx stylelint \"**/*.css\"", diff --git a/special-pages/README.md b/special-pages/README.md index 5b806fc0de..9e82f0426c 100644 --- a/special-pages/README.md +++ b/special-pages/README.md @@ -37,6 +37,7 @@ Then access the Example page you edited via: `http://127.0.0.1:3210/example/` > **Note**: The output of the build command is just plain HTML/CSS/JS, so you can serve the build directory in any way that suits you. + ### Step 4: Watch Mode The build command builds every special page, but to run just 1 in isolation: diff --git a/special-pages/index.mjs b/special-pages/index.mjs index a2a19390b2..26d96eabf1 100644 --- a/special-pages/index.mjs +++ b/special-pages/index.mjs @@ -13,7 +13,7 @@ import { baseEsbuildOptions } from './opts.mjs'; const CWD = cwd(import.meta.url); const ROOT = join(CWD, '../'); const BUILD = join(ROOT, 'build'); -const APPLE_BUILD = join(ROOT, 'Sources/ContentScopeScripts/dist'); +const APPLE_BUILD = join(BUILD, 'apple'); const args = parseArgs(process.argv.slice(2), []); const NODE_ENV = args.env || 'production'; const DEBUG = Boolean(args.debug); diff --git a/special-pages/pages/duckplayer/integration-tests/duck-player.js b/special-pages/pages/duckplayer/integration-tests/duck-player.js index a6da9b318c..51460d6f6a 100644 --- a/special-pages/pages/duckplayer/integration-tests/duck-player.js +++ b/special-pages/pages/duckplayer/integration-tests/duck-player.js @@ -560,7 +560,7 @@ export class DuckPlayerPage { return this.build.switch({ windows: () => '../build/windows/pages/duckplayer', android: () => '../build/android/pages/duckplayer', - apple: () => '../Sources/ContentScopeScripts/dist/pages/duckplayer', + apple: () => '../build/apple/pages/duckplayer', }); } diff --git a/special-pages/pages/errorpage/readme.md b/special-pages/pages/errorpage/readme.md index d0cff014d4..3ca05aa6bb 100644 --- a/special-pages/pages/errorpage/readme.md +++ b/special-pages/pages/errorpage/readme.md @@ -20,8 +20,7 @@ The main HTML file is located at `src/index.html`. You can edit this file direct ### CSS The main stylesheet is located at `src/style.css`. You can edit this file directly -The build process will create a bundle and place it inside `Sources/ContentScopeScripts/dist/pages/onboarding` -on macOS - other platforms will be under `build//pages/errorpage` +The build process will create a bundle and place it under `build//pages/errorpage` Don't edit the generated files directly - any changes you make will not be reflected in the final build output. diff --git a/special-pages/pages/onboarding/integration-tests/onboarding.js b/special-pages/pages/onboarding/integration-tests/onboarding.js index 8057a5b86b..347c7a14e2 100644 --- a/special-pages/pages/onboarding/integration-tests/onboarding.js +++ b/special-pages/pages/onboarding/integration-tests/onboarding.js @@ -139,7 +139,7 @@ export class OnboardingPage { get basePath() { return this.build.switch({ windows: () => '../build/windows/pages/onboarding', - apple: () => '../Sources/ContentScopeScripts/dist/pages/onboarding', + apple: () => '../build/apple/pages/onboarding', }); } diff --git a/special-pages/pages/release-notes/integration-tests/release-notes.js b/special-pages/pages/release-notes/integration-tests/release-notes.js index 7895634f2d..d75b0655f9 100644 --- a/special-pages/pages/release-notes/integration-tests/release-notes.js +++ b/special-pages/pages/release-notes/integration-tests/release-notes.js @@ -68,7 +68,7 @@ export class ReleaseNotesPage { get basePath() { return this.build.switch({ // windows: () => '../../build/windows/pages/release-notes', - apple: () => '../Sources/ContentScopeScripts/dist/pages/release-notes', + apple: () => '../build/apple/pages/release-notes', }); } diff --git a/special-pages/pages/special-error/integration-tests/special-error.js b/special-pages/pages/special-error/integration-tests/special-error.js index 1cb3b6f7a3..b6a398d7aa 100644 --- a/special-pages/pages/special-error/integration-tests/special-error.js +++ b/special-pages/pages/special-error/integration-tests/special-error.js @@ -97,7 +97,7 @@ export class SpecialErrorPage { get basePath() { return this.build.switch({ windows: () => '../build/windows/pages/special-error', - apple: () => '../Sources/ContentScopeScripts/dist/pages/special-error', + apple: () => '../build/apple/pages/special-error', }); } From 60238fe2bef7246b1ac73c1b48551677920b7653 Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Wed, 9 Jul 2025 15:12:30 +0100 Subject: [PATCH 2/3] Remove Sources from build --- .github/scripts/diff-directories.js | 3 --- .github/workflows/build-pr.yml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/scripts/diff-directories.js b/.github/scripts/diff-directories.js index c2cd9c83db..8d1b5408ec 100644 --- a/.github/scripts/diff-directories.js +++ b/.github/scripts/diff-directories.js @@ -113,11 +113,8 @@ function sortFiles(dirFiles, dirName) { } const buildDir = '/build'; -const sourcesOutput = '/Sources/ContentScopeScripts/'; sortFiles(readFilesRecursively(dir1 + buildDir), 'dir1'); sortFiles(readFilesRecursively(dir2 + buildDir), 'dir2'); -sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1'); -sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2'); // console.log(Object.keys(files)) const fileOut = displayDiffs(sections.dir1, sections.dir2); diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index fc20bf2103..ab5c7fd443 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -41,7 +41,7 @@ jobs: git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git checkout -b pr-releases/pr-${PR_NUMBER} - git add -f build Sources + git add -f build git commit -m "Add build folder for PR ${PR_NUMBER}" git push -u origin pr-releases/pr-${PR_NUMBER} --force echo "BRANCH_NAME=pr-releases/pr-${PR_NUMBER}" >> $GITHUB_ENV From 7f308c0503632c07a0fcddfb0a636fb734aeb64b Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Wed, 9 Jul 2025 16:13:49 +0100 Subject: [PATCH 3/3] Remove apple dir fork --- special-pages/index.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/special-pages/index.mjs b/special-pages/index.mjs index 26d96eabf1..753fa0d681 100644 --- a/special-pages/index.mjs +++ b/special-pages/index.mjs @@ -13,7 +13,6 @@ import { baseEsbuildOptions } from './opts.mjs'; const CWD = cwd(import.meta.url); const ROOT = join(CWD, '../'); const BUILD = join(ROOT, 'build'); -const APPLE_BUILD = join(BUILD, 'apple'); const args = parseArgs(process.argv.slice(2), []); const NODE_ENV = args.env || 'production'; const DEBUG = Boolean(args.debug); @@ -84,7 +83,7 @@ for (const [pageName, injectNames] of Object.entries(support)) { } for (const [injectName, jobs] of Object.entries(injectNames)) { // output main dir - const buildDir = injectName === 'apple' ? APPLE_BUILD : join(BUILD, injectName); + const buildDir = join(BUILD, injectName); const pageOutputDirectory = join(buildDir, 'pages', pageName);