@cloudflare/realtimekit 1.2.5-staging.1 → 1.2.5-staging.3

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/AGENTS.md ADDED
@@ -0,0 +1,63 @@
1
+ # CORE PACKAGE KNOWLEDGE BASE
2
+
3
+ ## OVERVIEW
4
+ `@cloudflare/realtimekit` — the WebRTC SDK engine; single default export `RealtimeKitClient`.
5
+
6
+ ## STRUCTURE
7
+ ```
8
+ core/
9
+ ├── .config/ # 6 Vite build configs + build-types.sh + prepublish.js
10
+ ├── src/ # All source (controllers, media, roomNode, socketService, e2ee, mock, …)
11
+ ├── docs/ # Node-based API reference generator (jsdoc-to-markdown)
12
+ ├── samples/ # Standalone transformer examples (audio/video middleware demos)
13
+ ├── __mocks__/ # Vitest manual mocks: window globals + sockrates-client
14
+ └── dist/ # Build output (not committed; generated by build scripts)
15
+ ```
16
+
17
+ ## BUILD TARGETS
18
+
19
+ | Vite config | Output file(s) | Format | Purpose |
20
+ |-------------|---------------|--------|---------|
21
+ | `vite.config.ts` | `dist/index.es.js`, `dist/index.cjs.js` | ESM + CJS | Main tree-shakeable + CommonJS builds |
22
+ | `vite.iife.config.ts` | `dist/browser.js` | IIFE | Self-contained browser bundle; bundle diff tracked in CI |
23
+ | `vite.rn.config.ts` | `dist/index.rn.js` | CJS | React Native (keeps `@dyteinternals/mediasoup-client` as external) |
24
+ | `vite.es5.config.ts` | `dist/index.es5.js` | ESM+Babel | Babel-transpiled ES5-compatible output via `@babel/preset-env` |
25
+ | `vite.e2ee.es.ts` | `dist/EncryptionManager.{es,cjs}.js` | ESM + CJS | E2EE sub-module (`./e2ee` export path) |
26
+ | `vite.mock.es.ts` | `dist/ClientMock.{es,cjs}.js` | ESM + CJS | Mock client for testing (`./mock` export path); polyfills `events`+`buffer` |
27
+ | `build-types.sh` (tsup) | `dist/index.d.ts`, `dist/EncryptionManager.d.ts`, `dist/ClientMock.d.ts` | `.d.ts` | Type declarations via tsup `--dts-only`; strips `#private;` lines |
28
+
29
+ **Build order inside `core`:** All 6 Vite targets run in parallel via `concurrently`, then `build:types` runs, then `downlevel-dts`.
30
+
31
+ ## EXPORT PATHS
32
+
33
+ | Export path | File | Consumers |
34
+ |-------------|------|-----------|
35
+ | `.` | `dist/index.es.js` / `dist/index.cjs.js` | Standard ESM/CJS imports |
36
+ | `./inlined` | `dist/browser.js` | Script-tag / CDN — all deps bundled in |
37
+ | `./compatible` | `dist/index.es5.js` | Legacy bundlers requiring ES5 |
38
+ | `./e2ee` | `dist/EncryptionManager.{es,cjs}.js` | Apps opting into E2EE encryption |
39
+ | `./mock` | `dist/ClientMock.{es,cjs}.js` | Test environments (no real WebRTC) |
40
+
41
+ TypeScript `<4.0` consumers are redirected to `dist/ts3.4/` via `typesVersions`.
42
+
43
+ ## WHERE TO LOOK
44
+
45
+ | Task | Location |
46
+ |------|----------|
47
+ | Type declaration generation | `.config/build-types.sh` — strips `@dyte-in/*` deps before tsup, then strips `#private;` lines from `.d.ts` |
48
+ | Pre-publish package.json rewrite | `.config/prepublish.js` — removes private deps, injects `VERSION_PLACEHOLDER` into 4 dist files, sets npm tag from `ENVIRONMENT` env var |
49
+ | Post-publish restore | `package.json` backed up to `package.json.bak` before publish; restored via `postpublish` script |
50
+ | TS 3.4 compat types | `dist/ts3.4/` produced by `downlevel-dts dist dist/ts3.4/dist` after type build |
51
+ | Bundle analyzer | `stats.html` generated by `rollup-plugin-visualizer` when `VITE_ANALYZE=1` |
52
+ | Transformer samples | `samples/transformers/` — audio (low-pass, pitch, noise) + video middleware examples |
53
+ | API reference generator | `docs/api-reference-generator.js` — run via `npm run docs`; outputs Markdown from JSDoc |
54
+
55
+ ## NOTES
56
+
57
+ - `dist/browser.js` is the IIFE bundle — CI tracks its size diff on every PR; do not add large dependencies to the main entry without expecting a size alert.
58
+ - `react-native` field in `package.json` (`./dist/index.rn.js`) is read by Metro bundler; it is a CJS build that keeps `@dyteinternals/mediasoup-client` external (unlike the main CJS build which inlines it).
59
+ - `build-types.sh` temporarily strips `@dyte-in*` / `@dyteinternals/*` from `package.json` so tsup resolves and bundles their types into the output `.d.ts`; `package.json` is restored via `trap restore EXIT`.
60
+ - `prepublish.js` strips `lodash-es` and all `@dyte-in*`/`@dyteinternals/*` (except `mediasoup-client`) from `dependencies` before publishing — these are inlined in the dist.
61
+ - `envPrefix: 'RTK_'` — only `RTK_*` env vars are exposed to Vite builds; use `RTK_` prefix for any new build-time flags.
62
+ - `vite.mock.es.ts` adds Node polyfills (`events`, `buffer`) because `ClientMock` runs in Node test environments.
63
+ - `vitest-github-coverage-provider.mts` — custom coverage reporter that emits GitHub-compatible annotations; only active in CI.