goblin-laboratory 4.9.1 → 4.10.1
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/lib/termux.js
CHANGED
|
@@ -330,6 +330,9 @@ class Termux extends Elf.Alone {
|
|
|
330
330
|
for (const item of items) {
|
|
331
331
|
if (item in desc) {
|
|
332
332
|
desc = desc[item];
|
|
333
|
+
if (!desc) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
333
336
|
if (!Array.isArray(desc)) {
|
|
334
337
|
cmds = Object.keys(desc);
|
|
335
338
|
continue;
|
|
@@ -488,6 +491,21 @@ class Termux extends Elf.Alone {
|
|
|
488
491
|
return output;
|
|
489
492
|
}
|
|
490
493
|
|
|
494
|
+
async malloctrim$tool(horde) {
|
|
495
|
+
const {topology} = require('xcraft-core-etc')().load('xcraft-core-horde');
|
|
496
|
+
const _xcraftRPC = topology?.[horde]?.passive;
|
|
497
|
+
|
|
498
|
+
/* FIXME: must be moved on the server side */
|
|
499
|
+
if (_xcraftRPC && this.user.rank !== 'admin') {
|
|
500
|
+
throw new Error('Forbidden');
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const output = await this.quest.cmd(`bus.${horde}.malloctrim`, {
|
|
504
|
+
_xcraftRPC,
|
|
505
|
+
});
|
|
506
|
+
return output;
|
|
507
|
+
}
|
|
508
|
+
|
|
491
509
|
async $tool(tool) {
|
|
492
510
|
if (tool === 'man') {
|
|
493
511
|
return {
|
|
@@ -532,6 +550,16 @@ class Termux extends Elf.Alone {
|
|
|
532
550
|
return autocomp;
|
|
533
551
|
}, {});
|
|
534
552
|
}
|
|
553
|
+
if (tool === 'malloctrim') {
|
|
554
|
+
const {resp} = this.quest;
|
|
555
|
+
const registry = resp.getCommandsRegistry();
|
|
556
|
+
return Object.keys(registry)
|
|
557
|
+
.filter((cmd) => /^bus[.][^.]+[.]malloctrim$/.test(cmd))
|
|
558
|
+
.reduce((autocomp, cmd) => {
|
|
559
|
+
autocomp[cmd.split('.')[1]] = null;
|
|
560
|
+
return autocomp;
|
|
561
|
+
}, {});
|
|
562
|
+
}
|
|
535
563
|
return {};
|
|
536
564
|
}
|
|
537
565
|
|
package/package.json
CHANGED
|
@@ -77,7 +77,7 @@ export default function withC(Component, dispatchProps = {}, {modelProp} = {}) {
|
|
|
77
77
|
// It applies "inFunc" to the connected props and
|
|
78
78
|
// prevents giving internal props (starting with "_") to the underlying component
|
|
79
79
|
const ConnectedPropsMapper = (props) => {
|
|
80
|
-
let {_connectedProps, _connectedProp, ...otherProps} = props;
|
|
80
|
+
let {_connectedProps, _connectedProp, _model, ...otherProps} = props;
|
|
81
81
|
const newProps = {};
|
|
82
82
|
for (const prop of _connectedProps) {
|
|
83
83
|
const inFunc = prop.inFunc;
|
|
@@ -158,7 +158,7 @@ export default function withC(Component, dispatchProps = {}, {modelProp} = {}) {
|
|
|
158
158
|
if (path === null || path === undefined) {
|
|
159
159
|
return null;
|
|
160
160
|
}
|
|
161
|
-
const model = this.props.
|
|
161
|
+
const model = this.props._model || this.context.model;
|
|
162
162
|
return joinModels(model, path);
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -246,7 +246,8 @@ export default function withC(Component, dispatchProps = {}, {modelProp} = {}) {
|
|
|
246
246
|
|
|
247
247
|
// Render function used when there is no connected prop
|
|
248
248
|
renderNotConnected() {
|
|
249
|
-
|
|
249
|
+
const {_model, ...props} = this.props;
|
|
250
|
+
return <Component {...props} />;
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
render() {
|
|
@@ -276,7 +277,7 @@ export default function withC(Component, dispatchProps = {}, {modelProp} = {}) {
|
|
|
276
277
|
|
|
277
278
|
return (props) => (
|
|
278
279
|
<ModelContext.Consumer>
|
|
279
|
-
{(model) => <WithC
|
|
280
|
+
{(model) => <WithC _model={model} {...props} />}
|
|
280
281
|
</ModelContext.Consumer>
|
|
281
282
|
);
|
|
282
283
|
}
|
package/widgets/renderer.js
CHANGED
package/widgets/store/store.js
CHANGED
|
@@ -36,5 +36,18 @@ export default function configureStore(initialState, history, send) {
|
|
|
36
36
|
store.replaceReducer(nextRootReducer);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
const subscribe = store.subscribe.bind(store);
|
|
41
|
+
store.subscribe = (listener) => {
|
|
42
|
+
let previousState = undefined;
|
|
43
|
+
return subscribe(() => {
|
|
44
|
+
const state = store.getState();
|
|
45
|
+
if (state !== previousState) {
|
|
46
|
+
previousState = state;
|
|
47
|
+
listener();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
39
52
|
return store;
|
|
40
53
|
}
|
package/widgets/widget/index.js
CHANGED
|
@@ -29,6 +29,8 @@ const throttle250 = _.throttle((fct) => fct(), 250);
|
|
|
29
29
|
// }
|
|
30
30
|
|
|
31
31
|
class Widget extends React.Component {
|
|
32
|
+
static #nameCache = new Map();
|
|
33
|
+
|
|
32
34
|
constructor() {
|
|
33
35
|
super(...arguments);
|
|
34
36
|
this._names = this._getInheritedNames();
|
|
@@ -44,7 +46,14 @@ class Widget extends React.Component {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
static getWidgetName(constructorName) {
|
|
47
|
-
|
|
49
|
+
if (this.#nameCache.has(constructorName)) {
|
|
50
|
+
return this.#nameCache.get(constructorName);
|
|
51
|
+
}
|
|
52
|
+
const name = constructorName
|
|
53
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
54
|
+
.toLowerCase();
|
|
55
|
+
this.#nameCache.set(constructorName, name);
|
|
56
|
+
return name;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
_getInheritedNames() {
|
|
@@ -305,7 +314,8 @@ class Widget extends React.Component {
|
|
|
305
314
|
}
|
|
306
315
|
/** @deprecated Replace by doFor.
|
|
307
316
|
* It's possible to have a mismatch between service name and serviceId.
|
|
308
|
-
* Prefer to use doFor with the service id.
|
|
317
|
+
* Prefer to use doFor with the service id.
|
|
318
|
+
*/
|
|
309
319
|
doAs(service, action, args) {
|
|
310
320
|
const id = this.props.id || this.context.id;
|
|
311
321
|
if (!id) {
|
|
@@ -5,15 +5,28 @@ import Shredder from 'xcraft-core-shredder';
|
|
|
5
5
|
import shallowEqualShredder from './shallowEqualShredder';
|
|
6
6
|
import wrapMapStateToProps from './wrapMapStateToProps';
|
|
7
7
|
|
|
8
|
+
let lastState = null;
|
|
9
|
+
let lastShredder = null;
|
|
10
|
+
|
|
11
|
+
function stateToShredder(state) {
|
|
12
|
+
if (state === lastState) {
|
|
13
|
+
return lastShredder;
|
|
14
|
+
}
|
|
15
|
+
const s = new Shredder({
|
|
16
|
+
backend: state.backend,
|
|
17
|
+
widgets: state.widgets,
|
|
18
|
+
network: state.network,
|
|
19
|
+
});
|
|
20
|
+
lastState = state;
|
|
21
|
+
lastShredder = s;
|
|
22
|
+
return s;
|
|
23
|
+
}
|
|
24
|
+
|
|
8
25
|
function withShredder(mapStateToProps) {
|
|
9
26
|
mapStateToProps = wrapMapStateToProps(mapStateToProps);
|
|
10
27
|
|
|
11
28
|
const mapStateToPropsWithOwnProps = (state, ownProps) => {
|
|
12
|
-
const s =
|
|
13
|
-
backend: state.backend,
|
|
14
|
-
widgets: state.widgets,
|
|
15
|
-
network: state.network,
|
|
16
|
-
});
|
|
29
|
+
const s = stateToShredder(state);
|
|
17
30
|
return mapStateToProps(s, ownProps);
|
|
18
31
|
};
|
|
19
32
|
|