Skip to content

Commit ba51f61

Browse files
authored
Add top level and special-pages .cursorrules (#2078)
1 parent 867ec4d commit ba51f61

File tree

2 files changed

+136
-16
lines changed

2 files changed

+136
-16
lines changed

.cursorrules

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,79 @@
1-
# Content Scope Scripts - Cursor Rules
2-
3-
## Documentation References
4-
5-
When asked about Content Scope Scripts topics, refer to these documentation files:
6-
7-
- **API Reference**: `injected/docs/api-reference.md`
8-
- **Feature Development**: `injected/docs/features-guide.md`
9-
- **Platform Integration and engine support**: `injected/docs/platform-integration.md`
10-
- **Development Utilities**: `injected/docs/development-utilities.md`
11-
- **Testing**: `injected/docs/testing-guide.md`
12-
- **Favicon**: `injected/docs/favicon.md`
13-
- **Message Bridge**: `injected/docs/message-bridge.md`
14-
- **Test Pages**: `injected/docs/test-pages-guide.md`
15-
- **Documentation Index**: `injected/docs/README.md`
16-
- **High-level Overview**: `injected/README.md`
1+
# Content Scope Scripts (C-S-S)
2+
3+
Shared JavaScript projects powering privacy features and special pages in DuckDuckGo's native apps (macOS, Windows, iOS, Android).
4+
5+
## Workspaces
6+
7+
This is an npm workspace monorepo with four sub-projects:
8+
9+
### `injected/` - Browser Privacy Features
10+
11+
JavaScript features injected into web pages for privacy protections. Features extend `ConfigFeature` and integrate with remote configuration for per-site enable/disable.
12+
13+
**Features** (in `injected/src/features/`):
14+
- `api-manipulation` - API behavior modifications
15+
- `autofill-import` - Credential import support
16+
- `breakage-reporting` - Site breakage reports
17+
- `broker-protection` - Data broker removal automation
18+
- `click-to-load` - Social embed blocking
19+
- `cookie` - Cookie management
20+
- `duck-player` / `duck-player-native` - YouTube privacy player
21+
- `element-hiding` - Hide page elements
22+
- `exception-handler` - Error handling
23+
- `favicon` - Favicon privacy
24+
- `fingerprinting-*` - Audio, battery, canvas, hardware, screen, storage fingerprint protection
25+
- `google-rejected` - Google rejection handling
26+
- `gpc` - Global Privacy Control
27+
- `harmful-apis` - Dangerous API restrictions
28+
- `message-bridge` - Page↔content script messaging
29+
- `navigator-interface` - Navigator API modifications
30+
- `performance-metrics` - Performance tracking
31+
- `referrer` - Referrer protection
32+
- `web-compat` - Site compatibility fixes
33+
- `web-interference-detection` / `web-telemetry` - Monitoring
34+
35+
**Docs:** `injected/docs/README.md` (index to all docs)
36+
37+
### `special-pages/` - Embedded Browser Pages
38+
39+
Preact-based HTML/CSS/JS applications embedded in browsers. Each page lives in `special-pages/pages/<name>/`.
40+
41+
**Pages:**
42+
- `duckplayer` - YouTube privacy player UI
43+
- `errorpage` - Browser error pages
44+
- `example` - Template for new pages
45+
- `history` - Browsing history viewer
46+
- `new-tab` - New Tab Page
47+
- `onboarding` - First-run experience
48+
- `release-notes` - Browser release notes
49+
- `special-error` - SSL/certificate error pages
50+
51+
**Docs:** `special-pages/README.md`, plus `readme.md` in each page directory
52+
53+
### `messaging/` - Web-Native Communication
54+
55+
Abstraction layer for web↔native messaging: `notify` (fire-and-forget), `request` (async response), `subscribe` (push updates).
56+
57+
**Docs:** `messaging/docs/messaging.md`
58+
59+
### `types-generator/` - Schema to TypeScript
60+
61+
Generates TypeScript types from JSON Schema files. Used by other workspaces.
62+
63+
## Commands
64+
65+
Run from root. Use `nvm use` to set the correct Node version.
66+
67+
| Command | Purpose |
68+
|---------|---------|
69+
| `npm run build` | Build all workspaces |
70+
| `npm run test-unit` | Unit tests (all workspaces) |
71+
| `npm run test-int` | Integration tests (Playwright) |
72+
| `npm run lint` | ESLint + TypeScript + Prettier |
73+
| `npm run lint-fix` | Auto-fix lint issues |
74+
| `npm run serve` | Serve injected test pages (port 3220) |
75+
| `npm run serve-special-pages` | Serve special pages (port 3221) |
76+
77+
## Notes
78+
79+
- When running Playwright commands, use `--reporter list` to prevent the Shell tool from hanging

special-pages/.cursorrules

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Special Pages
2+
3+
Preact-based HTML/CSS/JS applications embedded in DuckDuckGo browsers. Each page is an isolated app with privileged native API access.
4+
5+
## Structure
6+
7+
```
8+
pages/<name>/
9+
├── app/ # Preact components (App.jsx, *.module.css)
10+
├── src/index.js # Page class with messaging methods
11+
├── messages/ # JSON schemas → auto-generates types/
12+
├── types/<name>.ts # Generated types (DO NOT EDIT)
13+
├── public/ # Static assets, index.html, locales/
14+
└── integration-tests/
15+
```
16+
17+
**Shared code:** `shared/` contains reusable components (`Button`, `Card`, `Switch`, `Text`), `Environment` class, `TranslationProvider`, and `createSpecialPageMessaging()`.
18+
19+
## Messaging Pattern
20+
21+
Pages communicate with native via `@duckduckgo/messaging`. Define schemas in `messages/`:
22+
- `*.request.json` + `*.response.json` → async request/response
23+
- `*.notify.json` → fire-and-forget notification
24+
- `*.subscribe.json` → push-based subscription
25+
26+
## TypeScript
27+
28+
JSDoc types in JavaScript files. Import types via `@typedef` after imports:
29+
30+
```javascript
31+
/** @typedef {import('./types.js').MyType} MyType */
32+
```
33+
34+
## Styling
35+
36+
- Use CSS Modules (`*.module.css`)
37+
- Global styles: `shared/styles/`
38+
39+
## Testing
40+
41+
Run from `special-pages/` directory:
42+
43+
| Command | Purpose |
44+
|---------|---------|
45+
| `npm run test-unit` | Unit tests |
46+
| `npm run test-int` | Integration tests (all platforms) |
47+
| `npm run test-int -- --project ios` | Single platform |
48+
| `npm run test.screenshots` | Screenshot tests only |
49+
50+
Integration tests use Page Object pattern—see `integration-tests/<name>.js` for helpers.
51+
52+
Top-level commands (`npm run build`, `npm run lint`) also work from this directory.
53+
54+
## Notes
55+
56+
- When running Playwright commands, use `--reporter list` to prevent the Shell tool from hanging
57+
- Types in `types/` are auto-generated from `messages/` schemas—never edit manually

0 commit comments

Comments
 (0)