@jbrowse/text-indexing 2.16.0 → 2.17.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/dist/types/common.d.ts +6 -7
- package/dist/types/common.js +18 -12
- package/dist/types/gff3Adapter.js +5 -6
- package/dist/types/vcfAdapter.js +5 -6
- package/esm/types/common.d.ts +6 -7
- package/esm/types/common.js +18 -12
- package/esm/types/gff3Adapter.js +5 -6
- package/esm/types/vcfAdapter.js +5 -6
- package/package.json +3 -3
package/dist/types/common.d.ts
CHANGED
|
@@ -3,13 +3,12 @@ import fetch from 'node-fetch';
|
|
|
3
3
|
import { LocalPathLocation, UriLocation, Track } from '../util';
|
|
4
4
|
export declare function createRemoteStream(urlIn: string): Promise<fetch.Response>;
|
|
5
5
|
export declare function isURL(FileName: string): boolean;
|
|
6
|
-
export declare function getLocalOrRemoteStream(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
totalBytes: number;
|
|
11
|
-
|
|
12
|
-
}>;
|
|
6
|
+
export declare function getLocalOrRemoteStream({ file, out, onBytesReceived, onTotalBytes, }: {
|
|
7
|
+
file: string;
|
|
8
|
+
out: string;
|
|
9
|
+
onBytesReceived: (totalBytesReceived: number) => void;
|
|
10
|
+
onTotalBytes: (totalBytes: number) => void;
|
|
11
|
+
}): Promise<NodeJS.ReadableStream | fs.ReadStream>;
|
|
13
12
|
export declare function makeLocation(location: string, protocol: string): UriLocation | LocalPathLocation;
|
|
14
13
|
export declare function guessAdapterFromFileName(filePath: string): Track;
|
|
15
14
|
/**
|
package/dist/types/common.js
CHANGED
|
@@ -33,20 +33,26 @@ function isURL(FileName) {
|
|
|
33
33
|
}
|
|
34
34
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
35
35
|
}
|
|
36
|
-
async function getLocalOrRemoteStream(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
async function getLocalOrRemoteStream({ file, out, onBytesReceived, onTotalBytes, }) {
|
|
37
|
+
let receivedBytes = 0;
|
|
38
|
+
if (isURL(file)) {
|
|
39
|
+
const result = await createRemoteStream(file);
|
|
40
|
+
result.body.on('data', chunk => {
|
|
41
|
+
receivedBytes += chunk.length;
|
|
42
|
+
onBytesReceived(receivedBytes);
|
|
43
|
+
});
|
|
44
|
+
onTotalBytes(+(result.headers.get('Content-Length') || 0));
|
|
45
|
+
return result.body;
|
|
43
46
|
}
|
|
44
47
|
else {
|
|
45
|
-
const filename = path_1.default.isAbsolute(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const filename = path_1.default.isAbsolute(file) ? file : path_1.default.join(out, file);
|
|
49
|
+
const stream = fs_1.default.createReadStream(filename);
|
|
50
|
+
stream.on('data', chunk => {
|
|
51
|
+
receivedBytes += chunk.length;
|
|
52
|
+
onBytesReceived(receivedBytes);
|
|
53
|
+
});
|
|
54
|
+
onTotalBytes(fs_1.default.statSync(filename).size);
|
|
55
|
+
return stream;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
function makeLocation(location, protocol) {
|
|
@@ -11,12 +11,11 @@ const util_1 = require("../util");
|
|
|
11
11
|
const common_1 = require("./common");
|
|
12
12
|
async function* indexGff3({ config, attributesToIndex, inLocation, outDir, featureTypesToExclude, onStart, onUpdate, }) {
|
|
13
13
|
const { trackId } = config;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onUpdate(receivedBytes);
|
|
14
|
+
const stream = await (0, common_1.getLocalOrRemoteStream)({
|
|
15
|
+
file: inLocation,
|
|
16
|
+
out: outDir,
|
|
17
|
+
onTotalBytes: onStart,
|
|
18
|
+
onBytesReceived: onUpdate,
|
|
20
19
|
});
|
|
21
20
|
const rl = readline_1.default.createInterface({
|
|
22
21
|
input: /.b?gz$/.exec(inLocation) ? stream.pipe((0, zlib_1.createGunzip)()) : stream,
|
package/dist/types/vcfAdapter.js
CHANGED
|
@@ -11,12 +11,11 @@ const util_1 = require("../util");
|
|
|
11
11
|
const common_1 = require("./common");
|
|
12
12
|
async function* indexVcf({ config, attributesToIndex, inLocation, outDir, onStart, onUpdate, }) {
|
|
13
13
|
const { trackId } = config;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onUpdate(receivedBytes);
|
|
14
|
+
const stream = await (0, common_1.getLocalOrRemoteStream)({
|
|
15
|
+
file: inLocation,
|
|
16
|
+
out: outDir,
|
|
17
|
+
onTotalBytes: onStart,
|
|
18
|
+
onBytesReceived: onUpdate,
|
|
20
19
|
});
|
|
21
20
|
const gzStream = /.b?gz$/.exec(inLocation)
|
|
22
21
|
? stream.pipe((0, zlib_1.createGunzip)())
|
package/esm/types/common.d.ts
CHANGED
|
@@ -3,13 +3,12 @@ import fetch from 'node-fetch';
|
|
|
3
3
|
import { LocalPathLocation, UriLocation, Track } from '../util';
|
|
4
4
|
export declare function createRemoteStream(urlIn: string): Promise<fetch.Response>;
|
|
5
5
|
export declare function isURL(FileName: string): boolean;
|
|
6
|
-
export declare function getLocalOrRemoteStream(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
totalBytes: number;
|
|
11
|
-
|
|
12
|
-
}>;
|
|
6
|
+
export declare function getLocalOrRemoteStream({ file, out, onBytesReceived, onTotalBytes, }: {
|
|
7
|
+
file: string;
|
|
8
|
+
out: string;
|
|
9
|
+
onBytesReceived: (totalBytesReceived: number) => void;
|
|
10
|
+
onTotalBytes: (totalBytes: number) => void;
|
|
11
|
+
}): Promise<NodeJS.ReadableStream | fs.ReadStream>;
|
|
13
12
|
export declare function makeLocation(location: string, protocol: string): UriLocation | LocalPathLocation;
|
|
14
13
|
export declare function guessAdapterFromFileName(filePath: string): Track;
|
|
15
14
|
/**
|
package/esm/types/common.js
CHANGED
|
@@ -22,20 +22,26 @@ export function isURL(FileName) {
|
|
|
22
22
|
}
|
|
23
23
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
24
24
|
}
|
|
25
|
-
export async function getLocalOrRemoteStream(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
export async function getLocalOrRemoteStream({ file, out, onBytesReceived, onTotalBytes, }) {
|
|
26
|
+
let receivedBytes = 0;
|
|
27
|
+
if (isURL(file)) {
|
|
28
|
+
const result = await createRemoteStream(file);
|
|
29
|
+
result.body.on('data', chunk => {
|
|
30
|
+
receivedBytes += chunk.length;
|
|
31
|
+
onBytesReceived(receivedBytes);
|
|
32
|
+
});
|
|
33
|
+
onTotalBytes(+(result.headers.get('Content-Length') || 0));
|
|
34
|
+
return result.body;
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
34
|
-
const filename = path.isAbsolute(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const filename = path.isAbsolute(file) ? file : path.join(out, file);
|
|
38
|
+
const stream = fs.createReadStream(filename);
|
|
39
|
+
stream.on('data', chunk => {
|
|
40
|
+
receivedBytes += chunk.length;
|
|
41
|
+
onBytesReceived(receivedBytes);
|
|
42
|
+
});
|
|
43
|
+
onTotalBytes(fs.statSync(filename).size);
|
|
44
|
+
return stream;
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
export function makeLocation(location, protocol) {
|
package/esm/types/gff3Adapter.js
CHANGED
|
@@ -5,12 +5,11 @@ import { decodeURIComponentNoThrow } from '../util';
|
|
|
5
5
|
import { getLocalOrRemoteStream } from './common';
|
|
6
6
|
export async function* indexGff3({ config, attributesToIndex, inLocation, outDir, featureTypesToExclude, onStart, onUpdate, }) {
|
|
7
7
|
const { trackId } = config;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onUpdate(receivedBytes);
|
|
8
|
+
const stream = await getLocalOrRemoteStream({
|
|
9
|
+
file: inLocation,
|
|
10
|
+
out: outDir,
|
|
11
|
+
onTotalBytes: onStart,
|
|
12
|
+
onBytesReceived: onUpdate,
|
|
14
13
|
});
|
|
15
14
|
const rl = readline.createInterface({
|
|
16
15
|
input: /.b?gz$/.exec(inLocation) ? stream.pipe(createGunzip()) : stream,
|
package/esm/types/vcfAdapter.js
CHANGED
|
@@ -5,12 +5,11 @@ import { decodeURIComponentNoThrow } from '../util';
|
|
|
5
5
|
import { getLocalOrRemoteStream } from './common';
|
|
6
6
|
export async function* indexVcf({ config, attributesToIndex, inLocation, outDir, onStart, onUpdate, }) {
|
|
7
7
|
const { trackId } = config;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onUpdate(receivedBytes);
|
|
8
|
+
const stream = await getLocalOrRemoteStream({
|
|
9
|
+
file: inLocation,
|
|
10
|
+
out: outDir,
|
|
11
|
+
onTotalBytes: onStart,
|
|
12
|
+
onBytesReceived: onUpdate,
|
|
14
13
|
});
|
|
15
14
|
const gzStream = /.b?gz$/.exec(inLocation)
|
|
16
15
|
? stream.pipe(createGunzip())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/text-indexing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "JBrowse 2 text indexing for desktop",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "^7.16.3",
|
|
45
|
-
"@jbrowse/core": "^2.
|
|
45
|
+
"@jbrowse/core": "^2.17.0",
|
|
46
46
|
"ixixx": "^2.0.1",
|
|
47
47
|
"node-fetch": "^2.6.0",
|
|
48
48
|
"sanitize-filename": "^1.6.3"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "eed30b5e671f8f7823652d7cecc51aa89226de46"
|
|
62
62
|
}
|