@zenflux/react-commander 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,8 +2,9 @@
2
2
  "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/package.json",
3
3
  "name": "@zenflux/react-commander",
4
4
  "author": "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)",
5
- "version": "0.0.5",
5
+ "version": "0.0.7",
6
6
  "type": "module",
7
+ "sideEffects": false,
7
8
  "types": "src/index.ts",
8
9
  "files": [
9
10
  "src"
@@ -347,7 +347,19 @@ class CommandsManager {
347
347
  }
348
348
  }
349
349
 
350
- export const commands = new CommandsManager();
350
+ const COMMANDS_MANAGER_KEY = Symbol.for( "@zenflux/react-commander/commands-manager" );
351
+
352
+ function getOrCreateCommandsManager(): CommandsManager {
353
+ const globalStore = globalThis as unknown as Record<symbol, CommandsManager>;
354
+
355
+ if ( ! globalStore[ COMMANDS_MANAGER_KEY ] ) {
356
+ globalStore[ COMMANDS_MANAGER_KEY ] = new CommandsManager();
357
+ }
358
+
359
+ return globalStore[ COMMANDS_MANAGER_KEY ];
360
+ }
361
+
362
+ export const commands = getOrCreateCommandsManager();
351
363
 
352
364
  if ( import.meta.env.DEV ) {
353
365
  ( window as any ).$$commands = commands;