Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension integration #240

Merged
merged 14 commits into from
Aug 15, 2024
Merged

Extension integration #240

merged 14 commits into from
Aug 15, 2024

Conversation

ai
Copy link
Contributor

@ai ai commented Aug 15, 2024

Integrate extension into the project code style

@@ -12,6 +12,7 @@ on:
- 'core/test/**'
- 'loader-tests/**'
- '.devcontainer/**'
- 'extensions/**'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid calling CI without a reason.

For instance, we do not publish staging on changes irrelevant to web client.

@@ -102,6 +102,7 @@ Slow Reader is a local-first app. Clients do most of the work, and the server ju
- See **[`web/README.md`](./web/README.md)** for web client architecture.
- [`server/`](./server/): a small server that syncs data between users’ devices.
- [`proxy/`](./proxy/): HTTP proxy server to bypass censorship or to try web clients before they install the upcoming extensions (to bypass the CORS limit of the web apps).
- [`extension/`](./extension/): browser’s extension to avoid CORS limits in web client.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-links between docs

- Run `pnpm dev` to build the extension and watch the changes
- Open `chrome://extensions/` -> `Load unpacked` and choose `dist` folder from this repo. The extension should appear in the list of your extensions
- In the `.env` file of the main app, place the next line (`EXTENSION_ID` can be found in the `ID` line inside the uploaded extension block):
1. Run `cd extension && pnpm start` to build the extension and watch the changes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For steps it is better to use <ol>


`VITE_EXTENSION_ID=<EXTENSION_ID>`
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do nested code blocks in lists in Markdown

}

export type ExtensionMessage =
| { data: string; type: 'fetched' }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of typing messages is better because it tells that msg.error will be only for msg.type = 'error'

if (message.url) {
await fetch(message.url, {
try {
let response = await fetch(message.url, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using await everywhere we are having better readability in contrast with mixing await and .then()

@@ -0,0 +1,21 @@
import { defineManifest } from '@crxjs/vite-plugin'

const URL =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use function instead of static JSON file for manifest


export default defineConfig({
build: {
outDir
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to specify outDir since dist is the default value

@@ -5,3 +5,4 @@ packages:
- web
- proxy
- loader-tests
- extension
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm has great monorepo support (when you have multiple package.json in dirs).

By having pnpm-workspace.yaml you can specify project’s folders and they all will have common pnpm-lock.yaml.

},
"keywords": [],
"author": "[email protected]",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need this keys on private: true

@ai ai merged commit 104272e into extension Aug 15, 2024
7 of 8 checks passed
@ai ai deleted the extension-integration branch August 15, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant