@extension.dev/skill 0.5.0 → 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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +3 -3
- package/CHANGELOG.md +137 -2
- package/LICENSE +201 -21
- package/README.md +52 -16
- package/package.json +15 -7
- package/skills/extension-dev/SKILL.md +113 -31
- package/skills/extension-dev/references/cross-browser.md +49 -33
- package/skills/extension-dev/references/debugging.md +159 -50
- 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 +200 -11
- 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
|
@@ -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.
|
|
@@ -14,8 +14,8 @@ reference for the pattern.
|
|
|
14
14
|
|
|
15
15
|
## Discovering templates
|
|
16
16
|
|
|
17
|
-
Use the MCP
|
|
18
|
-
framework, tags, or free text, and `
|
|
17
|
+
Use the MCP tool `extension_templates`: `action: "list"` filters the catalog by
|
|
18
|
+
surface, framework, tags, or free text, and `action: "source"` reads a
|
|
19
19
|
template's files without cloning. These cover discovery end to end.
|
|
20
20
|
|
|
21
21
|
The underlying registry is `templates-meta.json`, a static JSON asset
|
|
@@ -39,9 +39,12 @@ the SPA HTML. Use the GitHub release asset or raw.githubusercontent.com.
|
|
|
39
39
|
| Content script | `content` | `content-react` | `content-vue` | `content-svelte` | |
|
|
40
40
|
| Sidebar | `sidebar` | `sidebar-shadcn` | | | `ai-claude` |
|
|
41
41
|
| Action popup | `action` | | | | `ai-chatgpt` |
|
|
42
|
-
| New tab | `
|
|
42
|
+
| New tab | `newtab` | `newtab-react` | `newtab-vue` | `newtab-svelte` | |
|
|
43
43
|
| Full framework | `javascript` | `react` | `vue` | `svelte` | |
|
|
44
44
|
|
|
45
|
+
`newtab-preact` and `newtab-typescript` cover Preact and plain TypeScript
|
|
46
|
+
for the new tab surface.
|
|
47
|
+
|
|
45
48
|
For complex content script patterns (multi-level imports, main-world
|
|
46
49
|
isolation), read `content-multi-one-entry`, `content-multi-three-entries`,
|
|
47
50
|
and `content-main-world`.
|
|
@@ -67,8 +70,8 @@ and zip URLs also work as `--template` values.
|
|
|
67
70
|
|
|
68
71
|
When building an unfamiliar feature, read the actual source of the closest
|
|
69
72
|
template instead of recalling API shapes from memory. The MCP tool
|
|
70
|
-
`
|
|
71
|
-
browsing by hand, each template lives at:
|
|
73
|
+
`extension_templates` with `action: "source"` returns a template's files
|
|
74
|
+
directly. For browsing by hand, each template lives at:
|
|
72
75
|
|
|
73
76
|
```
|
|
74
77
|
https://github.com/extension-js/examples/tree/main/examples/<slug>/src
|