Skip to content
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
10 changes: 5 additions & 5 deletions docs/config/setup/mermaid/interfaces/DetailedError.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@

# Interface: DetailedError

Defined in: [packages/mermaid/src/utils.ts:783](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L783)
Defined in: [packages/mermaid/src/utils.ts:803](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L803)

## Properties

### error?

> `optional` **error**: `any`

Defined in: [packages/mermaid/src/utils.ts:788](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L788)
Defined in: [packages/mermaid/src/utils.ts:808](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L808)

---

### hash

> **hash**: `any`

Defined in: [packages/mermaid/src/utils.ts:786](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L786)
Defined in: [packages/mermaid/src/utils.ts:806](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L806)

---

### message?

> `optional` **message**: `string`

Defined in: [packages/mermaid/src/utils.ts:789](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L789)
Defined in: [packages/mermaid/src/utils.ts:809](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L809)

---

### str

> **str**: `string`

Defined in: [packages/mermaid/src/utils.ts:784](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L784)
Defined in: [packages/mermaid/src/utils.ts:804](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L804)
28 changes: 24 additions & 4 deletions packages/mermaid/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,33 @@ export const calculateTextDimensions: (
export class InitIDGenerator {
private count = 0;
public next: () => number;

constructor(deterministic = false, seed?: string) {
// TODO: Seed is only used for length?
// v11: Use the actual value of seed string to generate an initial value for count.
this.count = seed ? seed.length : 0;
this.next = deterministic ? () => this.count++ : () => Date.now();
if (deterministic) {
// Keep backward-compatible behavior: initialize the counter from the seed length.
this.count = seed ? seed.length : 0;
this.next = () => this.count++;
} else {
// Non-deterministic: use a timestamp + per-ms nonce to avoid collisions
// when many calls happen in the same millisecond.
// We multiply timestamp by 1000 and add nonce, giving room for 1000
// calls in the same ms. This keeps the result numeric and monotonic.
let lastTs = 0;
let nonce = 0;
this.next = () => {
const now = Date.now();
if (now === lastTs) {
nonce++;
} else {
lastTs = now;
nonce = 0;
}
return now * 1000 + nonce;
};
}
}
}
// Please note that the function still returns a number (as before), so the rest of the code (which concatenates it into mermaid-<id>) keeps working.

let decoder: HTMLDivElement;

Expand Down
Loading