Skip to content

Commit

Permalink
refactor: unify builds
Browse files Browse the repository at this point in the history
  • Loading branch information
pnd280 committed Oct 15, 2024
1 parent 6cadef7 commit 2121a25
Show file tree
Hide file tree
Showing 48 changed files with 2,799 additions and 1,805 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .env.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TARGET_BROWSER=chrome
VITE_METADATA_BRANCH=chrome-ext
2 changes: 2 additions & 0 deletions .env.gecko
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TARGET_BROWSER=firefox
VITE_METADATA_BRANCH=moz
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/coverage

# production
/build
/dist
/package

# misc
Expand All @@ -28,4 +28,5 @@
# secrets
secrets.*.js

.env
.env
unimport.d.ts
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package-lock.json
.history

# ignore compiled files
build
dist
types
coverage

Expand Down
9 changes: 0 additions & 9 deletions .vscode/cody.json

This file was deleted.

64 changes: 36 additions & 28 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"workbench.editor.customLabels.patterns": {
"**/src/**/*.test.ts": "Test - ${dirname}: ${filename}",
"**/src/**": "${dirname}: ${filename}"
"editor.quickSuggestions": {
"comments": false,
"other": true,
"strings": false
},
"workbench.editor.labelFormat": "medium",
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"**/build/**/*": true,
"**/package/**/*": true
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true,
"**/Thumbs.db": true,
"**/node_modules": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.hg/store/**": true,
"**/build/**/*": true,
"**/dist/**/*": true,
"**/node_modules/*/**": true,
"**/package/**/*": true
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true
},
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
"npm.exclude": ["**/build", "**/dist", "**/package"],
"npm.scriptExplorerExclude": ["preinstall"],
"search.exclude": {
"**/*.code-search": true,
"**/bower_components": true,
"**/build/**/*": true,
"**/dist/**/*": true,
"**/node_modules": true,
"**/package/**/*": true
},
"tailwindCSS.experimental.classRegex": [
["addClass\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["toggleClass\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
],
"npm.scriptExplorerExclude": ["preinstall"],
"npm.exclude": ["**/build", "**/package"]
"typescript.tsdk": "node_modules\\typescript\\lib",
// "typescript.tsserver.experimental.enableProjectDiagnostics": true,
"typescript.tsserver.maxTsServerMemory": 8192,
"typescript.tsserver.watchOptions": {
"watchFile": "useFsEventsOnParentDirectory",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriorityPolling"
},
"workbench.editor.customLabels.patterns": {
"**/src/**": "${dirname}: ${filename}",
"**/src/**/*.test.ts": "Test - ${dirname}: ${filename}"
},
"workbench.editor.labelFormat": "medium"
}
16 changes: 1 addition & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
Ahh, we all know how things work. Just don't throw in random, unverified AI-generated stuff. You can contribute to this project by opening issues and PRs. Please adhere to the following coding/refactoring conventions:

- No unused modules.
- No deprecated methods/modules.
- TypeScript:
- Always prefer `type` over `interface` for type declarations.
- Don't use `any` type, regardless of implicit or explicit.
- Use built-in types whenever possible.
- Don't use types that are banned by `eslint@typescript-eslint/ban-types`. e.g. `Function`.
- React:
- Directly import modules/types instead of namespaces: `useState` instead of `React.useState`, `ReactNode` instead of `React.ReactNode`.
- Always prefer the functional component format `function Component` over `const Component = React<FC>...`.
- Always prefer to `export default function Component()...` than have the default export statement in a separated line.

> Note: I know that the project itself, in some places, doesn't fully comply with the above conventions (there are still some explicit `any` types). But they will eventually be refactored. So, please follow them when contributing.
The project is undergoing significant refactoring, thus PRs are not welcome at the moment.
66 changes: 25 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<p align="center">An enhanced version of <a href="https://perplexity.ai/" target="_blank" style="font-weight: bold">Perplexity.ai</a> which everyone has ever wanted.<br/>Community-driven, open-source, and free to use.</p>

<div align="center">
<a href="https://chromewebstore.google.com/detail/complexity/ffppmilmeaekegkpckebkeahjgmhggpj" target="_blank"><img src="https://storage.googleapis.com/web-dev-uploads/image/WlD8wC6g8khYWPJUsQceQkhXSlv1/HRs9MPufa1J1h5glNhut.png" width="200px" style="border-radius: .5rem"></a>
<a href="https://addons.mozilla.org/en-US/firefox/addon/complexity/" target="_blank"><img src="https://extensionworkshop.com/assets/img/documentation/publish/get-the-addon-178x60px.dad84b42.png" width="180px"></a>
<a href="https://chromewebstore.google.com/detail/complexity/ffppmilmeaekegkpckebkeahjgmhggpj" target="_blank"><img src="https://i.imgur.com/9QWBxZO.png" width="200px" style="border-radius: .5rem"></a>
<a href="https://addons.mozilla.org/en-US/firefox/addon/complexity/" target="_blank"><img src="https://i.imgur.com/RpP2H81.png" width="200px"></a>
<p align="center" style="font-style: italic; font-size: .8rem;">Complexity is a third-party extension, it does NOT affiliate with Perplexity.ai.</p>
💖 support the development
<div>
Expand All @@ -34,12 +34,15 @@

