@jupyterlab/apputils 0.19.1-alpha.0 → 0.19.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/vdom.d.ts CHANGED
@@ -1,90 +1,90 @@
1
- import { IDisposable } from '@phosphor/disposable';
2
- import { Message } from '@phosphor/messaging';
3
- import { ISignal, Signal } from '@phosphor/signaling';
4
- import { Widget } from '@phosphor/widgets';
5
- import * as React from 'react';
6
- /**
7
- * Phosphor widget that encodes best practices for VDOM based rendering.
8
- */
9
- export declare abstract class VDomRenderer<T extends VDomRenderer.IModel | null> extends Widget {
10
- /**
11
- * A signal emitted when the model changes.
12
- */
13
- readonly modelChanged: ISignal<this, void>;
14
- /**
15
- * Set the model and fire changed signals.
16
- */
17
- /**
18
- * Get the current model.
19
- */
20
- model: T | null;
21
- /**
22
- * Dispose this widget.
23
- */
24
- dispose(): void;
25
- /**
26
- * Called to update the state of the widget.
27
- *
28
- * The default implementation of this method triggers
29
- * VDOM based rendering by calling the this.render() method.
30
- */
31
- protected onUpdateRequest(msg: Message): void;
32
- protected onAfterAttach(msg: Message): void;
33
- /**
34
- * Render the content of this widget using the virtual DOM.
35
- *
36
- * This method will be called anytime the widget needs to be rendered,
37
- * which includes layout triggered rendering and all model changes.
38
- *
39
- * Subclasses should define this method and use the current model state
40
- * to create a virtual node or nodes to render.
41
- */
42
- protected abstract render(): Array<React.ReactElement<any>> | React.ReactElement<any> | null;
43
- private _model;
44
- private _modelChanged;
45
- }
46
- /**
47
- * Phosphor widget that renders React Element(s).
48
- *
49
- * All messages will re-render the element.
50
- */
51
- export declare class ReactElementWidget extends VDomRenderer<any> {
52
- /**
53
- * Creates a Phosphor widget that renders the element(s) `es`.
54
- */
55
- constructor(es: Array<React.ReactElement<any>> | React.ReactElement<any> | null);
56
- render(): Array<React.ReactElement<any>> | React.ReactElement<any> | null;
57
- private _es;
58
- }
59
- /**
60
- * The namespace for VDomRenderer statics.
61
- */
62
- export declare namespace VDomRenderer {
63
- /**
64
- * An interface for a model to be used with vdom rendering.
65
- */
66
- interface IModel extends IDisposable {
67
- /**
68
- * A signal emitted when any model state changes.
69
- */
70
- readonly stateChanged: ISignal<this, void>;
71
- }
72
- }
73
- /**
74
- * Concrete implementation of VDomRenderer model.
75
- */
76
- export declare class VDomModel implements VDomRenderer.IModel {
77
- /**
78
- * A signal emitted when any model state changes.
79
- */
80
- readonly stateChanged: Signal<this, void>;
81
- /**
82
- * Test whether the model is disposed.
83
- */
84
- readonly isDisposed: boolean;
85
- /**
86
- * Dispose the model.
87
- */
88
- dispose(): void;
89
- private _isDisposed;
90
- }
1
+ import { IDisposable } from '@phosphor/disposable';
2
+ import { Message } from '@phosphor/messaging';
3
+ import { ISignal, Signal } from '@phosphor/signaling';
4
+ import { Widget } from '@phosphor/widgets';
5
+ import * as React from 'react';
6
+ /**
7
+ * Phosphor widget that encodes best practices for VDOM based rendering.
8
+ */
9
+ export declare abstract class VDomRenderer<T extends VDomRenderer.IModel | null> extends Widget {
10
+ /**
11
+ * A signal emitted when the model changes.
12
+ */
13
+ readonly modelChanged: ISignal<this, void>;
14
+ /**
15
+ * Set the model and fire changed signals.
16
+ */
17
+ /**
18
+ * Get the current model.
19
+ */
20
+ model: T | null;
21
+ /**
22
+ * Dispose this widget.
23
+ */
24
+ dispose(): void;
25
+ /**
26
+ * Called to update the state of the widget.
27
+ *
28
+ * The default implementation of this method triggers
29
+ * VDOM based rendering by calling the this.render() method.
30
+ */
31
+ protected onUpdateRequest(msg: Message): void;
32
+ protected onAfterAttach(msg: Message): void;
33
+ /**
34
+ * Render the content of this widget using the virtual DOM.
35
+ *
36
+ * This method will be called anytime the widget needs to be rendered,
37
+ * which includes layout triggered rendering and all model changes.
38
+ *
39
+ * Subclasses should define this method and use the current model state
40
+ * to create a virtual node or nodes to render.
41
+ */
42
+ protected abstract render(): Array<React.ReactElement<any>> | React.ReactElement<any> | null;
43
+ private _model;
44
+ private _modelChanged;
45
+ }
46
+ /**
47
+ * Phosphor widget that renders React Element(s).
48
+ *
49
+ * All messages will re-render the element.
50
+ */
51
+ export declare class ReactElementWidget extends VDomRenderer<any> {
52
+ /**
53
+ * Creates a Phosphor widget that renders the element(s) `es`.
54
+ */
55
+ constructor(es: Array<React.ReactElement<any>> | React.ReactElement<any> | null);
56
+ render(): Array<React.ReactElement<any>> | React.ReactElement<any> | null;
57
+ private _es;
58
+ }
59
+ /**
60
+ * The namespace for VDomRenderer statics.
61
+ */
62
+ export declare namespace VDomRenderer {
63
+ /**
64
+ * An interface for a model to be used with vdom rendering.
65
+ */
66
+ interface IModel extends IDisposable {
67
+ /**
68
+ * A signal emitted when any model state changes.
69
+ */
70
+ readonly stateChanged: ISignal<this, void>;
71
+ }
72
+ }
73
+ /**
74
+ * Concrete implementation of VDomRenderer model.
75
+ */
76
+ export declare class VDomModel implements VDomRenderer.IModel {
77
+ /**
78
+ * A signal emitted when any model state changes.
79
+ */
80
+ readonly stateChanged: Signal<this, void>;
81
+ /**
82
+ * Test whether the model is disposed.
83
+ */
84
+ readonly isDisposed: boolean;
85
+ /**
86
+ * Dispose the model.
87
+ */
88
+ dispose(): void;
89
+ private _isDisposed;
90
+ }
package/lib/vdom.js CHANGED
@@ -1,130 +1,130 @@
1
- "use strict";
2
- // Copyright (c) Jupyter Development Team.
3
- // Distributed under the terms of the Modified BSD License.
4
- var __importStar = (this && this.__importStar) || function (mod) {
5
- if (mod && mod.__esModule) return mod;
6
- var result = {};
7
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
8
- result["default"] = mod;
9
- return result;
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const messaging_1 = require("@phosphor/messaging");
13
- const signaling_1 = require("@phosphor/signaling");
14
- const widgets_1 = require("@phosphor/widgets");
15
- const ReactDOM = __importStar(require("react-dom"));
16
- /**
17
- * Phosphor widget that encodes best practices for VDOM based rendering.
18
- */
19
- class VDomRenderer extends widgets_1.Widget {
20
- constructor() {
21
- super(...arguments);
22
- this._modelChanged = new signaling_1.Signal(this);
23
- }
24
- /**
25
- * A signal emitted when the model changes.
26
- */
27
- get modelChanged() {
28
- return this._modelChanged;
29
- }
30
- /**
31
- * Set the model and fire changed signals.
32
- */
33
- set model(newValue) {
34
- if (this._model === newValue) {
35
- return;
36
- }
37
- if (this._model) {
38
- this._model.stateChanged.disconnect(this.update, this);
39
- }
40
- this._model = newValue;
41
- if (newValue) {
42
- newValue.stateChanged.connect(this.update, this);
43
- }
44
- this.update();
45
- this._modelChanged.emit(void 0);
46
- }
47
- /**
48
- * Get the current model.
49
- */
50
- get model() {
51
- return this._model;
52
- }
53
- /**
54
- * Dispose this widget.
55
- */
56
- dispose() {
57
- this._model = null;
58
- super.dispose();
59
- }
60
- /**
61
- * Called to update the state of the widget.
62
- *
63
- * The default implementation of this method triggers
64
- * VDOM based rendering by calling the this.render() method.
65
- */
66
- onUpdateRequest(msg) {
67
- let vnode = this.render();
68
- if (Array.isArray(vnode)) {
69
- ReactDOM.render(vnode, this.node);
70
- }
71
- else {
72
- ReactDOM.render(vnode, this.node);
73
- }
74
- }
75
- /* Called after the widget is attached to the DOM
76
- *
77
- * Make sure the widget is rendered, even if the model has not changed.
78
- */
79
- onAfterAttach(msg) {
80
- messaging_1.MessageLoop.sendMessage(this, widgets_1.Widget.Msg.UpdateRequest);
81
- }
82
- }
83
- exports.VDomRenderer = VDomRenderer;
84
- /**
85
- * Phosphor widget that renders React Element(s).
86
- *
87
- * All messages will re-render the element.
88
- */
89
- class ReactElementWidget extends VDomRenderer {
90
- /**
91
- * Creates a Phosphor widget that renders the element(s) `es`.
92
- */
93
- constructor(es) {
94
- super();
95
- this._es = es;
96
- }
97
- render() {
98
- return this._es;
99
- }
100
- }
101
- exports.ReactElementWidget = ReactElementWidget;
102
- /**
103
- * Concrete implementation of VDomRenderer model.
104
- */
105
- class VDomModel {
106
- constructor() {
107
- /**
108
- * A signal emitted when any model state changes.
109
- */
110
- this.stateChanged = new signaling_1.Signal(this);
111
- this._isDisposed = false;
112
- }
113
- /**
114
- * Test whether the model is disposed.
115
- */
116
- get isDisposed() {
117
- return this._isDisposed;
118
- }
119
- /**
120
- * Dispose the model.
121
- */
122
- dispose() {
123
- if (this.isDisposed) {
124
- return;
125
- }
126
- this._isDisposed = true;
127
- signaling_1.Signal.clearData(this);
128
- }
129
- }
130
- exports.VDomModel = VDomModel;
1
+ "use strict";
2
+ // Copyright (c) Jupyter Development Team.
3
+ // Distributed under the terms of the Modified BSD License.
4
+ var __importStar = (this && this.__importStar) || function (mod) {
5
+ if (mod && mod.__esModule) return mod;
6
+ var result = {};
7
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
8
+ result["default"] = mod;
9
+ return result;
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const messaging_1 = require("@phosphor/messaging");
13
+ const signaling_1 = require("@phosphor/signaling");
14
+ const widgets_1 = require("@phosphor/widgets");
15
+ const ReactDOM = __importStar(require("react-dom"));
16
+ /**
17
+ * Phosphor widget that encodes best practices for VDOM based rendering.
18
+ */
19
+ class VDomRenderer extends widgets_1.Widget {
20
+ constructor() {
21
+ super(...arguments);
22
+ this._modelChanged = new signaling_1.Signal(this);
23
+ }
24
+ /**
25
+ * A signal emitted when the model changes.
26
+ */
27
+ get modelChanged() {
28
+ return this._modelChanged;
29
+ }
30
+ /**
31
+ * Set the model and fire changed signals.
32
+ */
33
+ set model(newValue) {
34
+ if (this._model === newValue) {
35
+ return;
36
+ }
37
+ if (this._model) {
38
+ this._model.stateChanged.disconnect(this.update, this);
39
+ }
40
+ this._model = newValue;
41
+ if (newValue) {
42
+ newValue.stateChanged.connect(this.update, this);
43
+ }
44
+ this.update();
45
+ this._modelChanged.emit(void 0);
46
+ }
47
+ /**
48
+ * Get the current model.
49
+ */
50
+ get model() {
51
+ return this._model;
52
+ }
53
+ /**
54
+ * Dispose this widget.
55
+ */
56
+ dispose() {
57
+ this._model = null;
58
+ super.dispose();
59
+ }
60
+ /**
61
+ * Called to update the state of the widget.
62
+ *
63
+ * The default implementation of this method triggers
64
+ * VDOM based rendering by calling the this.render() method.
65
+ */
66
+ onUpdateRequest(msg) {
67
+ let vnode = this.render();
68
+ if (Array.isArray(vnode)) {
69
+ ReactDOM.render(vnode, this.node);
70
+ }
71
+ else {
72
+ ReactDOM.render(vnode, this.node);
73
+ }
74
+ }
75
+ /* Called after the widget is attached to the DOM
76
+ *
77
+ * Make sure the widget is rendered, even if the model has not changed.
78
+ */
79
+ onAfterAttach(msg) {
80
+ messaging_1.MessageLoop.sendMessage(this, widgets_1.Widget.Msg.UpdateRequest);
81
+ }
82
+ }
83
+ exports.VDomRenderer = VDomRenderer;
84
+ /**
85
+ * Phosphor widget that renders React Element(s).
86
+ *
87
+ * All messages will re-render the element.
88
+ */
89
+ class ReactElementWidget extends VDomRenderer {
90
+ /**
91
+ * Creates a Phosphor widget that renders the element(s) `es`.
92
+ */
93
+ constructor(es) {
94
+ super();
95
+ this._es = es;
96
+ }
97
+ render() {
98
+ return this._es;
99
+ }
100
+ }
101
+ exports.ReactElementWidget = ReactElementWidget;
102
+ /**
103
+ * Concrete implementation of VDomRenderer model.
104
+ */
105
+ class VDomModel {
106
+ constructor() {
107
+ /**
108
+ * A signal emitted when any model state changes.
109
+ */
110
+ this.stateChanged = new signaling_1.Signal(this);
111
+ this._isDisposed = false;
112
+ }
113
+ /**
114
+ * Test whether the model is disposed.
115
+ */
116
+ get isDisposed() {
117
+ return this._isDisposed;
118
+ }
119
+ /**
120
+ * Dispose the model.
121
+ */
122
+ dispose() {
123
+ if (this.isDisposed) {
124
+ return;
125
+ }
126
+ this._isDisposed = true;
127
+ signaling_1.Signal.clearData(this);
128
+ }
129
+ }
130
+ exports.VDomModel = VDomModel;
@@ -1,37 +1,37 @@
1
- import { Token } from '@phosphor/coreutils';
2
- /**
3
- * The default window resolver token.
4
- */
5
- export declare const IWindowResolver: Token<IWindowResolver>;
6
- /**
7
- * The description of a window name resolver.
8
- */
9
- export interface IWindowResolver {
10
- /**
11
- * A window name to use as a handle among shared resources.
12
- */
13
- readonly name: string;
14
- }
15
- /**
16
- * A concrete implementation of a window name resolver.
17
- */
18
- export declare class WindowResolver implements IWindowResolver {
19
- /**
20
- * The resolved window name.
21
- */
22
- readonly name: string;
23
- /**
24
- * Resolve a window name to use as a handle among shared resources.
25
- *
26
- * @param candidate - The potential window name being resolved.
27
- *
28
- * #### Notes
29
- * Typically, the name candidate should be a JupyterLab workspace name or
30
- * an empty string if there is no workspace.
31
- *
32
- * If the returned promise rejects, a window name cannot be resolved without
33
- * user intervention, which typically means navigation to a new URL.
34
- */
35
- resolve(candidate: string): Promise<void>;
36
- private _name;
37
- }
1
+ import { Token } from '@phosphor/coreutils';
2
+ /**
3
+ * The default window resolver token.
4
+ */
5
+ export declare const IWindowResolver: Token<IWindowResolver>;
6
+ /**
7
+ * The description of a window name resolver.
8
+ */
9
+ export interface IWindowResolver {
10
+ /**
11
+ * A window name to use as a handle among shared resources.
12
+ */
13
+ readonly name: string;
14
+ }
15
+ /**
16
+ * A concrete implementation of a window name resolver.
17
+ */
18
+ export declare class WindowResolver implements IWindowResolver {
19
+ /**
20
+ * The resolved window name.
21
+ */
22
+ readonly name: string;
23
+ /**
24
+ * Resolve a window name to use as a handle among shared resources.
25
+ *
26
+ * @param candidate - The potential window name being resolved.
27
+ *
28
+ * #### Notes
29
+ * Typically, the name candidate should be a JupyterLab workspace name or
30
+ * an empty string if there is no workspace.
31
+ *
32
+ * If the returned promise rejects, a window name cannot be resolved without
33
+ * user intervention, which typically means navigation to a new URL.
34
+ */
35
+ resolve(candidate: string): Promise<void>;
36
+ private _name;
37
+ }