@jupyterlab/rendermime 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/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ Copyright (c) 2015 Project Jupyter Contributors
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ Semver File License
30
+ ===================
31
+
32
+ The semver.py file is from https://github.com/podhmo/python-semver
33
+ which is licensed under the "MIT" license. See the semver.py file for details.
34
+
@@ -1,94 +1,94 @@
1
- import { nbformat } from '@jupyterlab/coreutils';
2
- import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
3
- import { JSONObject, ReadonlyJSONObject } from '@phosphor/coreutils';
4
- import { ISignal } from '@phosphor/signaling';
5
- /**
6
- * The interface for an attachment model.
7
- */
8
- export interface IAttachmentModel extends IRenderMime.IMimeModel {
9
- /**
10
- * A signal emitted when the attachment model changes.
11
- */
12
- readonly changed: ISignal<this, void>;
13
- /**
14
- * Dispose of the resources used by the attachment model.
15
- */
16
- dispose(): void;
17
- /**
18
- * Serialize the model to JSON.
19
- */
20
- toJSON(): nbformat.IMimeBundle;
21
- }
22
- /**
23
- * The namespace for IAttachmentModel sub-interfaces.
24
- */
25
- export declare namespace IAttachmentModel {
26
- /**
27
- * The options used to create a notebook attachment model.
28
- */
29
- interface IOptions {
30
- /**
31
- * The raw attachment value.
32
- */
33
- value: nbformat.IMimeBundle;
34
- }
35
- }
36
- /**
37
- * The default implementation of a notebook attachment model.
38
- */
39
- export declare class AttachmentModel implements IAttachmentModel {
40
- /**
41
- * Construct a new attachment model.
42
- */
43
- constructor(options: IAttachmentModel.IOptions);
44
- /**
45
- * A signal emitted when the attachment model changes.
46
- */
47
- readonly changed: ISignal<this, void>;
48
- /**
49
- * Dispose of the resources used by the attachment model.
50
- */
51
- dispose(): void;
52
- /**
53
- * The data associated with the model.
54
- */
55
- readonly data: ReadonlyJSONObject;
56
- /**
57
- * The metadata associated with the model.
58
- */
59
- readonly metadata: ReadonlyJSONObject;
60
- /**
61
- * Set the data associated with the model.
62
- *
63
- * #### Notes
64
- * Depending on the implementation of the mime model,
65
- * this call may or may not have deferred effects,
66
- */
67
- setData(options: IRenderMime.IMimeModel.ISetDataOptions): void;
68
- /**
69
- * Serialize the model to JSON.
70
- */
71
- toJSON(): nbformat.IMimeBundle;
72
- readonly trusted: boolean;
73
- /**
74
- * Update an observable JSON object using a readonly JSON object.
75
- */
76
- private _updateObservable;
77
- private _changed;
78
- private _raw;
79
- private _rawData;
80
- private _data;
81
- }
82
- /**
83
- * The namespace for AttachmentModel statics.
84
- */
85
- export declare namespace AttachmentModel {
86
- /**
87
- * Get the data for an attachment.
88
- *
89
- * @params bundle - A kernel attachment MIME bundle.
90
- *
91
- * @returns - The data for the payload.
92
- */
93
- function getData(bundle: nbformat.IMimeBundle): JSONObject;
94
- }
1
+ import { nbformat } from '@jupyterlab/coreutils';
2
+ import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
3
+ import { JSONObject, ReadonlyJSONObject } from '@phosphor/coreutils';
4
+ import { ISignal } from '@phosphor/signaling';
5
+ /**
6
+ * The interface for an attachment model.
7
+ */
8
+ export interface IAttachmentModel extends IRenderMime.IMimeModel {
9
+ /**
10
+ * A signal emitted when the attachment model changes.
11
+ */
12
+ readonly changed: ISignal<this, void>;
13
+ /**
14
+ * Dispose of the resources used by the attachment model.
15
+ */
16
+ dispose(): void;
17
+ /**
18
+ * Serialize the model to JSON.
19
+ */
20
+ toJSON(): nbformat.IMimeBundle;
21
+ }
22
+ /**
23
+ * The namespace for IAttachmentModel sub-interfaces.
24
+ */
25
+ export declare namespace IAttachmentModel {
26
+ /**
27
+ * The options used to create a notebook attachment model.
28
+ */
29
+ interface IOptions {
30
+ /**
31
+ * The raw attachment value.
32
+ */
33
+ value: nbformat.IMimeBundle;
34
+ }
35
+ }
36
+ /**
37
+ * The default implementation of a notebook attachment model.
38
+ */
39
+ export declare class AttachmentModel implements IAttachmentModel {
40
+ /**
41
+ * Construct a new attachment model.
42
+ */
43
+ constructor(options: IAttachmentModel.IOptions);
44
+ /**
45
+ * A signal emitted when the attachment model changes.
46
+ */
47
+ readonly changed: ISignal<this, void>;
48
+ /**
49
+ * Dispose of the resources used by the attachment model.
50
+ */
51
+ dispose(): void;
52
+ /**
53
+ * The data associated with the model.
54
+ */
55
+ readonly data: ReadonlyJSONObject;
56
+ /**
57
+ * The metadata associated with the model.
58
+ */
59
+ readonly metadata: ReadonlyJSONObject;
60
+ /**
61
+ * Set the data associated with the model.
62
+ *
63
+ * #### Notes
64
+ * Depending on the implementation of the mime model,
65
+ * this call may or may not have deferred effects,
66
+ */
67
+ setData(options: IRenderMime.IMimeModel.ISetDataOptions): void;
68
+ /**
69
+ * Serialize the model to JSON.
70
+ */
71
+ toJSON(): nbformat.IMimeBundle;
72
+ readonly trusted: boolean;
73
+ /**
74
+ * Update an observable JSON object using a readonly JSON object.
75
+ */
76
+ private _updateObservable;
77
+ private _changed;
78
+ private _raw;
79
+ private _rawData;
80
+ private _data;
81
+ }
82
+ /**
83
+ * The namespace for AttachmentModel statics.
84
+ */
85
+ export declare namespace AttachmentModel {
86
+ /**
87
+ * Get the data for an attachment.
88
+ *
89
+ * @params bundle - A kernel attachment MIME bundle.
90
+ *
91
+ * @returns - The data for the payload.
92
+ */
93
+ function getData(bundle: nbformat.IMimeBundle): JSONObject;
94
+ }
@@ -1,166 +1,166 @@
1
- "use strict";
2
- /*-----------------------------------------------------------------------------
3
- | Copyright (c) Jupyter Development Team.
4
- | Distributed under the terms of the Modified BSD License.
5
- |----------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const observables_1 = require("@jupyterlab/observables");
8
- const coreutils_1 = require("@phosphor/coreutils");
9
- const signaling_1 = require("@phosphor/signaling");
10
- /**
11
- * The default implementation of a notebook attachment model.
12
- */
13
- class AttachmentModel {
14
- /**
15
- * Construct a new attachment model.
16
- */
17
- constructor(options) {
18
- // All attachments are untrusted
19
- this.trusted = false;
20
- this._changed = new signaling_1.Signal(this);
21
- this._raw = {};
22
- let { data } = Private.getBundleOptions(options);
23
- this._data = new observables_1.ObservableJSON({ values: data });
24
- this._rawData = data;
25
- // Make a copy of the data.
26
- let value = options.value;
27
- for (let key in value) {
28
- // Ignore data and metadata that were stripped.
29
- switch (key) {
30
- case 'data':
31
- break;
32
- default:
33
- this._raw[key] = Private.extract(value, key);
34
- }
35
- }
36
- }
37
- /**
38
- * A signal emitted when the attachment model changes.
39
- */
40
- get changed() {
41
- return this._changed;
42
- }
43
- /**
44
- * Dispose of the resources used by the attachment model.
45
- */
46
- dispose() {
47
- this._data.dispose();
48
- signaling_1.Signal.clearData(this);
49
- }
50
- /**
51
- * The data associated with the model.
52
- */
53
- get data() {
54
- return this._rawData;
55
- }
56
- /**
57
- * The metadata associated with the model.
58
- */
59
- get metadata() {
60
- return undefined;
61
- }
62
- /**
63
- * Set the data associated with the model.
64
- *
65
- * #### Notes
66
- * Depending on the implementation of the mime model,
67
- * this call may or may not have deferred effects,
68
- */
69
- setData(options) {
70
- if (options.data) {
71
- this._updateObservable(this._data, options.data);
72
- this._rawData = options.data;
73
- }
74
- this._changed.emit(void 0);
75
- }
76
- /**
77
- * Serialize the model to JSON.
78
- */
79
- toJSON() {
80
- let attachment = {};
81
- for (let key in this._raw) {
82
- attachment[key] = Private.extract(this._raw, key);
83
- }
84
- return attachment;
85
- }
86
- /**
87
- * Update an observable JSON object using a readonly JSON object.
88
- */
89
- _updateObservable(observable, data) {
90
- let oldKeys = observable.keys();
91
- let newKeys = Object.keys(data);
92
- // Handle removed keys.
93
- for (let key of oldKeys) {
94
- if (newKeys.indexOf(key) === -1) {
95
- observable.delete(key);
96
- }
97
- }
98
- // Handle changed data.
99
- for (let key of newKeys) {
100
- let oldValue = observable.get(key);
101
- let newValue = data[key];
102
- if (oldValue !== newValue) {
103
- observable.set(key, newValue);
104
- }
105
- }
106
- }
107
- }
108
- exports.AttachmentModel = AttachmentModel;
109
- /**
110
- * The namespace for AttachmentModel statics.
111
- */
112
- (function (AttachmentModel) {
113
- /**
114
- * Get the data for an attachment.
115
- *
116
- * @params bundle - A kernel attachment MIME bundle.
117
- *
118
- * @returns - The data for the payload.
119
- */
120
- function getData(bundle) {
121
- return Private.getData(bundle);
122
- }
123
- AttachmentModel.getData = getData;
124
- })(AttachmentModel = exports.AttachmentModel || (exports.AttachmentModel = {}));
125
- /**
126
- * The namespace for module private data.
127
- */
128
- var Private;
129
- (function (Private) {
130
- /**
131
- * Get the data from a notebook attachment.
132
- */
133
- function getData(bundle) {
134
- return convertBundle(bundle);
135
- }
136
- Private.getData = getData;
137
- /**
138
- * Get the bundle options given attachment model options.
139
- */
140
- function getBundleOptions(options) {
141
- let data = getData(options.value);
142
- return { data };
143
- }
144
- Private.getBundleOptions = getBundleOptions;
145
- /**
146
- * Extract a value from a JSONObject.
147
- */
148
- function extract(value, key) {
149
- let item = value[key];
150
- if (coreutils_1.JSONExt.isPrimitive(item)) {
151
- return item;
152
- }
153
- return coreutils_1.JSONExt.deepCopy(item);
154
- }
155
- Private.extract = extract;
156
- /**
157
- * Convert a mime bundle to mime data.
158
- */
159
- function convertBundle(bundle) {
160
- let map = Object.create(null);
161
- for (let mimeType in bundle) {
162
- map[mimeType] = extract(bundle, mimeType);
163
- }
164
- return map;
165
- }
166
- })(Private || (Private = {}));
1
+ "use strict";
2
+ /*-----------------------------------------------------------------------------
3
+ | Copyright (c) Jupyter Development Team.
4
+ | Distributed under the terms of the Modified BSD License.
5
+ |----------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const observables_1 = require("@jupyterlab/observables");
8
+ const coreutils_1 = require("@phosphor/coreutils");
9
+ const signaling_1 = require("@phosphor/signaling");
10
+ /**
11
+ * The default implementation of a notebook attachment model.
12
+ */
13
+ class AttachmentModel {
14
+ /**
15
+ * Construct a new attachment model.
16
+ */
17
+ constructor(options) {
18
+ // All attachments are untrusted
19
+ this.trusted = false;
20
+ this._changed = new signaling_1.Signal(this);
21
+ this._raw = {};
22
+ let { data } = Private.getBundleOptions(options);
23
+ this._data = new observables_1.ObservableJSON({ values: data });
24
+ this._rawData = data;
25
+ // Make a copy of the data.
26
+ let value = options.value;
27
+ for (let key in value) {
28
+ // Ignore data and metadata that were stripped.
29
+ switch (key) {
30
+ case 'data':
31
+ break;
32
+ default:
33
+ this._raw[key] = Private.extract(value, key);
34
+ }
35
+ }
36
+ }
37
+ /**
38
+ * A signal emitted when the attachment model changes.
39
+ */
40
+ get changed() {
41
+ return this._changed;
42
+ }
43
+ /**
44
+ * Dispose of the resources used by the attachment model.
45
+ */
46
+ dispose() {
47
+ this._data.dispose();
48
+ signaling_1.Signal.clearData(this);
49
+ }
50
+ /**
51
+ * The data associated with the model.
52
+ */
53
+ get data() {
54
+ return this._rawData;
55
+ }
56
+ /**
57
+ * The metadata associated with the model.
58
+ */
59
+ get metadata() {
60
+ return undefined;
61
+ }
62
+ /**
63
+ * Set the data associated with the model.
64
+ *
65
+ * #### Notes
66
+ * Depending on the implementation of the mime model,
67
+ * this call may or may not have deferred effects,
68
+ */
69
+ setData(options) {
70
+ if (options.data) {
71
+ this._updateObservable(this._data, options.data);
72
+ this._rawData = options.data;
73
+ }
74
+ this._changed.emit(void 0);
75
+ }
76
+ /**
77
+ * Serialize the model to JSON.
78
+ */
79
+ toJSON() {
80
+ let attachment = {};
81
+ for (let key in this._raw) {
82
+ attachment[key] = Private.extract(this._raw, key);
83
+ }
84
+ return attachment;
85
+ }
86
+ /**
87
+ * Update an observable JSON object using a readonly JSON object.
88
+ */
89
+ _updateObservable(observable, data) {
90
+ let oldKeys = observable.keys();
91
+ let newKeys = Object.keys(data);
92
+ // Handle removed keys.
93
+ for (let key of oldKeys) {
94
+ if (newKeys.indexOf(key) === -1) {
95
+ observable.delete(key);
96
+ }
97
+ }
98
+ // Handle changed data.
99
+ for (let key of newKeys) {
100
+ let oldValue = observable.get(key);
101
+ let newValue = data[key];
102
+ if (oldValue !== newValue) {
103
+ observable.set(key, newValue);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ exports.AttachmentModel = AttachmentModel;
109
+ /**
110
+ * The namespace for AttachmentModel statics.
111
+ */
112
+ (function (AttachmentModel) {
113
+ /**
114
+ * Get the data for an attachment.
115
+ *
116
+ * @params bundle - A kernel attachment MIME bundle.
117
+ *
118
+ * @returns - The data for the payload.
119
+ */
120
+ function getData(bundle) {
121
+ return Private.getData(bundle);
122
+ }
123
+ AttachmentModel.getData = getData;
124
+ })(AttachmentModel = exports.AttachmentModel || (exports.AttachmentModel = {}));
125
+ /**
126
+ * The namespace for module private data.
127
+ */
128
+ var Private;
129
+ (function (Private) {
130
+ /**
131
+ * Get the data from a notebook attachment.
132
+ */
133
+ function getData(bundle) {
134
+ return convertBundle(bundle);
135
+ }
136
+ Private.getData = getData;
137
+ /**
138
+ * Get the bundle options given attachment model options.
139
+ */
140
+ function getBundleOptions(options) {
141
+ let data = getData(options.value);
142
+ return { data };
143
+ }
144
+ Private.getBundleOptions = getBundleOptions;
145
+ /**
146
+ * Extract a value from a JSONObject.
147
+ */
148
+ function extract(value, key) {
149
+ let item = value[key];
150
+ if (coreutils_1.JSONExt.isPrimitive(item)) {
151
+ return item;
152
+ }
153
+ return coreutils_1.JSONExt.deepCopy(item);
154
+ }
155
+ Private.extract = extract;
156
+ /**
157
+ * Convert a mime bundle to mime data.
158
+ */
159
+ function convertBundle(bundle) {
160
+ let map = Object.create(null);
161
+ for (let mimeType in bundle) {
162
+ map[mimeType] = extract(bundle, mimeType);
163
+ }
164
+ return map;
165
+ }
166
+ })(Private || (Private = {}));
@@ -1,33 +1,33 @@
1
- import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
2
- /**
3
- * A mime renderer factory for raw html.
4
- */
5
- export declare const htmlRendererFactory: IRenderMime.IRendererFactory;
6
- /**
7
- * A mime renderer factory for images.
8
- */
9
- export declare const imageRendererFactory: IRenderMime.IRendererFactory;
10
- /**
11
- * A mime renderer factory for LaTeX.
12
- */
13
- export declare const latexRendererFactory: IRenderMime.IRendererFactory;
14
- /**
15
- * A mime renderer factory for Markdown.
16
- */
17
- export declare const markdownRendererFactory: IRenderMime.IRendererFactory;
18
- /**
19
- * A mime renderer factory for svg.
20
- */
21
- export declare const svgRendererFactory: IRenderMime.IRendererFactory;
22
- /**
23
- * A mime renderer factory for plain and jupyter console text data.
24
- */
25
- export declare const textRendererFactory: IRenderMime.IRendererFactory;
26
- /**
27
- * A placeholder factory for deprecated rendered JavaScript.
28
- */
29
- export declare const javaScriptRendererFactory: IRenderMime.IRendererFactory;
30
- /**
31
- * The standard factories provided by the rendermime package.
32
- */
33
- export declare const standardRendererFactories: ReadonlyArray<IRenderMime.IRendererFactory>;
1
+ import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
2
+ /**
3
+ * A mime renderer factory for raw html.
4
+ */
5
+ export declare const htmlRendererFactory: IRenderMime.IRendererFactory;
6
+ /**
7
+ * A mime renderer factory for images.
8
+ */
9
+ export declare const imageRendererFactory: IRenderMime.IRendererFactory;
10
+ /**
11
+ * A mime renderer factory for LaTeX.
12
+ */
13
+ export declare const latexRendererFactory: IRenderMime.IRendererFactory;
14
+ /**
15
+ * A mime renderer factory for Markdown.
16
+ */
17
+ export declare const markdownRendererFactory: IRenderMime.IRendererFactory;
18
+ /**
19
+ * A mime renderer factory for svg.
20
+ */
21
+ export declare const svgRendererFactory: IRenderMime.IRendererFactory;
22
+ /**
23
+ * A mime renderer factory for plain and jupyter console text data.
24
+ */
25
+ export declare const textRendererFactory: IRenderMime.IRendererFactory;
26
+ /**
27
+ * A placeholder factory for deprecated rendered JavaScript.
28
+ */
29
+ export declare const javaScriptRendererFactory: IRenderMime.IRendererFactory;
30
+ /**
31
+ * The standard factories provided by the rendermime package.
32
+ */
33
+ export declare const standardRendererFactories: ReadonlyArray<IRenderMime.IRendererFactory>;