- Consolidated duplicate UndoManagers to single instance - Fixed connection promise to only resolve on 'connected' status - Fixed WebSocketProvider import (WebsocketProvider) - Added proper doc.destroy() cleanup - Renamed isPresenceInitialized property to avoid conflict Co-Authored-By: Paperclip <noreply@paperclip.ing>
40 lines
775 B
Plaintext
40 lines
775 B
Plaintext
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const genPrefix = '$$gen$';
|
|
|
|
export default class GenID {
|
|
genN: number = 0;
|
|
+used: Set<string> = new Set();
|
|
+prefix: string;
|
|
|
|
constructor(uniqueTransformPrefix: string) {
|
|
this.prefix = `${genPrefix}${uniqueTransformPrefix}`;
|
|
}
|
|
|
|
id(): string {
|
|
let name;
|
|
do {
|
|
name = `${this.prefix}${this.genN}`;
|
|
this.genN++;
|
|
} while (this.used.has(name));
|
|
this.used.add(name);
|
|
return name;
|
|
}
|
|
|
|
addUsage(name: string): void {
|
|
if (name.startsWith(this.prefix)) {
|
|
this.used.add(name);
|
|
}
|
|
}
|
|
}
|