@zenflux/react-commander 0.0.6 → 0.0.8
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,7 +2,7 @@
|
|
|
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
|
+
"version": "0.0.8",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"types": "src/index.ts",
|
package/src/_internal/core.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
UNREGISTER_INTERNAL_SYMBOL
|
|
8
8
|
} from "./constants";
|
|
9
9
|
|
|
10
|
+
import { version } from "../../package.json";
|
|
11
|
+
|
|
10
12
|
import type { DCoreContext, DCoreInterface, DCoreRegisterArgs } from "./definitions";
|
|
11
13
|
|
|
12
14
|
import type { DCommandSingleComponentContext } from "@zenflux/react-commander/definitions";
|
|
@@ -44,6 +46,8 @@ function setSortedContextKeys( keys: string[] ) {
|
|
|
44
46
|
* It provides methods to register, unregister, get and link components.
|
|
45
47
|
*/
|
|
46
48
|
class Core implements DCoreInterface {
|
|
49
|
+
public version = version;
|
|
50
|
+
|
|
47
51
|
/**
|
|
48
52
|
* Registers the context for a React component.
|
|
49
53
|
*/
|
package/src/commands-manager.ts
CHANGED
|
@@ -347,7 +347,19 @@ class CommandsManager {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
|
|
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;
|