Skip to content

Commit ad0d21a

Browse files
authored
Merge pull request #1280 from wumail/master
remove ids from extension
2 parents ac3a774 + a3fb1a8 commit ad0d21a

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

packages/extension/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
],
3434
"dependencies": {
3535
"@logicflow/core": "^1.2.11",
36-
"ids": "^1.0.0",
3736
"jest": "27.5.1",
3837
"lodash-es": "^4.17.21",
3938
"preact": "^10.4.8"

packages/extension/src/bpmn-adapter/bpmnIds.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1-
import Ids from 'ids';
1+
/* eslint-disable no-bitwise */
2+
class IDS {
3+
private _ids: Set<string>;
4+
constructor() {
5+
globalThis._ids = this;
6+
this._ids = new Set();
7+
}
8+
generateId() {
9+
const id = 'xxxxxxxx'.replace(/[x]/g, (c) => {
10+
const r = (Math.random() * 16) | 0;
11+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
12+
return v.toString(16);
13+
});
14+
return id;
15+
}
16+
next() {
17+
let id = this.generateId();
18+
while (this._ids.has(id)) {
19+
id = this.generateId();
20+
}
21+
this._ids.add(id);
22+
return id;
23+
}
24+
}
225

3-
const ids = new Ids([32, 32, 1]);
26+
const ids = globalThis?._ids || new IDS();
427

528
export function getBpmnId(): string {
629
return ids.next();

0 commit comments

Comments
 (0)