Skip to content

Build on tinode-sdk instead of the in-repo TypeScript port - #2

Merged
amerllica merged 14 commits into
mainfrom
refactor/tinode-sdk
Oct 25, 2026
Merged

amerllica merged 14 commits into
mainfrom
refactor/tinode-sdk

Conversation

@amerllica

Copy link
Copy Markdown
Owner

Why

tinode/tinode-js#103 is merged into tinode-js devel: the official SDK now takes storage, netInfo and network in new Tinode(config) and ships KeyValueAdapter, fromMMKV, MemoryAdapter and IndexedDBAdapter. That was the reason this package carried its own TypeScript port of the SDK in src/core. This PR deletes the port and builds the React layer on tinode-sdk.

What changes

  • Dependency: tinode-sdk from github:tinode/tinode-js#commit=70436161 (the merge of #103 on devel) until the next npm release. Yarn packs it once and keeps the checksum in yarn.lock, so yarn install --immutable reproduces it.
  • Types: tinode-sdk is plain JavaScript, so src/sdk declares its surface (types.ts), tells TypeScript what the untyped module exports (tinode-sdk.d.ts, inline imports only), and re-exports the values with those types (index.ts). Emitted lib/typescript never refers to tinode-sdk.
  • Hermes: tinode-sdk calls new Intl.Segmenter() when it loads and uses TextDecoder for vCards; Hermes has neither. src/platform installs a grapheme-only Intl.Segmenter and a UTF-8 TextDecoder only when they are missing, and src/index.tsx imports it before the SDK. sideEffects lists src/platform and lib/module/platform.
  • React layer: imports from ../sdk; TOPIC_ME, LOCAL_SEQID and DEFAULT_MESSAGES_PAGE move to src/react/constants.ts (upstream does not export them). createTinode passes storage, netInfo and network to the SDK.
  • Removed: src/core (the port and its 14 test suites), src/react/netinfo.ts, the fake-indexeddb devDependency and the src/core ESLint overrides.
  • Docs: README, docs/DECISIONS.md, NOTICE, the auth-token guide.

Breaking changes (release as 0.2.0)

  • netInfo moves from a TinodeProvider / TinodeStoresProvider prop into the config: createTinode({ ...config, netInfo: NetInfo }) or <TinodeProvider config={{ ...config, netInfo }}>. The SDK then retries at once when the network comes back. The provider still reconnects on AppState change.
  • Topic, TopicMe, TopicFnd, CommError, MetaGetBuilder and LargeFileHelper are types only now, because upstream does not export the classes. Use isCommError(error) instead of instanceof CommError.
  • LargeFileHelper.download() works on the web only until the next tinode-js PR (it still needs a DOM). upload() with { uri, name, type } works on native.

How I checked it

  • Every commit passes yarn install --immutable, yarn typecheck, yarn lint, yarn test and yarn prepare.
  • yarn test: 10 suites, 48 tests. src/sdk/__tests__ loads the real tinode-sdk: a client with MemoryAdapter, a KeyValueAdapter round trip, fromMMKV, Drafty parsing. src/platform/__tests__ removes the native Intl.Segmenter / TextDecoder, loads this package and then tinode-sdk, and parses Drafty / imports a UTF-8 vCard. Without the shim that test fails with Intl.Segmenter is not a constructor, which is the Hermes crash.
  • yarn prepare: lib/module/index.js imports ./platform/index.js first; no tinode-sdk.d.js in lib/module; no import("tinode-sdk") in lib/typescript.
  • A scratch consumer type-checks against lib/typescript: createTinode with KeyValueAdapter and netInfo, getMeTopic().startMetaQuery(), isCommError, and a wrong storage value is rejected.
  • The example app starts in Expo Go (Hermes) on the iOS 27 simulator with this branch and shows the sign-in screen, so the SDK loads on Hermes.
  • Not done: signing in against a local Tinode server, because Docker Desktop did not start on my machine.

@amerllica
amerllica merged commit 0d41cab into main Oct 25, 2026
7 checks passed
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