Skip to content

Commit b829605

Browse files
Merge branch 'master' into rc
2 parents 7bcf67c + 34ee89c commit b829605

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1879
-837
lines changed

.github/workflows/docusaurus.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/pr-check.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Check PR title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: aslafy-z/conventional-pr-title-action@v3
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@ name: Release
22
on:
33
workflow_dispatch:
44
inputs:
5+
docs_only:
6+
description: Skip package release and publish documentation only
7+
default: false
8+
type: boolean
59
dry_run:
6-
description: 'Run semantic-release in "dry run" mode'
10+
description: Run package release in "dry run" mode (does not publish either)
711
default: false
812
type: boolean
13+
docs_env:
14+
description: Pick environment to publish documentation to
15+
required: true
16+
type: choice
17+
default: staging
18+
options:
19+
- production
20+
- staging
921

10-
env:
11-
NODE_OPTIONS: --max_old_space_size=4096
1222
jobs:
13-
release:
14-
name: Release
23+
package_release:
24+
name: Release from "${{ github.ref_name }}" branch
1525
runs-on: ubuntu-latest
1626
# GH does not allow to limit branches in the workflow_dispatch settings so this here is a safety measure
17-
if: ${{ github.ref_name == 'master' || github.ref_name == 'rc' || github.ref_name == 'release-v9' }}
27+
if: ${{ !inputs.docs_only && (github.ref_name == 'master' || github.ref_name == 'rc' || github.ref_name == 'release-v9') }}
28+
env:
29+
NODE_OPTIONS: --max_old_space_size=4096
1830
steps:
1931
- name: Checkout
2032
uses: actions/checkout@v3
@@ -31,7 +43,33 @@ jobs:
3143
- name: Release
3244
env:
3345
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
# https://github.com/stream-ci-bot
47+
GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }}
3548
run: >
3649
yarn semantic-release
3750
${{ inputs.dry_run && '--dry-run' || '' }}
51+
52+
docs_release:
53+
name: Publish documentation from "${{ github.ref_name }}" branch to ${{ inputs.docs_env }}
54+
runs-on: ubuntu-latest
55+
# skip during dry runs, release to production only from master, release to staging from anywhere
56+
if: ${{ !inputs.dry_run && ((inputs.docs_env == 'production' && github.ref_name == 'master') || (github.ref_name != 'master' && inputs.docs_env == 'staging')) }}
57+
outputs:
58+
target-version: $${{ steps.target-version.outputs }}
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v3
62+
- name: Setup Node.js
63+
uses: actions/setup-node@v3
64+
with:
65+
node-version: 20
66+
- name: Install dependencies
67+
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
68+
- name: Merge shared "@stream-io/stream-chat-css" docs
69+
run: bash scripts/merge-stream-chat-css-docs.sh node_modules/@stream-io/stream-chat-css/docs
70+
- name: Push to stream-chat-docusaurus
71+
uses: GetStream/push-stream-chat-docusaurus-action@main
72+
with:
73+
target-branch: ${{ inputs.docs_env }}
74+
env:
75+
DOCUSAURUS_GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }}

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@
99
### BREAKING CHANGES
1010

