@extension.dev/skill 0.5.1 → 1.0.0

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.
@@ -21,8 +21,8 @@ my-extension/
21
21
  styles.css
22
22
  images/
23
23
  icon.png
24
- pages/ Special folder: HTML pages not in the manifest
25
- scripts/ Special folder: scripts not in the manifest
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 production build behaves before shipping: `npm run start` builds
15
- and launches without HMR, which catches dev-only assumptions (HMR globals,
16
- unhashed asset paths, dev CSP relaxations).
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`, `extension_preview`.
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
- `extension-deploy` reads `STORE.md` automatically and submits the fields the
57
- store APIs accept: Firefox reviewer and release notes, and Edge certification
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 trio: Desktop-app client ID
84
- (`123.apps.googleusercontent.com`), client secret (`GOCSPX-...`), refresh
85
- token (`1//...`). Mint the refresh token with `npx extension-deploy init`
86
- (local loopback consent flow). Never recommend the Google OAuth Playground
87
- for this: it needs a Web-application redirect URI and fails a Desktop-app
88
- client with redirect_uri_mismatch. If the OAuth consent screen is in
89
- Testing status, Google revokes the refresh token after 7 days.
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 on the platform track: per project, never per workspace.
109
- Each project's credentials are written as write-only GitHub Actions secrets
110
- on that project's managed mirror repo (STORE_CHROME_*, STORE_FIREFOX_API_KEY/
111
- API_SECRET, STORE_EDGE_CLIENT_ID/CLIENT_SECRET; the Edge CLIENT_SECRET holds
112
- the API key). Identifiers go to the mirror's _extension-dev/settings.json.
113
- Rotation always means re-entering values. Direct mode keeps the same values
114
- in a per-repo `.env.submit` (written by `npx extension-deploy init`, keep out
115
- of git).
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,72 @@ of git).
134
137
  The platform has its own publish flow for hosting and distribution:
135
138
 
136
139
  ```bash
137
- # One-time device-code login (GitHub)
138
- extension login # MCP: extension_login
139
- extension whoami # MCP: 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 # MCP: extension_publish
145
+ EXTENSION_DEV_TOKEN=<token> extension publish # MCP: extension_publish
143
146
  ```
144
147
 
145
- `extension_logout` signs the session out again. Publishing requires a prior
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
+ ## Sharing a build before it ships
175
+
176
+ `extension_preview_web` with `share: true` uploads the build and returns a
177
+ link that opens the extension in a web emulator: no install, no sign-in, no
178
+ dev server on the other end. It is the way to show a build to a reviewer, a
179
+ client, or a teammate, and it is the only lane of that tool that works from
180
+ an npm install of the MCP server. Without `share: true` the tool returns a
181
+ `preview://build` deep link that resolves only against a local
182
+ preview.extension.dev dev server, which is for people developing
183
+ extension.dev itself.
184
+
185
+ Say what a share does before making one: it also serves the build as a zip,
186
+ so the recipient gets the built code, not just a rendering of it. Read the
187
+ `share` property of the response back to the user.
188
+
189
+ `extension_shares` is the other half, and the reason a share is not a
190
+ one-way door:
191
+
192
+ - `action: "list"` returns every share the token owns, live and dead, with
193
+ its `artifactId`, `previewUrl`, `zipUrl`, `revokeUrl` and expiry, so a link
194
+ whose response was lost is findable again.
195
+ - `action: "revoke"` kills one permanently, by `artifactId` or by any URL of
196
+ the share. The link you sent someone is enough to pull it back.
197
+ - `attribution.ownership` says who may revoke: `project` means any workspace
198
+ member can, `personal` means one person holds it alone, `unknown` means no
199
+ owner was disclosed. Read `attribution.credit` as credit only, never as
200
+ access.
201
+
202
+ Never share a build and leave the session without recording the link. If it
203
+ is already lost, `extension_shares` with `action: "list"` is the recovery
204
+ path, not a support ticket.
205
+
148
206
  ## Promoting releases headlessly
149
207
 
150
208
  Projects released through extension.dev promote tested builds to channels
@@ -161,3 +219,78 @@ caller passes only the build sha and target channel.
161
219
 
162
220
  Cutting a release (the version-bump PR) stays interactive by design: it
163
221
  writes to the source repo.
