@extension.dev/skill 0.5.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +131 -2
- package/LICENSE +201 -21
- package/README.md +52 -16
- package/package.json +15 -7
- package/skills/extension-dev/SKILL.md +111 -29
- package/skills/extension-dev/references/cross-browser.md +49 -33
- package/skills/extension-dev/references/debugging.md +149 -48
- package/skills/extension-dev/references/migrating.md +72 -0
- package/skills/extension-dev/references/project-structure.md +42 -6
- package/skills/extension-dev/references/publishing.md +186 -26
- package/skills/extension-dev/references/store-md.md +19 -5
- package/skills/extension-dev/references/surface-content.md +54 -0
- package/skills/extension-dev/references/surface-devtools.md +49 -0
- package/skills/extension-dev/references/surface-newtab.md +44 -0
- package/skills/extension-dev/references/surface-options.md +41 -0
- package/skills/extension-dev/references/surface-popup.md +44 -0
- package/skills/extension-dev/references/surface-sidepanel.md +52 -0
- package/skills/extension-dev/references/templates.md +8 -5
|
@@ -21,8 +21,8 @@ my-extension/
|
|
|
21
21
|
styles.css
|
|
22
22
|
images/
|
|
23
23
|
icon.png
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
pages/ Special folder: HTML pages not in the manifest
|
|
25
|
+
scripts/ Special folder: scripts not in the manifest
|
|
26
26
|
public/ Special folder: static files copied verbatim
|
|
27
27
|
_locales/ i18n messages at project root, NOT src/ (see below)
|
|
28
28
|
extension.config.js Optional build config
|
|
@@ -53,15 +53,28 @@ Two more bundling facts that surprise people:
|
|
|
53
53
|
|
|
54
54
|
### Special folders
|
|
55
55
|
|
|
56
|
-
Three folders get build treatment without manifest references
|
|
56
|
+
Three folders get build treatment without manifest references. All three
|
|
57
|
+
live at the **project root**, next to `package.json`, never under `src/`:
|
|
58
|
+
the engine discovers them at the root and ignores `src/pages/` and
|
|
59
|
+
`src/scripts/` without a word, so pages placed there are not emitted.
|
|
57
60
|
|
|
58
61
|
- `pages/`: HTML pages bundled and served like manifest pages (open them via
|
|
59
62
|
`chrome.runtime.getURL`).
|
|
60
63
|
- `scripts/`: script files compiled as standalone entries (for
|
|
61
|
-
`chrome.scripting.executeScript` targets and similar).
|
|
64
|
+
`chrome.scripting.executeScript` targets and similar). The name collides
|
|
65
|
+
with the `scripts/` folder many repositories keep for tooling: every file
|
|
66
|
+
in it becomes a build entry, and the first build writes outputs for them.
|
|
67
|
+
If the repository already has a tooling `scripts/`, move the tooling or do
|
|
68
|
+
not adopt the special folder; there is no opt-out key yet.
|
|
62
69
|
- `public/`: copied to the output root verbatim, no bundling or hashing. The
|
|
63
70
|
build refuses files in `public/` that would overwrite generated assets, and
|
|
64
|
-
a manifest.json inside `public/` is an error.
|
|
71
|
+
a manifest.json inside `public/` is an error. On Extension.js 4.1.30 and
|
|
72
|
+
earlier, manifest icons and pages are resolved next to the **manifest**,
|
|
73
|
+
so the layout above (`src/manifest.json`, root `public/`) cannot name an
|
|
74
|
+
icon kept in `public/`: the build reports it NOT FOUND under `src/`. Until
|
|
75
|
+
the project runs a newer engine, keep icons the manifest names under
|
|
76
|
+
`src/` (or the manifest at the root); newer engines resolve `public/` at
|
|
77
|
+
the project root for icons, pages and web-accessible resources alike.
|
|
65
78
|
|
|
66
79
|
## i18n and `_locales`
|
|
67
80
|
|
|
@@ -172,7 +185,30 @@ debugging stateful features far less painful.
|
|
|
172
185
|
|
|
173
186
|
- Import images and fonts directly from code; the bundler handles emission.
|
|
174
187
|
- CSS Modules: `*.module.css` / `*.module.scss`. Never add the `?url` suffix
|
|
175
|
-
to a CSS module import; it silently breaks class-name hashing.
|
|
188
|
+
to a CSS module import; it silently breaks class-name hashing. On
|
|
189
|
+
Extension.js 4.1.30 and earlier a CSS module has **named exports only**:
|
|
190
|
+
write `import * as styles from "./x.module.scss"` or
|
|
191
|
+
`import { button } from "./x.module.scss"`; the common
|
|
192
|
+
`import styles from "./x.module.scss"` fails with one
|
|
193
|
+
"export 'default' was not found" linking error per class. To keep the
|
|
194
|
+
default import on those engines, set the parser option in
|
|
195
|
+
`extension.config.js`:
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
export default {
|
|
199
|
+
config: (config) => {
|
|
200
|
+
config.module.parser ??= {};
|
|
201
|
+
config.module.parser["css/module"] = {
|
|
202
|
+
...config.module.parser["css/module"],
|
|
203
|
+
namedExports: false,
|
|
204
|
+
};
|
|
205
|
+
return config;
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Newer engines export a default again, so the switch can go once the
|
|
211
|
+
project upgrades.
|
|
176
212
|
- Tailwind works out of the box in templates that ship it; check the template
|
|
177
213
|
source rather than wiring it by hand.
|
|
178
214
|
|
|
@@ -11,11 +11,13 @@ npm run build -- --browser=chrome --zip
|
|
|
11
11
|
npm run build -- --browser=firefox --zip --zip-source
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Verify the
|
|
15
|
-
|
|
16
|
-
unhashed asset paths, dev CSP
|
|
14
|
+
Verify the artifact you ship before shipping: `npm run build`, then
|
|
15
|
+
`npm run preview`, which opens the built directory without rebuilding and
|
|
16
|
+
catches dev-only assumptions (HMR globals, unhashed asset paths, dev CSP
|
|
17
|
+
relaxations). `start` rebuilds with the polyfill on, so it tests a different
|
|
18
|
+
artifact (core rule 5).
|
|
17
19
|
|
|
18
|
-
MCP: `extension_build`, `extension_start
|
|
20
|
+
MCP: `extension_build`, `extension_start`.
|
|
19
21
|
|
|
20
22
|
## Zip hygiene
|
|
21
23
|
|
|
@@ -53,8 +55,8 @@ store, so resubmissions do not reinvent them. The full convention, template,
|
|
|
53
55
|
and maintenance rules live in [store-md.md](store-md.md). Exclude the file
|
|
54
56
|
from the zip.
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
A submission reads `STORE.md` automatically and sends the fields the store
|
|
59
|
+
APIs accept: Firefox reviewer and release notes, and Edge certification
|
|
58
60
|
notes. Chrome listing fields are dashboard-only by store policy and stay
|
|
59
61
|
copy-paste.
|
|
60
62
|
|
|
@@ -80,13 +82,14 @@ Credential shapes and portals:
|
|
|
80
82
|
|
|
81
83
|
- Chrome: publisher UUID (from chrome.google.com/webstore/devconsole/<UUID>)
|
|
82
84
|
plus either a GCP service account JSON (grant its email under dev console >
|
|
83
|
-
Account; preferred, no expiry) or the OAuth
|
|
84
|
-
(`123.apps.googleusercontent.com`), client
|
|
85
|
-
token (`1//...`).
|
|
86
|
-
|
|
87
|
-
for this: it needs a Web-application
|
|
88
|
-
|
|
89
|
-
Testing status, Google revokes the refresh
|
|
85
|
+
Account; preferred, no expiry, and nothing has to be minted) or the OAuth
|
|
86
|
+
trio: Desktop-app client ID (`123.apps.googleusercontent.com`), client
|
|
87
|
+
secret (`GOCSPX-...`), refresh token (`1//...`). The refresh token comes
|
|
88
|
+
from a local loopback consent flow against that Desktop-app client. Never
|
|
89
|
+
recommend the Google OAuth Playground for this: it needs a Web-application
|
|
90
|
+
redirect URI and fails a Desktop-app client with redirect_uri_mismatch. If
|
|
91
|
+
the OAuth consent screen is in Testing status, Google revokes the refresh
|
|
92
|
+
token after 7 days. Prefer the service account and skip the trio.
|
|
90
93
|
- Firefox: JWT issuer (`user:12345678:987`) and JWT secret (64 hex, shown
|
|
91
94
|
once) from addons.mozilla.org/developers/addon/api/key/. Listed channel
|
|
92
95
|
requires an existing add-on GUID. Unlisted with an empty GUID creates a
|
|
@@ -105,14 +108,14 @@ Blast radius: all three stores' API credentials are account-wide, not
|
|
|
105
108
|
per-extension. For multi-client work, keep each client's listings under that
|
|
106
109
|
client's own store accounts.
|
|
107
110
|
|
|
108
|
-
Where they live
|
|
109
|
-
|
|
110
|
-
on that project's
|
|
111
|
-
|
|
112
|
-
the
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
Where they live: per project, never per workspace. Credentials are entered
|
|
112
|
+
once in the extension.dev console under the project's store settings, and the
|
|
113
|
+
platform writes them as write-only GitHub Actions secrets on that project's
|
|
114
|
+
managed mirror repo (STORE_CHROME_*, STORE_FIREFOX_API_KEY/API_SECRET,
|
|
115
|
+
STORE_EDGE_CLIENT_ID/CLIENT_SECRET; the Edge CLIENT_SECRET holds the API
|
|
116
|
+
key). Identifiers go to the mirror's _extension-dev/settings.json. Rotation
|
|
117
|
+
always means re-entering values. Credentials are never tool arguments and
|
|
118
|
+
never leave the console, so no submission command takes one.
|
|
116
119
|
|
|
117
120
|
## Firefox specifics
|
|
118
121
|
|
|
@@ -134,17 +137,99 @@ of git).
|
|
|
134
137
|
The platform has its own publish flow for hosting and distribution:
|
|
135
138
|
|
|
136
139
|
```bash
|
|
137
|
-
# One-time device
|
|
138
|
-
extension login
|
|
139
|
-
extension whoami
|
|
140
|
+
# One-time device login: approve the printed code at extension.dev/device
|
|
141
|
+
npx @extension.dev/mcp login --project <workspace>/<project> # MCP: extension_auth action:login
|
|
142
|
+
npx @extension.dev/mcp whoami # MCP: extension_auth action:status
|
|
140
143
|
|
|
141
144
|
# Publish the built extension (shareable preview URL)
|
|
142
|
-
extension publish
|
|
145
|
+
EXTENSION_DEV_TOKEN=<token> extension publish # MCP: extension_publish
|
|
143
146
|
```
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
Login is a two-phase RFC 8628 device flow hosted by extension.dev itself: the
|
|
149
|
+
first call returns a user code plus `extension.dev/device`, the user approves
|
|
150
|
+
it there in a browser signed in to extension.dev, and the second call stores a
|
|
151
|
+
project-scoped token that lives at most 7 days. GitHub is federated
|
|
152
|
+
server-side, so no GitHub token ever lands on the developer's machine, and
|
|
153
|
+
there is no github.com step to send the user to. `extension_auth` with
|
|
154
|
+
`action: "logout"` signs the session out again. Publishing requires a prior
|
|
146
155
|
successful build for the target browser.
|
|
147
156
|
|
|
157
|
+
Token pickup is the same on both surfaces: the MCP tool `extension_publish`
|
|
158
|
+
reads `EXTENSION_DEV_TOKEN` first and falls back to the stored device login,
|
|
159
|
+
and the `extension publish` CLI reads `--token`, then `EXTENSION_DEV_TOKEN`,
|
|
160
|
+
then the same stored device login that `extension_auth` wrote, so neither
|
|
161
|
+
needs anything after login. There is no `extension login`; device login
|
|
162
|
+
lives in the MCP package only.
|
|
163
|
+
|
|
164
|
+
`extension_auth` can only sign in to a project that already exists. If the
|
|
165
|
+
extension has no extension.dev project yet, push the source to GitHub first,
|
|
166
|
+
then call `extension_project_create`, then `extension_auth`. In that order,
|
|
167
|
+
and never the reverse: logging in first just fails against a project that is
|
|
168
|
+
not there. Project creation can only target an existing workspace, so when
|
|
169
|
+
the workspace itself is not there yet, call `extension_workspace_create`
|
|
170
|
+
before `extension_project_create`: it is two-phase like login (a code and a
|
|
171
|
+
URL a signed-in GitHub user approves, then a second call with the returned
|
|
172
|
+
`deviceCode`), and whoever approves the code owns the workspace.
|
|
173
|
+
|
|
174
|
+
Several projects in one workspace cost one approval, not two each. Both
|
|
175
|
+
tools take `projects` in place of `project`:
|
|
176
|
+
|
|
177
|
+
- `extension_project_create` with `projects: [{ project, repo }, ...]`
|
|
178
|
+
creates up to 10 projects and stores each one's 7-day token as that
|
|
179
|
+
project's login, so no `extension_auth` call follows. Ten per approval
|
|
180
|
+
is the platform's cap, because it creates at most 10 projects per hour
|
|
181
|
+
for one approving account: plan a longer set as ten now and the next ten
|
|
182
|
+
in a new call once that hourly limit allows. Build inputs given at the
|
|
183
|
+
top level are the default; an entry may override them.
|
|
184
|
+
- `extension_auth` with `action: "login"` and `projects: ["<workspace>/<project>", ...]`
|
|
185
|
+
signs in to up to 20 existing projects, and is how logins that expire
|
|
186
|
+
together are renewed in one approval.
|
|
187
|
+
|
|
188
|
+
Name each project by its exact slug (lowercase letters and digits joined by
|
|
189
|
+
single dashes, at most 48 characters), all in one workspace, none twice; the
|
|
190
|
+
tool refuses anything else before a device code is spent, and refuses any
|
|
191
|
+
list on a platform that does not advertise batch onboarding, in which case
|
|
192
|
+
make one call per project. The approval page
|
|
193
|
+
lists every name, so tell the user to read the list before approving. A
|
|
194
|
+
create list takes a few calls: while the answer is `status: "creating"`,
|
|
195
|
+
call again with the same `deviceCode` and arguments. Read the per-project
|
|
196
|
+
rows in the answer rather than the top-level status: one project refused
|
|
197
|
+
does not stop the others, a row marked `loggedIn: false` needs a batch
|
|
198
|
+
login, and a row marked `not-attempted` needs a new create call. Do not mix
|
|
199
|
+
existing and new projects in one create list; the platform refuses it whole.
|
|
200
|
+
|
|
201
|
+
## Sharing a build before it ships
|
|
202
|
+
|
|
203
|
+
`extension_preview_web` with `share: true` uploads the build and returns a
|
|
204
|
+
link that opens the extension in a web emulator: no install, no sign-in, no
|
|
205
|
+
dev server on the other end. It is the way to show a build to a reviewer, a
|
|
206
|
+
client, or a teammate, and it is the only lane of that tool that works from
|
|
207
|
+
an npm install of the MCP server. Without `share: true` the tool returns a
|
|
208
|
+
`preview://build` deep link that resolves only against a local
|
|
209
|
+
preview.extension.dev dev server, which is for people developing
|
|
210
|
+
extension.dev itself.
|
|
211
|
+
|
|
212
|
+
Say what a share does before making one: it also serves the build as a zip,
|
|
213
|
+
so the recipient gets the built code, not just a rendering of it. Read the
|
|
214
|
+
`share` property of the response back to the user.
|
|
215
|
+
|
|
216
|
+
`extension_shares` is the other half, and the reason a share is not a
|
|
217
|
+
one-way door:
|
|
218
|
+
|
|
219
|
+
- `action: "list"` returns every share the token owns, live and dead, with
|
|
220
|
+
its `artifactId`, `previewUrl`, `zipUrl`, `revokeUrl` and expiry, so a link
|
|
221
|
+
whose response was lost is findable again.
|
|
222
|
+
- `action: "revoke"` kills one permanently, by `artifactId` or by any URL of
|
|
223
|
+
the share. The link you sent someone is enough to pull it back.
|
|
224
|
+
- `attribution.ownership` says who may revoke: `project` means any workspace
|
|
225
|
+
member can, `personal` means one person holds it alone, `unknown` means no
|
|
226
|
+
owner was disclosed. Read `attribution.credit` as credit only, never as
|
|
227
|
+
access.
|
|
228
|
+
|
|
229
|
+
Never share a build and leave the session without recording the link. If it
|
|
230
|
+
is already lost, `extension_shares` with `action: "list"` is the recovery
|
|
231
|
+
path, not a support ticket.
|
|
232
|
+
|
|
148
233
|
## Promoting releases headlessly
|
|
149
234
|
|
|
150
235
|
Projects released through extension.dev promote tested builds to channels
|
|
@@ -161,3 +246,78 @@ caller passes only the build sha and target channel.
|
|
|
161
246
|
|
|
162
247
|
Cutting a release (the version-bump PR) stays interactive by design: it
|
|
163
248
|
writes to the source repo.
|
|
249
|
+
|
|
250
|
+
## Submitting to the stores through extension.dev
|
|
251
|
+
|
|
252
|
+
`extension_submit` is the tool for store review. It is the most consequential
|
|
253
|
+
call in this document and the least reversible, so read this section before
|
|
254
|
+
using it.
|
|
255
|
+
|
|
256
|
+
What it does: submits a built commit for review at the Chrome Web Store,
|
|
257
|
+
Firefox AMO, Edge Add-ons and the App Store (Safari). The platform holds the
|
|
258
|
+
store credentials and dispatches from the project's mirror CI, so no
|
|
259
|
+
credential is ever an argument and no local file is uploaded. There is no
|
|
260
|
+
`extension` CLI equivalent.
|
|
261
|
+
|
|
262
|
+
What it is not: it does not push a build to the extension.dev platform and it
|
|
263
|
+
does not make a shareable link. Those are `extension_publish` and
|
|
264
|
+
`extension_preview_web`. When a user says "deploy", "ship" or "release", they
|
|
265
|
+
almost always mean publish. Reach for `extension_submit` only when the ask is
|
|
266
|
+
explicitly a store submission.
|
|
267
|
+
|
|
268
|
+
```text
|
|
269
|
+
extension_submit
|
|
270
|
+
browsers: ["chrome", "firefox"] required
|
|
271
|
+
buildSha: <built commit sha> required; from extension_release_status
|
|
272
|
+
channel: stable default
|
|
273
|
+
dryRun: true DEFAULT. false dispatches, irreversibly.
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
How to use it safely:
|
|
277
|
+
|
|
278
|
+
1. **Dry run first, always.** `dryRun` defaults to `true` and dispatches
|
|
279
|
+
nothing. The platform checks auth, project, build and store workflow, and
|
|
280
|
+
the tool adds a per-store credential-health verdict on top. Trust the
|
|
281
|
+
per-store rows over the platform's bare preflight line, which does not
|
|
282
|
+
check store health.
|
|
283
|
+
2. **Read every row before passing `dryRun: false`.** A row reading NOT
|
|
284
|
+
actionable means that store would fail. A row reading cannot be verified
|
|
285
|
+
means the check could not read the project's store configuration, not that
|
|
286
|
+
the store is fine.
|
|
287
|
+
3. **`dryRun: false` is a one-way door.** It enters store review. Confirm
|
|
288
|
+
with the user in the same breath as calling it; never pass it because a
|
|
289
|
+
dry run looked good.
|
|
290
|
+
4. **The build sha must already exist.** An unknown sha is rejected. Get one
|
|
291
|
+
from `extension_release_status`, never from `git rev-parse` and hope.
|
|
292
|
+
5. **Store publish mode is invisible from here.** Whether a store is set to
|
|
293
|
+
draft, skip-publish or live is not readable with a CLI token, so the tool
|
|
294
|
+
says so instead of guessing. Check it in the console.
|
|
295
|
+
6. **Safari is a paid lane.** A free workspace is refused for the App Store;
|
|
296
|
+
the other three stores are unaffected by that refusal.
|
|
297
|
+
|
|
298
|
+
The tool also reads the project's `STORE.md` and warns when Firefox reviewer
|
|
299
|
+
notes or Edge certification notes are missing. Trust that advisory: the
|
|
300
|
+
parser is a pinned port of the one the real submission uses, held to it by a
|
|
301
|
+
test that replays both over the same corpus, so a warning here means a
|
|
302
|
+
missing field there. One caveat it states itself: the submission reads
|
|
303
|
+
`STORE.md` from the project's source repository at the built commit, so an
|
|
304
|
+
uncommitted or unpushed edit does not travel with it.
|
|
305
|
+
|
|
306
|
+
## Reading where a project stands
|
|
307
|
+
|
|
308
|
+
`extension_release_status` reads the project's state from the public registry
|
|
309
|
+
and is read-only: it dispatches nothing and promotes nothing, so it is always
|
|
310
|
+
safe to call.
|
|
311
|
+
|
|
312
|
+
- `include: ["releases"]` returns the release channels (channel to promoted
|
|
313
|
+
build sha), recent builds, and a public build-page URL for each. **This is
|
|
314
|
+
where a valid sha for `extension_release_promote`, `extension_submit` or
|
|
315
|
+
`extension_publish` comes from.**
|
|
316
|
+
- `include: ["stores"]` returns the per-store picture after a submission:
|
|
317
|
+
configured or not, the last credential health check, the last recorded
|
|
318
|
+
submission, and the latest review status. This is how "was it approved?"
|
|
319
|
+
gets answered without opening the console.
|
|
320
|
+
|
|
321
|
+
Both are included by default. It reads the logged-in project unless you pass
|
|
322
|
+
`workspace` and `project`. Registry state can lag the store dashboards by up
|
|
323
|
+
to a polling interval, so a status that has not moved yet is not a failure.
|
|
@@ -6,9 +6,9 @@ justifications, privacy disclosures, version history, and per-store notes.
|
|
|
6
6
|
Cross-browser extensions submit to several stores; this file is the one place
|
|
7
7
|
where that paperwork lives, so resubmissions never reinvent it.
|
|
8
8
|
|
|
9
|
-
It has a second job:
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
It has a second job: a store submission through extension.dev reads it
|
|
10
|
+
automatically and attaches the fields the store APIs accept. Everything else
|
|
11
|
+
stays a copy-paste reference for the dashboard forms.
|
|
12
12
|
|
|
13
13
|
## When to create it
|
|
14
14
|
|
|
@@ -82,8 +82,8 @@ Anything the certification team needs to test the extension.
|
|
|
82
82
|
|
|
83
83
|
## What gets submitted automatically
|
|
84
84
|
|
|
85
|
-
At
|
|
86
|
-
submission; explicit
|
|
85
|
+
At submission time these fields are read from the file and sent with the
|
|
86
|
+
submission; explicit flags or config values win over the file:
|
|
87
87
|
|
|
88
88
|
| Store section | `###` field | Sent as |
|
|
89
89
|
| --- | --- | --- |
|
|
@@ -96,6 +96,20 @@ Chrome section is dashboard-only. Its shape mirrors the `CHROMEWEBSTORE.md`
|
|
|
96
96
|
convention other agent tooling expects, so an agent looking for that file's
|
|
97
97
|
sections finds them here.
|
|
98
98
|
|
|
99
|
+
Two facts about where the file is read from, both of which have bitten people:
|
|
100
|
+
|
|
101
|
+
- **The submission reads `STORE.md` from the project's source repository at
|
|
102
|
+
the built commit**, not from the working directory. An uncommitted or
|
|
103
|
+
unpushed edit does not travel with the submission. Commit and push the
|
|
104
|
+
file, then rebuild, then submit.
|
|
105
|
+
- **`extension_submit` checks the local copy and warns**, and the warning is
|
|
106
|
+
worth acting on. Its parser is a pinned port of the one the real submission
|
|
107
|
+
runs, held to the original by a test that replays both implementations over
|
|
108
|
+
the same corpus, so "no Firefox reviewer notes" here means no Firefox
|
|
109
|
+
reviewer notes there. Section headings are matched the same way in both:
|
|
110
|
+
`## Firefox Add-ons`, `## firefox-amo` and `## AMO` all resolve to Firefox,
|
|
111
|
+
and the `###` field heading is matched by prefix.
|
|
112
|
+
|
|
99
113
|
## Maintenance rules
|
|
100
114
|
|
|
101
115
|
Update `STORE.md` in the same change that makes it stale:
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Surface: content script
|
|
2
|
+
|
|
3
|
+
A content script runs inside web pages the manifest matches, in an isolated
|
|
4
|
+
world with the page's DOM and none of the page's JavaScript. Read this when
|
|
5
|
+
the extension changes or reads pages.
|
|
6
|
+
|
|
7
|
+
## Manifest
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
"content_scripts": [
|
|
11
|
+
{ "matches": ["<all_urls>"], "js": ["content/scripts.js"] }
|
|
12
|
+
],
|
|
13
|
+
"host_permissions": ["<all_urls>"]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`matches` decides where it runs; `host_permissions` is what lets it fetch
|
|
17
|
+
cross-origin and lets the worker reach those tabs. Narrow both to the sites
|
|
18
|
+
the extension is for.
|
|
19
|
+
|
|
20
|
+
## Files the starter lays out
|
|
21
|
+
|
|
22
|
+
- `content/scripts.js`: the entry. It exports a default `initial()` that the
|
|
23
|
+
framework calls on injection and whose returned function it calls on
|
|
24
|
+
teardown and hot reload; do not call it yourself.
|
|
25
|
+
- `content/ContentApp.js`, `content/styles.css`: the injected UI and its
|
|
26
|
+
stylesheet. The starter mounts the UI inside a shadow root on a host
|
|
27
|
+
element marked `data-extension-root` with `all: initial`, so page CSS
|
|
28
|
+
cannot restyle it and its CSS cannot leak out.
|
|
29
|
+
- `background.js`: the worker. A content script cannot open extension pages
|
|
30
|
+
or call most `chrome.*` APIs; it sends a message and the worker does it.
|
|
31
|
+
|
|
32
|
+
## What bites
|
|
33
|
+
|
|
34
|
+
- Styles imported by the script are inlined into its bundle; a stylesheet
|
|
35
|
+
the script fetches with `new URL("./styles.css", import.meta.url)` is the
|
|
36
|
+
pattern the starter uses to put CSS inside the shadow root.
|
|
37
|
+
- Injection happens at `document_idle` by default and once per page load.
|
|
38
|
+
A page that renders after load (a feed, a search result) needs a
|
|
39
|
+
`MutationObserver`, not a longer delay.
|
|
40
|
+
- Batch DOM writes with `requestAnimationFrame`. A synchronous loop over
|
|
41
|
+
thousands of nodes freezes the page and the site gets blamed.
|
|
42
|
+
- The script's memory is per page and per frame. Share state through
|
|
43
|
+
`chrome.storage` (declare the `storage` permission) or the worker, never
|
|
44
|
+
through a module variable.
|
|
45
|
+
- The worker may be asleep; a message wakes it, its caches are gone.
|
|
46
|
+
|
|
47
|
+
## What proves it works
|
|
48
|
+
|
|
49
|
+
- On a matching page the host element is in the DOM and the injected UI is
|
|
50
|
+
visible over the page's own styles.
|
|
51
|
+
- The count or change the script makes agrees with the page (for links,
|
|
52
|
+
`document.querySelectorAll("a").length`).
|
|
53
|
+
- The worker's log shows the relay when the injected UI asks it for
|
|
54
|
+
something.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Surface: DevTools panel
|
|
2
|
+
|
|
3
|
+
A DevTools extension adds a panel to the browser's developer tools. Read
|
|
4
|
+
this when the extension's main surface is a `devtools_page`.
|
|
5
|
+
|
|
6
|
+
## Manifest
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
"devtools_page": "devtools/index.html"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
No permission is needed for the panel itself. Reading network traffic or
|
|
13
|
+
evaluating in the page is granted by being a DevTools page.
|
|
14
|
+
|
|
15
|
+
## Files the starter lays out
|
|
16
|
+
|
|
17
|
+
- `devtools/index.html`, `devtools/scripts.js`: the DevTools page. It shows
|
|
18
|
+
nothing; its script calls
|
|
19
|
+
`chrome.devtools.panels.create(title, icon, "panel/index.html")`.
|
|
20
|
+
- `panel/index.html`, `panel/scripts.js`, `panel/styles.css`: the panel that
|
|
21
|
+
the person sees, created once per DevTools window.
|
|
22
|
+
|
|
23
|
+
## What bites
|
|
24
|
+
|
|
25
|
+
- The panel exists only while DevTools is open on a tab, and it is torn down
|
|
26
|
+
when DevTools closes. Persist anything worth keeping in `chrome.storage`,
|
|
27
|
+
which needs the `storage` permission.
|
|
28
|
+
- DevTools pages get `chrome.devtools.*`, `chrome.runtime.*` and
|
|
29
|
+
`chrome.extension.*`. For anything else (tabs, windows, storage areas
|
|
30
|
+
beyond the basics) message the worker and let it do the call.
|
|
31
|
+
- `chrome.devtools.inspectedWindow.eval(code)` runs `code` in the inspected
|
|
32
|
+
page's own world, not the extension's, and hands back a JSON-serialisable
|
|
33
|
+
result plus an error object; check the error every time.
|
|
34
|
+
- `chrome.devtools.inspectedWindow.tabId` names the tab being inspected;
|
|
35
|
+
`chrome.devtools.network.onRequestFinished` streams its requests.
|
|
36
|
+
- A DevTools window does not count as a browser tab for `tabs.query`;
|
|
37
|
+
handle an empty result.
|
|
38
|
+
|
|
39
|
+
## What proves it works
|
|
40
|
+
|
|
41
|
+
- Opening DevTools on a page shows the panel by its title, and switching to
|
|
42
|
+
it paints without errors. From an agent, `extension_open` with
|
|
43
|
+
`surface: "devtools"` (Chromium, headed or headless) opens DevTools on a
|
|
44
|
+
tab, shows the panel (`panel` picks a title) and returns the panel
|
|
45
|
+
document's url; `extension_eval` with `context: "page"` and that url
|
|
46
|
+
reads the panel with `chrome.devtools` available. Firefox has no protocol
|
|
47
|
+
command that opens its developer tools, so there the check is by hand.
|
|
48
|
+
- What the panel reports about the page (a title, a request, a value from
|
|
49
|
+
`eval`) agrees with the page it inspects.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Surface: new tab page
|
|
2
|
+
|
|
3
|
+
A new tab override replaces the page every new tab opens on. Read this when
|
|
4
|
+
the extension's main surface is `chrome_url_overrides.newtab`.
|
|
5
|
+
|
|
6
|
+
## Manifest
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
"chrome_url_overrides": { "newtab": "newtab/index.html" }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The key is the same on Firefox. An extension may override one of `newtab`,
|
|
13
|
+
`history` or `bookmarks`, and only one installed extension can hold each
|
|
14
|
+
page.
|
|
15
|
+
|
|
16
|
+
## Files the starter lays out
|
|
17
|
+
|
|
18
|
+
- `newtab/index.html`, `newtab/scripts.js`, `newtab/styles.css`: the page,
|
|
19
|
+
its script and styles.
|
|
20
|
+
- `background.js`: the worker, for work that should not restart on every new
|
|
21
|
+
tab.
|
|
22
|
+
|
|
23
|
+
## What bites
|
|
24
|
+
|
|
25
|
+
- The page is an extension page: it has every `chrome.*` API the manifest's
|
|
26
|
+
permissions allow and needs no host permission to exist.
|
|
27
|
+
- It loads on every new tab, so it has to be fast. Remote scripts are
|
|
28
|
+
forbidden by Manifest V3 anyway; keep fonts and images local too, because
|
|
29
|
+
a remote asset that stalls is a blank new tab.
|
|
30
|
+
- `chrome.topSites` needs the `topSites` permission, `chrome.search.query`
|
|
31
|
+
needs `search`, and a plain form that navigates to a search URL needs
|
|
32
|
+
neither.
|
|
33
|
+
- Persist preferences (the clock format, the last query) in
|
|
34
|
+
`chrome.storage.local`, which needs the `storage` permission, and read
|
|
35
|
+
them before first paint to avoid a flash of defaults.
|
|
36
|
+
- On first run real Chrome asks whether to keep the override; that prompt
|
|
37
|
+
is the browser's and cannot be suppressed.
|
|
38
|
+
|
|
39
|
+
## What proves it works
|
|
40
|
+
|
|
41
|
+
- Opening a new tab shows the page instead of the browser's own, and it
|
|
42
|
+
paints without errors.
|
|
43
|
+
- The clock or content it draws is right for the moment, and a preference
|
|
44
|
+
set on one new tab is honoured on the next.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Surface: options page
|
|
2
|
+
|
|
3
|
+
The options page is where a person configures the extension. Read this when
|
|
4
|
+
the extension declares `options_ui`, on its own or beside another surface.
|
|
5
|
+
|
|
6
|
+
## Manifest
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
"options_ui": { "page": "options/index.html", "open_in_tab": false }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`open_in_tab: false` embeds the page inside the browser's extensions
|
|
13
|
+
management page; `true` opens it as a full tab. Firefox honours the same key.
|
|
14
|
+
|
|
15
|
+
## Files the starter lays out
|
|
16
|
+
|
|
17
|
+
- `options/index.html`, `options/scripts.js`, `options/styles.css`: the
|
|
18
|
+
page, its script and styles.
|
|
19
|
+
- `background.js`: the worker. A content script cannot open the options
|
|
20
|
+
page; it sends `open-options` and the worker calls
|
|
21
|
+
`chrome.runtime.openOptionsPage()`.
|
|
22
|
+
|
|
23
|
+
## What bites
|
|
24
|
+
|
|
25
|
+
- Embedded options render in an iframe with a constrained height. Set
|
|
26
|
+
explicit sizes on the page or the browser clips it.
|
|
27
|
+
- Both areas need the `storage` permission in the manifest. Save settings
|
|
28
|
+
to `chrome.storage.sync` when they should follow the person across
|
|
29
|
+
devices and to `local` otherwise; `sync` has small quotas and
|
|
30
|
+
per-minute write limits, so never write on every keystroke.
|
|
31
|
+
- Other contexts learn about a change through `chrome.storage.onChanged`,
|
|
32
|
+
never by re-reading on a timer.
|
|
33
|
+
- `chrome.runtime.openOptionsPage()` works from the worker and from
|
|
34
|
+
extension pages, not from a content script.
|
|
35
|
+
|
|
36
|
+
## What proves it works
|
|
37
|
+
|
|
38
|
+
- The page opens from the extensions list, or from the worker on request,
|
|
39
|
+
and paints without errors.
|
|
40
|
+
- A setting changed here is visible to the surface that reads it, on the
|
|
41
|
+
next event, without a reload.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Surface: toolbar popup
|
|
2
|
+
|
|
3
|
+
The popup is a page that opens under the toolbar icon and dies the moment it
|
|
4
|
+
loses focus. Read this when the extension's main surface is an `action`.
|
|
5
|
+
|
|
6
|
+
## Manifest
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
"chromium:action": { "default_popup": "action/index.html", "default_icon": { "16": "images/icon.png" }, "default_title": "Open" },
|
|
10
|
+
"firefox:browser_action": { "default_popup": "action/index.html", "default_icon": { "16": "images/icon.png" } }
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`chrome.action` is undefined unless the manifest has an `action` key. A popup
|
|
14
|
+
needs no permission of its own, but `chrome.storage` does: declare
|
|
15
|
+
`"permissions": ["storage"]` or every read throws before the first paint.
|
|
16
|
+
|
|
17
|
+
## Files the starter lays out
|
|
18
|
+
|
|
19
|
+
- `action/index.html`, `action/scripts.js`, `action/styles.css`: the popup
|
|
20
|
+
document, its script and its stylesheet.
|
|
21
|
+
- `background.js`: the worker, for anything that must outlive the popup.
|
|
22
|
+
- `images/icon.png`: the toolbar icon, also the manifest icon.
|
|
23
|
+
|
|
24
|
+
## What bites
|
|
25
|
+
|
|
26
|
+
- Every open is a fresh document and closing it is a hard teardown. Nothing
|
|
27
|
+
in the popup's memory survives, so state lives in `chrome.storage.local`
|
|
28
|
+
(declare the `storage` permission first) and the popup re-reads it on
|
|
29
|
+
load. A counter that "forgets" is this.
|
|
30
|
+
- The popup sizes to its content up to 800 by 600 CSS pixels. Give `body` an
|
|
31
|
+
explicit width or it collapses to the widest word.
|
|
32
|
+
- A button inside the popup is not a user gesture for `activeTab`. Ask for a
|
|
33
|
+
host permission if the popup must read the page.
|
|
34
|
+
- `chrome.action.openPopup()` exists only in Chrome 127 and later and needs a
|
|
35
|
+
gesture; do not design a flow around opening the popup from code.
|
|
36
|
+
- The popup and the worker are different contexts. `runtime.sendMessage`
|
|
37
|
+
from the popup wakes the worker; the worker cannot reach popup memory.
|
|
38
|
+
|
|
39
|
+
## What proves it works
|
|
40
|
+
|
|
41
|
+
- The toolbar icon opens the page and it paints without console errors.
|
|
42
|
+
- A value written from the popup is still there after the popup is closed
|
|
43
|
+
and opened again.
|
|
44
|
+
- The worker's log shows any message the popup sent.
|