1111
* **emoji-mart:** `reactionOptions` signature has changed, see [release guide](https://github.com/GetStream/stream-chat-react/blob/7a19e386aa3adcc5741a7f0d92bc816a1a424094/docusaurus/docs/React/release-guides/new-reactions.mdx) for more information
12+
13+
# [10.15.0](https://github.com/GetStream/stream-chat-react/compare/v10.14.1...v10.15.0) (2023-10-25)
14+
15+
16+
### Features
17+
18+
* **renderText:** allow custom remark and rehype plugin composition ([#2142](https://github.com/GetStream/stream-chat-react/issues/2142)) ([4a25912](https://github.com/GetStream/stream-chat-react/commit/4a259125a41d49d50473b6f0edc89a9f56d21ea6))
19+
* **VirtualizedMessageList:** allow to merge custom virtuoso components with the SDK defaults ([#2140](https://github.com/GetStream/stream-chat-react/issues/2140)) ([6ea9ff0](https://github.com/GetStream/stream-chat-react/commit/6ea9ff0ca01782ec1b4ceffffb74d9fa9a2fdc1c))
20+
21+
## [10.14.1](https://github.com/GetStream/stream-chat-react/compare/v10.14.0...v10.14.1) (2023-10-19)
22+
23+
24+
###
25+
* chore(deps): bump stream-chat from 8.12.4 to 8.13.1
26+
27+
# [10.14.0](https://github.com/GetStream/stream-chat-react/compare/v10.13.1...v10.14.0) (2023-10-11)
28+
29+
30+
### Features
31+
32+
* allow complete channel list throttled reload on internet connection recovery ([#2123](https://github.com/GetStream/stream-chat-react/issues/2123)) ([252cac3](https://github.com/GetStream/stream-chat-react/commit/252cac3366986523b9f6b1152c9408ccab0af710))
1233

1334
## [10.13.1](https://github.com/GetStream/stream-chat-react/compare/v10.13.0...v10.13.1) (2023-10-09)
1435

developers/RELEASE.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
# Release
1+
# Release process (for package and documentation)
2+
23
The `stream-chat-react` package follows semantic versioning and the release is to a big part automated by `semantic-release`. The utility automates:
34

4-
1. Collects release notes from the commits added since the last release
5-
2. Creates a [GitHub release](https://github.com/GetStream/stream-chat-react/releases)
6-
3. Appends release notes to `CHANGELOG.md`
7-
4. Publishes a new package version to NPM.
5+
1. release notes collection from the commits added since the last release
6+
2. [GitHub release](https://github.com/GetStream/stream-chat-react/releases) creation
7+
3. release notes (`CHANGELOG.md`) update
8+
4. version bump and package release to the NPM
9+
10+
In order to get the above generated outputs, each contributor should follow [Angular's Commit Message Format rules](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format).
11+
12+
## Required steps
813

9-
In order the above generates correct outputs, each contributor should [Angular's Commit Messag Format rules](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format).
14+
At the moment these manual actions have to be taken to achieve a successfull release:
1015

11-
At the moment these manual actions have to be taken while doing a release:
16+
1. make sure that all the new required features and bug fixes in peer dependency repositories `@stream-io/stream-chat-css` and `stream-chat-js` are released
17+
2. make sure that the peer dependencies `@stream-io/stream-chat-css` and `stream-chat-js` are installed at their latest version (see `package.json`, `yarn.lock`) (if applicable)
18+
3. squash-merge required pull requests to `master` branch with appropriate message name, for example: `fix(scope): new feature`, if this feature is breaking, make sure to include `BREAKING CHANGE: <reason>` in the message footer
19+
4. navigate to ["Actions"](https://github.com/GetStream/stream-chat-react/actions) and in the left bar select the "Release" workflow
20+
5. click "Run workflow" and select the branch you want to release from then adjust the prompt options and click "Run workflow", note that allowed branches for __PACKAGE RELEASE__ are: `master`, `release-v9` and `rc`, there's _is no such limititation_ for the __DOCUMENTATION RELEASE__, extend the workflow condition and `.releaserc.json` as needed
1221

13-
0. Make sure that all the new required features and bug fixes in peer dependency repositories `@stream-io/stream-chat-css` and `stream-chat-js` are released
14-
1. Make sure that the peer dependencies `@stream-io/stream-chat-css` and `stream-chat-js` are installed at their latest version (see `package.json`, `yarn.lock`)
15-
2. Create a new PR request from `develop` to `master` branch.
16-
- The PR name should correspond to the next package version that is to be released (e.g. v1.1, v8, v9.1.2). You can use GitHub's CLI utility (e.g. `gh pr create —base master`)
17-
- The PR description should list all the changes in form of commit messages (therefore we require squashing the commit history when merging into `develop`).
18-
3. Solve potential conflicts between the two branches
19-
- As `master` receives updates only from `develop`, there should be no conflicts.
20-
4. Merge the PR and make sure that:
21-
- the `CHANGELOG.md` file has been correctly updated
22-
- a new (correct) version of the package has been published at NPM
23-
- a new release with correct version number has be created in GitHub
22+
## Available release prompt options
23+
24+
- `docs_only` option if checked will skip the `package_release` job and will only run the `docs_release`
25+
- `dry_run` option if checked will run the `semantic-release` command in ["dry run" mode](https://semantic-release.gitbook.io/semantic-release/usage/configuration#dryrun) and will skip `docs_release`
26+
- `docs_env` (required) option offers two environment options to which the documentation will be pushed to via `GetStream/push-stream-chat-docusaurus-action` - defaults to `staging`
2427

2528
## After the release
29+
2630
We maintain multiple demo applications developed with `stream-chat-react`. With each new version of the package, the applications should have their dependencies upgraded explicitly in their `package.json`.
2731

2832
The demo apps repositories are:

docusaurus/docs/React/components/contexts/message-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Custom function to render message text content.
341341

342342
| Type | Default |
343343
| -------- | -------------------------------------------------------------------------------------- |
344-
| function | [renderText](https://github.com/GetStream/stream-chat-react/blob/master/src/utils.tsx) |
344+
| function | <GHComponentLink text='renderText' path='/Message/renderText/renderText.tsx'/> |
345345

346346
### setEditingState
347347

docusaurus/docs/React/components/core-components/message-list.mdx

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,20 @@ The `MessageList` internally creates a mapping of message id to a style group. T
6666

6767
### Default behaviour
6868

69-
The output of the default [`renderText`](#render-text) function is a message text processed by the `ReactMarkdown` component with [`remark`](https://github.com/remarkjs/remark/blob/main/doc/plugins.md) [`remark-gfm`](https://github.com/remarkjs/remark-gfm) plugin and custom [`rehype`](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md) plugins for mentions and emojis.
69+
The default [`renderText`](#render-text) function parses a markdown string and outputs a `ReactElement`. Under the hood, the output is generated by the `ReactMarkdown` component from [react-markdown library](https://github.com/remarkjs/react-markdown). The component transforms the markdown to `ReactElement` by using [`remark` parser](https://github.com/remarkjs/remark/tree/main) and [`remark`](https://github.com/remarkjs/remark/blob/main/doc/plugins.md) and [`rehype`](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md) plugins.
70+
71+
The default `remark` plugins used by SDK are:
72+
73+
1. [`remark-gfm`](https://github.com/remarkjs/remark-gfm) - a third party plugin to add GitHub-like markdown support
74+
75+
The default `rehype` plugins (both specific to this SDK) are:
76+
1. plugin to render user mentions
77+
2. plugin to render emojis
7078

7179
### Overriding defaults
7280

81+
#### Custom `renderText` function
82+
7383
If you don't want your chat implementation to support markdown syntax by default you can override the default behaviour by creating a custom `renderText` function which returns a React node and passing it down to the `MessageList` or `MessageSimple` component via `renderText` property.
7484

7585
For this particular example we'll create a very primitive one which takes the message text passed down to it as a first argument and returns it wrapped in `span` element:
@@ -112,10 +122,12 @@ const App = () => (
112122
);
113123
```
114124

115-
If you feel like the default output is sufficient but you'd like to adjust how certain [ReactMarkdown components](https://github.com/remarkjs/react-markdown#appendix-b-components) look like (like `strong` element generated by typing \*\*strong\*\*) you can do so by passing down options to a third argument of the default `renderText` function:
125+
#### Custom element rendering
126+
127+
If you feel like the default output is sufficient, but you'd like to adjust how certain [ReactMarkdown components](https://github.com/remarkjs/react-markdown#appendix-b-components) look like (like `strong` element generated by typing \*\*strong\*\*) you can do so by passing down options to a third argument of the default `renderText` function:
116128

117129
:::note
118-
Types `mention` and `emoji` are special case component types generated by our custom rehype plugins. Currently we do not allow to add custom rehype/remark plugins to our default `renderText` function due to compatibility reasons regarding our custom plugins.
130+
Types `mention` and `emoji` are special case component types generated by our SDK's custom rehype plugins.
119131
:::
120132

121133
```tsx
@@ -146,6 +158,66 @@ const App = () => (
146158
);
147159
```
148160

161+
#### Custom remark and rehype plugins
162+
163+
If you would like to extend the array of plugins used to parse the markdown, you can provide your own lists of remark resp. rehype plugins. The logic that determines what plugins are used and in which order can be specified in custom `getRehypePlugins` and `getRemarkPlugins` functions. These receive the default array of rehype and remark plugins for further customization. Both custom functions ought to be passed to the third `renderText()` parameter. An example follows:
164+
165+
:::note
166+
It is important to understand what constitutes a rehype or remark plugin. A good start is to learn about the library called [`react-remark`](https://github.com/remarkjs/react-remark) which is used under the hood in our `renderText()` function.
167+
:::
168+
169+
170+
```tsx
171+
import { renderText, RenderTextPluginConfigurator } from 'stream-chat-react';
172+
import {customRehypePlugin} from './rehypePlugins';
173+
import {customRemarkPlugin} from './remarkPlugins';
174+
175+
const getRehypePlugins: RenderTextPluginConfigurator = (plugins) => {
176+
return [customRehypePlugin, ...plugins];
177+
}
178+
const getRemarkPlugins: RenderTextPluginConfigurator = (plugins) => {
179+
return [customRemarkPlugin, ...plugins];
180+
}
181+
182+
const customRenderText = (text, mentionedUsers) =>
183+
renderText(text, mentionedUsers, {
184+
getRehypePlugins,
185+
getRemarkPlugins
186+
});
187+
188+
const CustomMessageList = () => (
189+
<MessageList renderText={customRenderText}/>
190+
);
191+
```
192+
193+
It is also possible to define your custom set of allowed tag names for the elements rendered from the parsed markdown. To perform the tree transformations, you will need to use libraries like [`unist-builder`](https://github.com/syntax-tree/unist-builder) to build the trees and [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit-parents) or [`hast-util-find-and-replace`](https://github.com/syntax-tree/hast-util-find-and-replace) to traverse the tree:
194+
195+
```tsx
196+
import { findAndReplace } from 'hast-util-find-and-replace';
197+
import { u } from 'unist-builder';
198+
import { defaultAllowedTagNames, renderText, RenderTextPluginConfigurator } from 'stream-chat-react';
199+
200+
// wraps every letter b in <xxx></xxx> tags
201+
const customTagName = 'xxx';
202+
const replace = (match) => u('element', { tagName: customTagName }, [u('text', match)]);
203+
const customRehypePlugin = () => (tree) => findAndReplace(tree, /b/, replace);
204+
205+
const getRehypePlugins: RenderTextPluginConfigurator = (plugins) => {
206+
return [customRehypePlugin, ...plugins];
207+
}
208+
209+
210+
const customRenderText = (text, mentionedUsers) =>
211+
renderText(text, mentionedUsers, {
212+
allowedTagNames: [...defaultAllowedTagNames, customTagName],
213+
getRehypePlugins,
214+
});
215+
216+
const CustomMessageList = () => (
217+
<MessageList renderText={customRenderText}/>
218+
);
219+
```
220+
149221
## Props
150222

151223
### additionalMessageInputProps
@@ -434,7 +506,7 @@ Custom function to render message text content.
434506

435507
| Type | Default |
436508
| -------- | -------------------------------------------------------------------------------------- |
437-
| function | [renderText](https://github.com/GetStream/stream-chat-react/blob/master/src/utils.tsx) |
509+
| function | <GHComponentLink text='renderText' path='/Message/renderText/renderText.tsx'/> |
438510

439511
### retrySendMessage
440512

docusaurus/docs/React/components/message-components/message-ui.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Custom function to render message text content (overrides the function stored in
460460

461461
| Type | Default |
462462
| -------- | -------------------------------------------------------------------------------------- |
463-
| function | [renderText](https://github.com/GetStream/stream-chat-react/blob/master/src/utils.tsx) |
463+
| function | <GHComponentLink text='renderText' path='/Message/renderText/renderText.tsx'/> |
464464

465465
### setEditingState
466466

docusaurus/docs/React/components/message-components/message.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ Custom function to render message text content.
326326

327327
| Type | Default |
328328
| -------- | -------------------------------------------------------------------------------------- |
329-
| function | [renderText](https://github.com/GetStream/stream-chat-react/blob/master/src/utils.tsx) |
329+
| function | <GHComponentLink text='renderText' path='/Message/renderText/renderText.tsx'/> |
330330

331331
### retrySendMessage
332332

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"rollup-plugin-url": "^3.0.1",
170170
"rollup-plugin-visualizer": "^4.2.0",
171171
"semantic-release": "^19.0.5",
172-
"stream-chat": "^8.12.4",
172+
"stream-chat": "^8.13.1",
173173
"style-loader": "^2.0.0",
174174
"ts-jest": "^26.5.1",
175175
"typescript": "^4.7.4",

0 commit comments

Comments
 (0)