@jbrowse/plugin-trix 3.7.0 → 4.0.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/esm/TrixTextSearchAdapter/TrixTextSearchAdapter.js +3 -0
- package/esm/TrixTextSearchAdapter/configSchema.d.ts +2 -2
- package/esm/index.js +3 -6
- package/package.json +20 -29
- package/dist/TrixTextSearchAdapter/TrixTextSearchAdapter.d.ts +0 -14
- package/dist/TrixTextSearchAdapter/TrixTextSearchAdapter.js +0 -73
- package/dist/TrixTextSearchAdapter/configSchema.d.ts +0 -34
- package/dist/TrixTextSearchAdapter/configSchema.js +0 -56
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -59
|
@@ -20,6 +20,9 @@ function shorten(str, term, w = 15) {
|
|
|
20
20
|
(tidx + term.length < str.length ? '...' : '');
|
|
21
21
|
}
|
|
22
22
|
export default class TrixTextSearchAdapter extends BaseAdapter {
|
|
23
|
+
indexingAttributes;
|
|
24
|
+
trixJs;
|
|
25
|
+
tracksNames;
|
|
23
26
|
constructor(config, getSubAdapter, pluginManager) {
|
|
24
27
|
super(config, getSubAdapter, pluginManager);
|
|
25
28
|
const ixFilePath = readConfObject(config, 'ixFilePath');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const TrixTextSearchAdapter: import("
|
|
1
|
+
declare const TrixTextSearchAdapter: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
2
|
ixFilePath: {
|
|
3
3
|
type: string;
|
|
4
4
|
defaultValue: {
|
|
@@ -30,5 +30,5 @@ declare const TrixTextSearchAdapter: import("@jbrowse/core/configuration/configu
|
|
|
30
30
|
defaultValue: never[];
|
|
31
31
|
description: string;
|
|
32
32
|
};
|
|
33
|
-
}, import("
|
|
33
|
+
}, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "textSearchAdapterId">>;
|
|
34
34
|
export default TrixTextSearchAdapter;
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
2
|
import TextSearchAdapterType from '@jbrowse/core/pluggableElementTypes/TextSearchAdapterType';
|
|
3
|
-
import configSchema from
|
|
3
|
+
import configSchema from "./TrixTextSearchAdapter/configSchema.js";
|
|
4
4
|
export default class TrixPlugin extends Plugin {
|
|
5
|
-
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.name = 'TrixPlugin';
|
|
8
|
-
}
|
|
5
|
+
name = 'TrixPlugin';
|
|
9
6
|
install(pluginManager) {
|
|
10
7
|
pluginManager.addTextSearchAdapterType(() => {
|
|
11
8
|
return new TextSearchAdapterType({
|
|
@@ -13,7 +10,7 @@ export default class TrixPlugin extends Plugin {
|
|
|
13
10
|
displayName: 'Trix text search adapter',
|
|
14
11
|
configSchema,
|
|
15
12
|
description: 'Trix text search adapter',
|
|
16
|
-
getAdapterClass: () => import(
|
|
13
|
+
getAdapterClass: () => import("./TrixTextSearchAdapter/TrixTextSearchAdapter.js").then(d => d.default),
|
|
17
14
|
});
|
|
18
15
|
});
|
|
19
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-trix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "JBrowse 2 trix text search adapter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -15,42 +15,33 @@
|
|
|
15
15
|
"directory": "plugins/trix"
|
|
16
16
|
},
|
|
17
17
|
"author": "JBrowse Team",
|
|
18
|
-
"
|
|
19
|
-
"srcMain": "src/index.ts",
|
|
20
|
-
"main": "dist/index.js",
|
|
18
|
+
"main": "esm/index.js",
|
|
21
19
|
"files": [
|
|
22
|
-
"dist",
|
|
23
20
|
"esm"
|
|
24
21
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "npm-run-all build:*",
|
|
27
|
-
"test": "cd ../..; jest --passWithNoTests plugins/trix",
|
|
28
|
-
"prepublishOnly": "yarn test",
|
|
29
|
-
"prepack": "yarn build && yarn useDist",
|
|
30
|
-
"postpack": "yarn useSrc",
|
|
31
|
-
"useDist": "node ../../scripts/useDist.js",
|
|
32
|
-
"useSrc": "node ../../scripts/useSrc.js",
|
|
33
|
-
"prebuild": "npm run clean",
|
|
34
|
-
"build:esm": "tsc --build tsconfig.build.esm.json",
|
|
35
|
-
"build:commonjs": "tsc --build tsconfig.build.commonjs.json",
|
|
36
|
-
"clean": "rimraf dist esm *.tsbuildinfo"
|
|
37
|
-
},
|
|
38
22
|
"peerDependencies": {
|
|
39
23
|
"react": ">=18.0.0"
|
|
40
24
|
},
|
|
41
25
|
"dependencies": {
|
|
42
|
-
"@gmod/trix": "^3.0.
|
|
43
|
-
"@jbrowse/core": "^
|
|
44
|
-
"@mui/material": "^7.0.0",
|
|
45
|
-
"mobx": "^6.0.0",
|
|
46
|
-
"mobx-react": "^9.0.0",
|
|
47
|
-
"mobx-state-tree": "^5.0.0"
|
|
26
|
+
"@gmod/trix": "^3.0.4",
|
|
27
|
+
"@jbrowse/core": "^4.0.1"
|
|
48
28
|
},
|
|
49
29
|
"publishConfig": {
|
|
50
30
|
"access": "public"
|
|
51
31
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "pnpm run /^build:/",
|
|
35
|
+
"test": "cd ../..; jest --passWithNoTests plugins/trix",
|
|
36
|
+
"prebuild": "pnpm clean",
|
|
37
|
+
"build:esm": "tsc -p tsconfig.build.esm.json",
|
|
38
|
+
"clean": "rimraf esm *.tsbuildinfo"
|
|
39
|
+
},
|
|
40
|
+
"types": "esm/index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./esm/index.d.ts",
|
|
44
|
+
"import": "./esm/index.js"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Trix from '@gmod/trix';
|
|
2
|
-
import BaseResult from '@jbrowse/core/TextSearch/BaseResults';
|
|
3
|
-
import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
-
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
5
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
6
|
-
import type { BaseTextSearchAdapter, BaseTextSearchArgs } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
7
|
-
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
8
|
-
export default class TrixTextSearchAdapter extends BaseAdapter implements BaseTextSearchAdapter {
|
|
9
|
-
indexingAttributes?: string[];
|
|
10
|
-
trixJs: Trix;
|
|
11
|
-
tracksNames?: string[];
|
|
12
|
-
constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
13
|
-
searchIndex(args: BaseTextSearchArgs): Promise<BaseResult[]>;
|
|
14
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const trix_1 = __importDefault(require("@gmod/trix"));
|
|
7
|
-
const BaseResults_1 = __importDefault(require("@jbrowse/core/TextSearch/BaseResults"));
|
|
8
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
9
|
-
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
10
|
-
const io_1 = require("@jbrowse/core/util/io");
|
|
11
|
-
function decodeURIComponentNoThrow(uri) {
|
|
12
|
-
try {
|
|
13
|
-
return decodeURIComponent(uri);
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
return uri;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function shorten(str, term, w = 15) {
|
|
20
|
-
const tidx = str.toLowerCase().indexOf(term);
|
|
21
|
-
return str.length < 40
|
|
22
|
-
? str
|
|
23
|
-
: (Math.max(0, tidx - w) > 0 ? '...' : '') +
|
|
24
|
-
str.slice(Math.max(0, tidx - w), tidx + term.length + w).trim() +
|
|
25
|
-
(tidx + term.length < str.length ? '...' : '');
|
|
26
|
-
}
|
|
27
|
-
class TrixTextSearchAdapter extends BaseAdapter_1.BaseAdapter {
|
|
28
|
-
constructor(config, getSubAdapter, pluginManager) {
|
|
29
|
-
super(config, getSubAdapter, pluginManager);
|
|
30
|
-
const ixFilePath = (0, configuration_1.readConfObject)(config, 'ixFilePath');
|
|
31
|
-
const ixxFilePath = (0, configuration_1.readConfObject)(config, 'ixxFilePath');
|
|
32
|
-
if (!ixFilePath) {
|
|
33
|
-
throw new Error('must provide out.ix');
|
|
34
|
-
}
|
|
35
|
-
if (!ixxFilePath) {
|
|
36
|
-
throw new Error('must provide out.ixx');
|
|
37
|
-
}
|
|
38
|
-
this.trixJs = new trix_1.default((0, io_1.openLocation)(ixxFilePath, pluginManager), (0, io_1.openLocation)(ixFilePath, pluginManager), 1500);
|
|
39
|
-
}
|
|
40
|
-
async searchIndex(args) {
|
|
41
|
-
const query = args.queryString.toLowerCase();
|
|
42
|
-
const strs = query.split(' ');
|
|
43
|
-
const results = await this.trixJs.search(query);
|
|
44
|
-
const formatted = results
|
|
45
|
-
.filter(([, data]) => strs.every(r => decodeURIComponentNoThrow(data).toLowerCase().includes(r)))
|
|
46
|
-
.map(([term, data]) => {
|
|
47
|
-
const result = JSON.parse(data.replaceAll('|', ','));
|
|
48
|
-
const [loc, trackId, ...rest] = result.map(record => decodeURIComponentNoThrow(record));
|
|
49
|
-
const labelFieldIdx = rest.findIndex(elt => !!elt);
|
|
50
|
-
const contextIdx = rest
|
|
51
|
-
.map(elt => elt.toLowerCase())
|
|
52
|
-
.findIndex(f => f.includes(term.toLowerCase()));
|
|
53
|
-
const labelField = rest[labelFieldIdx];
|
|
54
|
-
const contextField = rest[contextIdx];
|
|
55
|
-
const context = contextIdx !== -1 ? shorten(contextField, term) : undefined;
|
|
56
|
-
const label = shorten(labelField, term);
|
|
57
|
-
const displayString = !context || label.toLowerCase() === context.toLowerCase()
|
|
58
|
-
? label
|
|
59
|
-
: `${label} (${context})`;
|
|
60
|
-
return new BaseResults_1.default({
|
|
61
|
-
locString: loc,
|
|
62
|
-
label: labelField,
|
|
63
|
-
displayString,
|
|
64
|
-
matchedObject: result.map(record => decodeURIComponent(record)),
|
|
65
|
-
trackId,
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
return args.searchType === 'exact'
|
|
69
|
-
? formatted.filter(r => r.getLabel().toLowerCase() === args.queryString.toLowerCase())
|
|
70
|
-
: formatted;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.default = TrixTextSearchAdapter;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
declare const TrixTextSearchAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
ixFilePath: {
|
|
3
|
-
type: string;
|
|
4
|
-
defaultValue: {
|
|
5
|
-
uri: string;
|
|
6
|
-
locationType: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
ixxFilePath: {
|
|
10
|
-
type: string;
|
|
11
|
-
defaultValue: {
|
|
12
|
-
uri: string;
|
|
13
|
-
locationType: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
metaFilePath: {
|
|
17
|
-
type: string;
|
|
18
|
-
defaultValue: {
|
|
19
|
-
uri: string;
|
|
20
|
-
locationType: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
tracks: {
|
|
24
|
-
type: string;
|
|
25
|
-
defaultValue: never[];
|
|
26
|
-
description: string;
|
|
27
|
-
};
|
|
28
|
-
assemblyNames: {
|
|
29
|
-
type: string;
|
|
30
|
-
defaultValue: never[];
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "textSearchAdapterId">>;
|
|
34
|
-
export default TrixTextSearchAdapter;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
-
function x() { }
|
|
5
|
-
const TrixTextSearchAdapter = (0, configuration_1.ConfigurationSchema)('TrixTextSearchAdapter', {
|
|
6
|
-
ixFilePath: {
|
|
7
|
-
type: 'fileLocation',
|
|
8
|
-
defaultValue: {
|
|
9
|
-
uri: 'out.ix',
|
|
10
|
-
locationType: 'UriLocation',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
ixxFilePath: {
|
|
14
|
-
type: 'fileLocation',
|
|
15
|
-
defaultValue: {
|
|
16
|
-
uri: 'out.ixx',
|
|
17
|
-
locationType: 'UriLocation',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
metaFilePath: {
|
|
21
|
-
type: 'fileLocation',
|
|
22
|
-
defaultValue: {
|
|
23
|
-
uri: 'meta.json',
|
|
24
|
-
locationType: 'UriLocation',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
tracks: {
|
|
28
|
-
type: 'stringArray',
|
|
29
|
-
defaultValue: [],
|
|
30
|
-
description: 'List of tracks covered by text search adapter',
|
|
31
|
-
},
|
|
32
|
-
assemblyNames: {
|
|
33
|
-
type: 'stringArray',
|
|
34
|
-
defaultValue: [],
|
|
35
|
-
description: 'List of assemblies covered by text search adapter',
|
|
36
|
-
},
|
|
37
|
-
}, {
|
|
38
|
-
explicitlyTyped: true,
|
|
39
|
-
explicitIdentifier: 'textSearchAdapterId',
|
|
40
|
-
preProcessSnapshot: snap => {
|
|
41
|
-
return snap.uri
|
|
42
|
-
? {
|
|
43
|
-
...snap,
|
|
44
|
-
ixFilePath: {
|
|
45
|
-
uri: snap.uri,
|
|
46
|
-
baseUri: snap.baseUri,
|
|
47
|
-
},
|
|
48
|
-
ixxFilePath: {
|
|
49
|
-
uri: `${snap.uri}x`,
|
|
50
|
-
baseUri: snap.baseUri,
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
: snap;
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
exports.default = TrixTextSearchAdapter;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
40
|
-
const TextSearchAdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/TextSearchAdapterType"));
|
|
41
|
-
const configSchema_1 = __importDefault(require("./TrixTextSearchAdapter/configSchema"));
|
|
42
|
-
class TrixPlugin extends Plugin_1.default {
|
|
43
|
-
constructor() {
|
|
44
|
-
super(...arguments);
|
|
45
|
-
this.name = 'TrixPlugin';
|
|
46
|
-
}
|
|
47
|
-
install(pluginManager) {
|
|
48
|
-
pluginManager.addTextSearchAdapterType(() => {
|
|
49
|
-
return new TextSearchAdapterType_1.default({
|
|
50
|
-
name: 'TrixTextSearchAdapter',
|
|
51
|
-
displayName: 'Trix text search adapter',
|
|
52
|
-
configSchema: configSchema_1.default,
|
|
53
|
-
description: 'Trix text search adapter',
|
|
54
|
-
getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./TrixTextSearchAdapter/TrixTextSearchAdapter'))).then(d => d.default),
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.default = TrixPlugin;
|