Files
AFFiNE-Mirror/blocksuite/docs/api/@blocksuite/block-std/index/classes/CommandManager.md
renovate 883d5e6f33 chore: bump up all non-major dependencies (#11121)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@capgo/inappbrowser](https://redirect.github.com/Cap-go/capacitor-inappbrowser) | [`7.6.0` -> `7.6.4`](https://renovatebot.com/diffs/npm/@capgo%2finappbrowser/7.6.0/7.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@capgo%2finappbrowser/7.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@capgo%2finappbrowser/7.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@capgo%2finappbrowser/7.6.0/7.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@capgo%2finappbrowser/7.6.0/7.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@swc/core](https://swc.rs) ([source](https://redirect.github.com/swc-project/swc)) | [`1.11.11` -> `1.11.13`](https://renovatebot.com/diffs/npm/@swc%2fcore/1.11.11/1.11.13) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@swc%2fcore/1.11.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@swc%2fcore/1.11.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@swc%2fcore/1.11.11/1.11.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@swc%2fcore/1.11.11/1.11.13?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [bullmq](https://bullmq.io/) ([source](https://redirect.github.com/taskforcesh/bullmq)) | [`5.44.2` -> `5.44.3`](https://renovatebot.com/diffs/npm/bullmq/5.44.2/5.44.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/bullmq/5.44.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/bullmq/5.44.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/bullmq/5.44.2/5.44.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/bullmq/5.44.2/5.44.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [lib0](https://redirect.github.com/dmonad/lib0) | [`0.2.99` -> `0.2.100`](https://renovatebot.com/diffs/npm/lib0/0.2.99/0.2.100) | [![age](https://developer.mend.io/api/mc/badges/age/npm/lib0/0.2.100?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/lib0/0.2.100?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/lib0/0.2.99/0.2.100?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/lib0/0.2.99/0.2.100?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [typedoc-plugin-markdown](https://typedoc-plugin-markdown.org) ([source](https://redirect.github.com/typedoc2md/typedoc-plugin-markdown/tree/HEAD/packages/typedoc-plugin-markdown)) | [`4.5.2` -> `4.6.0`](https://renovatebot.com/diffs/npm/typedoc-plugin-markdown/4.5.2/4.6.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/typedoc-plugin-markdown/4.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typedoc-plugin-markdown/4.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typedoc-plugin-markdown/4.5.2/4.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typedoc-plugin-markdown/4.5.2/4.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Cap-go/capacitor-inappbrowser (@&#8203;capgo/inappbrowser)</summary>

### [`v7.6.4`](https://redirect.github.com/Cap-go/capacitor-inappbrowser/blob/HEAD/CHANGELOG.md#764-2025-03-24)

[Compare Source](https://redirect.github.com/Cap-go/capacitor-inappbrowser/compare/7.6.3...7.6.4)

### [`v7.6.3`](https://redirect.github.com/Cap-go/capacitor-inappbrowser/blob/HEAD/CHANGELOG.md#763-2025-03-23)

[Compare Source](https://redirect.github.com/Cap-go/capacitor-inappbrowser/compare/7.6.2...7.6.3)

### [`v7.6.2`](https://redirect.github.com/Cap-go/capacitor-inappbrowser/blob/HEAD/CHANGELOG.md#762-2025-03-23)

[Compare Source](https://redirect.github.com/Cap-go/capacitor-inappbrowser/compare/7.6.1...7.6.2)

### [`v7.6.1`](https://redirect.github.com/Cap-go/capacitor-inappbrowser/blob/HEAD/CHANGELOG.md#761-2025-03-23)

[Compare Source](https://redirect.github.com/Cap-go/capacitor-inappbrowser/compare/7.6.0...7.6.1)

</details>

<details>
<summary>swc-project/swc (@&#8203;swc/core)</summary>

### [`v1.11.13`](https://redirect.github.com/swc-project/swc/blob/HEAD/CHANGELOG.md#11113---2025-03-24)

[Compare Source](https://redirect.github.com/swc-project/swc/compare/v1.11.12...v1.11.13)

##### Features

-   **(es/minifier)** Merge alt's cons with cons ([#&#8203;10256](https://redirect.github.com/swc-project/swc/issues/10256)) ([589bcd7](589bcd70c4))

-   **(swc_core)** Expose features of `swc_parallel` ([#&#8203;10258](https://redirect.github.com/swc-project/swc/issues/10258)) ([042f19f](042f19ff66))

##### Performance

-   **(es/minifier)** Merge `expr_simplifier` into pure optimizer ([#&#8203;10202](https://redirect.github.com/swc-project/swc/issues/10202)) ([9c9b0ba](9c9b0baaac))

### [`v1.11.12`](https://redirect.github.com/swc-project/swc/blob/HEAD/CHANGELOG.md#11112---2025-03-23)

[Compare Source](https://redirect.github.com/swc-project/swc/compare/v1.11.11...v1.11.12)

##### Bug Fixes

-   **(es/minifier)** Make `inline_globals` noop by default ([#&#8203;10231](https://redirect.github.com/swc-project/swc/issues/10231)) ([b192dc8](b192dc82e6))

-   **(es/minifier)** Fix access to `GLOBALS` in char freq compute ([#&#8203;10239](https://redirect.github.com/swc-project/swc/issues/10239)) ([6286663](6286663868))

-   **(es/parser)** Fix span of wrong `await` tokens ([#&#8203;10252](https://redirect.github.com/swc-project/swc/issues/10252)) ([5c28dc3](5c28dc3964))

-   **(es/types)** Fix broken types ([#&#8203;10224](https://redirect.github.com/swc-project/swc/issues/10224)) ([540bdf8](540bdf868d))

##### Documentation

-   **(es)** Improve documentation ([#&#8203;10247](https://redirect.github.com/swc-project/swc/issues/10247)) ([549e38d](549e38db9e))

##### Features

-   **(es/fast-lexer)** Enhance identifier handling with Unicode support ([#&#8203;10226](https://redirect.github.com/swc-project/swc/issues/10226)) ([482b63a](482b63a905))

-   **(es/minifier)** Invoke IIFE into block ([#&#8203;10220](https://redirect.github.com/swc-project/swc/issues/10220)) ([c9a6c23](c9a6c23787))

-   **(es/minifier)** Remove needless blocks ([#&#8203;10234](https://redirect.github.com/swc-project/swc/issues/10234)) ([0817970](08179702bf))

-   **(swc_parallel)** Introduce `rayon` mode ([#&#8203;10237](https://redirect.github.com/swc-project/swc/issues/10237)) ([3c2213c](3c2213c829))

-   **(ts/fast-strip)** Add start/end span information ([#&#8203;10251](https://redirect.github.com/swc-project/swc/issues/10251)) ([ab39a62](ab39a62528))

-   **(ts/fast-strip)** Improve error message snippet ([#&#8203;10253](https://redirect.github.com/swc-project/swc/issues/10253)) ([f4f426c](f4f426c9c9))

-   **(ts/fast-strip)** Remove line numbers ([#&#8203;10254](https://redirect.github.com/swc-project/swc/issues/10254)) ([40e216d](40e216db82))

##### Performance

-   **(es/minifier)** Merge `dead_branch_remover` into pure optimizer ([#&#8203;10201](https://redirect.github.com/swc-project/swc/issues/10201)) ([6841523](6841523977))

</details>

<details>
<summary>taskforcesh/bullmq (bullmq)</summary>

### [`v5.44.3`](https://redirect.github.com/taskforcesh/bullmq/releases/tag/v5.44.3)

[Compare Source](https://redirect.github.com/taskforcesh/bullmq/compare/v5.44.2...v5.44.3)

##### Bug Fixes

-   **flow:** only validate pending dependencies when moving to completed ([#&#8203;3164](https://redirect.github.com/taskforcesh/bullmq/issues/3164)) ([d3c397f](d3c397fa3f))

</details>

<details>
<summary>dmonad/lib0 (lib0)</summary>

### [`v0.2.100`](https://redirect.github.com/dmonad/lib0/releases/tag/v0.2.100)

[Compare Source](https://redirect.github.com/dmonad/lib0/compare/v0.2.99...v0.2.100)

-   \[testing] properly compare objects that don't have a constructor  [`a2433fc`](https://redirect.github.com/dmonad/lib0/commit/a2433fc)
-   \[sha256] docs  [`5ee9bf2`](https://redirect.github.com/dmonad/lib0/commit/5ee9bf2)
-   Merge pull request [#&#8203;96](https://redirect.github.com/dmonad/lib0/issues/96) from jthemphill/fix-condititons-spelling  [`08fe7d5`](https://redirect.github.com/dmonad/lib0/commit/08fe7d5)
-   Fix references to nonexistent files in package.json  [`2cb51c4`](https://redirect.github.com/dmonad/lib0/commit/2cb51c4)

***

</details>

<details>
<summary>typedoc2md/typedoc-plugin-markdown (typedoc-plugin-markdown)</summary>

### [`v4.6.0`](https://redirect.github.com/typedoc2md/typedoc-plugin-markdown/blob/HEAD/packages/typedoc-plugin-markdown/CHANGELOG.md#460-2025-03-23)

[Compare Source](https://redirect.github.com/typedoc2md/typedoc-plugin-markdown/compare/typedoc-plugin-markdown@4.5.2...typedoc-plugin-markdown@4.6.0)

This release continues the effort to further align to TypeDoc’s default theme, with improvements that make the plugin more consistent and predictable.

##### Architectural Changes

-   Introduced support for TypeDoc core routers. This allows output files to be generated in the same structure as the default HTML theme, while still using the plugin’s Markdown theme.
-   Exported routers to the public API, enabling customization by other plugins.

##### Structural Changes

-   Package readme's (when "entryPointStrategy" is "packages") are now merged with the package index page producing a single entrypoint for packages with an associated readme.
    This aligns with the default theme and improves navigation.
-   To support core routers, a "Hierarchy Summary" page has been introduced to all routers. This feature is turned off by default but can be enabled by setting "includeHierarchySummary" to "true".
-   When "includeHierarchySummary" is "true", symbols with an available hierarchy now include an associated "Hierarchy" Markdown heading with a "View Summary" link as per the default theme.
-   Class constructor headings now read "Constructor". This aligns to the TypeDoc internal reflection name and fixes issues with internal anchoring not resolving correctly.

##### Minor Changes

-   Implemented support for consuming TypeDoc core routers.
-   Exported routers to public api.
-   Implemented a hierarchy summary page as per default theme.
-   Updated "Constructor" titles of classes to fix internal anchor issues.

##### Patch Changes

-   Fix incompatibility when used with "outputs" ([#&#8203;788](https://redirect.github.com/typedoc2md/typedoc-plugin-markdown/issues/788)).
-   Utilize "anchorPrefix" option to ensure unique anchors linking if required ([#&#8203;764](https://redirect.github.com/typedoc2md/typedoc-plugin-markdown/issues/764)).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIwNy4xIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
2025-03-24 07:19:44 +00:00

3.8 KiB

BlockSuite API Documentation


BlockSuite API Documentation / @blocksuite/block-std / index / CommandManager

Class: CommandManager

Command manager to manage all commands

Commands are functions that take a context and a next function as arguments

const myCommand: Command<input, output> = (ctx, next) => {
 const count = ctx.count || 0;

 const success = someOperation();
 if (success) {
   return next({ count: count + 1 });
 }
 // if the command is not successful, you can return without calling next
 return;

Command input and output data can be defined in the Command type

// input: ctx.firstName, ctx.lastName
// output: ctx.fullName
const myCommand: Command<{ firstName: string; lastName: string }, { fullName: string }> = (ctx, next) => {
  const { firstName, lastName } = ctx;
  const fullName = `${firstName} ${lastName}`;
  return next({ fullName });
}


Commands can be run in two ways:

  1. Using exec method exec is used to run a single command
const [result, data] = commandManager.exec(myCommand, payload);
  1. Using chain method chain is used to run a series of commands
const chain = commandManager.chain();
const [result, data] = chain
  .pipe(myCommand1)
  .pipe(myCommand2, payload)
  .run();

Command chains will stop running if a command is not successful

const chain = commandManager.chain();
const [result, data] = chain
  .chain(myCommand1) <-- if this fail
  .chain(myCommand2, payload) <- this won't run
  .run();

result <- result will be `false`

You can use try to run a series of commands and if one of them is successful, it will continue to the next command

const chain = commandManager.chain();
const [result, data] = chain
  .try(chain => [
    chain.pipe(myCommand1), <- if this fail
    chain.pipe(myCommand2, payload), <- this will run, if this success
    chain.pipe(myCommand3), <- this won't run
  ])
  .run();

The tryAll method is similar to try, but it will run all commands even if one of them is successful

const chain = commandManager.chain();
const [result, data] = chain
  .try(chain => [
    chain.pipe(myCommand1), <- if this success
    chain.pipe(myCommand2), <- this will also run
    chain.pipe(myCommand3), <- so will this
  ])
  .run();

Extends

Methods

chain()

chain(): Chain<InitCommandCtx>

Create a chain to run a series of commands

const chain = commandManager.chain();
const [result, data] = chain
  .myCommand1()
  .myCommand2(payload)
  .run();

Returns

Chain<InitCommandCtx>

[success, data] - success is a boolean to indicate if the chain is successful, data is the final context after running the chain


created()

created(): void

Called when std is created.

Returns

void

Inherited from

LifeCycleWatcher.created


mounted()

mounted(): void

Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.

Returns

void

Inherited from

LifeCycleWatcher.mounted


rendered()

rendered(): void

Called when std.render is called.

Returns

void

Inherited from

LifeCycleWatcher.rendered


unmounted()

unmounted(): void

Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.

Returns

void

Inherited from

LifeCycleWatcher.unmounted