@zenflux/react-commander 0.0.15 → 0.0.16
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 +2 -2
- package/src/_internal/core.ts +6 -3
- package/src/command-base.ts +3 -5
- package/src/query/query-router.ts +0 -2
- package/src/vite-env.d.ts +6 -0
- package/src/with-commands.tsx +1 -1
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.16",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"types": "src/index.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@zenflux/core": "0.1.
|
|
51
|
+
"@zenflux/core": "0.1.32",
|
|
52
52
|
"eventemitter3": "^5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
package/src/_internal/core.ts
CHANGED
|
@@ -203,8 +203,7 @@ class Core implements DCoreInterface {
|
|
|
203
203
|
return -1; // Symbol not found
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
public __devDebug( ... args: any[] ): void {
|
|
206
|
+
public __devDebug( ... _args: any[] ): void {
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
declare public __devGetContextLength: () => number;
|
|
@@ -229,7 +228,11 @@ const core = getOrCreateCore();
|
|
|
229
228
|
if ( /* from vite */ import.meta.env.DEV ) {
|
|
230
229
|
if ( DEBUG_ENABLED ) {
|
|
231
230
|
core.__devDebug = ( ... args: Parameters<DCoreInterface[ "__devDebug" ]> ) => {
|
|
232
|
-
|
|
231
|
+
// Spread into `debug( caller, message, ...params )`, whose message is not optional:
|
|
232
|
+
// the first argument was already filling it, and now says so.
|
|
233
|
+
const [ message = "", ... params ] = args;
|
|
234
|
+
|
|
235
|
+
logger.debug( core.__devDebug, String( message ), ... params );
|
|
233
236
|
};
|
|
234
237
|
}
|
|
235
238
|
|
package/src/command-base.ts
CHANGED
|
@@ -43,7 +43,7 @@ export abstract class CommandBase<TState = React.ComponentState, TArgs = DComman
|
|
|
43
43
|
* React-commander creates command instances during registration (not per-execution),
|
|
44
44
|
* so we pass empty args/options to core's CommandBase constructor.
|
|
45
45
|
*/
|
|
46
|
-
public constructor(
|
|
46
|
+
public constructor( _registerArgs: DCommandRegisterArgs ) {
|
|
47
47
|
super( {}, {} );
|
|
48
48
|
|
|
49
49
|
this.commandName = ( new.target as typeof CommandBase ).getName();
|
|
@@ -97,16 +97,14 @@ export abstract class CommandBase<TState = React.ComponentState, TArgs = DComman
|
|
|
97
97
|
return result;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
protected validateArgs?( args: TArgs, options?: DCommandOptions<TState> ) {
|
|
100
|
+
protected validateArgs?( _args: TArgs, _options?: DCommandOptions<TState> ) {
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
/**
|
|
105
104
|
* Override core's `apply()` (which throws `ForceMethodImplementation`) to be
|
|
106
105
|
* optional — react-commander commands may or may not implement apply.
|
|
107
106
|
*/
|
|
108
|
-
|
|
109
|
-
protected apply( args?: any, _options?: any ): Promise<any> | any {
|
|
107
|
+
protected apply( _args?: any, _options?: any ): Promise<any> | any {
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
protected get state(): TState {
|
|
@@ -9,7 +9,6 @@ export abstract class QueryRouterBase<Resource, Model extends QueryModel = Query
|
|
|
9
9
|
protected readonly resource: string;
|
|
10
10
|
protected readonly model: Model;
|
|
11
11
|
|
|
12
|
-
private listCache?: Promise<Resource[]>;
|
|
13
12
|
private itemCache: Map<string, Promise<Resource>> = new Map();
|
|
14
13
|
|
|
15
14
|
public constructor( api: QueryClient, resource: string, model: Model ) {
|
|
@@ -67,7 +66,6 @@ export abstract class QueryRouterBase<Resource, Model extends QueryModel = Query
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
protected invalidate( key?: string ) {
|
|
70
|
-
this.listCache = undefined;
|
|
71
69
|
if ( key ) this.itemCache.delete( key );
|
|
72
70
|
}
|
|
73
71
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
// `import.meta.env` and `import.meta.hot` are vite's, and this package reads both - the dev only
|
|
4
|
+
// debug hooks in `_internal/core.ts` and the hot reload guard in `commands-manager.ts`. Declared
|
|
5
|
+
// here so the package typechecks on its own: a consumer that is a vite app already carries this
|
|
6
|
+
// reference, which is why it compiled there and not here.
|
package/src/with-commands.tsx
CHANGED
|
@@ -262,7 +262,7 @@ export function withCommands(
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
public componentDidUpdate( prevProps: any,
|
|
265
|
+
public componentDidUpdate( prevProps: any, _prevState: any, snapshot?: any ) {
|
|
266
266
|
if ( this.$$commander.lifecycleHandlers[ INTERNAL_ON_UPDATE ] ) {
|
|
267
267
|
const context = core[ GET_INTERNAL_SYMBOL ]( this.context.getNameUnique() );
|
|
268
268
|
|