@jbrowse/text-indexing 4.0.2 → 4.0.4

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.
@@ -18,6 +18,17 @@ export function isURL(FileName) {
18
18
  }
19
19
  return url.protocol === 'http:' || url.protocol === 'https:';
20
20
  }
21
+ function fileUrlToPath(fileUrl) {
22
+ try {
23
+ const url = new URL(fileUrl);
24
+ if (url.protocol === 'file:') {
25
+ return url.pathname;
26
+ }
27
+ }
28
+ catch {
29
+ }
30
+ return undefined;
31
+ }
21
32
  export async function getLocalOrRemoteStream({ file, out, onBytesReceived, onTotalBytes, }) {
22
33
  let receivedBytes = 0;
23
34
  if (isURL(file)) {
@@ -30,7 +41,10 @@ export async function getLocalOrRemoteStream({ file, out, onBytesReceived, onTot
30
41
  return result.body;
31
42
  }
32
43
  else {
33
- const filename = path.isAbsolute(file) ? file : path.join(out, file);
44
+ const localPath = fileUrlToPath(file) ?? file;
45
+ const filename = path.isAbsolute(localPath)
46
+ ? localPath
47
+ : path.join(out, localPath);
34
48
  const stream = fs.createReadStream(filename);
35
49
  stream.on('data', chunk => {
36
50
  receivedBytes += chunk.length;
package/esm/util.d.ts CHANGED
@@ -89,9 +89,9 @@ export interface TextSearching {
89
89
  export interface TrixTextSearchAdapter {
90
90
  type: string;
91
91
  textSearchAdapterId: string;
92
- ixFilePath: UriLocation;
93
- ixxFilePath: UriLocation;
94
- metaFilePath: UriLocation;
92
+ ixFilePath: UriLocation | LocalPathLocation;
93
+ ixxFilePath: UriLocation | LocalPathLocation;
94
+ metaFilePath: UriLocation | LocalPathLocation;
95
95
  assemblyNames: string[];
96
96
  }
97
97
  export interface Config {
@@ -109,15 +109,15 @@ export declare function createTextSearchConf(name: string, trackIds: string[], a
109
109
  textSearchAdapterId: string;
110
110
  ixFilePath: {
111
111
  localPath: string;
112
- locationType: string;
112
+ locationType: "LocalPathLocation";
113
113
  };
114
114
  ixxFilePath: {
115
115
  localPath: string;
116
- locationType: string;
116
+ locationType: "LocalPathLocation";
117
117
  };
118
118
  metaFilePath: {
119
119
  localPath: string;
120
- locationType: string;
120
+ locationType: "LocalPathLocation";
121
121
  };
122
122
  tracks: string[];
123
123
  assemblyNames: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/text-indexing",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "JBrowse 2 text indexing for desktop",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -26,7 +26,7 @@
26
26
  "ixixx": "^3.0.2",
27
27
  "node-fetch": "^2.7.0",
28
28
  "sanitize-filename": "^1.6.3",
29
- "@jbrowse/core": "^4.0.2"
29
+ "@jbrowse/core": "^4.0.4"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=18.0.0",