Skip to content

Commit c4a6ef1

Browse files
committed
Update dependencies and make the library buildable again
1 parent d754f75 commit c4a6ef1

23 files changed

+14116
-11929
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
/.cache
77
/demo-dist
88
/docs/tmp
9+
/.parcel-cache

README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Big JSON Viewer
22

33
[![npm](https://img.shields.io/npm/v/big-json-viewer.svg)](https://www.npmjs.com/package/big-json-viewer)
4-
[![Travis](https://img.shields.io/travis/dhcode/big-json-viewer.svg)](https://travis-ci.org/dhcode/big-json-viewer)
54
[![Codecov](https://img.shields.io/codecov/c/github/dhcode/big-json-viewer.svg)](https://codecov.io/gh/dhcode/big-json-viewer)
65
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://www.npmjs.com/package/big-json-viewer)
76

@@ -26,7 +25,7 @@ test.ts
2625
```typescript
2726
import { BigJsonViewerDom } from 'big-json-viewer';
2827

29-
BigJsonViewerDom.fromData(JSON.stringify({ test: 23 })).then(viewer => {
28+
BigJsonViewerDom.fromData(JSON.stringify({ test: 23 })).then((viewer) => {
3029
const node = viewer.getRootElement();
3130
document.body.appendChild(node);
3231
node.openAll(1);
@@ -38,14 +37,14 @@ index.html
3837
```html
3938
<!DOCTYPE html>
4039
<html lang="en">
41-
<head>
42-
<meta charset="UTF-8">
43-
<title>Test</title>
44-
<link rel="stylesheet" href="./node_modules/big-json-viewer/styles/default.css">
45-
</head>
46-
<body>
47-
<script src="src/test.ts"></script>
48-
</body>
40+
<head>
41+
<meta charset="UTF-8" />
42+
<title>Test</title>
43+
<link rel="stylesheet" href="./node_modules/big-json-viewer/styles/default.css" />
44+
</head>
45+
<body>
46+
<script src="src/test.ts"></script>
47+
</body>
4948
</html>
5049
```
5150

@@ -110,11 +109,11 @@ Call this to free resources. It will terminate any by the instance started worke
110109

111110
Searches the tree by the specified `pattern` and `searchArea`. Returns a `TreeSearchCursor`, which contains all matches and methods to jump the focus between the matches.
112111

113-
* `openLimit` is `1` by default. But can be `Infinity` or any number.
114-
* `searchArea` describes where the pattern should be searched. Has the following options:
115-
* `'all'` search in keys and values (default)
116-
* `'keys'` search only in keys
117-
* `'values'` search only in values
112+
- `openLimit` is `1` by default. But can be `Infinity` or any number.
113+
- `searchArea` describes where the pattern should be searched. Has the following options:
114+
- `'all'` search in keys and values (default)
115+
- `'keys'` search only in keys
116+
- `'values'` search only in values
118117

119118
## `JsonNodeElement` methods
120119

@@ -138,11 +137,11 @@ Opens the specified path and returns the opened node, in case it was found.
138137

139138
Opens all nodes until the defined depth. Returns the number of opened nodes.
140139

141-
* `maxDepth` is `Infinity` by default
142-
* `paginated` is a string of the following options
143-
* `'first'` open only the first pagination stub (default)
144-
* `'all'` open all pagination stubs
145-
* `'none'` open no pagination stubs
140+
- `maxDepth` is `Infinity` by default
141+
- `paginated` is a string of the following options
142+
- `'first'` open only the first pagination stub (default)
143+
- `'all'` open all pagination stubs
144+
- `'none'` open no pagination stubs
146145

147146
#### `getOpenPaths(withStubs?: boolean): string[][]`
148147

@@ -162,7 +161,7 @@ Fires when a node is being opened by the user directly with a click. The target
162161
Example logs the opened path:
163162

164163
```javascript
165-
rootNode.addEventListener('openNode', function(e) {
164+
rootNode.addEventListener('openNode', function (e) {
166165
console.log('openNode', e.target.jsonNode.path);
167166
});
168167
```
@@ -197,8 +196,8 @@ If something has changed that affects the Docs/Demo page, run:
197196

198197
### Future TODOs
199198

200-
* Improve display of large strings.
201-
* Support JSON Schema. If provided show meta information from the schema definition.
199+
- Improve display of large strings.
200+
- Support JSON Schema. If provided show meta information from the schema definition.
202201

203202
## License
204203

docs-src/demo.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'babel-polyfill';
21
import { BigJsonViewerDom, JsonNodeElement } from '../src';
32

43
const demoData = {
@@ -11,9 +10,9 @@ const demoData = {
1110
element6: {
1211
name: 'Hero',
1312
age: 32,
14-
birthday: { year: 1986, month: 4, day: 30 }
13+
birthday: { year: 1986, month: 4, day: 30 },
1514
},
16-
element7: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
15+
element7: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
1716
},
1817
jsData: {
1918
element1: 'str',
@@ -24,12 +23,12 @@ const demoData = {
2423
element6: {
2524
name: 'Hero',
2625
age: 32,
27-
birthday: { year: 1986, month: 4, day: 30 }
26+
birthday: { year: 1986, month: 4, day: 30 },
2827
},
2928
element7: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
30-
element8: { un: undefined, nu: null }
29+
element8: { un: undefined, nu: null },
3130
},
32-
largeData: (function() {
31+
largeData: (function () {
3332
const list = new Array(Math.floor(Math.random() * 1000));
3433
for (let i = 0; i < list.length; i++) {
3534
list[i] = Math.random();
@@ -45,7 +44,7 @@ const demoData = {
4544
}
4645
}
4746
return list;
48-
})()
47+
})(),
4948
};
5049

5150
const codeElement = document.getElementById('code') as HTMLTextAreaElement;
@@ -54,7 +53,7 @@ const pathsElement = document.getElementById('paths') as HTMLTextAreaElement;
5453
const copiedElement = document.getElementById('copied') as HTMLInputElement;
5554
const searchElement = document.getElementById('search') as HTMLInputElement;
5655
const searchInfoElement = document.getElementById(
57-
'searchInfo'
56+
'searchInfo',
5857
) as HTMLSpanElement;
5958
let viewer = null;
6059
let rootNode = document.getElementById('rootNode') as JsonNodeElement;
@@ -63,29 +62,29 @@ querySelectorArray('[data-load]').forEach((link: any) => {
6362
const load = link.getAttribute('data-load');
6463
if (demoData[load] && !link.loadListener) {
6564
link.loadListener = true;
66-
link.addEventListener('click', e => {
65+
link.addEventListener('click', (e) => {
6766
e.preventDefault();
6867
loadStructureData(demoData[load], load === 'jsData');
6968
});
7069
}
7170
});
7271

73-
codeElement.addEventListener('input', e => {
72+
codeElement.addEventListener('input', (e) => {
7473
console.log('show data based on input');
7574
showData(codeElement.value);
7675
});
77-
searchElement.addEventListener('input', async e => {
76+
searchElement.addEventListener('input', async (e) => {
7877
if (searchElement.value.length >= 2) {
7978
const cursor = await viewer.openBySearch(
80-
new RegExp(searchElement.value, 'i')
79+
new RegExp(searchElement.value, 'i'),
8180
);
8281
searchInfoElement.textContent = cursor.matches.length + ' matches';
8382

8483
searchInfoElement.appendChild(document.createTextNode(' '));
8584

8685
const prevBtn = searchInfoElement.appendChild(document.createElement('a'));
8786
prevBtn.href = 'javascript:';
88-
prevBtn.addEventListener('click', e => {
87+
prevBtn.addEventListener('click', (e) => {
8988
e.preventDefault();
9089
cursor.previous();
9190
});
@@ -95,7 +94,7 @@ searchElement.addEventListener('input', async e => {
9594

9695
const nextBtn = searchInfoElement.appendChild(document.createElement('a'));
9796
nextBtn.href = 'javascript:';
98-
nextBtn.addEventListener('click', e => {
97+
nextBtn.addEventListener('click', (e) => {
9998
e.preventDefault();
10099
cursor.next();
101100
});
@@ -126,7 +125,7 @@ async function loadStructureData(structure, jsData = false) {
126125
async function showData(data: any, jsData = false) {
127126
const index =
128127
'showDataIndex' in viewerElement
129-
? ++viewerElement['showDataIndex']
128+
? ++(viewerElement['showDataIndex'] as number)
130129
: (viewerElement['showDataIndex'] = 0);
131130
if (viewerElement.children.length) {
132131
viewerElement.removeChild(viewerElement.children[0]);
@@ -161,7 +160,7 @@ async function showData(data: any, jsData = false) {
161160
}
162161

163162
function setupRootNode() {
164-
const listener = e => {
163+
const listener = (e) => {
165164
console.log('event', e.type);
166165
showPaths();
167166
};
@@ -170,7 +169,7 @@ function setupRootNode() {
170169
rootNode.addEventListener('openedNodes', listener);
171170
rootNode.addEventListener('openStub', listener);
172171
rootNode.addEventListener('closeStub', listener);
173-
rootNode.addEventListener('copyPath', e => {
172+
rootNode.addEventListener('copyPath', (e) => {
174173
const node = e.target as JsonNodeElement;
175174
copiedElement.value = node.jsonNode.path.join('.');
176175
});
@@ -183,7 +182,7 @@ function showPaths() {
183182

184183
pathsElement.value = rootNode
185184
.getOpenPaths()
186-
.map(path => path.join('.'))
185+
.map((path) => path.join('.'))
187186
.join('\n');
188187
}
189188

docs-src/index.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
@@ -19,7 +19,13 @@
1919
<body>
2020
<div
2121
class="p-3"
22-
style="position: fixed; top: 0; right: 0; background: white; border: 1px solid #ccc"
22+
style="
23+
position: fixed;
24+
top: 0;
25+
right: 0;
26+
background: white;
27+
border: 1px solid #ccc;
28+
"
2329
>
2430
<input type="text" placeholder="Search" id="search" />
2531
<span id="searchInfo"></span>
@@ -43,7 +49,12 @@ <h4 class="mt-3">JSON text</h4>
4349
<div>
4450
<textarea
4551
id="code"
46-
style="min-height: 15em; width: 100%; font-family: monospace, serif; font-size: 0.8em"
52+
style="
53+
min-height: 15em;
54+
width: 100%;
55+
font-family: monospace, serif;
56+
font-size: 0.8em;
57+
"
4758
></textarea>
4859
</div>
4960

@@ -55,7 +66,12 @@ <h5 class="mt-3">Open paths</h5>
5566
<div>
5667
<textarea
5768
id="paths"
58-
style="min-height: 6em; width: 100%; font-family: monospace, serif; font-size: 0.8em"
69+
style="
70+
min-height: 6em;
71+
width: 100%;
72+
font-family: monospace, serif;
73+
font-size: 0.8em;
74+
"
5975
></textarea>
6076
</div>
6177

@@ -73,6 +89,6 @@ <h5 class="mt-3">Copied paths</h5>
7389
</footer>
7490
</div>
7591

76-
<script src="demo.ts"></script>
92+
<script type="module" src="./demo.ts"></script>
7793
</body>
7894
</html>

docs/default.40d73132.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/default.40d73132.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)