Perplexity.ai is famously known for its LLM-based search engine, but many may not know that it is also a decent portal which provides access to various SOTA LLMs and image generation models and have somewhat a very generous rate limit compared to other services. But it lacks a lot of basic features, the UX isn't that great either. Hence, Complexity was created to fill that gap.

## Complexity is packed with features
## Complexity will enrich your experience with:

- Various UI/UX/QoL tweaks.
- LLM/Image gen model selectors; directly chat to a collection; export your searches/conversations, etc.
- LLM/Image gen model selectors.
- Directly chat to a collection.
- Export your searches/conversations.
- Highly customizable ADHD-friendly theme (custom css is supported).
- Various UI/UX/QoL tweaks.
- A dedicated solution for prompts management: Prompts Library (in development).
- [And many more...](https://github.com/pnd280/complexity/issues/19).

[Read more](https://cplx.vercel.app)

Expand All @@ -48,55 +51,38 @@ Perplexity.ai is famously known for its LLM-based search engine, but many may no
This is a high-level overview of the network traffic interception approach, which provides the extension with the ability to alter the behavior of the host page.

```mermaid
graph TD
graph TD
subgraph Browser
W[perplexity.ai]
CS[Content Scripts]
BP[Background Page]
end
subgraph InterceptAPIs["Intercept native APIs"]
WI["Singleton Instance (Main-world)"]
WI --> |Initializes| PWS[Proxy WebSocket]
WI --> |Initializes| PXHR[Proxy XMLHttpRequest]
WI --> AM[Active Connection Manager]
WI --> ML[Message Listener]
subgraph InterceptAPIs
WI[Interceptor Instance]
WI --> PWS[Proxy WebSocket]
WI --> PXHR[Proxy XMLHttpRequest]
end
subgraph Interceptors
WM["Controller (Isolated)"]
WM[Controller]
WM --> MP[Message Processor]
WM --> IC[Interceptor Chain]
WM --> EL[Event Listeners]
end
WI <-. "window.postMessage" .-> WM
W <--> |WebSocket/XHR| PWS
W <--> |WebSocket/XHR| PXHR
PWS --> |Intercepts| AM
PXHR --> |Intercepts| AM
AM --> |Notifies| ML
ML --> |Sends Messages to| WM
WI <-.-> WM
CS <--> |Communicates| WM
BP <--> |Communicates| WM
CS <--> WM
BP <--> WM
WM --> |Processes Messages| MP
MP --> |Applies Interceptors| IC
IC --> |Modifies Data| MP
MP --> |Sends Modified Data| AM
AM --> |Sends to Webpage| W
WM --> |Registers| EL
EL --> |Triggers Events| MP
MP --> IC
IC --> MP
classDef singleton fill:#72aefd,stroke:#333,color:#ffffff,stroke-width:2px;
class WI,WM singleton;
```

[Read more](./docs/architecture.md)
Expand All @@ -109,22 +95,20 @@ This is a high-level overview of the network traffic interception approach, whic

## Build from source

1. Clone this repository
2. `pnpm clean-zip`
3. Load the extension from the zip file in the `package` folder.

The mozilla add-on version is available at the [moz](https://github.com/pnd280/complexity/tree/moz) branch.
1. Clone this repository.
2. `pnpm build` or `pnpm build:firefox`.
3. Load the extension from the `dist` folder.

## Limitations

- Because of frequent/unexpected changes in the host page, UI tweaks are prone to breakage and it will take some time for the review process to be passed.
- The dev runtime/overall DX on mozilla-based browsers is non-existent due to a non-compatible dev dependency [@crxjs/vite-plugin](https://github.com/crxjs/chrome-extension-tools).
- Limited testing: the e2e test suite has not been implemented due to the agressive Cloudflare protection of the host page itself (I'm still figuring out a way 🙂)
- Limited testing: the e2e test suite has not been implemented due to the aggressive Cloudflare protection of the host page itself (I'm still figuring out a way 🙂)

## Contributing

- Issues and PRs are welcome.
- Please follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md).
> [!NOTE]
> The project is undergoing significant refactoring, thus PRs are not welcome at the moment.
## Acknowledgements

Expand Down
Loading

0 comments on commit 2121a25

Please sign in to comment.