@jbrowse/img 2.2.0 → 2.2.2

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/README.md CHANGED
@@ -107,10 +107,7 @@ Some jbrowse track types (alignments, gene tracks, etc) will not display if
107
107
  zoomed too far out. Add force:true to make it render
108
108
 
109
109
  ```bash
110
- jb2export --config data/config.json \
111
- --loc 1:1,100,000-1,200,000 \
112
- --assembly hg19 \
113
- --configtracks hg00096_lowcov force:true
110
+ jb2export --bam file.bam force:true --loc 1:1,100,000-1,200,000 --fasta hg19.fa
114
111
  ```
115
112
 
116
113
  ### Render the sequence track
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
-
4
- require('./index.js');
3
+ require('./index.js');
4
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.js"],"names":[],"mappings":";;AACA,OAAO,CAAC,YAAY,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
package/dist/index.js CHANGED
@@ -1,209 +1,214 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _yargs = _interopRequireDefault(require("yargs"));
9
- var _parseArgv = require("./parseArgv");
10
- var _renderRegion = require("./renderRegion");
11
- var _tmp = _interopRequireDefault(require("tmp"));
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const fs_1 = __importDefault(require("fs"));
30
+ const yargs_1 = __importDefault(require("yargs"));
12
31
  require("abortcontroller-polyfill/dist/abortcontroller-polyfill-only");
13
- var _child_process = require("child_process");
14
- var _nodeFetch = _interopRequireWildcard(require("node-fetch"));
15
- var _jsdom = require("jsdom");
16
- var _canvas = require("canvas");
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
- /* eslint-disable no-console */
20
-
21
- global.nodeImage = _canvas.Image;
22
- global.nodeCreateCanvas = _canvas.createCanvas;
23
- var document = new _jsdom.JSDOM("...").window.document;
32
+ const node_fetch_1 = __importStar(require("node-fetch"));
33
+ const jsdom_1 = require("jsdom");
34
+ const canvas_1 = require("canvas");
35
+ // locals
36
+ const parseArgv_1 = require("./parseArgv");
37
+ const renderRegion_1 = require("./renderRegion");
38
+ const util_1 = require("./util");
39
+ // @ts-ignore
40
+ global.nodeImage = canvas_1.Image;
41
+ // @ts-ignore
42
+ global.nodeCreateCanvas = canvas_1.createCanvas;
43
+ const { document } = new jsdom_1.JSDOM(`...`).window;
24
44
  global.document = document;
25
- if (!global.fetch) {
26
- global.fetch = _nodeFetch.default;
27
- global.Headers = _nodeFetch.Headers;
28
- global.Response = _nodeFetch.Response;
29
- global.Request = _nodeFetch.Request;
30
- }
31
- var err = console.error;
32
- console.error = function () {
33
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
34
- args[_key] = arguments[_key];
35
- }
36
- if ("".concat(args[0]).match('useLayoutEffect')) {
37
- return null;
38
- } else {
39
- err(args);
40
- }
45
+ // force use of node-fetch polyfill, even if node 18+ fetch is available.
46
+ // native node 18+ fetch currently gives errors related to unidici and
47
+ // Uint8Array:
48
+ //
49
+ //
50
+ // % node --version
51
+ // v18.12.1
52
+ //
53
+ // % jb2export --fasta https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.fa --bam https://jbrowse.org/code/jb2/main/test_data/volvox/volvox-sorted.bam --loc ctgA:1-1000 --out out4.svg
54
+ // [
55
+ // '(node:1387934) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time\n' +
56
+ // '(Use `node --trace-warnings ...` to show where the warning was created)'
57
+ // ]
58
+ // [
59
+ // RangeError: offset is out of bounds
60
+ // at Uint8Array.set (<anonymous>)
61
+ // at Response.arrayBuffer (node:internal/deps/undici/undici:6117:23)
62
+ // at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
63
+ // ]
64
+ // @ts-ignore
65
+ global.fetch = node_fetch_1.default;
66
+ // @ts-ignore
67
+ global.Headers = node_fetch_1.Headers;
68
+ // @ts-ignore
69
+ global.Response = node_fetch_1.Response;
70
+ // @ts-ignore
71
+ global.Request = node_fetch_1.Request;
72
+ const err = console.error;
73
+ console.error = (...p) => {
74
+ if (!`${p[0]}`.match('useLayoutEffect')) {
75
+ err(p);
76
+ }
41
77
  };
