Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
777 changes: 0 additions & 777 deletions plans/kb.ttf.md

This file was deleted.

33 changes: 15 additions & 18 deletions plans/split-ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Goal:** Replace the single `shared/tsconfig.json` with per-platform configs so that `dom` APIs are forbidden in native code, native-only APIs are forbidden in desktop code, and the `.d.ts` type stubs are eliminated in favor of auto-generated `paths` that resolve directly to platform implementation files.

**Architecture:** A generator script (`shared/tools/gen-ts-paths.mjs`) scans the filesystem for modules that have `.desktop.tsx`/`.native.tsx` variants but no plain `.tsx`, then writes `tsconfig.paths.desktop.json` and `tsconfig.paths.native.json`. Each platform tsconfig extends `tsconfig.base.json` plus its generated paths file (TypeScript 5.0 array `extends`). The generated files are gitignored and regenerated before every type-check. Because TypeScript `paths` only intercept non-relative import specifiers, this works cleanly for the `@/*` alias style used throughout the codebase.
**Architecture:** A generator script (`shared/tools/gen-ts-paths.mjs`) scans the filesystem for modules that have `.desktop.tsx`/`.native.tsx` variants but no plain `.tsx`, then writes `tsconfig.paths.desktop.json` and `tsconfig.paths.native.json`. Each platform tsconfig extends `tsconfig.base.json` plus its generated paths file (TypeScript 5.0 array `extends`). The generated files are checked into the repo and must be regenerated (by running the generator script) whenever platform-split files are added or removed. Because TypeScript `paths` only intercept non-relative import specifiers, this works cleanly for the `@/*` alias style used throughout the codebase.

**Tech Stack:** TypeScript (`tsgo`), tsconfig `extends` array (TS 5.0+), Node ESM script, `yarn` scripts

Expand All @@ -18,12 +18,11 @@
| `shared/tsconfig.base.json` | Create — platform-agnostic compiler options |
| `shared/tsconfig.desktop.json` | Create — desktop lib/types, extends base + generated paths |
| `shared/tsconfig.native.json` | Create — native lib/types, extends base + generated paths |
| `shared/tsconfig.paths.desktop.json` | Generated (gitignored) — `@/foo` → `./foo.desktop` mappings |
| `shared/tsconfig.paths.native.json` | Generated (gitignored) — `@/foo` → `./foo.native` mappings |
| `shared/tsconfig.paths.desktop.json` | Generated (checked in) — `@/foo` → `./foo.desktop` mappings |
| `shared/tsconfig.paths.native.json` | Generated (checked in) — `@/foo` → `./foo.native` mappings |
| `shared/tools/gen-ts-paths.mjs` | Create — generator script |
| `shared/package.json` | Modify `tsc` script to run generator then both platform configs |
| `shared/**/*.d.ts` | Delete — replaced by generated paths (keep only non-platform stubs) |
| `.gitignore` | Modify — add generated paths files |

---

Expand Down Expand Up @@ -206,31 +205,29 @@ git commit -m "build: add gen-ts-paths.mjs to generate per-platform tsconfig pat

---

### Task 3: Gitignore the generated paths files
### Task 3: Commit the generated paths files

**Files:**
- Modify: root `.gitignore` or `shared/.gitignore`
- Commit: `shared/tsconfig.paths.desktop.json`, `shared/tsconfig.paths.native.json`

- [ ] **Step 1: Check which gitignore to update**
The generated paths files are checked into the repo so they are available without running the generator first (e.g. in CI before `node tools/gen-ts-paths.mjs` has run). The generator script must still be run whenever platform-split files are added or removed to keep them up to date.

```bash
ls /Users/chrisnojima/go/src/github.com/keybase/client/shared/.gitignore 2>/dev/null && echo "shared gitignore exists" || echo "use root"
```

- [ ] **Step 2: Add entries**
- [ ] **Step 1: Gitignore only the build output dirs**

