@jupyterlab/settingregistry 4.7.0-alpha.0 → 4.7.0-alpha.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/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/settingconnector.d.ts +30 -0
- package/lib/settingconnector.js +52 -0
- package/lib/settingconnector.js.map +1 -0
- package/package.json +10 -8
- package/src/index.ts +1 -0
- package/src/settingconnector.ts +74 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IDataConnector } from '@jupyterlab/statedb';
|
|
2
|
+
import { DataConnector } from '@jupyterlab/statedb';
|
|
3
|
+
import type { ISettingConnector, ISettingRegistry } from './tokens';
|
|
4
|
+
/**
|
|
5
|
+
* A data connector for fetching settings.
|
|
6
|
+
*
|
|
7
|
+
* #### Notes
|
|
8
|
+
* This connector adds a query parameter to the base services setting manager.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SettingConnector extends DataConnector<ISettingRegistry.IPlugin, string> implements ISettingConnector {
|
|
11
|
+
constructor(connector: IDataConnector<ISettingRegistry.IPlugin, string>);
|
|
12
|
+
/**
|
|
13
|
+
* Fetch settings for a plugin.
|
|
14
|
+
* @param id - The plugin ID
|
|
15
|
+
*
|
|
16
|
+
* #### Notes
|
|
17
|
+
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
18
|
+
*/
|
|
19
|
+
fetch(id: string): Promise<ISettingRegistry.IPlugin | undefined>;
|
|
20
|
+
list(query: 'ids'): Promise<{
|
|
21
|
+
ids: string[];
|
|
22
|
+
}>;
|
|
23
|
+
list(query: 'active' | 'all'): Promise<{
|
|
24
|
+
ids: string[];
|
|
25
|
+
values: ISettingRegistry.IPlugin[];
|
|
26
|
+
}>;
|
|
27
|
+
save(id: string, raw: string): Promise<void>;
|
|
28
|
+
private _connector;
|
|
29
|
+
private _throttlers;
|
|
30
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
6
|
+
import { DataConnector } from '@jupyterlab/statedb';
|
|
7
|
+
import { Throttler } from '@lumino/polling';
|
|
8
|
+
/**
|
|
9
|
+
* A data connector for fetching settings.
|
|
10
|
+
*
|
|
11
|
+
* #### Notes
|
|
12
|
+
* This connector adds a query parameter to the base services setting manager.
|
|
13
|
+
*/
|
|
14
|
+
export class SettingConnector extends DataConnector {
|
|
15
|
+
constructor(connector) {
|
|
16
|
+
super();
|
|
17
|
+
this._throttlers = Object.create(null);
|
|
18
|
+
this._connector = connector;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetch settings for a plugin.
|
|
22
|
+
* @param id - The plugin ID
|
|
23
|
+
*
|
|
24
|
+
* #### Notes
|
|
25
|
+
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
26
|
+
*/
|
|
27
|
+
fetch(id) {
|
|
28
|
+
const throttlers = this._throttlers;
|
|
29
|
+
if (!(id in throttlers)) {
|
|
30
|
+
throttlers[id] = new Throttler(() => this._connector.fetch(id), 100);
|
|
31
|
+
}
|
|
32
|
+
return throttlers[id].invoke();
|
|
33
|
+
}
|
|
34
|
+
async list(query = 'all') {
|
|
35
|
+
const { isDisabled } = PageConfig.Extension;
|
|
36
|
+
const { ids, values } = await this._connector.list(query === 'ids' ? 'ids' : undefined);
|
|
37
|
+
if (query === 'all') {
|
|
38
|
+
return { ids, values };
|
|
39
|
+
}
|
|
40
|
+
if (query === 'ids') {
|
|
41
|
+
return { ids };
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
ids: ids.filter(id => !isDisabled(id)),
|
|
45
|
+
values: values.filter(({ id }) => !isDisabled(id))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async save(id, raw) {
|
|
49
|
+
await this._connector.save(id, raw);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=settingconnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingconnector.js","sourceRoot":"","sources":["../src/settingconnector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;GAKG;AACH,MAAM,OAAO,gBACX,SAAQ,aAA+C;IAGvD,YAAY,SAA2D;QACrE,KAAK,EAAE,CAAC;QAkDF,gBAAW,GAAiC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAjDtE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,EAAU;QACd,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,CAAC,EAAE,IAAI,UAAU,CAAC,EAAE,CAAC;YACxB,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAMD,KAAK,CAAC,IAAI,CACR,QAAkC,KAAK;QAEvC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC;QAC5C,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAChD,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CACpC,CAAC;QAEF,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACpB,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACzB,CAAC;QAED,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACpB,OAAO,EAAE,GAAG,EAAE,CAAC;QACjB,CAAC;QAED,OAAO;YACL,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACtC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;SACnD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU,EAAE,GAAW;QAChC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CAIF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/settingregistry",
|
|
3
|
-
"version": "4.7.0-alpha.
|
|
3
|
+
"version": "4.7.0-alpha.1",
|
|
4
4
|
"description": "Settings registry for Jupyterlab",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -36,18 +36,20 @@
|
|
|
36
36
|
"watch": "tsc -b --watch"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@jupyterlab/
|
|
40
|
-
"@jupyterlab/
|
|
41
|
-
"@
|
|
42
|
-
"@lumino/
|
|
43
|
-
"@lumino/
|
|
44
|
-
"@lumino/
|
|
39
|
+
"@jupyterlab/coreutils": "^6.7.0-alpha.1",
|
|
40
|
+
"@jupyterlab/nbformat": "^4.7.0-alpha.1",
|
|
41
|
+
"@jupyterlab/statedb": "^4.7.0-alpha.1",
|
|
42
|
+
"@lumino/commands": "^2.3.4",
|
|
43
|
+
"@lumino/coreutils": "^2.2.3",
|
|
44
|
+
"@lumino/disposable": "^2.1.6",
|
|
45
|
+
"@lumino/polling": "^2.1.6",
|
|
46
|
+
"@lumino/signaling": "^2.1.6",
|
|
45
47
|
"@rjsf/utils": "^5.13.4",
|
|
46
48
|
"ajv": "^8.12.0",
|
|
47
49
|
"json5": "^2.2.3"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@jupyterlab/testing": "^4.7.0-alpha.
|
|
52
|
+
"@jupyterlab/testing": "^4.7.0-alpha.1",
|
|
51
53
|
"@types/jest": "^29.2.0",
|
|
52
54
|
"jest": "^29.2.0",
|
|
53
55
|
"rimraf": "~5.0.5",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
7
|
+
import type { IDataConnector } from '@jupyterlab/statedb';
|
|
8
|
+
import { DataConnector } from '@jupyterlab/statedb';
|
|
9
|
+
import { Throttler } from '@lumino/polling';
|
|
10
|
+
import type { ISettingConnector, ISettingRegistry } from './tokens';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A data connector for fetching settings.
|
|
14
|
+
*
|
|
15
|
+
* #### Notes
|
|
16
|
+
* This connector adds a query parameter to the base services setting manager.
|
|
17
|
+
*/
|
|
18
|
+
export class SettingConnector
|
|
19
|
+
extends DataConnector<ISettingRegistry.IPlugin, string>
|
|
20
|
+
implements ISettingConnector
|
|
21
|
+
{
|
|
22
|
+
constructor(connector: IDataConnector<ISettingRegistry.IPlugin, string>) {
|
|
23
|
+
super();
|
|
24
|
+
this._connector = connector;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Fetch settings for a plugin.
|
|
29
|
+
* @param id - The plugin ID
|
|
30
|
+
*
|
|
31
|
+
* #### Notes
|
|
32
|
+
* The REST API requests are throttled at one request per plugin per 100ms.
|
|
33
|
+
*/
|
|
34
|
+
fetch(id: string): Promise<ISettingRegistry.IPlugin | undefined> {
|
|
35
|
+
const throttlers = this._throttlers;
|
|
36
|
+
if (!(id in throttlers)) {
|
|
37
|
+
throttlers[id] = new Throttler(() => this._connector.fetch(id), 100);
|
|
38
|
+
}
|
|
39
|
+
return throttlers[id].invoke();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async list(query: 'ids'): Promise<{ ids: string[] }>;
|
|
43
|
+
async list(
|
|
44
|
+
query: 'active' | 'all'
|
|
45
|
+
): Promise<{ ids: string[]; values: ISettingRegistry.IPlugin[] }>;
|
|
46
|
+
async list(
|
|
47
|
+
query: 'active' | 'all' | 'ids' = 'all'
|
|
48
|
+
): Promise<{ ids: string[]; values?: ISettingRegistry.IPlugin[] }> {
|
|
49
|
+
const { isDisabled } = PageConfig.Extension;
|
|
50
|
+
const { ids, values } = await this._connector.list(
|
|
51
|
+
query === 'ids' ? 'ids' : undefined
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (query === 'all') {
|
|
55
|
+
return { ids, values };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (query === 'ids') {
|
|
59
|
+
return { ids };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
ids: ids.filter(id => !isDisabled(id)),
|
|
64
|
+
values: values.filter(({ id }) => !isDisabled(id))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async save(id: string, raw: string): Promise<void> {
|
|
69
|
+
await this._connector.save(id, raw);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private _connector: IDataConnector<ISettingRegistry.IPlugin, string>;
|
|
73
|
+
private _throttlers: { [key: string]: Throttler } = Object.create(null);
|
|
74
|
+
}
|