File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 33
33
],
34
34
"dependencies" : {
35
35
"@logicflow/core" : " ^1.2.11" ,
36
- "ids" : " ^1.0.0" ,
37
36
"jest" : " 27.5.1" ,
38
37
"lodash-es" : " ^4.17.21" ,
39
38
"preact" : " ^10.4.8"
Original file line number Diff line number Diff line change 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
+ }
2
25
3
- const ids = new Ids ( [ 32 , 32 , 1 ] ) ;
26
+ const ids = globalThis ?. _ids || new IDS ( ) ;
4
27
5
28
export function getBpmnId ( ) : string {
6
29
return ids . next ( ) ;
You can’t perform that action at this time.
0 commit comments