@jupyterlab/apputils 4.5.0-beta.0 → 4.5.0-beta.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/licenses.d.ts +334 -0
- package/lib/licenses.js +514 -0
- package/lib/licenses.js.map +1 -0
- package/lib/semanticCommand.d.ts +4 -0
- package/lib/semanticCommand.js +4 -0
- package/lib/semanticCommand.js.map +1 -1
- package/lib/tokens.d.ts +10 -0
- package/lib/tokens.js +4 -0
- package/lib/tokens.js.map +1 -1
- package/package.json +11 -11
- package/src/index.ts +1 -0
- package/src/licenses.tsx +777 -0
- package/src/semanticCommand.ts +5 -0
- package/src/tokens.ts +14 -0
- package/style/base.css +1 -0
- package/style/dialog.css +2 -0
- package/style/licenses.css +184 -0
package/lib/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './dialog';
|
|
|
17
17
|
export * from './domutils';
|
|
18
18
|
export * from './inputdialog';
|
|
19
19
|
export * from './kernelstatuses';
|
|
20
|
+
export * from './licenses';
|
|
20
21
|
export * from './mainareawidget';
|
|
21
22
|
export * from './menufactory';
|
|
22
23
|
export * from './notification';
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from './dialog';
|
|
|
18
18
|
export * from './domutils';
|
|
19
19
|
export * from './inputdialog';
|
|
20
20
|
export * from './kernelstatuses';
|
|
21
|
+
export * from './licenses';
|
|
21
22
|
export * from './mainareawidget';
|
|
22
23
|
export * from './menufactory';
|
|
23
24
|
export * from './notification';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AACH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEjE,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iB,OAAO;IACT,6BAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;IAC9D,4BAAoB,GAAG,eAAe,CAAC,oBAAoB,CAAC;IAC5D,8BAAsB,GAAG,eAAe,CAAC,sBAAsB,CAAC;IAChE,2BAAmB,GAAG,eAAe,CAAC,mBAAmB,CAAC;IACvE;;;OAGG;IACU,wBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAC;AAC7D,CAAC,EAVgB,OAAO,KAAP,OAAO,QAUvB"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
2
|
+
import { TranslationBundle } from '@jupyterlab/translation';
|
|
3
|
+
import { LabIcon, VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
|
|
4
|
+
import { ReadonlyJSONObject } from '@lumino/coreutils';
|
|
5
|
+
import { ISignal } from '@lumino/signaling';
|
|
6
|
+
import { VirtualElement } from '@lumino/virtualdom';
|
|
7
|
+
import { Panel, SplitPanel, TabBar, Widget } from '@lumino/widgets';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { ILicensesClient } from './tokens';
|
|
10
|
+
/**
|
|
11
|
+
* A license viewer
|
|
12
|
+
*/
|
|
13
|
+
export declare class Licenses extends SplitPanel {
|
|
14
|
+
readonly model: Licenses.Model;
|
|
15
|
+
constructor(options: Licenses.IOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Handle disposing of the widget
|
|
18
|
+
*/
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the left area for filters and bundles
|
|
22
|
+
*/
|
|
23
|
+
protected initLeftPanel(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the filters
|
|
26
|
+
*/
|
|
27
|
+
protected initFilters(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the listing of available bundles
|
|
30
|
+
*/
|
|
31
|
+
protected initBundles(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the listing of packages within the current bundle
|
|
34
|
+
*/
|
|
35
|
+
protected initGrid(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the full text of the current package
|
|
38
|
+
*/
|
|
39
|
+
protected initLicenseText(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Event handler for updating the model with the current bundle
|
|
42
|
+
*/
|
|
43
|
+
protected onBundleSelected(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Update the bundle tabs.
|
|
46
|
+
*/
|
|
47
|
+
protected _updateBundles(): void;
|
|
48
|
+
/**
|
|
49
|
+
* An area for selecting licenses by bundle and filters
|
|
50
|
+
*/
|
|
51
|
+
protected _leftPanel: Panel;
|
|
52
|
+
/**
|
|
53
|
+
* Filters on visible licenses
|
|
54
|
+
*/
|
|
55
|
+
protected _filters: Licenses.Filters;
|
|
56
|
+
/**
|
|
57
|
+
* Tabs reflecting available bundles
|
|
58
|
+
*/
|
|
59
|
+
protected _bundles: TabBar<Widget>;
|
|
60
|
+
/**
|
|
61
|
+
* A grid of the current bundle's packages' license metadata
|
|
62
|
+
*/
|
|
63
|
+
protected _grid: Licenses.Grid;
|
|
64
|
+
/**
|
|
65
|
+
* The currently-selected package's full license text
|
|
66
|
+
*/
|
|
67
|
+
protected _licenseText: Licenses.FullText;
|
|
68
|
+
}
|
|
69
|
+
/** A namespace for license components */
|
|
70
|
+
export declare namespace Licenses {
|
|
71
|
+
/** The information about a license report format */
|
|
72
|
+
interface IReportFormat {
|
|
73
|
+
title: string;
|
|
74
|
+
icon: LabIcon;
|
|
75
|
+
id: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* License report formats understood by the server (once lower-cased)
|
|
79
|
+
*/
|
|
80
|
+
const REPORT_FORMATS: Record<string, IReportFormat>;
|
|
81
|
+
/**
|
|
82
|
+
* The default format (most human-readable)
|
|
83
|
+
*/
|
|
84
|
+
const DEFAULT_FORMAT = "markdown";
|
|
85
|
+
/**
|
|
86
|
+
* Options for instantiating a license viewer
|
|
87
|
+
*/
|
|
88
|
+
interface IOptions {
|
|
89
|
+
model: Model;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Options for instantiating a license model
|
|
93
|
+
*/
|
|
94
|
+
interface IModelOptions extends ICreateArgs {
|
|
95
|
+
client: ILicensesClient;
|
|
96
|
+
trans: TranslationBundle;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A top-level report of the licenses for all code included in a bundle
|
|
100
|
+
*
|
|
101
|
+
* ### Note
|
|
102
|
+
*
|
|
103
|
+
* This is roughly informed by the terms defined in the SPDX spec, though is not
|
|
104
|
+
* an SPDX Document, since there seem to be several (incompatible) specs
|
|
105
|
+
* in that repo.
|
|
106
|
+
*
|
|
107
|
+
* @see https://github.com/spdx/spdx-spec/blob/development/v2.2.1/schemas/spdx-schema.json
|
|
108
|
+
**/
|
|
109
|
+
interface ILicenseBundle extends ReadonlyJSONObject {
|
|
110
|
+
packages: IPackageLicenseInfo[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A best-effort single bundled package's information.
|
|
114
|
+
*
|
|
115
|
+
* ### Note
|
|
116
|
+
*
|
|
117
|
+
* This is roughly informed by SPDX `packages` and `hasExtractedLicenseInfos`,
|
|
118
|
+
* as making it conformant would vastly complicate the structure.
|
|
119
|
+
*
|
|
120
|
+
* @see https://github.com/spdx/spdx-spec/blob/development/v2.2.1/schemas/spdx-schema.json
|
|
121
|
+
**/
|
|
122
|
+
interface IPackageLicenseInfo extends ReadonlyJSONObject {
|
|
123
|
+
/**
|
|
124
|
+
* the name of the package as it appears in package.json
|
|
125
|
+
*/
|
|
126
|
+
name: string;
|
|
127
|
+
/**
|
|
128
|
+
* the version of the package, or an empty string if unknown
|
|
129
|
+
*/
|
|
130
|
+
versionInfo: string;
|
|
131
|
+
/**
|
|
132
|
+
* an SPDX license identifier or LicenseRef, or an empty string if unknown
|
|
133
|
+
*/
|
|
134
|
+
licenseId: string;
|
|
135
|
+
/**
|
|
136
|
+
* the verbatim extracted text of the license, or an empty string if unknown
|
|
137
|
+
*/
|
|
138
|
+
extractedText: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The format information for a download
|
|
142
|
+
*/
|
|
143
|
+
interface IDownloadOptions {
|
|
144
|
+
format: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The fields which can be filtered
|
|
148
|
+
*/
|
|
149
|
+
type TFilterKey = 'name' | 'versionInfo' | 'licenseId';
|
|
150
|
+
interface ICreateArgs {
|
|
151
|
+
currentBundleName?: string | null;
|
|
152
|
+
packageFilter?: Partial<IPackageLicenseInfo> | null;
|
|
153
|
+
currentPackageIndex?: number | null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The options for a new license client.
|
|
157
|
+
*/
|
|
158
|
+
interface ILicenseClientOptions {
|
|
159
|
+
/**
|
|
160
|
+
* The URL for the licenses API
|
|
161
|
+
*/
|
|
162
|
+
licensesUrl?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The server settings
|
|
165
|
+
*/
|
|
166
|
+
serverSettings?: ServerConnection.ISettings;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The JSON response from the API
|
|
170
|
+
*/
|
|
171
|
+
interface ILicenseResponse {
|
|
172
|
+
bundles: {
|
|
173
|
+
[key: string]: Licenses.ILicenseBundle;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A class used for fetching licenses from the server.
|
|
178
|
+
*/
|
|
179
|
+
class LicensesClient implements ILicensesClient {
|
|
180
|
+
/**
|
|
181
|
+
* Create a new license client.
|
|
182
|
+
*/
|
|
183
|
+
constructor(options?: ILicenseClientOptions);
|
|
184
|
+
/**
|
|
185
|
+
* Get the link to download the licenses in a given format.
|
|
186
|
+
*/
|
|
187
|
+
getDownloadLink(options: IDownloadOptions): Promise<string>;
|
|
188
|
+
/**
|
|
189
|
+
* Fetch the license bundles from the server.
|
|
190
|
+
*/
|
|
191
|
+
getBundles(): Promise<ILicenseResponse>;
|
|
192
|
+
private _serverSettings;
|
|
193
|
+
private _licensesUrl;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* A model for license data
|
|
197
|
+
*/
|
|
198
|
+
class Model extends VDomModel implements ICreateArgs {
|
|
199
|
+
constructor(options: IModelOptions);
|
|
200
|
+
/**
|
|
201
|
+
* Handle the initial request for the licenses from the server.
|
|
202
|
+
*/
|
|
203
|
+
initLicenses(): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Create a temporary download link, and emulate clicking it to trigger a named
|
|
206
|
+
* file download.
|
|
207
|
+
*/
|
|
208
|
+
download(options: IDownloadOptions): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* A promise that resolves when the licenses from the server change
|
|
211
|
+
*/
|
|
212
|
+
get selectedPackageChanged(): ISignal<Model, void>;
|
|
213
|
+
/**
|
|
214
|
+
* A promise that resolves when the trackable data changes
|
|
215
|
+
*/
|
|
216
|
+
get trackerDataChanged(): ISignal<Model, void>;
|
|
217
|
+
/**
|
|
218
|
+
* The names of the license bundles available
|
|
219
|
+
*/
|
|
220
|
+
get bundleNames(): string[];
|
|
221
|
+
/**
|
|
222
|
+
* The current license bundle
|
|
223
|
+
*/
|
|
224
|
+
get currentBundleName(): string | null;
|
|
225
|
+
/**
|
|
226
|
+
* Set the current license bundle, and reset the selected index
|
|
227
|
+
*/
|
|
228
|
+
set currentBundleName(currentBundleName: string | null);
|
|
229
|
+
/**
|
|
230
|
+
* A promise that resolves when the licenses are available from the server
|
|
231
|
+
*/
|
|
232
|
+
get licensesReady(): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* All the license bundles, keyed by the distributing packages
|
|
235
|
+
*/
|
|
236
|
+
get bundles(): null | {
|
|
237
|
+
[key: string]: ILicenseBundle;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* The index of the currently-selected package within its license bundle
|
|
241
|
+
*/
|
|
242
|
+
get currentPackageIndex(): number | null;
|
|
243
|
+
/**
|
|
244
|
+
* Update the currently-selected package within its license bundle
|
|
245
|
+
*/
|
|
246
|
+
set currentPackageIndex(currentPackageIndex: number | null);
|
|
247
|
+
/**
|
|
248
|
+
* The license data for the currently-selected package
|
|
249
|
+
*/
|
|
250
|
+
get currentPackage(): IPackageLicenseInfo | null;
|
|
251
|
+
/**
|
|
252
|
+
* A translation bundle
|
|
253
|
+
*/
|
|
254
|
+
get trans(): TranslationBundle;
|
|
255
|
+
get title(): string;
|
|
256
|
+
/**
|
|
257
|
+
* The current package filter
|
|
258
|
+
*/
|
|
259
|
+
get packageFilter(): Partial<IPackageLicenseInfo>;
|
|
260
|
+
set packageFilter(packageFilter: Partial<IPackageLicenseInfo>);
|
|
261
|
+
/**
|
|
262
|
+
* Get filtered packages from current bundle where at least one token of each
|
|
263
|
+
* key is present.
|
|
264
|
+
*/
|
|
265
|
+
getFilteredPackages(allRows: IPackageLicenseInfo[]): IPackageLicenseInfo[];
|
|
266
|
+
private _selectedPackageChanged;
|
|
267
|
+
private _trackerDataChanged;
|
|
268
|
+
private _serverResponse;
|
|
269
|
+
private _client;
|
|
270
|
+
private _currentBundleName;
|
|
271
|
+
private _trans;
|
|
272
|
+
private _currentPackageIndex;
|
|
273
|
+
private _licensesReady;
|
|
274
|
+
private _packageFilter;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A filter form for limiting the packages displayed
|
|
278
|
+
*/
|
|
279
|
+
class Filters extends VDomRenderer<Model> {
|
|
280
|
+
constructor(model: Model);
|
|
281
|
+
protected render(): JSX.Element;
|
|
282
|
+
/**
|
|
283
|
+
* Render a filter input
|
|
284
|
+
*/
|
|
285
|
+
protected renderFilter: (key: TFilterKey) => JSX.Element;
|
|
286
|
+
/**
|
|
287
|
+
* Handle a filter input changing
|
|
288
|
+
*/
|
|
289
|
+
protected onFilterInput: (evt: React.ChangeEvent<HTMLInputElement>) => void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A fancy bundle renderer with the package count
|
|
293
|
+
*/
|
|
294
|
+
class BundleTabRenderer extends TabBar.Renderer {
|
|
295
|
+
/**
|
|
296
|
+
* A model of the state of license viewing as well as the underlying data
|
|
297
|
+
*/
|
|
298
|
+
model: Model;
|
|
299
|
+
readonly closeIconSelector = ".lm-TabBar-tabCloseIcon";
|
|
300
|
+
constructor(model: Model);
|
|
301
|
+
/**
|
|
302
|
+
* Render a full bundle
|
|
303
|
+
*/
|
|
304
|
+
renderTab(data: TabBar.IRenderData<Widget>): VirtualElement;
|
|
305
|
+
/**
|
|
306
|
+
* Render the package count
|
|
307
|
+
*/
|
|
308
|
+
renderCountBadge(data: TabBar.IRenderData<Widget>): VirtualElement;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* A grid of licenses
|
|
312
|
+
*/
|
|
313
|
+
class Grid extends VDomRenderer<Licenses.Model> {
|
|
314
|
+
constructor(model: Licenses.Model);
|
|
315
|
+
/**
|
|
316
|
+
* Render a grid of package license information
|
|
317
|
+
*/
|
|
318
|
+
protected render(): JSX.Element;
|
|
319
|
+
/**
|
|
320
|
+
* Render a single package's license information
|
|
321
|
+
*/
|
|
322
|
+
protected renderRow: (row: Licenses.IPackageLicenseInfo, index: number) => JSX.Element;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* A package's full license text
|
|
326
|
+
*/
|
|
327
|
+
class FullText extends VDomRenderer<Model> {
|
|
328
|
+
constructor(model: Model);
|
|
329
|
+
/**
|
|
330
|
+
* Render the license text, or a null state if no package is selected
|
|
331
|
+
*/
|
|
332
|
+
protected render(): JSX.Element[];
|
|
333
|
+
}
|
|
334
|
+
}
|