222
+
223
+ ## Submitting to the stores through extension.dev
224
+
225
+ `extension_submit` is the tool for store review. It is the most consequential
226
+ call in this document and the least reversible, so read this section before
227
+ using it.
228
+
229
+ What it does: submits a built commit for review at the Chrome Web Store,
230
+ Firefox AMO, Edge Add-ons and the App Store (Safari). The platform holds the
231
+ store credentials and dispatches from the project's mirror CI, so no
232
+ credential is ever an argument and no local file is uploaded. There is no
233
+ `extension` CLI equivalent.
234
+
235
+ What it is not: it does not push a build to the extension.dev platform and it
236
+ does not make a shareable link. Those are `extension_publish` and
237
+ `extension_preview_web`. When a user says "deploy", "ship" or "release", they
238
+ almost always mean publish. Reach for `extension_submit` only when the ask is
239
+ explicitly a store submission.
240
+
241
+ ```text
242
+ extension_submit
243
+ browsers: ["chrome", "firefox"] required
244
+ buildSha: <built commit sha> required; from extension_release_status
245
+ channel: stable default
246
+ dryRun: true DEFAULT. false dispatches, irreversibly.
247
+ ```
248
+
249
+ How to use it safely:
250
+
251
+ 1. **Dry run first, always.** `dryRun` defaults to `true` and dispatches
252
+ nothing. The platform checks auth, project, build and store workflow, and
253
+ the tool adds a per-store credential-health verdict on top. Trust the
254
+ per-store rows over the platform's bare preflight line, which does not
255
+ check store health.
256
+ 2. **Read every row before passing `dryRun: false`.** A row reading NOT
257
+ actionable means that store would fail. A row reading cannot be verified
258
+ means the check could not read the project's store configuration, not that
259
+ the store is fine.
260
+ 3. **`dryRun: false` is a one-way door.** It enters store review. Confirm
261
+ with the user in the same breath as calling it; never pass it because a
262
+ dry run looked good.
263
+ 4. **The build sha must already exist.** An unknown sha is rejected. Get one
264
+ from `extension_release_status`, never from `git rev-parse` and hope.
265
+ 5. **Store publish mode is invisible from here.** Whether a store is set to
266
+ draft, skip-publish or live is not readable with a CLI token, so the tool
267
+ says so instead of guessing. Check it in the console.
268
+ 6. **Safari is a paid lane.** A free workspace is refused for the App Store;
269
+ the other three stores are unaffected by that refusal.
270
+
271
+ The tool also reads the project's `STORE.md` and warns when Firefox reviewer
272
+ notes or Edge certification notes are missing. Trust that advisory: the
273
+ parser is a pinned port of the one the real submission uses, held to it by a
274
+ test that replays both over the same corpus, so a warning here means a
275
+ missing field there. One caveat it states itself: the submission reads
276
+ `STORE.md` from the project's source repository at the built commit, so an
277
+ uncommitted or unpushed edit does not travel with it.
278
+
279
+ ## Reading where a project stands
280
+
281
+ `extension_release_status` reads the project's state from the public registry
282
+ and is read-only: it dispatches nothing and promotes nothing, so it is always
283
+ safe to call.
284
+
285
+ - `include: ["releases"]` returns the release channels (channel to promoted
286
+ build sha), recent builds, and a public build-page URL for each. **This is
287
+ where a valid sha for `extension_release_promote`, `extension_submit` or
288
+ `extension_publish` comes from.**
289
+ - `include: ["stores"]` returns the per-store picture after a submission:
290
+ configured or not, the last credential health check, the last recorded
291
+ submission, and the latest review status. This is how "was it approved?"
292
+ gets answered without opening the console.
293
+
294
+ Both are included by default. It reads the logged-in project unless you pass
295
+ `workspace` and `project`. Registry state can lag the store dashboards by up
296
+ 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: `extension-deploy` (and platform releases through
10
- extension.dev) read it automatically and attach the fields the store APIs
11
- accept. Everything else stays a copy-paste reference for the dashboard forms.
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 deploy time these fields are read from the file and sent with the
86
- submission; explicit CLI flags or config values win over the file:
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.
@@ -0,0 +1,52 @@
1
+ # Surface: side panel
2
+
3
+ The side panel is a page docked beside the tab strip that stays open while
4
+ the person switches tabs. Read this when the extension's main surface is a
5
+ `side_panel` (Chromium) or `sidebar_action` (Firefox).
6
+
7
+ ## Manifest
8
+
9
+ ```json
10
+ "chromium:side_panel": { "default_path": "sidebar/index.html" },
11
+ "firefox:sidebar_action": { "default_panel": "sidebar/index.html" },
12
+ "chromium:permissions": ["sidePanel"],
13
+ "chromium:action": { "default_icon": { "16": "images/icon.png" }, "default_title": "Open side panel" },
14
+ "firefox:browser_action": { "default_icon": { "16": "images/icon.png" } }
15
+ ```
16
+
17
+ The `action` has no `default_popup` on purpose: it is the panel's opener.
18
+ Removing it leaves a panel nobody can open from the toolbar.
19
+
20
+ ## Files the starter lays out
21
+
22
+ - `sidebar/index.html`, `sidebar/scripts.js`, `sidebar/SidebarApp.js`,
23
+ `sidebar/styles.css`: the panel document, its script, its UI and styles.
24
+ - `background.js`: the worker. At its top level it calls
25
+ `chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true })`, and
26
+ on Firefox it opens the sidebar from `browserAction.onClicked`.
27
+ - `content/scripts.js`, `content/ContentApp.js`: a content script whose UI
28
+ sends `openSidebar` to the worker; the worker calls
29
+ `chrome.sidePanel.open({ tabId })` synchronously inside that gesture.
30
+
31
+ ## What bites
32
+
33
+ - `sidePanel.open()` only works inside a user gesture, and the gesture is
34
+ gone after any `await`. Call it synchronously from the message handler.
35
+ - `setPanelBehavior` affects future action clicks only; registering it inside
36
+ `onClicked` swallows the first click, so it stays at the worker's top level.
37
+ - The panel has no tab of its own. To read the page it sits beside, query
38
+ `chrome.tabs.query({ active: true, currentWindow: true })` and message the
39
+ content script in that tab, or use `chrome.scripting.executeScript` with
40
+ the `scripting` permission and host access.
41
+ - The panel outlives tab switches. Listen to `chrome.tabs.onActivated` and
42
+ `chrome.tabs.onUpdated` and refresh what it shows.
43
+ - Firefox needs no `sidePanel` permission and opens the sidebar from
44
+ `browser.sidebarAction.open()`, also gesture-bound.
45
+
46
+ ## What proves it works
47
+
48
+ - Clicking the toolbar icon opens the panel and it paints without errors.
49
+ - What the panel lists matches the page beside it, and changes when the
50
+ active tab changes.
51
+ - The worker's log shows the open request when the content script's UI asks
52
+ for it.