42
- console.warn = function () {
43
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
44
- args[_key2] = arguments[_key2];
45
- }
46
- if ("".concat(args[0]).match('estimation reached timeout')) {
47
- return null;
48
- } else {
49
- err(args);
50
- }
78
+ const warn = console.warn;
79
+ console.warn = (...p) => {
80
+ if (!`${p[0]}`.match('estimation reached timeout')) {
81
+ warn(p);
82
+ }
51
83
  };
52
-
53
- // eslint-disable-next-line no-unused-expressions
54
- _yargs.default.command('jb2export', 'Creates a jbrowse 2 image snapshot').option('config', {
55
- description: 'Path to config file',
56
- type: 'string'
57
- }).option('session', {
58
- description: 'Path to session file',
59
- type: 'string'
60
- }).option('assembly', {
61
- description: 'Path to an assembly configuration, or a name of an assembly in the configFile',
62
- type: 'string'
63
- }).option('tracks', {
64
- description: 'Path to tracks portion of a session',
65
- type: 'string'
66
- }).option('loc', {
67
- description: 'A locstring to navigate to, or --loc all to view the whole genome',
68
- type: 'string'
69
- }).option('fasta', {
70
- description: 'Supply a fasta for the assembly',
71
- type: 'string'
72
- }).option('aliases', {
73
- description: 'Supply aliases for the assembly, e.g. mapping of 1 to chr1. Tab separated file where column 1 matches the names from the FASTA',
74
- type: 'string'
75
- }).option('width', {
76
- description: 'Set the width of the window that jbrowse renders to, default: 1500px',
77
- type: 'number'
78
- }).option('pngwidth', {
79
- description: 'Set the width of the png canvas if using png output, default 2048px',
80
- type: 'number',
81
- default: 2048
82
- })
83
- // track types
84
- .option('configtracks', {
85
- description: 'A list of track labels from a config file',
86
- type: 'array'
87
- }).option('bam', {
88
- description: 'A bam file, flag --bam can be used multiple times to specify multiple bam files',
89
- type: 'array'
90
- }).option('bigwig', {
91
- description: 'A bigwig file, the --bigwig flag can be used multiple times to specify multiple bigwig files',
92
- type: 'array'
93
- }).option('cram', {
94
- description: 'A cram file, the --cram flag can be used multiple times to specify multiple cram files',
95
- type: 'array'
96
- }).option('vcfgz', {
97
- description: 'A tabixed VCF, the --vcfgz flag can be used multiple times to specify multiple vcfgz files',
98
- type: 'array'
99
- }).option('gffgz', {
100
- description: 'A tabixed GFF, the --gffgz can be used multiple times to specify multiple gffgz files',
101
- type: 'array'
102
- }).option('hic', {
103
- description: 'A .hic file, the --hic can be used multiple times to specify multiple hic files',
104
- type: 'array'
105
- }).option('bigbed', {
106
- description: 'A .bigBed file, the --bigbed can be used multiple times to specify multiple bigbed files',
107
- type: 'array'
108
- }).option('bedgz', {
109
- description: 'A bed tabix file, the --bedgz can be used multiple times to specify multiple bedtabix files',
110
- type: 'array'
111
- })
112
-
113
- // other
114
- .option('out', {
115
- description: 'File to output to. Default: out.svg. If a filename with extension .png is supplied the program will try to automatically execute rsvg-convert to convert it to png',
116
- type: 'string',
117
- default: 'out.svg'
118
- }).option('noRasterize', {
119
- description: 'Use full SVG rendering with no rasterized layers, this can substantially increase filesize',
120
- type: 'boolean'
121
- }).option('defaultSession', {
122
- description: 'Use the defaultSession from config.json',
123
- type: 'boolean'
124
- }).help().alias('help', 'h').alias('width', 'w').argv;
125
-
126
- // prints to stderr the time it takes to execute cb
127
- function time(_x) {
128
- return _time.apply(this, arguments);
129
- }
130
- function _time() {
131
- _time = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(cb) {
132
- var start, ret;
133
- return _regenerator.default.wrap(function _callee2$(_context2) {
134
- while (1) {
135
- switch (_context2.prev = _context2.next) {
136
- case 0:
137
- start = +Date.now();
138
- _context2.next = 3;
139
- return cb();
140
- case 3:
141
- ret = _context2.sent;
142
- console.log("Finished rendering: ".concat((+Date.now() - start) / 1000, "s"));
143
- return _context2.abrupt("return", ret);
144
- case 6:
145
- case "end":
146
- return _context2.stop();
84
+ // note: yargs is actually unused except for printing help
85
+ // we do custom command line parsing, see parseArgv.ts
86
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
87
+ yargs_1.default
88
+ .command('jb2export', 'Creates a jbrowse 2 image snapshot')
89
+ .option('config', {
90
+ description: 'Path to config file',
91
+ type: 'string',
92
+ })
93
+ .option('session', {
94
+ description: 'Path to session file',
95
+ type: 'string',
96
+ })
97
+ .option('assembly', {
98
+ description: 'Path to an assembly configuration, or a name of an assembly in the configFile',
99
+ type: 'string',
100
+ })
101
+ .option('tracks', {
102
+ description: 'Path to tracks portion of a session',
103
+ type: 'string',
104
+ })
105
+ .option('loc', {
106
+ description: 'A locstring to navigate to, or --loc all to view the whole genome',
107
+ type: 'string',
108
+ })
109
+ .option('fasta', {
110
+ description: 'Supply a fasta for the assembly',
111
+ type: 'string',
112
+ })
113
+ .option('aliases', {
114
+ description: 'Supply aliases for the assembly, e.g. mapping of 1 to chr1. Tab separated file where column 1 matches the names from the FASTA',
115
+ type: 'string',
116
+ })
117
+ .option('width', {
118
+ description: 'Set the width of the window that jbrowse renders to, default: 1500px',
119
+ type: 'number',
120
+ })
121
+ .option('pngwidth', {
122
+ description: 'Set the width of the png canvas if using png output, default 2048px',
123
+ type: 'number',
124
+ default: 2048,
125
+ })
126
+ // track types
127
+ .option('configtracks', {
128
+ description: 'A list of track labels from a config file',
129
+ type: 'array',
130
+ })
131
+ .option('bam', {
132
+ description: 'A bam file, flag --bam can be used multiple times to specify multiple bam files',
133
+ type: 'array',
134
+ })
135
+ .option('bigwig', {
136
+ description: 'A bigwig file, the --bigwig flag can be used multiple times to specify multiple bigwig files',
137
+ type: 'array',
138
+ })
139
+ .option('cram', {
140
+ description: 'A cram file, the --cram flag can be used multiple times to specify multiple cram files',
141
+ type: 'array',
142
+ })
143
+ .option('vcfgz', {
144
+ description: 'A tabixed VCF, the --vcfgz flag can be used multiple times to specify multiple vcfgz files',
145
+ type: 'array',
146
+ })
147
+ .option('gffgz', {
148
+ description: 'A tabixed GFF, the --gffgz can be used multiple times to specify multiple gffgz files',
149
+ type: 'array',
150
+ })
151
+ .option('hic', {
152
+ description: 'A .hic file, the --hic can be used multiple times to specify multiple hic files',
153
+ type: 'array',
154
+ })
155
+ .option('bigbed', {
156
+ description: 'A .bigBed file, the --bigbed can be used multiple times to specify multiple bigbed files',
157
+ type: 'array',
158
+ })
159
+ .option('bedgz', {
160
+ description: 'A bed tabix file, the --bedgz can be used multiple times to specify multiple bedtabix files',
161
+ type: 'array',
162
+ })
163
+ // other
164
+ .option('out', {
165
+ description: 'File to output to. Default: out.svg. If a filename with extension .png is supplied the program will try to automatically execute rsvg-convert to convert it to png',
166
+ type: 'string',
167
+ default: 'out.svg',
168
+ })
169
+ .option('noRasterize', {
170
+ description: 'Use full SVG rendering with no rasterized layers, this can substantially increase filesize',
171
+ type: 'boolean',
172
+ })
173
+ .option('defaultSession', {
174
+ description: 'Use the defaultSession from config.json',
175
+ type: 'boolean',
176
+ })
177
+ .help()
178
+ .alias('help', 'h')
179
+ .alias('width', 'w').argv;
180
+ const args = (0, parseArgv_1.standardizeArgv)((0, parseArgv_1.parseArgv)(process.argv.slice(2)), [
181
+ 'bam',
182
+ 'cram',
183
+ 'vcfgz',
184
+ 'hic',
185
+ 'bigwig',
186
+ 'bigbed',
187
+ 'bedgz',
188
+ 'gffgz',
189
+ 'configtracks',
190
+ ]);
191
+ (async () => {
192
+ try {
193
+ const result = await (0, renderRegion_1.renderRegion)(args);
194
+ const { out = 'out.svg', pngwidth = '2048' } = args;
195
+ if (out.endsWith('.png')) {
196
+ (0, util_1.convert)(result, { out, pngwidth });
147
197
  }
148
- }
149
- }, _callee2);
150
- }));
151
- return _time.apply(this, arguments);
152
- }
153
- var args = (0, _parseArgv.standardizeArgv)((0, _parseArgv.parseArgv)(process.argv.slice(2)), ['bam', 'cram', 'vcfgz', 'hic', 'bigwig', 'bigbed', 'bedgz', 'gffgz', 'configtracks']);
154
- time( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
155
- var result, outfile, tmpobj, ls, _tmpobj, _ls;
156
- return _regenerator.default.wrap(function _callee$(_context) {
157
- while (1) {
158
- switch (_context.prev = _context.next) {
159
- case 0:
160
- _context.prev = 0;
161
- _context.next = 3;
162
- return (0, _renderRegion.renderRegion)(args);
163
- case 3:
164
- result = _context.sent;
165
- outfile = args.out || 'out.svg';
166
- if (outfile.endsWith('.png')) {
167
- tmpobj = _tmp.default.fileSync({
168
- mode: 420,
169
- prefix: 'prefix-',
170
- postfix: '.svg'
171
- });
172
- _fs.default.writeFileSync(tmpobj.name, result);
173
- ls = (0, _child_process.spawnSync)('rsvg-convert', ['-w', args.pngwidth || 2048, tmpobj.name, '-o', outfile]);
174
- console.log("rsvg-convert stderr: ".concat(ls.stderr.toString()));
175
- console.log("rsvg-convert stdout: ".concat(ls.stdout.toString()));
176
- _fs.default.unlinkSync(tmpobj.name);
177
- } else if (outfile.endsWith('.pdf')) {
178
- _tmpobj = _tmp.default.fileSync({
179
- mode: 420,
180
- prefix: 'prefix-',
181
- postfix: '.svg'
182
- });
183
- _fs.default.writeFileSync(_tmpobj.name, result);
184
- _ls = (0, _child_process.spawnSync)('rsvg-convert', ['-w', args.pngwidth || 2048, _tmpobj.name, '-f', 'pdf', '-o', outfile]);
185
- console.log("rsvg-convert stderr: ".concat(_ls.stderr.toString()));
186
- console.log("rsvg-convert stdout: ".concat(_ls.stdout.toString()));
187
- _fs.default.unlinkSync(_tmpobj.name);
188
- } else {
189
- _fs.default.writeFileSync(outfile, result);
190
- }
191
-
192
- // manually exit the process after done rendering because autoruns or
193
- // something similar otherwise keeps the nodejs process alive xref
194
- // https://github.com/GMOD/jb2export/issues/6
195
- process.exit(0);
196
- _context.next = 13;
197
- break;
198
- case 9:
199
- _context.prev = 9;
200
- _context.t0 = _context["catch"](0);
201
- console.error(_context.t0);
202
- process.exit(1);
203
- case 13:
204
- case "end":
205
- return _context.stop();
206
- }
198
+ else if (out.endsWith('.pdf')) {
199
+ (0, util_1.convert)(result, { out, pngwidth }, ['-f', 'pdf']);
200
+ }
201
+ else {
202
+ fs_1.default.writeFileSync(out, result);
203
+ }
204
+ // manually exit the process after done rendering because autoruns or
205
+ // something similar otherwise keeps the nodejs process alive xref
206
+ // https://github.com/GMOD/jb2export/issues/6
207
+ process.exit(0);
208
+ }
209
+ catch (e) {
210
+ console.error(e);
211
+ process.exit(1);
207
212
  }
208
- }, _callee, null, [[0, 9]]);
209
- })));
213
+ })();
214
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,kDAAyB;AACzB,uEAAoE;AACpE,yDAA8D;AAC9D,iCAA6B;AAC7B,mCAA4C;AAE5C,SAAS;AACT,2CAAwD;AACxD,iDAAmD;AACnD,iCAAgC;AAEhC,aAAa;AACb,MAAM,CAAC,SAAS,GAAG,cAAK,CAAA;AACxB,aAAa;AACb,MAAM,CAAC,gBAAgB,GAAG,qBAAY,CAAA;AAEtC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,aAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA;AAC5C,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;AAE1B,yEAAyE;A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EAAE,QAAQ,EAAE,CAAC,CAAA;SACnC;aAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YAC/B,IAAA,cAAO,EAAC,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;SAClD;aAAM;YACL,YAAE,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;SAC9B;QAED,qEAAqE;QACrE,kEAAkE;QAClE,6CAA6C;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;AACH,CAAC,CAAC,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ export type Entry = [string, string[]];
2
+ export declare function parseArgv(argv: string[]): Entry[];
3
+ export declare function standardizeArgv(args: Entry[], trackTypes: string[]): {
4
+ [key: string]: unknown;
5
+ trackList: Entry[];
6
+ out?: string | undefined;
7
+ pngwidth?: string | undefined;
8
+ };
package/dist/parseArgv.js CHANGED
@@ -1,38 +1,47 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseArgv = parseArgv;
7
- exports.standardizeArgv = standardizeArgv;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.standardizeArgv = exports.parseArgv = void 0;
4
+ // example (see parseArgv.test.js):
5
+ // const args =
6
+ // '--bam dad.bam color:red --vcf variants.vcf --bam mom.bam --defaultSession --out out.svg --noRasterize'
7
+ //
8
+ // expect(parseArgv(args.split(' '))).toEqual([
9
+ // ['bam', ['dad.bam', 'color:red']],
10
+ // ['vcf', ['variants.vcf']],
11
+ // ['bam', ['mom.bam']],
12
+ // ['defaultSession', []],
13
+ // ['out', ['out.svg']],
14
+ // ['noRasterize', []],
15
+ // ])
8
16
  function parseArgv(argv) {
9
- var map = [];
10
- while (argv.length) {
11
- var val = argv[0].slice(2);
12
- argv = argv.slice(1);
13
- var next = argv.findIndex(function (arg) {
14
- return arg.startsWith('-');
15
- });
16
- if (next !== -1) {
17
- map.push([val, argv.slice(0, next)]);
18
- argv = argv.slice(next);
19
- } else {
20
- map.push([val, argv]);
21
- break;
17
+ const map = [];
18
+ while (argv.length) {
19
+ const val = argv[0].slice(2);
20
+ argv = argv.slice(1);
21
+ const next = argv.findIndex(arg => arg.startsWith('-'));
22
+ if (next !== -1) {
23
+ map.push([val, argv.slice(0, next)]);
24
+ argv = argv.slice(next);
25
+ }
26
+ else {
27
+ map.push([val, argv]);
28
+ break;
29
+ }
22
30
  }
23
- }
24
- return map;
31
+ return map;
25
32
  }
33
+ exports.parseArgv = parseArgv;
26
34
  function standardizeArgv(args, trackTypes) {
27
- var result = {
28
- trackList: []
29
- };
30
- args.forEach(function (arg) {
31
- if (trackTypes.includes(arg[0])) {
32
- result.trackList.push(arg);
33
- } else {
34
- result[arg[0]] = arg[1][0] || true;
35
- }
36
- });
37
- return result;
38
- }
35
+ const result = { trackList: [] };
36
+ args.forEach(arg => {
37
+ if (trackTypes.includes(arg[0])) {
38
+ result.trackList.push(arg);
39
+ }
40
+ else {
41
+ result[arg[0]] = arg[1][0] || true;
42
+ }
43
+ });
44
+ return result;
45
+ }
46
+ exports.standardizeArgv = standardizeArgv;
47
+ //# sourceMappingURL=parseArgv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseArgv.js","sourceRoot":"","sources":["../src/parseArgv.ts"],"names":[],"mappings":";;;AAEA,mCAAmC;AACnC,eAAe;AACf,4GAA4G;AAC5G,EAAE;AACF,+CAA+C;AAC/C,uCAAuC;AACvC,+BAA+B;AAC/B,0BAA0B;AAC1B,4BAA4B;AAC5B,0BAA0B;AAC1B,yBAAyB;AACzB,KAAK;AACL,SAAgB,SAAS,CAAC,IAAc;IACtC,MAAM,G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+ export interface Opts {
3
+ noRasterize?: boolean;
4
+ loc?: string;
5
+ width?: number;
6
+ session?: string;
7
+ assembly?: string;
8
+ config?: string;
9
+ fasta?: string;
10
+ aliases?: string;
11
+ cytobands?: string;
12
+ defaultSession?: string;
13
+ trackList: Entry[];
14
+ tracks?: string;
15
+ }
16
+ interface Assembly {
17
+ name: string;
18
+ sequence: Record<string, unknown>;
19
+ refNameAliases?: Record<string, unknown>;
20
+ cytobands?: Record<string, unknown>;
21
+ }
22
+ interface Track {
23
+ trackId: string;
24
+ [key: string]: unknown;
25
+ }
26
+ interface Config {
27
+ assemblies: Assembly[];
28
+ assembly: Assembly;
29
+ tracks: Track[];
30
+ [key: string]: unknown;
31
+ }
32
+ export declare function readData({ assembly: asm, config, session, fasta, aliases, cytobands, defaultSession, tracks, trackList, }: Opts): Config;
33
+ export declare const muiCache: import("@emotion/utils").EmotionCache;
34
+ export declare function renderRegion(opts: Opts): Promise<string>;
35
+ export {};