File tree Expand file tree Collapse file tree 8 files changed +19
-25
lines changed Expand file tree Collapse file tree 8 files changed +19
-25
lines changed Original file line number Diff line number Diff line change 3939 "@types/react" : " ^17.0.5" ,
4040 "debounce" : " ^1.2.0" ,
4141 "lodash" : " ^4.17.20" ,
42- "shortid" : " ^2.2.15" ,
4342 "tiny-invariant" : " ^1.0.6"
4443 },
4544 "devDependencies" : {
Original file line number Diff line number Diff line change 1+ import { getRandomId as getRandomNodeId } from '@craftjs/utils' ;
12import React from 'react' ;
23
3- import { getRandomNodeId } from './getRandomNodeId' ;
4-
54import { Node , FreshNode , UserComponentConfig } from '../interfaces' ;
65import {
76 defaultElementProps ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1717 "@types/react" : " ^17.0.5" ,
1818 "immer" : " ^8.0.1" ,
1919 "lodash" : " ^4.17.20" ,
20+ "nanoid" : " ^3.1.23" ,
2021 "shallowequal" : " ^1.1.0" ,
2122 "tiny-invariant" : " ^1.0.6"
2223 },
Original file line number Diff line number Diff line change 11import isEqual from 'shallowequal' ;
2- import shortid from 'shortid' ;
32
43import { Connector } from './interfaces' ;
54
5+ import { getRandomId } from '../getRandomId' ;
6+
67type ConnectorToRegister = {
78 name : string ;
89 required : any ;
@@ -30,7 +31,7 @@ export class ConnectorRegistry {
3031 return existingId ;
3132 }
3233
33- const newId = shortid ( ) ;
34+ const newId = getRandomId ( ) ;
3435 this . elementIdMap . set ( element , newId ) ;
3536 return newId ;
3637 }
Original file line number Diff line number Diff line change 1+ import { nanoid } from 'nanoid' ;
2+
3+ // By default nanoid generate an ID with 21 characters. To reduce the footprint, we default to 10 characters.
4+ // We have a higher probability for collisions, though
5+
6+ /**
7+ * Generate a random ID. That ID can for example be used as a node ID.
8+ *
9+ * @param size The number of characters that are generated for the ID. Defaults to `10`
10+ * @returns A random id
11+ */
12+ export const getRandomId = ( size : number = 10 ) => nanoid ( size ) ;
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ export * from './useEffectOnce';
88export * from './deprecate' ;
99export * from './utilityTypes' ;
1010export * from './History' ;
11+ export * from './getRandomId' ;
Original file line number Diff line number Diff line change @@ -3016,7 +3016,6 @@ __metadata:
30163016 debounce: ^1.2.0
30173017 lodash: ^4.17.20
30183018 react: ^17.0.2
3019- shortid: ^2.2.15
30203019 tiny-invariant: ^1.0.6
30213020 peerDependencies:
30223021 react: ^16.8.0
@@ -3044,6 +3043,7 @@ __metadata:
30443043 "@types/react": ^17.0.5
30453044 immer: ^8.0.1
30463045 lodash: ^4.17.20
3046+ nanoid: ^3.1.23
30473047 shallowequal: ^1.1.0
30483048 tiny-invariant: ^1.0.6
30493049 peerDependencies:
@@ -17605,13 +17605,6 @@ fsevents@~2.3.1:
1760517605 languageName: node
1760617606 linkType: hard
1760717607
17608- "nanoid@npm:^2.1.0":
17609- version: 2.1.6
17610- resolution: "nanoid@npm:2.1.6"
17611- checksum: b34d842ce85feeacd12275dc79728802e8b08f1466b66d00cf46f0883fcf9e40caceb504ea9f67c6921c0246a063f62c29ccd76a32bc7472cc699480a4831358
17612- languageName: node
17613- linkType: hard
17614-
1761517608"nanoid@npm:^3.1.22, nanoid@npm:^3.1.23":
1761617609 version: 3.1.23
1761717610 resolution: "nanoid@npm:3.1.23"
@@ -23419,15 +23412,6 @@ resolve@^1.17.0:
2341923412 languageName: node
2342023413 linkType: hard
2342123414
23422- "shortid@npm:^2.2.15":
23423- version: 2.2.15
23424- resolution: "shortid@npm:2.2.15"
23425- dependencies:
23426- nanoid: ^2.1.0
23427- checksum: 0b657c406153029ba5fe3df357115d31c53929b6e603cbd2ff2aae7ddc016290179dfaa49625a3abc8967df8d53d04bd2c07a617562c1057ace8558f67558235
23428- languageName: node
23429- linkType: hard
23430-
2343123415"signal-exit@npm:^3.0.0":
2343223416 version: 3.0.2
2343323417 resolution: "signal-exit@npm:3.0.2"
You can’t perform that action at this time.
0 commit comments