Skip to content

Commit

Permalink
🚧 Partial implementation of the pageAction api (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr authored Dec 24, 2023
1 parent 520c72a commit 572d313
Show file tree
Hide file tree
Showing 53 changed files with 2,418 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const sharedSettings = (contentFiles, dev) => {
}),
new WebpackLicensePlugin({
licenseOverrides: {
'remixicon@3.5.0': 'Apache-2.0',
'remixicon@3.7.0': 'Apache-2.0',
},

includePackages: () =>
Expand Down
5 changes: 5 additions & 0 deletions docs/webext/background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Background pages

## Differences

- Non-persistent background pages will not restart
5 changes: 5 additions & 0 deletions docs/webext/pageAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# PageActions

## Differences

- `onClicked`: The first argument is the click info, not the `Tab` info
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"eslint": "^8.53.0",
"eslint-plugin-listeners": "^1.4.0",
"execa": "^8.0.1",
"gecko-types": "github:quark-platform/gecko-types",
"html-webpack-plugin": "^5.5.3",
Expand All @@ -54,9 +55,9 @@
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-svelte": "^3.0.3",
"style-loader": "^3.3.3",
"svelte": "^4.2.1",
"svelte": "^4.2.8",
"svelte-loader": "^3.1.9",
"svelte-preprocess": "^5.0.4",
"svelte-preprocess": "^5.1.2",
"svelte-sequential-preprocessor": "^2.0.1",
"ts-loader": "^9.5.0",
"typescript": "^5.2.2",
Expand All @@ -72,12 +73,12 @@
"fnts": "^2.0.1",
"mitt": "^3.0.1",
"nanoid": "^5.0.3",
"remixicon": "^3.5.0",
"remixicon": "^3.7.0",
"snarkdown": "^2.0.0"
},
"pnpm": {
"patchedDependencies": {
"svelte@4.2.1": "patches/svelte@4.2.1.patch",
"svelte@4.2.8": "patches/svelte@4.2.1.patch",
"webpack-license-plugin@4.4.2": "patches/webpack-license-plugin@4.4.2.patch",
"@melt-ui/svelte@0.64.5": "patches/@melt-ui__svelte@0.64.5.patch"
}
Expand Down Expand Up @@ -123,7 +124,8 @@
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"listeners"
],
"rules": {
"@typescript-eslint/triple-slash-reference": "off",
Expand Down
84 changes: 48 additions & 36 deletions pnpm-lock.yaml

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

11 changes: 10 additions & 1 deletion scripts/lib/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ import { getArtifactFile } from './constants.js'
export const CHANGES: { file: string; append?: string | string[] }[] = [
{
file: 'chrome/chrome.manifest',
append:
append: [
'locale branding en-US en-US/locale/branding/',
'resource search-extensions browser/content/browser/search-extensions/ contentaccessible=yes',
],
},
{
file: 'components/components.manifest',
append: [
'category webextension-modules browser chrome://browser/content/extensions/ext-browser.json',
'category webextension-scripts c-browser chrome://browser/content/extensions/parent/ext-browser.js',
],
},
]

Expand Down
6 changes: 5 additions & 1 deletion scripts/lib/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MPL_HEADER = [

const FIXES = [
{
regex: new RegExp('.*\\.(css|((j|t)s))'),
regex: new RegExp('.*\\.(css|(m?(j|t)s))'),
commentOpen: '/* ',
comment: ' * ',
commentClose: ' */\n',
Expand All @@ -22,6 +22,10 @@ const FIXES = [
comment: ' - ',
commentClose: ' -->\n',
},
{
regex: new RegExp('.*\\.(py|ftl)'),
comment: '# ',
},
]

export function isValidLicense(file: string): boolean {
Expand Down
27 changes: 22 additions & 5 deletions scripts/lib/linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,38 @@ export async function linkTscFolder(folderName: string) {
}
}

export async function linkStaticFolder(folderName: string) {
export async function linkStaticFolder(
folderName: string,
outFolderName?: string,
ext = '.sys.mjs',
) {
const linkFile = await readFile(
getStaticFile(`${folderName}/link.json`),
'utf-8',
)
const links = JSON.parse(linkFile) as string[]

for (const link of links) {
const fileName = `${link}.sys.mjs`
const geckoPath = getArtifactFile(`${folderName}/${fileName}`)
const fileName = `${link}${ext}`
const geckoPath = getArtifactFile(
`${outFolderName || folderName}/${fileName}`,
)
const srcFile = getStaticFile(`${folderName}/${fileName}`)

if (existsSync(geckoPath)) await rm(geckoPath)
if (!existsSync(dirname(srcFile)))
if (!existsSync(dirname(geckoPath)))
await mkdir(dirname(geckoPath), { recursive: true })
await symlink(getStaticFile(`${folderName}/${fileName}`), geckoPath)
await symlink(srcFile, geckoPath)
}
}

export async function linkFolder(staticName: string, outputName: string) {
const staticFolder = getStaticFile(staticName)
const geckoFolder = getArtifactFile(outputName)

if (existsSync(geckoFolder)) await rm(geckoFolder, { recursive: true })
if (!existsSync(dirname(geckoFolder)))
await mkdir(dirname(geckoFolder), { recursive: true })

await symlink(staticFolder, geckoFolder)
}
Loading

0 comments on commit 572d313

Please sign in to comment.