Repository navigation
Build on tinode-sdk instead of the in-repo TypeScript port - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
tinode/tinode-js#103 is merged into tinode-js
devel: the official SDK now takesstorage,netInfoandnetworkinnew Tinode(config)and shipsKeyValueAdapter,fromMMKV,MemoryAdapterandIndexedDBAdapter. That was the reason this package carried its own TypeScript port of the SDK insrc/core. This PR deletes the port and builds the React layer ontinode-sdk.What changes
tinode-sdkfromgithub:tinode/tinode-js#commit=70436161(the merge of #103 ondevel) until the next npm release. Yarn packs it once and keeps the checksum inyarn.lock, soyarn install --immutablereproduces it.tinode-sdkis plain JavaScript, sosrc/sdkdeclares 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). Emittedlib/typescriptnever refers totinode-sdk.tinode-sdkcallsnew Intl.Segmenter()when it loads and usesTextDecoderfor vCards; Hermes has neither.src/platforminstalls a grapheme-onlyIntl.Segmenterand a UTF-8TextDecoderonly when they are missing, andsrc/index.tsximports it before the SDK.sideEffectslistssrc/platformandlib/module/platform.../sdk;TOPIC_ME,LOCAL_SEQIDandDEFAULT_MESSAGES_PAGEmove tosrc/react/constants.ts(upstream does not export them).createTinodepassesstorage,netInfoandnetworkto the SDK.src/core(the port and its 14 test suites),src/react/netinfo.ts, thefake-indexeddbdevDependency and thesrc/coreESLint overrides.docs/DECISIONS.md,NOTICE, the auth-token guide.Breaking changes (release as 0.2.0)
netInfomoves from aTinodeProvider/TinodeStoresProviderprop 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 onAppStatechange.Topic,TopicMe,TopicFnd,CommError,MetaGetBuilderandLargeFileHelperare types only now, because upstream does not export the classes. UseisCommError(error)instead ofinstanceof 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
yarn install --immutable,yarn typecheck,yarn lint,yarn testandyarn prepare.yarn test: 10 suites, 48 tests.src/sdk/__tests__loads the realtinode-sdk: a client withMemoryAdapter, aKeyValueAdapterround trip,fromMMKV, Drafty parsing.src/platform/__tests__removes the nativeIntl.Segmenter/TextDecoder, loads this package and thentinode-sdk, and parses Drafty / imports a UTF-8 vCard. Without the shim that test fails withIntl.Segmenter is not a constructor, which is the Hermes crash.yarn prepare:lib/module/index.jsimports./platform/index.jsfirst; notinode-sdk.d.jsinlib/module; noimport("tinode-sdk")inlib/typescript.lib/typescript:createTinodewithKeyValueAdapterandnetInfo,getMeTopic().startMetaQuery(),isCommError, and a wrongstoragevalue is rejected.