@jupyterlab/apputils 4.5.0-beta.0 → 4.5.0-beta.2

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 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,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,SAAS,IAAI,QAAQ,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,MAAM,EAGN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,OAAO,EACP,aAAa,EACb,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,c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AAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;AACnB,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,0CAA0C;AAC1C;;;GAGG;AACH,MAAM,OAAO,OAAmC,SAAQ,SAAY;CAAG;AAEvE,WAAiB,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,333 @@
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
+ * Download the licenses in the requested format.
186
+ */
187
+ download(options: IDownloadOptions): Promise<void>;
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
+ * Download the licenses in the requested format.
206
+ */
207
+ download(options: IDownloadOptions): Promise<void>;
208
+ /**
209
+ * A promise that resolves when the licenses from the server change
210
+ */
211
+ get selectedPackageChanged(): ISignal<Model, void>;
212
+ /**
213
+ * A promise that resolves when the trackable data changes
214
+ */
215
+ get trackerDataChanged(): ISignal<Model, void>;
216
+ /**
217
+ * The names of the license bundles available
218
+ */
219
+ get bundleNames(): string[];
220
+ /**
221
+ * The current license bundle
222
+ */
223
+ get currentBundleName(): string | null;
224
+ /**
225
+ * Set the current license bundle, and reset the selected index
226
+ */
227
+ set currentBundleName(currentBundleName: string | null);
228
+ /**
229
+ * A promise that resolves when the licenses are available from the server
230
+ */
231
+ get licensesReady(): Promise<void>;
232
+ /**
233
+ * All the license bundles, keyed by the distributing packages
234
+ */
235
+ get bundles(): null | {
236
+ [key: string]: ILicenseBundle;
237
+ };
238
+ /**
239
+ * The index of the currently-selected package within its license bundle
240
+ */
241
+ get currentPackageIndex(): number | null;
242
+ /**
243
+ * Update the currently-selected package within its license bundle
244
+ */
245
+ set currentPackageIndex(currentPackageIndex: number | null);
246
+ /**
247
+ * The license data for the currently-selected package
248
+ */
249
+ get currentPackage(): IPackageLicenseInfo | null;
250
+ /**
251
+ * A translation bundle
252
+ */
253
+ get trans(): TranslationBundle;
254
+ get title(): string;
255
+ /**
256
+ * The current package filter
257
+ */
258
+ get packageFilter(): Partial<IPackageLicenseInfo>;
259
+ set packageFilter(packageFilter: Partial<IPackageLicenseInfo>);
260
+ /**
261
+ * Get filtered packages from current bundle where at least one token of each
262
+ * key is present.
263
+ */
264
+ getFilteredPackages(allRows: IPackageLicenseInfo[]): IPackageLicenseInfo[];
265
+ private _selectedPackageChanged;
266
+ private _trackerDataChanged;
267
+ private _serverResponse;
268
+ private _client;
269
+ private _currentBundleName;
270
+ private _trans;
271
+ private _currentPackageIndex;
272
+ private _licensesReady;
273
+ private _packageFilter;
274
+ }
275
+ /**
276
+ * A filter form for limiting the packages displayed
277
+ */
278
+ class Filters extends VDomRenderer<Model> {
279
+ constructor(model: Model);
280
+ protected render(): JSX.Element;
281
+ /**
282
+ * Render a filter input
283
+ */
284
+ protected renderFilter: (key: TFilterKey) => JSX.Element;
285
+ /**
286
+ * Handle a filter input changing
287
+ */
288
+ protected onFilterInput: (evt: React.ChangeEvent<HTMLInputElement>) => void;
289
+ }
290
+ /**
291
+ * A fancy bundle renderer with the package count
292
+ */
293
+ class BundleTabRenderer extends TabBar.Renderer {
294
+ /**
295
+ * A model of the state of license viewing as well as the underlying data
296
+ */
297
+ model: Model;
298
+ readonly closeIconSelector = ".lm-TabBar-tabCloseIcon";
299
+ constructor(model: Model);
300
+ /**
301
+ * Render a full bundle
302
+ */
303
+ renderTab(data: TabBar.IRenderData<Widget>): VirtualElement;
304
+ /**
305
+ * Render the package count
306
+ */
307
+ renderCountBadge(data: TabBar.IRenderData<Widget>): VirtualElement;
308
+ }
309
+ /**
310
+ * A grid of licenses
311
+ */
312
+ class Grid extends VDomRenderer<Licenses.Model> {
313
+ constructor(model: Licenses.Model);
314
+ /**
315
+ * Render a grid of package license information
316
+ */
317
+ protected render(): JSX.Element;
318
+ /**
319
+ * Render a single package's license information
320
+ */
321
+ protected renderRow: (row: Licenses.IPackageLicenseInfo, index: number) => JSX.Element;
322
+ }
323
+ /**
324
+ * A package's full license text
325
+ */
326
+ class FullText extends VDomRenderer<Model> {
327
+ constructor(model: Model);
328
+ /**
329
+ * Render the license text, or a null state if no package is selected
330
+ */
331
+ protected render(): JSX.Element[];
332
+ }
333
+ }