···3232> bext --source=src # --source or -s: specify source directory (default: "source")
3333> bext --source=src --static=assets # --static or -t: specify static assets directory (default: "static")
3434> bext --source=src --static=assets --output=build # --output or -o: specify output directory (default: "dist")
3535+3636+> bext --config=../deno.json # --config or -c: specify deno.json config file. If using a workspace, point at the root workspace deno.json
3537```
36383739## Types and Utilities
···6365bext `browserAPI` will also return a mock browser when running in a Deno environment (where native extension apis don't exist). This makes writing unit tests a breeze!
64666567```ts
6666-import browserAPI, { isDeno } from 'jsr:@bpev/bext';
6767-import { assertStrictEquals } from 'jsr:@std/assert';
6868-import { assertSpyCall, assertSpyCalls, stub } from 'jsr:@std/testing/mock';
6868+import browserAPI, { isDeno } from 'jsr:@bpev/bext'
6969+import { assertStrictEquals } from 'jsr:@std/assert'
7070+import { assertSpyCall, assertSpyCalls, stub } from 'jsr:@std/testing/mock'
69717070-import { getStorage } from './storage_helpers.ts';
7272+import { getStorage } from './storage_helpers.ts'
71737274Deno.test('is running in test env', () => {
7375 assert()
···75777678Deno.test('uses browser storage', async () => {
7779 const getStorageStub = stub(browserAPI.storage.sync, 'get', () => {
7878- return Promise.resolve({ storage_key: 'mock_storage_value' });
7979- });
8080+ return Promise.resolve({ storage_key: 'mock_storage_value' })
8181+ })
80828181- assertStrictEquals(await getStorage(), 'mock_storage_value');
8282- assertSpyCalls(getStorageStub, 1);
8383+ assertStrictEquals(await getStorage(), 'mock_storage_value')
8484+ assertSpyCalls(getStorageStub, 1)
83858486 // Expect `chrome.sync.storage.get` to be called with the storage_key
8585- assertSpyCall(getStorageStub, 0, { args: ['storage_key'] });
8686- getStorageStub.restore();
8787-});
8787+ assertSpyCall(getStorageStub, 0, { args: ['storage_key'] })
8888+ getStorageStub.restore()
8989+})
8890```
89919092# Running this repo (for Bext development)
91939294Tasks are defined in [deno.json](./deno.json), but basically:
93959494-- `deno task dev`: Run the example app in watch-mode
9696+- `deno task dev:{project}`: Run the example app in watch-mode
9597- `deno task test`: Makes sure it all works. Use this before committing!
9698 - runs fmt, lint, type-checks, unit tests for source and example apps
9799 - builds example apps using local bext copy
100100+101101+## `/examples`
102102+103103+Note that the `deno tasks` in the example projects are meant to show the client usage, and therefore have tasks that don't work within the context of this repo's workspace.
104104+105105+If you want to run these projects from the Bext repo, please use the tasks in the root `deno.json` (instead of the `deno.json` in the `/examples/{project}`)
106106+107107+Also, for this same reason, do not put any imports in the root `deno.json`.
···11# Barebones
2233The bare minimum needed for a chrome extension
44-55-Note: Since is also used for internal dev. In your own app, the
66-`internal-dev-only` tasks can be removed.
···2233A Preact-Rendered Chrome/Firefox extension built with Bext.
4455-Note: Since is also used for internal dev. In your own app, the `browser` dependency should point to `jsr:@bpev/bext`. Also, the `internal-dev-only` tasks can be removed.
66-75Uses:
8697- `background.ts` logs url to extension console for each new tab update
···11-import type Chrome from 'browser/types/chrome.ts'
22-import browserAPI from 'browser'
11+import type Chrome from '@bpev/bext/types/chrome'
22+import browserAPI from '@bpev/bext'
3344browserAPI.tabs.onUpdated.addListener(
55 (