Add to whichever `.gitignore` covers `shared/`:
```
shared/tsconfig.paths.desktop.json
shared/tsconfig.paths.native.json
shared/.tsOuts/
```

- [ ] **Step 3: Commit**
```bash
ls /Users/chrisnojima/go/src/github.com/keybase/client/shared/.gitignore 2>/dev/null && echo "shared gitignore exists" || echo "use root"
```

- [ ] **Step 2: Commit the generated files**

```bash
git add .gitignore
git commit -m "chore: gitignore generated tsconfig paths files and tsOuts"
cd shared && git add tsconfig.paths.desktop.json tsconfig.paths.native.json
git commit -m "build: add generated tsconfig paths files"
```

---
Expand Down Expand Up @@ -550,7 +547,7 @@ git commit -m "build: yarn tsc generates paths and checks desktop + native confi
- [x] **tsconfig.base.json** has all platform-agnostic options, no lib/types
- [x] **tsconfig.desktop.json** adds `dom`, `webpack-env`, excludes `.native.*` files
- [x] **tsconfig.native.json** drops `dom`/`webpack-env`, excludes `.desktop.*` and `./desktop/`
- [x] **Generated paths files** are gitignored
- [x] **Generated paths files** are checked into the repo
- [x] **Platform-split .d.ts stubs** deleted; non-platform stubs (`globals.d.ts` etc.) kept
- [x] **tsconfig.json** is editor fallback extending desktop
- [x] **yarn tsc** runs generator then both platform configs
Expand Down
3 changes: 2 additions & 1 deletion plans/todo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
look for opportunities to use gap in all boxes
any leftover zustand store
ios bg colors wrong
ios push to convo broken
ts split maybe
legend list for chat thread desktop
legend list for chat thread native
update deps
remove zoom toolkit
1 change: 1 addition & 0 deletions shared/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ gem 'bigdecimal'
gem 'logger'
gem 'benchmark'
gem 'mutex_m'
gem 'nkf'
4 changes: 2 additions & 2 deletions shared/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ react {

/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// skip the bundling of the JS bundle and the assets. Default is "debug", "debugOptimized".
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
// debuggableVariants = ["liteDebug", "liteDebugOptimized", "prodDebug", "prodDebugOptimized"]

/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
Expand Down
2 changes: 1 addition & 1 deletion shared/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Mon May 06 15:15:57 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 0 additions & 3 deletions shared/android/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions shared/android/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion shared/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
},
"android": {
"package": "io.keybase.ossifrage"
}
},
"plugins": [
"expo-asset",
"expo-audio",
"expo-image",
"expo-localization",
"expo-mail-composer",
"expo-video"
]
}
}
36 changes: 18 additions & 18 deletions shared/app/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,24 @@ if (__DEV__ && !globalThis.DEBUGmadeEngine) {
// once per module
let inited = false
const useInit = () => {
if (inited) return
inited = true
initDarkMode()
Animated.addWhitelistedNativeProps({text: true})
install()
const {batch} = C.useWaitingState.getState().dispatch
const eng = makeEngine(batch, c => {
if (c) {
onEngineConnected()
} else {
onEngineDisconnected()
}
}, onEngineIncoming)
initPlatformListener()
eng.listenersAreReady()

// On mobile there is no installer
useConfigState.getState().dispatch.installerRan()
React.useEffect(() => {
if (inited) return
inited = true
initDarkMode()
Animated.addWhitelistedNativeProps({text: true})
install()
const {batch} = C.useWaitingState.getState().dispatch
const eng = makeEngine(batch, c => {
if (c) {
onEngineConnected()
} else {
onEngineDisconnected()
}
}, onEngineIncoming)
initPlatformListener()
eng.listenersAreReady()
useConfigState.getState().dispatch.installerRan()
}, [])
}

// reanimated has issues updating shared values with this on seemingly w/ zoom toolkit
Expand Down
Loading