jupyter-ijavascript-utils 1.2.0 → 1.3.0
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/DOCS.md +25 -2
- package/README.md +21 -1
- package/docResources/img/htmlScriptD3.png +0 -0
- package/docResources/img/htmlScriptPassData.png +0 -0
- package/docResources/img/htmlScript_leaflet.png +0 -0
- package/docResources/img/htmlScript_qrCode.png +0 -0
- package/docResources/img/leafletDefaultProvider.png +0 -0
- package/docResources/img/leafletMissingAddToMap.png +0 -0
- package/docResources/img/leafletRenderMarkers.png +0 -0
- package/docResources/img/vegaObjectSchema.png +0 -0
- package/docResources/img/vegaStringSchema.png +0 -0
- package/package.json +2 -1
- package/src/__tests__/TableGenerator__spec.js +11 -11
- package/src/__tests__/file__spec.js +13 -0
- package/src/__tests__/ijs__spec.js +3 -0
- package/src/__tests__/ijs_htmlScript__spec.js +632 -0
- package/src/__tests__/leaflet__spec.js +551 -0
- package/src/file.js +4 -0
- package/src/ijs.js +268 -1
- package/src/index.js +3 -0
- package/src/leaflet.js +336 -0
- package/src/vega.js +162 -32
- package/tutorials/htmlScript.markdown +330 -0
- package/tutorials/tutorials.json +3 -0
package/DOCS.md
CHANGED
|
@@ -14,17 +14,18 @@ See the [#Installation section for requirements and installation](#install)
|
|
|
14
14
|
| {@link module:format} | Utilities for formatting and massaging data to be legible. |
|
|
15
15
|
| {@link module:group} | Library to group collections of objects - generating Maps of records ({@link SourceMap}) |
|
|
16
16
|
| {@link module:ijs} | Utility methods to support working within the iJavaScript kernel within Jupyter. |
|
|
17
|
+
| {@link module:leaflet} | Library to simplify rendering maps. |
|
|
17
18
|
| {@link module:object} | Utilities for massaging and managing JavaScript Objects or collections of Objects. |
|
|
18
19
|
| {@link module:set} | Functional Utilities for managing JavaScript Sets - allowing for chaining. |
|
|
19
20
|
| {@link module:vega} | Simple utility to streamline showing Vega-Lite charts within iJS Notebooks. |
|
|
20
|
-
| {@link SourceMap} | SubClass of Maps - generated by the {@link module:group} and reducible with {@link module:aggregate}
|
|
21
|
+
| {@link SourceMap} | SubClass of Maps - generated by the {@link module:group} and reducible with {@link module:aggregate}|
|
|
21
22
|
| {@link TableGenerator} | Class that can filter, sorts, manage and then generate HTML, CSV, Markdown, etc. |
|
|
22
23
|
|
|
23
24
|
-------
|
|
24
25
|
|
|
25
26
|
## What's New
|
|
26
27
|
|
|
27
|
-
5.
|
|
28
|
+
5.3 - Add {@link module:leaflet|Leaflet} for Maps, allow Vega to use {@link module:vega.svgFromSpec|explicit specs} (so [Examples can be copied and pasted](https://vega.github.io/vega-lite/examples/), and add in {@link module:ijs.htmlScript|htmlScripts}
|
|
28
29
|
|
|
29
30
|
-------
|
|
30
31
|
|
|
@@ -173,6 +174,28 @@ utils.vega.svg((vl) => vl.markPoint()
|
|
|
173
174
|
|
|
174
175
|

|
|
175
176
|
|
|
177
|
+
## Render Maps
|
|
178
|
+
|
|
179
|
+
({@link module:leaflet|See the Leaflet module for more})
|
|
180
|
+
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
## Render Other Libraries
|
|
184
|
+
|
|
185
|
+
(See the {@tutorial htmlScript} tutorial for more)
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
utils.ijs.htmlScript({
|
|
189
|
+
scripts: ['https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js'],
|
|
190
|
+
height: '100%',
|
|
191
|
+
onReady: ({rootEl}) => {
|
|
192
|
+
new QRCode(rootEl, "https://jupyter-ijavascript-utils.onrender.com/");
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+

|
|
198
|
+
|
|
176
199
|
<a name="install"> </a>
|
|
177
200
|
# Install
|
|
178
201
|
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ See documentation at: [https://jupyter-ijavascript-utils.onrender.com/](https://
|
|
|
18
18
|
|
|
19
19
|
# What's New
|
|
20
20
|
|
|
21
|
-
5.
|
|
21
|
+
5.3 - Add Leaflet for Maps, allow Vega to use explicit specs (so [Examples can be copied and pasted](https://vega.github.io/vega-lite/examples/), and add in htmlScripts
|
|
22
22
|
|
|
23
23
|
# For Example
|
|
24
24
|
|
|
@@ -157,8 +157,28 @@ utils.vega.svg((vl) => vl.markPoint()
|
|
|
157
157
|
)
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
+
## Render Charts
|
|
161
|
+
|
|
160
162
|

|
|
161
163
|
|
|
164
|
+
## Render Maps
|
|
165
|
+
|
|
166
|
+

|
|
167
|
+
|
|
168
|
+
## Render Other Libraries
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
utils.ijs.htmlScript({
|
|
172
|
+
scripts: ['https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js'],
|
|
173
|
+
height: '100%',
|
|
174
|
+
onReady: ({rootEl}) => {
|
|
175
|
+
new QRCode(rootEl, "https://jupyter-ijavascript-utils.onrender.com/");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
162
182
|
# License
|
|
163
183
|
|
|
164
184
|
See [License](https://jupyter-ijavascript-utils.onrender.com/LICENSE) (MIT License).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jupyter-ijavascript-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Utilities for working with iJavaScript - a Jupyter Kernel",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"pino-pretty": "^5.1.2",
|
|
46
46
|
"plantuml-encoder": "^1.4.0",
|
|
47
47
|
"promise-sequential": "^1.1.1",
|
|
48
|
+
"uuid": "^8.3.2",
|
|
48
49
|
"vega": "^5.22.0",
|
|
49
50
|
"vega-datasets": "^2.3.0",
|
|
50
51
|
"vega-lite": "^5.2.0",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const ArrayUtils = require('../array');
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line no-unused-vars
|
|
6
|
-
const FileUtil = require('../file');
|
|
6
|
+
// const FileUtil = require('../file');
|
|
7
7
|
|
|
8
8
|
const TableGenerator = require('../TableGenerator');
|
|
9
9
|
|
|
@@ -362,7 +362,7 @@ global.describe('tableGenerator', () => {
|
|
|
362
362
|
const results = new TableGenerator(data)
|
|
363
363
|
.printOptions({ collapseObjects: true, dateFormat: 'toISOString' })
|
|
364
364
|
.generateMarkdown();
|
|
365
|
-
// FileUtil.writeFileStd('
|
|
365
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
366
366
|
global.expect(results).toStrictEqual(expected);
|
|
367
367
|
});
|
|
368
368
|
});
|
|
@@ -430,7 +430,7 @@ global.describe('tableGenerator', () => {
|
|
|
430
430
|
\t<td >2.68</td>
|
|
431
431
|
</tr>
|
|
432
432
|
</table>`;
|
|
433
|
-
// FileUtil.writeFileStd('
|
|
433
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
434
434
|
global.expect(results).toBe(expected);
|
|
435
435
|
});
|
|
436
436
|
});
|
|
@@ -461,7 +461,7 @@ global.describe('tableGenerator', () => {
|
|
|
461
461
|
\t<td >2.68</td>
|
|
462
462
|
</tr>
|
|
463
463
|
</table>`;
|
|
464
|
-
// FileUtil.writeFileStd('
|
|
464
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
465
465
|
global.expect(results).toBe(expected);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
@@ -493,7 +493,7 @@ global.describe('tableGenerator', () => {
|
|
|
493
493
|
const results = new TableGenerator(weather)
|
|
494
494
|
.styleRow(styleRowFn)
|
|
495
495
|
.generateHTML();
|
|
496
|
-
// FileUtil.writeFileStd('
|
|
496
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
497
497
|
global.expect(results).toBe(expected);
|
|
498
498
|
});
|
|
499
499
|
});
|
|
@@ -524,7 +524,7 @@ global.describe('tableGenerator', () => {
|
|
|
524
524
|
const results = new TableGenerator(weather)
|
|
525
525
|
.styleCell(styleRowFn)
|
|
526
526
|
.generateHTML();
|
|
527
|
-
// FileUtil.writeFileStd('
|
|
527
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
528
528
|
global.expect(results).toBe(expected);
|
|
529
529
|
});
|
|
530
530
|
});
|
|
@@ -560,7 +560,7 @@ global.describe('tableGenerator', () => {
|
|
|
560
560
|
.augment(({ fullMonth: (row) => monthMap.get(row.month) }))
|
|
561
561
|
.columns(['id', 'city', 'precip', 'month', 'fullMonth'])
|
|
562
562
|
.generateHTML();
|
|
563
|
-
//FileUtil.writeFileStd('
|
|
563
|
+
//FileUtil.writeFileStd('./tmp/tmp', results);
|
|
564
564
|
global.expect(results).toBe(expected);
|
|
565
565
|
});
|
|
566
566
|
global.it('clears the format if we send a null formatter', () => {
|
|
@@ -588,7 +588,7 @@ global.describe('tableGenerator', () => {
|
|
|
588
588
|
const results = new TableGenerator(weather)
|
|
589
589
|
.augment(null)
|
|
590
590
|
.generateHTML();
|
|
591
|
-
// FileUtil.writeFileStd('
|
|
591
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
592
592
|
global.expect(results).toBe(expected);
|
|
593
593
|
});
|
|
594
594
|
|
|
@@ -745,7 +745,7 @@ global.describe('tableGenerator', () => {
|
|
|
745
745
|
</tr>
|
|
746
746
|
</table>`;
|
|
747
747
|
const results = htmlSpy.mock.calls[0][0];
|
|
748
|
-
// FileUtil.writeFileStd('
|
|
748
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
749
749
|
|
|
750
750
|
global.expect(results).toBe(expected);
|
|
751
751
|
});
|
|
@@ -776,7 +776,7 @@ global.describe('tableGenerator', () => {
|
|
|
776
776
|
1 |Seattle|Aug |0.87
|
|
777
777
|
0 |Seattle|Apr |2.68 `;
|
|
778
778
|
const results = consoleSpy.mock.calls[0][0];
|
|
779
|
-
//FileUtil.writeFileStd('
|
|
779
|
+
//FileUtil.writeFileStd('./tmp/tmp', results);
|
|
780
780
|
|
|
781
781
|
global.expect(results).toBe(expected);
|
|
782
782
|
});
|
|
@@ -806,7 +806,7 @@ global.describe('tableGenerator', () => {
|
|
|
806
806
|
"1","Seattle","Aug","0.87"
|
|
807
807
|
"0","Seattle","Apr","2.68"`;
|
|
808
808
|
const results = consoleSpy.mock.calls[0][0];
|
|
809
|
-
FileUtil.writeFileStd('
|
|
809
|
+
// FileUtil.writeFileStd('./tmp/tmp', results);
|
|
810
810
|
|
|
811
811
|
global.expect(results).toBe(expected);
|
|
812
812
|
});
|
|
@@ -179,6 +179,19 @@ global.describe('FileUtil', () => {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
global.describe('writeFileStd', () => {
|
|
182
|
+
//-- disable warning about using filestd in tests
|
|
183
|
+
const ORIGINAL_CONSOLE = global.console;
|
|
184
|
+
global.beforeEach(() => {
|
|
185
|
+
global.console = ({
|
|
186
|
+
error: jest.fn(),
|
|
187
|
+
log: jest.fn(),
|
|
188
|
+
warn: jest.fn()
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
global.afterAll(() => {
|
|
192
|
+
global.console = ORIGINAL_CONSOLE;
|
|
193
|
+
});
|
|
194
|
+
|
|
182
195
|
global.it('writes text', () => {
|
|
183
196
|
const path = './tmp/sampleFile';
|
|
184
197
|
const message = 'Success';
|