Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename packages/rrweb-player to packages/rrweb-playback-ui #661

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ rrweb is mainly composed of 3 parts:

- **[rrweb-snapshot](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-snapshot/)**, including both snapshot and rebuilding features. The snapshot is used to convert the DOM and its state into a serializable data structure with a unique identifier; the rebuilding feature is to rebuild the snapshot into corresponding DOM.
- **[rrweb](https://github.com/rrweb-io/rrweb)**, including two functions, record and replay. The record function is used to record all the mutations in the DOM; the replay is to replay the recorded mutations one by one according to the corresponding timestamp.
- **[rrweb-player](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-player/)**, is a player UI for rrweb, providing GUI-based functions like pause, fast-forward, drag and drop to play at any time.
- **[rrweb-playback-ui](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-playback-ui/)**, is a player UI for rrweb, providing GUI-based functions like pause, fast-forward, drag and drop to play at any time.

## Roadmap

Expand Down
2 changes: 1 addition & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rrweb 主要由 3 部分组成:

- **[rrweb-snapshot](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-snapshot/)**,包含 snapshot 和 rebuild 两个功能。snapshot 用于将 DOM 及其状态转化为可序列化的数据结构并添加唯一标识;rebuild 则是将 snapshot 记录的数据结构重建为对应的 DOM。
- **[rrweb](https://github.com/rrweb-io/rrweb)**,包含 record 和 replay 两个功能。record 用于记录 DOM 中的所有变更(mutation);replay 则是将记录的变更按照对应的时间一一重放。
- **[rrweb-player](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-player/)**,为 rrweb 提供一套 UI 控件,提供基于 GUI 的暂停、快进、拖拽至任意时间点播放等功能。
- **[rrweb-playback-ui](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-playback-ui/)**,为 rrweb 提供一套 UI 控件,提供基于 GUI 的暂停、快进、拖拽至任意时间点播放等功能。

## Roadmap

Expand Down
6 changes: 3 additions & 3 deletions docs/recipes/custom-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rrweb.record.addCustomEvent('some-error', {

`addCustomEvent` accepts two parameters. The first one is a string-type `tag`, while the second one is an any-type `payload`.

During the replay, we can add an event listener to custom events, or configure the style of custom events in rrweb-player's timeline.
During the replay, we can add an event listener to custom events, or configure the style of custom events in rrweb-playback-ui's timeline.

**Listen to custom events**

Expand All @@ -36,10 +36,10 @@ replayer.on('custom-event', (event) => {
});
```

**Display in rrweb-player**
**Display in rrweb-playback-ui**

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body,
props: {
events,
Expand Down
6 changes: 3 additions & 3 deletions docs/recipes/custom-event.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rrweb.record.addCustomEvent('some-error', {

`addCustomEvent` 接收两个参数,第一个是字符串类型的 `tag`,第二个是任意类型的 `payload`。

在回放时我们可以通过监听事件获取对应的事件,也可以通过配置 rrweb-player 在回放器 UI 的时间轴中展示对应事件。
在回放时我们可以通过监听事件获取对应的事件,也可以通过配置 rrweb-playback-ui 在回放器 UI 的时间轴中展示对应事件。

**获取对应事件**

Expand All @@ -36,10 +36,10 @@ replayer.on('custom-event', (event) => {
});
```

**在 rrweb-player 中展示**
**在 rrweb-playback-ui 中展示**

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body,
props: {
events,
Expand Down
38 changes: 19 additions & 19 deletions docs/recipes/customize-replayer.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Customize the Replayer

When rrweb's Replayer and the rrweb-player UI do not fit your need, you can customize your replayer UI.
When rrweb's Replayer and the rrweb-playback-ui UI do not fit your need, you can customize your replayer UI.

There are several ways to do this:

1. Use rrweb-player, and customize its CSS.
2. Use rrweb-player, and set `showController: false` to hide the controller UI. With this config, you can implement your controller UI.
1. Use rrweb-playback-ui, and customize its CSS.
2. Use rrweb-playback-ui, and set `showController: false` to hide the controller UI. With this config, you can implement your controller UI.
3. Use the `insertStyleRules` options to inject some CSS into the replay iframe.
4. Develop a new replayer UI with rrweb's Replayer.

## Implement Your Controller UI

When using rrweb-player, you can hide its controller UI:
When using rrweb-playback-ui, you can hide its controller UI:

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body,
props: {
events,
Expand All @@ -23,50 +23,50 @@ new rrwebPlayer({
});
```

When you are implementing a controller UI, you may need to interact with rrweb-player.
When you are implementing a controller UI, you may need to interact with rrweb-playback-ui.

The follwing APIs show some common use case of a controller UI:

```js
// toggle between play and pause
rrwebPlayer.toggle();
rrwebPlaybackUi.toggle();
// play
rrwebPlayer.play();
rrwebPlaybackUi.play();
// pause
rrwebPlayer.pause();
rrwebPlaybackUi.pause();
// update the dimension
rrwebPlayer.$set({
rrwebPlaybackUi.$set({
width: NEW_WIDTH,
height: NEW_HEIGHT,
});
rrwebPlayer.triggerResize();
rrwebPlaybackUi.triggerResize();
// toggle whether to skip the inactive time
rrwebPlayer.toggleSkipInactive();
rrwebPlaybackUi.toggleSkipInactive();
// set replay speed
rrwebPlayer.setSpeed(2);
rrwebPlaybackUi.setSpeed(2);
// go to some timing
rrwebPlayer.goto(3000);
rrwebPlaybackUi.goto(3000);
```

And there are some ways to listen rrweb-player's state:
And there are some ways to listen rrweb-playback-ui's state:

```js
// get current timing
rrwebPlayer.addEventListener('ui-update-current-time', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-current-time', (event) => {
console.log(event.payload);
});

// get current state
rrwebPlayer.addEventListener('ui-update-player-state', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-player-state', (event) => {
console.log(event.payload);
});

// get current progress
rrwebPlayer.addEventListener('ui-update-progress', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-progress', (event) => {
console.log(event.payload);
});
```

## Develop a new replayer UI with rrweb's Replayer.

Please refer [rrweb-player](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-player/).
Please refer [rrweb-playback-ui](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-playback-ui/).
42 changes: 21 additions & 21 deletions docs/recipes/customize-replayer.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# 自定义回放 UI

当 rrweb Replayer 和 rrweb-player 的 UI 不能满足需求时,可以通过自定义回放 UI 制作属于你自己的回放器。
当 rrweb Replayer 和 rrweb-playback-ui 的 UI 不能满足需求时,可以通过自定义回放 UI 制作属于你自己的回放器。

你可以通过以下几种方式从不同角度自定义回放 UI:

1. 使用 rrweb-player 时,通过覆盖 CSS 样式表定制 UI。
2. 使用 rrweb-player 时,通过 `showController: false` 隐藏控制器 UI,重新实现控制器 UI。
1. 使用 rrweb-playback-ui 时,通过覆盖 CSS 样式表定制 UI。
2. 使用 rrweb-playback-ui 时,通过 `showController: false` 隐藏控制器 UI,重新实现控制器 UI。
3. 通过 `insertStyleRules` 在回放页面(iframe)内定制 CSS 样式。
4. 基于 rrweb Replayer 开发自己的回放器 UI。

## 实现控制器 UI

使用 rrweb-player 时,可以隐藏其控制器 UI:
使用 rrweb-playback-ui 时,可以隐藏其控制器 UI:

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body,
props: {
events,
Expand All @@ -23,50 +23,50 @@ new rrwebPlayer({
});
```

实现自己的控制器 UI 时,你可能需要与 rrweb-player 进行交互。
实现自己的控制器 UI 时,你可能需要与 rrweb-playback-ui 进行交互。

通过 API 控制 rrweb-player
通过 API 控制 rrweb-playback-ui

```js
// 在播放和暂停间切换
rrwebPlayer.toggle();
rrwebPlaybackUi.toggle();
// 播放
rrwebPlayer.play();
rrwebPlaybackUi.play();
// 暂停
rrwebPlayer.pause();
// 更新 rrweb-player 宽高
rrwebPlayer.$set({
rrwebPlaybackUi.pause();
// 更新 rrweb-playback-ui 宽高
rrwebPlaybackUi.$set({
width: NEW_WIDTH,
height: NEW_HEIGHT,
});
rrwebPlayer.triggerResize();
rrwebPlaybackUi.triggerResize();
// 切换否跳过无操作时间
rrwebPlayer.toggleSkipInactive();
rrwebPlaybackUi.toggleSkipInactive();
// 设置播放速度为 2 倍
rrwebPlayer.setSpeed(2);
rrwebPlaybackUi.setSpeed(2);
// 跳转至播放 3 秒处
rrwebPlayer.goto(3000);
rrwebPlaybackUi.goto(3000);
```

通过监听事件获得 rrweb-player 的状态:
通过监听事件获得 rrweb-playback-ui 的状态:

```js
// 当前播放时间
rrwebPlayer.addEventListener('ui-update-current-time', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-current-time', (event) => {
console.log(event.payload);
});

// 当前播放状态
rrwebPlayer.addEventListener('ui-update-player-state', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-player-state', (event) => {
console.log(event.payload);
});

// 当前播放进度
rrwebPlayer.addEventListener('ui-update-progress', (event) => {
rrwebPlaybackUi.addEventListener('ui-update-progress', (event) => {
console.log(event.payload);
});
```

## 基于 rrweb Replayer 开发自己的回放器 UI

可以参照 [rrweb-player](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-player/) 的方式进行开发。
可以参照 [rrweb-playback-ui](https://github.com/rrweb-io/rrweb/tree/master/packages/rrweb-playback-ui/) 的方式进行开发。
2 changes: 1 addition & 1 deletion docs/recipes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ By default, the UI could not interact during replay. But you can use API to enab

### Customize The Replayer

When rrweb's Replayer and the rrweb-player UI do not fit your need, you can customize your own replayer UI.
When rrweb's Replayer and the rrweb-playback-ui UI do not fit your need, you can customize your own replayer UI.

[link](./customize-replayer.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/index.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

### 自定义回放 UI

当 rrweb Replayer 和 rrweb-player 的 UI 不能满足需求时,可以通过自定义回放 UI 制作属于你自己的回放器。
当 rrweb Replayer 和 rrweb-playback-ui 的 UI 不能满足需求时,可以通过自定义回放 UI 制作属于你自己的回放器。

[链接](./customize-replayer.zh_CN.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ The specific method includes two parts:
2. When playing back the mouse up mouse interaction event, add the `.:hover` class name to the event target and all its ancestors, and remove it when the mouse moves away again.

## Play from any point in time
In addition to the basic replay features, we also want players like `rrweb-player` to provide similar functionality to video players, such as dragging and dropping to the progress bar to any point in time.
In addition to the basic replay features, we also want players like `rrweb-playback-ui` to provide similar functionality to video players, such as dragging and dropping to the progress bar to any point in time.

In actual implementation, we pass a start time to the method. We can then divide the snapshot chain into two parts: The parts before and the part after the start time. Then, the snapshot chain before the start time is executed synchronously, and then the snapshot chain after the starting times uses the normal asynchronous execution. This way we can achieve starting replay from any point in time.
2 changes: 1 addition & 1 deletion docs/replay.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ parent

## 从任意时间点开始播放

除了基础的回放功能之外,我们还希望 `rrweb-player` 这样的播放器可以提供和视频播放器类似的功能,如拖拽到进度条至任意时间点播放。
除了基础的回放功能之外,我们还希望 `rrweb-playback-ui` 这样的播放器可以提供和视频播放器类似的功能,如拖拽到进度条至任意时间点播放。

实际实现时我们通过给定的起始时间点将快照链分为两部分,分别是时间点之前和之后的部分。然后同步执行之前的快照链,再正常异步执行之后的快照链就可以做到从任意时间点开始播放的效果。
16 changes: 8 additions & 8 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,37 +302,37 @@ The replayer accepts options as its constructor's second parameter, and it has t
| unpackFn | - | refer to the [storage optimization recipe](./docs/recipes/optimize-storage.md) |
| logConfig | - | configuration of console output playback, refer to the [console recipe](./docs/recipes/console.md) |

#### Use rrweb-player
#### Use rrweb-playback-ui

Since rrweb's replayer only provides a basic UI, you can choose rrweb-replayer which is based on rrweb's public APIs but has a feature-rich replayer UI.

##### Installation

rrweb-player can also be included with `<script>`:
rrweb-playback-ui can also be included with `<script>`:

```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/style.css"
href="https://cdn.jsdelivr.net/npm/rrweb-playback-ui@latest/dist/style.css"
/>
<script src="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rrweb-playback-ui@latest/dist/index.js"></script>
```

Or installed by using NPM:

```shell
npm install --save rrweb-player
npm install --save rrweb-playback-ui
```

```js
import rrwebPlayer from 'rrweb-player';
import 'rrweb-player/dist/style.css';
import rrwebPlaybackUi from 'rrweb-playback-ui';
import 'rrweb-playback-ui/dist/style.css';
```

##### Usage

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body, // customizable root element
props: {
events,
Expand Down
20 changes: 10 additions & 10 deletions guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,39 +298,39 @@ replayer.pause(5000);
| unpackFn | - | 数据解压缩函数,详见[优化存储策略](./docs/recipes/optimize-storage.zh_CN.md) |
| logConfig | - | console logger 数据播放设置,详见[console 录制和播放](./docs/recipes/console.zh_CN.md) |

#### 使用 rrweb-player
#### 使用 rrweb-playback-ui

rrweb 自带的回放只提供所有的 JS API 以及最基本的 UI,如果需要功能更强的回放播放器 UI,可以使用 rrweb-player
rrweb 自带的回放只提供所有的 JS API 以及最基本的 UI,如果需要功能更强的回放播放器 UI,可以使用 rrweb-playback-ui

##### 安装

rrweb-player 同样可以使用 CDN 方式安装:
rrweb-playback-ui 同样可以使用 CDN 方式安装:

```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/style.css"
href="https://cdn.jsdelivr.net/npm/rrweb-playback-ui@latest/dist/style.css"
/>
<script src="https://cdn.jsdelivr.net/npm/rrweb-player@latest/dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rrweb-playback-ui@latest/dist/index.js"></script>
```

或者通过 npm 安装:

```shell
npm install --save rrweb-player
npm install --save rrweb-playback-ui
```

```js
import rrwebPlayer from 'rrweb-player';
import 'rrweb-player/dist/style.css';
import rrwebPlaybackUi from 'rrweb-playback-ui';
import 'rrweb-playback-ui/dist/style.css';
```

##### 使用

通过 props 传入 events 数据及配置项

```js
new rrwebPlayer({
new rrwebPlaybackUi({
target: document.body, // 可以自定义 DOM 元素
// 配置项
props: {
Expand Down Expand Up @@ -382,7 +382,7 @@ replayer.on(EVENT_NAME, (payload) => {
| event-cast | 回放 event | event |
| custom-event | 回放自定义事件 | event |

使用 `rrweb-player` 时,也可以通过 `addEventListener` API 使用相同的事件功能,并且会获得 3 个额外的事件:
使用 `rrweb-playback-ui` 时,也可以通过 `addEventListener` API 使用相同的事件功能,并且会获得 3 个额外的事件:

| 事件类型 | 描述 | 值 |
| ---------------------- | -------------- | ----------- |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"workspaces": [
"packages/rrweb",
"packages/rrweb-snapshot",
"packages/rrweb-player"
"packages/rrweb-playback-ui"
]
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rrweb-player",
"name": "rrweb-playback-ui",
"version": "0.7.4",
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.0",
Expand Down
Loading