Skip to content

Move Apple dir PoC #1808

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 0 additions & 3 deletions .github/scripts/diff-directories.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 0 additions & 29 deletions Package.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Sources/ContentScopeScripts/ContentScopeScripts.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/ContentScopeScripts/dist/pages/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion injected/docs/development-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
4 changes: 2 additions & 2 deletions injected/integration-test/type-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down
4 changes: 2 additions & 2 deletions injected/scripts/entry-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 3 additions & 4 deletions injected/unit-test/verify-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 },
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"injected",
"special-pages",
"messaging",
"build",
"Sources/ContentScopeScripts/dist"
"build"
],
"scripts": {
"build": "npm run build --workspaces --if-present",
Expand All @@ -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\"",
Expand Down
1 change: 1 addition & 0 deletions special-pages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions special-pages/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
const CWD = cwd(import.meta.url);
const ROOT = join(CWD, '../');
const BUILD = join(ROOT, 'build');
const APPLE_BUILD = join(ROOT, 'Sources/ContentScopeScripts/dist');
const args = parseArgs(process.argv.slice(2), []);
const NODE_ENV = args.env || 'production';
const DEBUG = Boolean(args.debug);
Expand Down Expand Up @@ -84,7 +83,7 @@
}
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);

Expand All @@ -101,7 +100,7 @@
const outputDir = join(pageOutputDirectory, 'dist');
buildJobs.push({
outputDir,
injectName: /** @type {ImportMeta['injectName']} */ (injectName),

Check warning on line 103 in special-pages/index.mjs

View workflow job for this annotation

GitHub Actions / snapshots

Expected property shorthand

Check warning on line 103 in special-pages/index.mjs

View workflow job for this annotation

GitHub Actions / unit (windows-latest)

Expected property shorthand

Check warning on line 103 in special-pages/index.mjs

View workflow job for this annotation

GitHub Actions / unit (ubuntu-latest)

Expected property shorthand
pageName,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
}

Expand Down
3 changes: 1 addition & 2 deletions special-pages/pages/errorpage/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<PLATFORM>/pages/errorpage`
The build process will create a bundle and place it under `build/<PLATFORM>/pages/errorpage`

Don't edit the generated files directly - any changes you make will not be reflected in the final build output.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
}

Expand Down
Loading