@jbrowse/cli 3.6.5 → 3.7.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/bundle/index.js CHANGED
@@ -3116,7 +3116,7 @@ eval("{/*!\n * Tmp\n *\n * Copyright (c) 2011-2017 KARASZI Istvan <github@spam.r
3116
3116
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3117
3117
 
3118
3118
  "use strict";
3119
- eval("{\n\nvar Buffer = (__webpack_require__(/*! safe-buffer */ \"../../node_modules/safe-buffer/index.js\").Buffer);\nvar isArray = __webpack_require__(/*! isarray */ \"../../node_modules/isarray/index.js\");\nvar typedArrayBuffer = __webpack_require__(/*! typed-array-buffer */ \"../../node_modules/typed-array-buffer/index.js\");\n\nvar isView = ArrayBuffer.isView || function isView(obj) {\n\ttry {\n\t\ttypedArrayBuffer(obj);\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\n\nvar useUint8Array = typeof Uint8Array !== 'undefined';\nvar useArrayBuffer = typeof ArrayBuffer !== 'undefined'\n\t&& typeof Uint8Array !== 'undefined';\nvar useFromArrayBuffer = useArrayBuffer && (Buffer.prototype instanceof Uint8Array || Buffer.TYPED_ARRAY_SUPPORT);\n\nmodule.exports = function toBuffer(data, encoding) {\n\t/*\n\t * No need to do anything for exact instance\n\t * This is only valid when safe-buffer.Buffer === buffer.Buffer, i.e. when Buffer.from/Buffer.alloc existed\n\t */\n\tif (data instanceof Buffer) {\n\t\treturn data;\n\t}\n\n\tif (typeof data === 'string') {\n\t\treturn Buffer.from(data, encoding);\n\t}\n\n\t/*\n\t * Wrap any TypedArray instances and DataViews\n\t * Makes sense only on engines with full TypedArray support -- let Buffer detect that\n\t */\n\tif (useArrayBuffer && isView(data)) {\n\t\t// Bug in Node.js <6.3.1, which treats this as out-of-bounds\n\t\tif (data.byteLength === 0) {\n\t\t\treturn Buffer.alloc(0);\n\t\t}\n\n\t\t// When Buffer is based on Uint8Array, we can just construct it from ArrayBuffer\n\t\tif (useFromArrayBuffer) {\n\t\t\tvar res = Buffer.from(data.buffer, data.byteOffset, data.byteLength);\n\t\t\t/*\n\t\t\t * Recheck result size, as offset/length doesn't work on Node.js <5.10\n\t\t\t * We just go to Uint8Array case if this fails\n\t\t\t */\n\t\t\tif (res.byteLength === data.byteLength) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\n\t\t// Convert to Uint8Array bytes and then to Buffer\n\t\tvar uint8 = data instanceof Uint8Array ? data : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\t\tvar result = Buffer.from(uint8);\n\n\t\t/*\n\t\t * Let's recheck that conversion succeeded\n\t\t * We have .length but not .byteLength when useFromArrayBuffer is false\n\t\t */\n\t\tif (result.length === data.byteLength) {\n\t\t\treturn result;\n\t\t}\n\t}\n\n\t/*\n\t * Uint8Array in engines where Buffer.from might not work with ArrayBuffer, just copy over\n\t * Doesn't make sense with other TypedArray instances\n\t */\n\tif (useUint8Array && data instanceof Uint8Array) {\n\t\treturn Buffer.from(data);\n\t}\n\n\tvar isArr = isArray(data);\n\tif (isArr) {\n\t\tfor (var i = 0; i < data.length; i += 1) {\n\t\t\tvar x = data[i];\n\t\t\tif (\n\t\t\t\ttypeof x !== 'number'\n\t\t\t\t|| x < 0\n\t\t\t\t|| x > 255\n\t\t\t\t|| ~~x !== x // NaN and integer check\n\t\t\t) {\n\t\t\t\tthrow new RangeError('Array items must be numbers in the range 0-255.');\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Old Buffer polyfill on an engine that doesn't have TypedArray support\n\t * Also, this is from a different Buffer polyfill implementation then we have, as instanceof check failed\n\t * Convert to our current Buffer implementation\n\t */\n\tif (\n\t\tisArr || (\n\t\t\tBuffer.isBuffer(data)\n\t\t\t\t&& data.constructor\n\t\t\t\t&& typeof data.constructor.isBuffer === 'function'\n\t\t\t\t&& data.constructor.isBuffer(data)\n\t\t)\n\t) {\n\t\treturn Buffer.from(data);\n\t}\n\n\tthrow new TypeError('The \"data\" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.');\n};\n\n\n//# sourceURL=webpack://@jbrowse/cli/../../node_modules/to-buffer/index.js?\n}");
3119
+ eval("{\n\nvar Buffer = (__webpack_require__(/*! safe-buffer */ \"../../node_modules/safe-buffer/index.js\").Buffer);\nvar isArray = __webpack_require__(/*! isarray */ \"../../node_modules/isarray/index.js\");\nvar typedArrayBuffer = __webpack_require__(/*! typed-array-buffer */ \"../../node_modules/typed-array-buffer/index.js\");\n\nvar isView = ArrayBuffer.isView || function isView(obj) {\n\ttry {\n\t\ttypedArrayBuffer(obj);\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\n\nvar useUint8Array = typeof Uint8Array !== 'undefined';\nvar useArrayBuffer = typeof ArrayBuffer !== 'undefined'\n\t&& typeof Uint8Array !== 'undefined';\nvar useFromArrayBuffer = useArrayBuffer && (Buffer.prototype instanceof Uint8Array || Buffer.TYPED_ARRAY_SUPPORT);\n\nmodule.exports = function toBuffer(data, encoding) {\n\tif (Buffer.isBuffer(data)) {\n\t\tif (data.constructor && !('isBuffer' in data)) {\n\t\t\t// probably a SlowBuffer\n\t\t\treturn Buffer.from(data);\n\t\t}\n\t\treturn data;\n\t}\n\n\tif (typeof data === 'string') {\n\t\treturn Buffer.from(data, encoding);\n\t}\n\n\t/*\n\t * Wrap any TypedArray instances and DataViews\n\t * Makes sense only on engines with full TypedArray support -- let Buffer detect that\n\t */\n\tif (useArrayBuffer && isView(data)) {\n\t\t// Bug in Node.js <6.3.1, which treats this as out-of-bounds\n\t\tif (data.byteLength === 0) {\n\t\t\treturn Buffer.alloc(0);\n\t\t}\n\n\t\t// When Buffer is based on Uint8Array, we can just construct it from ArrayBuffer\n\t\tif (useFromArrayBuffer) {\n\t\t\tvar res = Buffer.from(data.buffer, data.byteOffset, data.byteLength);\n\t\t\t/*\n\t\t\t * Recheck result size, as offset/length doesn't work on Node.js <5.10\n\t\t\t * We just go to Uint8Array case if this fails\n\t\t\t */\n\t\t\tif (res.byteLength === data.byteLength) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\n\t\t// Convert to Uint8Array bytes and then to Buffer\n\t\tvar uint8 = data instanceof Uint8Array ? data : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\t\tvar result = Buffer.from(uint8);\n\n\t\t/*\n\t\t * Let's recheck that conversion succeeded\n\t\t * We have .length but not .byteLength when useFromArrayBuffer is false\n\t\t */\n\t\tif (result.length === data.byteLength) {\n\t\t\treturn result;\n\t\t}\n\t}\n\n\t/*\n\t * Uint8Array in engines where Buffer.from might not work with ArrayBuffer, just copy over\n\t * Doesn't make sense with other TypedArray instances\n\t */\n\tif (useUint8Array && data instanceof Uint8Array) {\n\t\treturn Buffer.from(data);\n\t}\n\n\tvar isArr = isArray(data);\n\tif (isArr) {\n\t\tfor (var i = 0; i < data.length; i += 1) {\n\t\t\tvar x = data[i];\n\t\t\tif (\n\t\t\t\ttypeof x !== 'number'\n\t\t\t\t|| x < 0\n\t\t\t\t|| x > 255\n\t\t\t\t|| ~~x !== x // NaN and integer check\n\t\t\t) {\n\t\t\t\tthrow new RangeError('Array items must be numbers in the range 0-255.');\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Old Buffer polyfill on an engine that doesn't have TypedArray support\n\t * Also, this is from a different Buffer polyfill implementation then we have, as instanceof check failed\n\t * Convert to our current Buffer implementation\n\t */\n\tif (\n\t\tisArr || (\n\t\t\tBuffer.isBuffer(data)\n\t\t\t&& data.constructor\n\t\t\t&& typeof data.constructor.isBuffer === 'function'\n\t\t\t&& data.constructor.isBuffer(data)\n\t\t)\n\t) {\n\t\treturn Buffer.from(data);\n\t}\n\n\tthrow new TypeError('The \"data\" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.');\n};\n\n\n//# sourceURL=webpack://@jbrowse/cli/../../node_modules/to-buffer/index.js?\n}");
3120
3120
 
3121
3121
  /***/ }),
3122
3122
 
@@ -3306,7 +3306,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
3306
3306
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3307
3307
 
3308
3308
  "use strict";
3309
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ run: () => (/* binding */ run)\n/* harmony export */ });\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! util */ \"util\");\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! json-parse-better-errors */ \"../../node_modules/json-parse-better-errors/index.js\");\n/* harmony import */ var json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _fetchWithProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../fetchWithProxy */ \"./src/fetchWithProxy.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\n\n\n\nfunction resolveURL(_x) {\n return _resolveURL.apply(this, arguments);\n}\nfunction _resolveURL() {\n _resolveURL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(location) {\n var check,\n locationUrl,\n response,\n _args = arguments,\n _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n check = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;\n _context.p = 1;\n locationUrl = new URL(location);\n _context.n = 3;\n break;\n case 2:\n _context.p = 2;\n _t = _context.v;\n throw new Error(\"The location \".concat(location, \" provided is not a valid URL\"));\n case 3:\n if (!check) {\n _context.n = 5;\n break;\n }\n _context.n = 4;\n return (0,_fetchWithProxy__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(\"\".concat(locationUrl), {\n method: 'HEAD'\n });\n case 4:\n response = _context.v;\n if (response.ok) {\n _context.n = 5;\n break;\n }\n throw new Error(\"HTTP \".concat(response.status, \" fetching \").concat(locationUrl));\n case 5:\n return _context.a(2, locationUrl.href);\n }\n }, _callee, null, [[1, 2]]);\n }));\n return _resolveURL.apply(this, arguments);\n}\nfunction determineConnectionType(url) {\n if (path__WEBPACK_IMPORTED_MODULE_1___default().basename(url) === 'hub.txt') {\n return 'UCSCTrackHubConnection';\n }\n if (url.includes('jbrowse/data')) {\n return 'JBrowse1Connection';\n }\n return 'custom';\n}\nfunction run(_x2) {\n return _run.apply(this, arguments);\n}\nfunction _run() {\n _run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(args) {\n var _configContents$assem, _configContents$assem2;\n var options, _parseArgs, flags, positionals, description, examples, connectionUrlOrPath, output, isDir, target, assemblyNames, type, name, config, connectionId, skipCheck, force, url, configContents, configType, id, connectionConfig, idx;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.n) {\n case 0:\n options = {\n help: {\n type: 'boolean',\n \"short\": 'h'\n },\n type: {\n type: 'string',\n \"short\": 't',\n description: 'Type of connection (e.g. JBrowse1Connection, UCSCTrackHubConnection, custom)'\n },\n assemblyNames: {\n type: 'string',\n \"short\": 'a',\n description: 'For UCSC: optional comma separated list of assembly names to filter. For JBrowse1: a single assembly name'\n },\n config: {\n type: 'string',\n \"short\": 'c',\n description: 'Extra config settings to add to connection in JSON object format'\n },\n connectionId: {\n type: 'string',\n description: 'Id for the connection that must be unique to JBrowse'\n },\n name: {\n type: 'string',\n \"short\": 'n',\n description: 'Name of the connection. Defaults to connectionId if not provided'\n },\n target: {\n type: 'string',\n description: 'Path to config file in JB2 installation directory to write out to'\n },\n out: {\n type: 'string',\n description: 'Synonym for target'\n },\n skipCheck: {\n type: 'boolean',\n description: \"Don't check whether the data directory URL exists\"\n },\n overwrite: {\n type: 'boolean',\n description: 'Overwrites any existing connections if same connection id'\n },\n force: {\n type: 'boolean',\n \"short\": 'f',\n description: 'Equivalent to --skipCheck --overwrite'\n }\n };\n _parseArgs = (0,util__WEBPACK_IMPORTED_MODULE_2__.parseArgs)({\n args: args,\n options: options,\n allowPositionals: true\n }), flags = _parseArgs.values, positionals = _parseArgs.positionals;\n description = 'Add a connection to a JBrowse 2 configuration';\n examples = ['$ jbrowse add-connection http://mysite.com/jbrowse/data/ -a hg19', '$ jbrowse add-connection http://mysite.com/jbrowse/custom_data_folder/ --type JBrowse1Connection -a hg38', '$ jbrowse add-connection http://mysite.com/path/to/hub.txt', '$ jbrowse add-connection http://mysite.com/path/to/custom_hub_name.txt --type UCSCTrackHubConnection', \"$ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config '{\\\"uri\\\":{\\\"url\\\":\\\"https://mysite.com/path/to/custom\\\"}, \\\"locationType\\\": \\\"UriLocation\\\"}' -a hg19\", '$ jbrowse add-connection https://mysite.com/path/to/hub.txt --connectionId newId --name newName --target /path/to/jb2/installation/config.json'];\n if (!flags.help) {\n _context2.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.printHelp)({\n description: description,\n examples: examples,\n usage: 'jbrowse add-connection <connectionUrlOrPath> [options]',\n options: options\n });\n return _context2.a(2);\n case 1:\n connectionUrlOrPath = positionals[0];\n if (!connectionUrlOrPath) {\n console.error('Error: Missing required argument: connectionUrlOrPath');\n console.error('Usage: jbrowse add-connection <connectionUrlOrPath> [options]');\n process.exit(1);\n }\n output = flags.target || flags.out || '.';\n isDir = fs__WEBPACK_IMPORTED_MODULE_0___default().lstatSync(output).isDirectory();\n target = isDir ? \"\".concat(output, \"/config.json\") : output;\n assemblyNames = flags.assemblyNames, type = flags.type, name = flags.name, config = flags.config, connectionId = flags.connectionId, skipCheck = flags.skipCheck, force = flags.force;\n _context2.n = 2;\n return resolveURL(connectionUrlOrPath, !(skipCheck || force));\n case 2:\n url = _context2.v;\n _context2.n = 3;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.readJsonFile)(target);\n case 3:\n configContents = _context2.v;\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.debug)(\"Using config file \".concat(target));\n if ((_configContents$assem = configContents.assemblies) !== null && _configContents$assem !== void 0 && _configContents$assem.length) {\n _context2.n = 4;\n break;\n }\n throw new Error('No assemblies found. Please add one before adding connections');\n case 4:\n configType = type || determineConnectionType(url);\n id = connectionId || [configType, assemblyNames, +Date.now()].filter(function (f) {\n return !!f;\n }).join('-');\n connectionConfig = _objectSpread(_objectSpread(_objectSpread({\n type: configType,\n name: name || id\n }, configType === 'UCSCTrackHubConnection' ? {\n hubTxtLocation: {\n uri: url,\n locationType: 'UriLocation'\n }\n } : {}), configType === 'JBrowse1Connection' ? {\n dataDirLocation: {\n uri: url,\n locationType: 'UriLocation'\n }\n } : {}), {}, {\n connectionId: id,\n assemblyNames: assemblyNames ? assemblyNames.split(',') : type === 'JBrowse1Connection' ? [(_configContents$assem2 = configContents.assemblies[0]) === null || _configContents$assem2 === void 0 ? void 0 : _configContents$assem2.name] : undefined\n }, config ? json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3___default()(config) : {});\n if (!configContents.connections) {\n configContents.connections = [];\n }\n idx = configContents.connections.findIndex(function (c) {\n return c.connectionId === connectionId;\n });\n if (!(idx !== -1)) {\n _context2.n = 7;\n break;\n }\n if (!(force || flags.overwrite)) {\n _context2.n = 5;\n break;\n }\n configContents.connections[idx] = connectionConfig;\n _context2.n = 6;\n break;\n case 5:\n throw new Error(\"Cannot add connection with id \".concat(connectionId, \", a connection with that id already exists.\\nUse --overwrite if you would like to replace the existing connection\"));\n case 6:\n _context2.n = 8;\n break;\n case 7:\n configContents.connections.push(connectionConfig);\n case 8:\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.debug)(\"Writing configuration to file \".concat(target));\n _context2.n = 9;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.writeJsonFile)(target, configContents);\n case 9:\n console.log(\"\".concat(idx !== -1 ? 'Overwrote' : 'Added', \" connection \\\"\").concat(name || id, \"\\\" \").concat(idx !== -1 ? 'in' : 'to', \" \").concat(target));\n case 10:\n return _context2.a(2);\n }\n }, _callee2);\n }));\n return _run.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/add-connection.ts?\n}");
3309
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ run: () => (/* binding */ run)\n/* harmony export */ });\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! util */ \"util\");\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! json-parse-better-errors */ \"../../node_modules/json-parse-better-errors/index.js\");\n/* harmony import */ var json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _fetchWithProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../fetchWithProxy */ \"./src/fetchWithProxy.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\n\n\n\nfunction resolveURL(_x) {\n return _resolveURL.apply(this, arguments);\n}\nfunction _resolveURL() {\n _resolveURL = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(location) {\n var check,\n locationUrl,\n response,\n _args = arguments,\n _t;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n check = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;\n _context.p = 1;\n locationUrl = new URL(location);\n _context.n = 3;\n break;\n case 2:\n _context.p = 2;\n _t = _context.v;\n throw new Error(\"The location \".concat(location, \" provided is not a valid URL\"));\n case 3:\n if (!check) {\n _context.n = 5;\n break;\n }\n _context.n = 4;\n return (0,_fetchWithProxy__WEBPACK_IMPORTED_MODULE_4__[\"default\"])(\"\".concat(locationUrl), {\n method: 'HEAD'\n });\n case 4:\n response = _context.v;\n if (response.ok) {\n _context.n = 5;\n break;\n }\n throw new Error(\"HTTP \".concat(response.status, \" fetching \").concat(locationUrl));\n case 5:\n return _context.a(2, locationUrl.href);\n }\n }, _callee, null, [[1, 2]]);\n }));\n return _resolveURL.apply(this, arguments);\n}\nfunction determineConnectionType(url) {\n if (path__WEBPACK_IMPORTED_MODULE_1___default().basename(url) === 'hub.txt') {\n return 'UCSCTrackHubConnection';\n }\n if (url.includes('jbrowse/data')) {\n return 'JBrowse1Connection';\n }\n return 'custom';\n}\nfunction run(_x2) {\n return _run.apply(this, arguments);\n}\nfunction _run() {\n _run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(args) {\n var _configContents$assem, _configContents$assem2;\n var options, _parseArgs, flags, positionals, description, examples, connectionUrlOrPath, output, isDir, target, assemblyNames, type, name, config, connectionId, skipCheck, force, url, configContents, configType, id, connectionConfig, idx;\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.n) {\n case 0:\n options = {\n help: {\n type: 'boolean',\n \"short\": 'h'\n },\n type: {\n type: 'string',\n \"short\": 't',\n description: 'Type of connection (e.g. JBrowse1Connection, UCSCTrackHubConnection, custom)'\n },\n assemblyNames: {\n type: 'string',\n \"short\": 'a',\n description: 'For UCSC: optional comma separated list of assembly names to filter. For JBrowse1: a single assembly name'\n },\n config: {\n type: 'string',\n \"short\": 'c',\n description: 'Extra config settings to add to connection in JSON object format'\n },\n connectionId: {\n type: 'string',\n description: 'Id for the connection that must be unique to JBrowse'\n },\n name: {\n type: 'string',\n \"short\": 'n',\n description: 'Name of the connection. Defaults to connectionId if not provided'\n },\n target: {\n type: 'string',\n description: 'Path to config file in JB2 installation directory to write out to'\n },\n out: {\n type: 'string',\n description: 'Synonym for target'\n },\n skipCheck: {\n type: 'boolean',\n description: \"Don't check whether the data directory URL exists\"\n },\n overwrite: {\n type: 'boolean',\n description: 'Overwrites any existing connections if same connection id'\n },\n force: {\n type: 'boolean',\n \"short\": 'f',\n description: 'Equivalent to --skipCheck --overwrite'\n }\n };\n _parseArgs = (0,util__WEBPACK_IMPORTED_MODULE_2__.parseArgs)({\n args: args,\n options: options,\n allowPositionals: true\n }), flags = _parseArgs.values, positionals = _parseArgs.positionals;\n description = 'Add a connection to a JBrowse 2 configuration';\n examples = ['$ jbrowse add-connection http://mysite.com/jbrowse/data/ -a hg19', '$ jbrowse add-connection http://mysite.com/jbrowse/custom_data_folder/ --type JBrowse1Connection -a hg38', '$ jbrowse add-connection http://mysite.com/path/to/hub.txt', '$ jbrowse add-connection http://mysite.com/path/to/custom_hub_name.txt --type UCSCTrackHubConnection', \"$ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config '{\\\"uri\\\":{\\\"url\\\":\\\"https://mysite.com/path/to/custom\\\"}, \\\"locationType\\\": \\\"UriLocation\\\"}' -a hg19\", '$ jbrowse add-connection https://mysite.com/path/to/hub.txt --connectionId newId --name newName --target /path/to/jb2/installation/config.json'];\n if (!flags.help) {\n _context2.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.printHelp)({\n description: description,\n examples: examples,\n usage: 'jbrowse add-connection <connectionUrlOrPath> [options]',\n options: options\n });\n return _context2.a(2);\n case 1:\n connectionUrlOrPath = positionals[0];\n if (!connectionUrlOrPath) {\n console.error('Error: Missing required argument: connectionUrlOrPath');\n console.error('Usage: jbrowse add-connection <connectionUrlOrPath> [options]');\n process.exit(1);\n }\n output = flags.target || flags.out || '.';\n isDir = fs__WEBPACK_IMPORTED_MODULE_0___default().lstatSync(output).isDirectory();\n target = isDir ? \"\".concat(output, \"/config.json\") : output;\n assemblyNames = flags.assemblyNames, type = flags.type, name = flags.name, config = flags.config, connectionId = flags.connectionId, skipCheck = flags.skipCheck, force = flags.force;\n _context2.n = 2;\n return resolveURL(connectionUrlOrPath, !(skipCheck || force));\n case 2:\n url = _context2.v;\n _context2.n = 3;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.readJsonFile)(target);\n case 3:\n configContents = _context2.v;\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.debug)(\"Using config file \".concat(target));\n if ((_configContents$assem = configContents.assemblies) !== null && _configContents$assem !== void 0 && _configContents$assem.length) {\n _context2.n = 4;\n break;\n }\n throw new Error('No assemblies found. Please add one before adding connections');\n case 4:\n configType = type || determineConnectionType(url);\n id = connectionId || [configType, assemblyNames, Date.now()].filter(function (f) {\n return !!f;\n }).join('-');\n connectionConfig = _objectSpread(_objectSpread(_objectSpread({\n type: configType,\n name: name || id\n }, configType === 'UCSCTrackHubConnection' ? {\n hubTxtLocation: {\n uri: url,\n locationType: 'UriLocation'\n }\n } : {}), configType === 'JBrowse1Connection' ? {\n dataDirLocation: {\n uri: url,\n locationType: 'UriLocation'\n }\n } : {}), {}, {\n connectionId: id,\n assemblyNames: assemblyNames ? assemblyNames.split(',') : type === 'JBrowse1Connection' ? [(_configContents$assem2 = configContents.assemblies[0]) === null || _configContents$assem2 === void 0 ? void 0 : _configContents$assem2.name] : undefined\n }, config ? json_parse_better_errors__WEBPACK_IMPORTED_MODULE_3___default()(config) : {});\n if (!configContents.connections) {\n configContents.connections = [];\n }\n idx = configContents.connections.findIndex(function (c) {\n return c.connectionId === connectionId;\n });\n if (!(idx !== -1)) {\n _context2.n = 7;\n break;\n }\n if (!(force || flags.overwrite)) {\n _context2.n = 5;\n break;\n }\n configContents.connections[idx] = connectionConfig;\n _context2.n = 6;\n break;\n case 5:\n throw new Error(\"Cannot add connection with id \".concat(connectionId, \", a connection with that id already exists.\\nUse --overwrite if you would like to replace the existing connection\"));\n case 6:\n _context2.n = 8;\n break;\n case 7:\n configContents.connections.push(connectionConfig);\n case 8:\n (0,_utils__WEBPACK_IMPORTED_MODULE_5__.debug)(\"Writing configuration to file \".concat(target));\n _context2.n = 9;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.writeJsonFile)(target, configContents);\n case 9:\n console.log(\"\".concat(idx !== -1 ? 'Overwrote' : 'Added', \" connection \\\"\").concat(name || id, \"\\\" \").concat(idx !== -1 ? 'in' : 'to', \" \").concat(target));\n case 10:\n return _context2.a(2);\n }\n }, _callee2);\n }));\n return _run.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/add-connection.ts?\n}");
3310
3310
 
3311
3311
  /***/ }),
3312
3312
 
@@ -3383,7 +3383,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
3383
3383
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3384
3384
 
3385
3385
  "use strict";
3386
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ isValidPort: () => (/* binding */ isValidPort),\n/* harmony export */ parsePort: () => (/* binding */ parsePort),\n/* harmony export */ setupConfigFile: () => (/* binding */ setupConfigFile),\n/* harmony export */ setupRoutes: () => (/* binding */ setupRoutes),\n/* harmony export */ setupServer: () => (/* binding */ setupServer),\n/* harmony export */ startServer: () => (/* binding */ startServer)\n/* harmony export */ });\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto */ \"crypto\");\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! os */ \"os\");\n/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var cors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! cors */ \"../../node_modules/cors/lib/index.js\");\n/* harmony import */ var cors__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(cors__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! express */ \"../../node_modules/express/index.js\");\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\n\n\n\n\n/**\n * Validates if a port number is in the valid range\n */\nfunction isValidPort(port) {\n return port > 0 && port < 65535;\n}\n\n/**\n * Parses and validates a port string\n */\nfunction parsePort(_ref) {\n var portStr = _ref.portStr,\n _ref$defaultPort = _ref.defaultPort,\n defaultPort = _ref$defaultPort === void 0 ? 9090 : _ref$defaultPort;\n if (!portStr) {\n return defaultPort;\n }\n var parsedPort = Number.parseInt(portStr, 10);\n if (!isValidPort(parsedPort)) {\n throw new Error(\"\".concat(portStr, \" is not a valid port\"));\n }\n return parsedPort;\n}\n\n/**\n * Generates a random alphanumeric string to serve as admin key\n */\nfunction generateKey() {\n return crypto__WEBPACK_IMPORTED_MODULE_0___default().randomBytes(5).toString('hex');\n}\n\n/**\n * Sets up the configuration file\n */\nfunction setupConfigFile() {\n return _setupConfigFile.apply(this, arguments);\n}\n\n/**\n * Validates admin key and extracts config path from request\n */\nfunction _setupConfigFile() {\n _setupConfigFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var _ref2,\n _ref2$root,\n root,\n output,\n isDir,\n outFile,\n baseDir,\n _args = arguments;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.n) {\n case 0:\n _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref2$root = _ref2.root, root = _ref2$root === void 0 ? '.' : _ref2$root;\n output = root;\n isDir = fs__WEBPACK_IMPORTED_MODULE_1___default().lstatSync(output).isDirectory();\n outFile = isDir ? \"\".concat(output, \"/config.json\") : output;\n baseDir = path__WEBPACK_IMPORTED_MODULE_3___default().dirname(outFile);\n if (!fs__WEBPACK_IMPORTED_MODULE_1___default().existsSync(outFile)) {\n _context.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_6__.debug)(\"Found existing config file \".concat(outFile));\n _context.n = 2;\n break;\n case 1:\n (0,_utils__WEBPACK_IMPORTED_MODULE_6__.debug)(\"Creating config file \".concat(outFile));\n _context.n = 2;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_6__.writeJsonFile)(outFile, {\n assemblies: [],\n configuration: {},\n connections: [],\n defaultSession: {\n name: 'New Session'\n },\n tracks: []\n });\n case 2:\n return _context.a(2, {\n outFile: outFile,\n baseDir: baseDir\n });\n }\n }, _callee);\n }));\n return _setupConfigFile.apply(this, arguments);\n}\nfunction validateAndExtractParams(_ref3) {\n var req = _ref3.req,\n key = _ref3.key,\n baseDir = _ref3.baseDir,\n outFile = _ref3.outFile;\n var body = req.body;\n // Check for adminKey in both query parameters and request body for backward compatibility\n var adminKeyFromQuery = req.query.adminKey;\n var adminKeyFromBody = body === null || body === void 0 ? void 0 : body.adminKey;\n var adminKey = adminKeyFromBody || adminKeyFromQuery;\n if (adminKey !== key) {\n return {\n isValid: false,\n error: 'Invalid admin key'\n };\n }\n\n // Get configPath from either body or query parameters\n var configPathParam = (body === null || body === void 0 ? void 0 : body.configPath) || req.query.config;\n try {\n // Normalize the config path\n var configPath = configPathParam ? path__WEBPACK_IMPORTED_MODULE_3___default().normalize(path__WEBPACK_IMPORTED_MODULE_3___default().join(baseDir, configPathParam)) : outFile;\n\n // Check for directory traversal attempts\n var normalizedBaseDir = path__WEBPACK_IMPORTED_MODULE_3___default().normalize(baseDir);\n var relPath = path__WEBPACK_IMPORTED_MODULE_3___default().relative(normalizedBaseDir, configPath);\n\n // Ensure the config path is within the base directory and doesn't contain path traversal\n if (relPath.startsWith('..') || path__WEBPACK_IMPORTED_MODULE_3___default().isAbsolute(relPath)) {\n return {\n isValid: false,\n error: 'Cannot perform directory traversal'\n };\n }\n return {\n isValid: true,\n configPath: configPath\n };\n } catch (error) {\n return {\n isValid: false,\n error: 'Failed to validate config path'\n };\n }\n}\n\n/**\n * Sets up the API routes for the server\n */\nfunction setupRoutes(_ref4) {\n var app = _ref4.app,\n baseDir = _ref4.baseDir,\n outFile = _ref4.outFile,\n key = _ref4.key,\n serverRef = _ref4.serverRef;\n // Root route\n app.get('/', function (_req, res) {\n res.setHeader('Content-Type', 'text/plain');\n res.send('JBrowse Admin Server');\n });\n\n // Update config route\n app.post('/updateConfig', function (req, res) {\n var body = req.body;\n var config = body.config;\n var validation = validateAndExtractParams({\n req: req,\n key: key,\n baseDir: baseDir,\n outFile: outFile\n });\n if (!validation.isValid) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send(\"Error: \".concat(validation.error));\n return;\n }\n\n // Remove adminKey from body before saving to config\n if (body.adminKey) {\n delete body.adminKey;\n }\n try {\n fs__WEBPACK_IMPORTED_MODULE_1___default().writeFileSync(validation.configPath, JSON.stringify(config, null, 2));\n res.setHeader('Content-Type', 'text/plain');\n res.send('Config updated successfully');\n } catch (error) {\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Error: Failed to update config');\n }\n });\n\n // Get config route\n app.get('/config', function (req, res) {\n var validation = validateAndExtractParams({\n req: req,\n key: key,\n baseDir: baseDir,\n outFile: outFile\n });\n if (!validation.isValid) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send(\"Error: \".concat(validation.error));\n return;\n }\n try {\n if (fs__WEBPACK_IMPORTED_MODULE_1___default().existsSync(validation.configPath)) {\n var config = fs__WEBPACK_IMPORTED_MODULE_1___default().readFileSync(validation.configPath, 'utf8');\n res.setHeader('Content-Type', 'text/plain');\n res.send(config);\n } else {\n res.status(404).setHeader('Content-Type', 'text/plain');\n res.send('Error: Config file not found');\n }\n } catch (error) {\n console.error('Error reading config:', error);\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Error: Failed to read config');\n }\n });\n\n // Shutdown route for testing\n app.post('/shutdown', function (req, res) {\n var body = req.body;\n var adminKey = body === null || body === void 0 ? void 0 : body.adminKey;\n if (adminKey !== key) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send('Error: Invalid admin key');\n return;\n }\n res.setHeader('Content-Type', 'text/plain');\n res.send('Server shutting down');\n\n // Shutdown the server after sending response\n setImmediate(function () {\n if (serverRef.current) {\n serverRef.current.close();\n }\n });\n });\n}\n\n/**\n * Sets up the Express server with routes\n */\nfunction setupServer(_ref5) {\n var baseDir = _ref5.baseDir,\n outFile = _ref5.outFile,\n bodySizeLimit = _ref5.bodySizeLimit;\n // Create Express application\n var app = express__WEBPACK_IMPORTED_MODULE_5___default()();\n\n // Configure middleware\n app.use(express__WEBPACK_IMPORTED_MODULE_5___default()[\"static\"](baseDir));\n app.use(cors__WEBPACK_IMPORTED_MODULE_4___default()());\n app.use(express__WEBPACK_IMPORTED_MODULE_5___default().json({\n limit: bodySizeLimit\n }));\n\n // Add error handling middleware\n app.use(function (err, _req, res, next) {\n if (err) {\n console.error('Server error:', err);\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Internal Server Error');\n } else {\n next();\n }\n });\n\n // Generate admin key and store it\n var key = generateKey();\n var keyPath = path__WEBPACK_IMPORTED_MODULE_3___default().join(os__WEBPACK_IMPORTED_MODULE_2___default().tmpdir(), \"jbrowse-admin-\".concat(key));\n try {\n fs__WEBPACK_IMPORTED_MODULE_1___default().writeFileSync(keyPath, key);\n (0,_utils__WEBPACK_IMPORTED_MODULE_6__.debug)(\"Admin key stored at \".concat(keyPath));\n } catch (error) {\n console.error(\"Failed to write admin key to \".concat(keyPath, \":\"), error.message);\n // Continue anyway, as this is not critical\n }\n\n // Create server reference for shutdown route\n var serverRef = {\n current: null\n };\n\n // Set up routes\n setupRoutes({\n app: app,\n baseDir: baseDir,\n outFile: outFile,\n key: key,\n serverRef: serverRef\n });\n return {\n app: app,\n key: key,\n keyPath: keyPath,\n serverRef: serverRef\n };\n}\n\n/**\n * Starts the server and sets up shutdown handlers\n */\nfunction startServer(_ref6) {\n var app = _ref6.app,\n port = _ref6.port,\n key = _ref6.key,\n outFile = _ref6.outFile,\n keyPath = _ref6.keyPath,\n serverRef = _ref6.serverRef;\n // Start the server\n var server = app.listen(port, function () {\n console.log(\"Admin server started on port \".concat(port, \"\\n\\n\") + \"To access the admin interface, open your browser to:\\n\" + \"http://localhost:\".concat(port, \"?adminKey=\").concat(key, \"\\n\\n\") + \"Admin key: \".concat(key, \"\\n\") + \"Config file: \".concat(outFile, \"\\n\\n\") + \"To stop the server, press Ctrl+C\");\n });\n\n // Store server reference for shutdown route\n serverRef.current = server;\n\n // Handle server errors\n server.on('error', function (error) {\n if (error.code === 'EADDRINUSE') {\n console.error(\"Error: Port \".concat(port, \" is already in use\"));\n } else {\n console.error('Server error:', error.message);\n }\n process.exit(1);\n });\n\n // Common shutdown handler\n var shutdownHandler = function shutdownHandler() {\n console.log('\\nShutting down admin server...');\n server.close(function () {\n // Clean up admin key file\n try {\n fs__WEBPACK_IMPORTED_MODULE_1___default().unlinkSync(keyPath);\n (0,_utils__WEBPACK_IMPORTED_MODULE_6__.debug)(\"Removed admin key file: \".concat(keyPath));\n } catch (error) {\n // Ignore errors when cleaning up\n }\n process.exit(0);\n });\n };\n\n // Handle server shutdown\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/admin-server-utils.ts?\n}");
3386
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateKey: () => (/* binding */ generateKey),\n/* harmony export */ isValidPort: () => (/* binding */ isValidPort),\n/* harmony export */ parsePort: () => (/* binding */ parsePort),\n/* harmony export */ setupConfigFile: () => (/* binding */ setupConfigFile),\n/* harmony export */ setupRoutes: () => (/* binding */ setupRoutes),\n/* harmony export */ startServer: () => (/* binding */ startServer)\n/* harmony export */ });\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto */ \"crypto\");\n/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\n\n/**\n * Validates if a port number is in the valid range\n */\nfunction isValidPort(port) {\n return port > 0 && port < 65535;\n}\n\n/**\n * Parses and validates a port string\n */\nfunction parsePort(_ref) {\n var portStr = _ref.portStr,\n _ref$defaultPort = _ref.defaultPort,\n defaultPort = _ref$defaultPort === void 0 ? 9090 : _ref$defaultPort;\n if (!portStr) {\n return defaultPort;\n }\n var parsedPort = Number.parseInt(portStr, 10);\n if (!isValidPort(parsedPort)) {\n throw new Error(\"\".concat(portStr, \" is not a valid port\"));\n }\n return parsedPort;\n}\n\n/**\n * Generates a random alphanumeric string to serve as admin key\n */\nfunction generateKey() {\n return crypto__WEBPACK_IMPORTED_MODULE_0___default().randomBytes(5).toString('hex');\n}\n\n/**\n * Sets up the configuration file\n */\nfunction setupConfigFile() {\n return _setupConfigFile.apply(this, arguments);\n}\n\n/**\n * Validates admin key and extracts config path from request\n */\nfunction _setupConfigFile() {\n _setupConfigFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n var _ref2,\n _ref2$root,\n root,\n output,\n isDir,\n outFile,\n baseDir,\n _args = arguments;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.n) {\n case 0:\n _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref2$root = _ref2.root, root = _ref2$root === void 0 ? '.' : _ref2$root;\n output = root;\n isDir = fs__WEBPACK_IMPORTED_MODULE_1___default().lstatSync(output).isDirectory();\n outFile = isDir ? \"\".concat(output, \"/config.json\") : output;\n baseDir = path__WEBPACK_IMPORTED_MODULE_2___default().dirname(outFile);\n if (!fs__WEBPACK_IMPORTED_MODULE_1___default().existsSync(outFile)) {\n _context.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_3__.debug)(\"Found existing config file \".concat(outFile));\n _context.n = 2;\n break;\n case 1:\n (0,_utils__WEBPACK_IMPORTED_MODULE_3__.debug)(\"Creating config file \".concat(outFile));\n _context.n = 2;\n return (0,_utils__WEBPACK_IMPORTED_MODULE_3__.writeJsonFile)(outFile, {\n assemblies: [],\n configuration: {},\n connections: [],\n defaultSession: {\n name: 'New Session'\n },\n tracks: []\n });\n case 2:\n return _context.a(2, {\n outFile: outFile,\n baseDir: baseDir\n });\n }\n }, _callee);\n }));\n return _setupConfigFile.apply(this, arguments);\n}\nfunction validateAndExtractParams(_ref3) {\n var req = _ref3.req,\n key = _ref3.key,\n baseDir = _ref3.baseDir,\n outFile = _ref3.outFile;\n var body = req.body;\n // Check for adminKey in both query parameters and request body for backward compatibility\n var adminKeyFromQuery = req.query.adminKey;\n var adminKeyFromBody = body === null || body === void 0 ? void 0 : body.adminKey;\n var adminKey = adminKeyFromBody || adminKeyFromQuery;\n if (adminKey !== key) {\n return {\n isValid: false,\n error: 'Invalid admin key'\n };\n }\n\n // Get configPath from either body or query parameters\n var configPathParam = (body === null || body === void 0 ? void 0 : body.configPath) || req.query.config;\n try {\n // Normalize the config path\n var configPath = configPathParam ? path__WEBPACK_IMPORTED_MODULE_2___default().normalize(path__WEBPACK_IMPORTED_MODULE_2___default().join(baseDir, configPathParam)) : outFile;\n\n // Check for directory traversal attempts\n var normalizedBaseDir = path__WEBPACK_IMPORTED_MODULE_2___default().normalize(baseDir);\n var relPath = path__WEBPACK_IMPORTED_MODULE_2___default().relative(normalizedBaseDir, configPath);\n\n // Ensure the config path is within the base directory and doesn't contain path traversal\n if (relPath.startsWith('..') || path__WEBPACK_IMPORTED_MODULE_2___default().isAbsolute(relPath)) {\n return {\n isValid: false,\n error: 'Cannot perform directory traversal'\n };\n }\n return {\n isValid: true,\n configPath: configPath\n };\n } catch (error) {\n return {\n isValid: false,\n error: 'Failed to validate config path'\n };\n }\n}\n\n/**\n * Sets up the API routes for the server\n */\nfunction setupRoutes(_ref4) {\n var app = _ref4.app,\n baseDir = _ref4.baseDir,\n outFile = _ref4.outFile,\n key = _ref4.key,\n serverRef = _ref4.serverRef;\n // Root route\n app.get('/', function (_req, res) {\n res.setHeader('Content-Type', 'text/plain');\n res.send('JBrowse Admin Server');\n });\n\n // Update config route\n app.post('/updateConfig', function (req, res) {\n var body = req.body;\n var config = body.config;\n var validation = validateAndExtractParams({\n req: req,\n key: key,\n baseDir: baseDir,\n outFile: outFile\n });\n if (!validation.isValid) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send(\"Error: \".concat(validation.error));\n return;\n }\n\n // Remove adminKey from body before saving to config\n if (body.adminKey) {\n delete body.adminKey;\n }\n try {\n fs__WEBPACK_IMPORTED_MODULE_1___default().writeFileSync(validation.configPath, JSON.stringify(config, null, 2));\n res.setHeader('Content-Type', 'text/plain');\n res.send('Config updated successfully');\n } catch (error) {\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Error: Failed to update config');\n }\n });\n\n // Get config route\n app.get('/config', function (req, res) {\n var validation = validateAndExtractParams({\n req: req,\n key: key,\n baseDir: baseDir,\n outFile: outFile\n });\n if (!validation.isValid) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send(\"Error: \".concat(validation.error));\n return;\n }\n try {\n if (fs__WEBPACK_IMPORTED_MODULE_1___default().existsSync(validation.configPath)) {\n var config = fs__WEBPACK_IMPORTED_MODULE_1___default().readFileSync(validation.configPath, 'utf8');\n res.setHeader('Content-Type', 'text/plain');\n res.send(config);\n } else {\n res.status(404).setHeader('Content-Type', 'text/plain');\n res.send('Error: Config file not found');\n }\n } catch (error) {\n console.error('Error reading config:', error);\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Error: Failed to read config');\n }\n });\n\n // Shutdown route for testing\n app.post('/shutdown', function (req, res) {\n var body = req.body;\n var adminKey = body === null || body === void 0 ? void 0 : body.adminKey;\n if (adminKey !== key) {\n res.status(401).setHeader('Content-Type', 'text/plain');\n res.send('Error: Invalid admin key');\n return;\n }\n res.setHeader('Content-Type', 'text/plain');\n res.send('Server shutting down');\n\n // Shutdown the server after sending response\n setImmediate(function () {\n if (serverRef.current) {\n serverRef.current.close();\n }\n });\n });\n}\n\n/**\n * Starts the server and sets up shutdown handlers\n */\nfunction startServer(_ref5) {\n var app = _ref5.app,\n port = _ref5.port,\n key = _ref5.key,\n outFile = _ref5.outFile,\n keyPath = _ref5.keyPath,\n serverRef = _ref5.serverRef;\n // Start the server\n var server = app.listen(port, function () {\n console.log(\"Admin server started on port \".concat(port, \"\\n\\n\") + \"To access the admin interface, open your browser to:\\n\" + \"http://localhost:\".concat(port, \"?adminKey=\").concat(key, \"\\n\\n\") + \"Admin key: \".concat(key, \"\\n\") + \"Config file: \".concat(outFile, \"\\n\\n\") + \"To stop the server, press Ctrl+C\");\n });\n\n // Store server reference for shutdown route\n serverRef.current = server;\n\n // Handle server errors\n server.on('error', function (error) {\n if (error.code === 'EADDRINUSE') {\n console.error(\"Error: Port \".concat(port, \" is already in use\"));\n } else {\n console.error('Server error:', error.message);\n }\n process.exit(1);\n });\n\n // Common shutdown handler\n var shutdownHandler = function shutdownHandler() {\n console.log('\\nShutting down admin server...');\n server.close(function () {\n // Clean up admin key file\n try {\n fs__WEBPACK_IMPORTED_MODULE_1___default().unlinkSync(keyPath);\n (0,_utils__WEBPACK_IMPORTED_MODULE_3__.debug)(\"Removed admin key file: \".concat(keyPath));\n } catch (error) {\n // Ignore errors when cleaning up\n }\n process.exit(0);\n });\n };\n\n // Handle server shutdown\n process.on('SIGINT', shutdownHandler);\n process.on('SIGTERM', shutdownHandler);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/admin-server-utils.ts?\n}");
3387
3387
 
3388
3388
  /***/ }),
3389
3389
 
@@ -3394,7 +3394,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
3394
3394
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3395
3395
 
3396
3396
  "use strict";
3397
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ run: () => (/* binding */ run)\n/* harmony export */ });\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! util */ \"util\");\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\n/* harmony import */ var _admin_server_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./admin-server-utils */ \"./src/commands/admin-server-utils.ts\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\nfunction run(_x) {\n return _run.apply(this, arguments);\n}\nfunction _run() {\n _run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(args) {\n var options, _parseArgs, flags, description, examples, root, _flags$bodySizeLimit, bodySizeLimit, _yield$setupConfigFil, outFile, baseDir, port, _setupServer, app, key, keyPath, serverRef;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.n) {\n case 0:\n options = {\n help: {\n type: 'boolean',\n \"short\": 'h'\n },\n port: {\n type: 'string',\n \"short\": 'p',\n description: 'Specified port to start the server on (default: 9090)'\n },\n root: {\n type: 'string',\n description: 'Path to the root of the JB2 installation'\n },\n bodySizeLimit: {\n type: 'string',\n description: 'Size limit of the update message (default: 25mb)'\n }\n };\n _parseArgs = (0,util__WEBPACK_IMPORTED_MODULE_0__.parseArgs)({\n args: args,\n options: options,\n allowPositionals: true\n }), flags = _parseArgs.values;\n description = 'Start up a small admin server for JBrowse configuration';\n examples = ['$ jbrowse admin-server', '$ jbrowse admin-server -p 8888'];\n if (!flags.help) {\n _context.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_1__.printHelp)({\n description: description,\n examples: examples,\n usage: 'jbrowse admin-server [options]',\n options: options\n });\n return _context.a(2);\n case 1:\n root = flags.root, _flags$bodySizeLimit = flags.bodySizeLimit, bodySizeLimit = _flags$bodySizeLimit === void 0 ? '25mb' : _flags$bodySizeLimit;\n _context.n = 2;\n return (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_2__.setupConfigFile)({\n root: root\n });\n case 2:\n _yield$setupConfigFil = _context.v;\n outFile = _yield$setupConfigFil.outFile;\n baseDir = _yield$setupConfigFil.baseDir;\n // Parse and validate port\n port = (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_2__.parsePort)({\n portStr: flags.port\n }); // Set up the Express server\n _setupServer = (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_2__.setupServer)({\n baseDir: baseDir,\n outFile: outFile,\n bodySizeLimit: bodySizeLimit\n }), app = _setupServer.app, key = _setupServer.key, keyPath = _setupServer.keyPath, serverRef = _setupServer.serverRef; // Start the server and set up shutdown handlers\n (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_2__.startServer)({\n app: app,\n port: port,\n key: key,\n outFile: outFile,\n keyPath: keyPath,\n serverRef: serverRef\n });\n case 3:\n return _context.a(2);\n }\n }, _callee);\n }));\n return _run.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/admin-server.ts?\n}");
3397
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ run: () => (/* binding */ run)\n/* harmony export */ });\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! os */ \"os\");\n/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! util */ \"util\");\n/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var cors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! cors */ \"../../node_modules/cors/lib/index.js\");\n/* harmony import */ var cors__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(cors__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! express */ \"../../node_modules/express/index.js\");\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _admin_server_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./admin-server-utils */ \"./src/commands/admin-server-utils.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils */ \"./src/utils.ts\");\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\n\n\n\n\n\n\n\n\nfunction run(_x) {\n return _run.apply(this, arguments);\n}\nfunction _run() {\n _run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(args) {\n var options, _parseArgs, flags, description, examples, root, _flags$bodySizeLimit, bodySizeLimit, _yield$setupConfigFil, outFile, baseDir, port, app, key, keyPath, serverRef;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.n) {\n case 0:\n options = {\n help: {\n type: 'boolean',\n \"short\": 'h'\n },\n port: {\n type: 'string',\n \"short\": 'p',\n description: 'Specified port to start the server on (default: 9090)'\n },\n root: {\n type: 'string',\n description: 'Path to the root of the JB2 installation'\n },\n bodySizeLimit: {\n type: 'string',\n description: 'Size limit of the update message (default: 25mb)'\n }\n };\n _parseArgs = (0,util__WEBPACK_IMPORTED_MODULE_3__.parseArgs)({\n args: args,\n options: options,\n allowPositionals: true\n }), flags = _parseArgs.values;\n description = 'Start up a small admin server for JBrowse configuration';\n examples = ['$ jbrowse admin-server', '$ jbrowse admin-server -p 8888'];\n if (!flags.help) {\n _context.n = 1;\n break;\n }\n (0,_utils__WEBPACK_IMPORTED_MODULE_7__.printHelp)({\n description: description,\n examples: examples,\n usage: 'jbrowse admin-server [options]',\n options: options\n });\n return _context.a(2);\n case 1:\n root = flags.root, _flags$bodySizeLimit = flags.bodySizeLimit, bodySizeLimit = _flags$bodySizeLimit === void 0 ? '25mb' : _flags$bodySizeLimit;\n _context.n = 2;\n return (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_6__.setupConfigFile)({\n root: root\n });\n case 2:\n _yield$setupConfigFil = _context.v;\n outFile = _yield$setupConfigFil.outFile;\n baseDir = _yield$setupConfigFil.baseDir;\n // Parse and validate port\n port = (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_6__.parsePort)({\n portStr: flags.port\n }); // Set up the Express server\n // const { app, key, keyPath, serverRef } = setupServer({\n // baseDir,\n // outFile,\n // bodySizeLimit,\n // })\n app = express__WEBPACK_IMPORTED_MODULE_5___default()(); // Configure middleware\n app.use(express__WEBPACK_IMPORTED_MODULE_5___default()[\"static\"](baseDir));\n app.use(cors__WEBPACK_IMPORTED_MODULE_4___default()());\n app.use(express__WEBPACK_IMPORTED_MODULE_5___default().json({\n limit: bodySizeLimit\n }));\n\n // Add error handling middleware\n app.use(function (err, _req, res, next) {\n if (err) {\n console.error('Server error:', err);\n res.status(500).setHeader('Content-Type', 'text/plain');\n res.send('Internal Server Error');\n } else {\n next();\n }\n });\n\n // Generate admin key and store it\n key = (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_6__.generateKey)();\n keyPath = path__WEBPACK_IMPORTED_MODULE_2___default().join(os__WEBPACK_IMPORTED_MODULE_1___default().tmpdir(), \"jbrowse-admin-\".concat(key));\n try {\n fs__WEBPACK_IMPORTED_MODULE_0___default().writeFileSync(keyPath, key);\n (0,_utils__WEBPACK_IMPORTED_MODULE_7__.debug)(\"Admin key stored at \".concat(keyPath));\n } catch (error) {\n console.error(\"Failed to write admin key to \".concat(keyPath, \":\"), error.message);\n // Continue anyway, as this is not critical\n }\n\n // Create server reference for shutdown route\n serverRef = {\n current: null\n }; // Set up routes\n (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_6__.setupRoutes)({\n app: app,\n baseDir: baseDir,\n outFile: outFile,\n key: key,\n serverRef: serverRef\n });\n\n // Start the server and set up shutdown handlers\n (0,_admin_server_utils__WEBPACK_IMPORTED_MODULE_6__.startServer)({\n app: app,\n port: port,\n key: key,\n outFile: outFile,\n keyPath: keyPath,\n serverRef: serverRef\n });\n case 3:\n return _context.a(2);\n }\n }, _callee);\n }));\n return _run.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/admin-server.ts?\n}");
3398
3398
 
3399
3399
  /***/ }),
3400
3400
 
@@ -3449,7 +3449,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
3449
3449
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3450
3450
 
3451
3451
  "use strict";
3452
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPIF: () => (/* binding */ createPIF),\n/* harmony export */ getOutputFilename: () => (/* binding */ getOutputFilename),\n/* harmony export */ spawnSortProcess: () => (/* binding */ spawnSortProcess),\n/* harmony export */ waitForProcessClose: () => (/* binding */ waitForProcessClose)\n/* harmony export */ });\n/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! child_process */ \"child_process\");\n/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _cigar_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cigar-utils */ \"./src/commands/make-pif-utils/cigar-utils.ts\");\n/* harmony import */ var _file_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./file-utils */ \"./src/commands/make-pif-utils/file-utils.ts\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _asyncIterator(r) { var n, t, o, e = 2; for (\"undefined\" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = \"@@asyncIterator\", o = \"@@iterator\"; } throw new TypeError(\"Object is not async iterable\"); }\nfunction AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + \" is not an object.\")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, \"return\": function _return(r) { var n = this.s[\"return\"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, \"throw\": function _throw(r) { var n = this.s[\"return\"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }\n\n\n\n\nfunction createPIF(_x, _x2) {\n return _createPIF.apply(this, arguments);\n}\nfunction _createPIF() {\n _createPIF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(filename, stream) {\n var rl1, writeWithBackpressure, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, _line$split, _line$split2, c1, l1, s1, e1, strand, c2, l2, s2, e2, rest, cigarIdx, CIGAR, _t, _t2;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n rl1 = filename ? (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.getReadline)(filename) : (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.getStdReadline)();\n writeWithBackpressure = (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.createWriteWithBackpressure)(stream); // Process the file line by line with backpressure handling\n _context.p = 1;\n _iteratorAbruptCompletion = false;\n _didIteratorError = false;\n _context.p = 2;\n _iterator = _asyncIterator(rl1);\n case 3:\n _context.n = 4;\n return _iterator.next();\n case 4:\n if (!(_iteratorAbruptCompletion = !(_step = _context.v).done)) {\n _context.n = 7;\n break;\n }\n line = _step.value;\n _line$split = line.split('\\t'), _line$split2 = _toArray(_line$split), c1 = _line$split2[0], l1 = _line$split2[1], s1 = _line$split2[2], e1 = _line$split2[3], strand = _line$split2[4], c2 = _line$split2[5], l2 = _line$split2[6], s2 = _line$split2[7], e2 = _line$split2[8], rest = _line$split2.slice(9); // Write the first line and handle backpressure\n _context.n = 5;\n return writeWithBackpressure(\"\".concat([\"t\".concat(c2), l2, s2, e2, strand, c1, l1, s1, e1].concat(_toConsumableArray(rest)).join('\\t'), \"\\n\"));\n case 5:\n cigarIdx = rest.findIndex(function (f) {\n return f.startsWith('cg:Z');\n });\n CIGAR = rest[cigarIdx];\n if (CIGAR) {\n rest[cigarIdx] = \"cg:Z:\".concat(strand === '-' ? (0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.flipCigar)((0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.parseCigar)(CIGAR.slice(5))).join('') : (0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.swapIndelCigar)(CIGAR.slice(5)));\n }\n\n // Write the second line and handle backpressure\n _context.n = 6;\n return writeWithBackpressure(\"\".concat([\"q\".concat(c1), l1, s1, e1, strand, c2, l2, s2, e2].concat(_toConsumableArray(rest)).join('\\t'), \"\\n\"));\n case 6:\n _iteratorAbruptCompletion = false;\n _context.n = 3;\n break;\n case 7:\n _context.n = 9;\n break;\n case 8:\n _context.p = 8;\n _t = _context.v;\n _didIteratorError = true;\n _iteratorError = _t;\n case 9:\n _context.p = 9;\n _context.p = 10;\n if (!(_iteratorAbruptCompletion && _iterator[\"return\"] != null)) {\n _context.n = 11;\n break;\n }\n _context.n = 11;\n return _iterator[\"return\"]();\n case 11:\n _context.p = 11;\n if (!_didIteratorError) {\n _context.n = 12;\n break;\n }\n throw _iteratorError;\n case 12:\n return _context.f(11);\n case 13:\n return _context.f(9);\n case 14:\n _context.n = 16;\n break;\n case 15:\n _context.p = 15;\n _t2 = _context.v;\n console.error('Error processing PAF file:', _t2);\n throw _t2;\n case 16:\n _context.p = 16;\n rl1.close();\n return _context.f(16);\n case 17:\n return _context.a(2);\n }\n }, _callee, null, [[10,, 11, 13], [2, 8, 9, 14], [1, 15, 16, 17]]);\n }));\n return _createPIF.apply(this, arguments);\n}\nfunction spawnSortProcess(outputFile, useCsi) {\n // Use a more portable approach to avoid E2BIG errors\n\n var sortCmd = \"sort -t\\\"`printf '\\\\t'`\\\" -k1,1 -k3,3n\";\n var bgzipCommand = \"bgzip > \\\"\".concat(outputFile, \"\\\"\");\n var tabixCommand = \"tabix \".concat(useCsi ? '-C ' : '', \"-s1 -b3 -e4 -0 \\\"\").concat(outputFile, \"\\\"\");\n var fullCommand = \"\".concat(sortCmd, \" | \").concat(bgzipCommand, \"; \").concat(tabixCommand);\n var minimalEnv = _objectSpread(_objectSpread({}, process.env), {}, {\n LC_ALL: 'C'\n });\n return (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)('sh', ['-c', fullCommand], {\n env: minimalEnv,\n stdio: ['pipe', process.stdout, process.stderr]\n });\n}\nfunction getOutputFilename(file, out) {\n return out || \"\".concat(path__WEBPACK_IMPORTED_MODULE_1___default().basename(file || 'output', '.paf'), \".pif.gz\");\n}\nfunction waitForProcessClose(_x3) {\n return _waitForProcessClose.apply(this, arguments);\n}\nfunction _waitForProcessClose() {\n _waitForProcessClose = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(child) {\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.n) {\n case 0:\n return _context2.a(2, new Promise(function (resolve) {\n child.on('close', resolve);\n }));\n }\n }, _callee2);\n }));\n return _waitForProcessClose.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/make-pif-utils/pif-generator.ts?\n}");
3452
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createPIF: () => (/* binding */ createPIF),\n/* harmony export */ getOutputFilename: () => (/* binding */ getOutputFilename),\n/* harmony export */ spawnSortProcess: () => (/* binding */ spawnSortProcess),\n/* harmony export */ waitForProcessClose: () => (/* binding */ waitForProcessClose)\n/* harmony export */ });\n/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! child_process */ \"child_process\");\n/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _cigar_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cigar-utils */ \"./src/commands/make-pif-utils/cigar-utils.ts\");\n/* harmony import */ var _file_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./file-utils */ \"./src/commands/make-pif-utils/file-utils.ts\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = \"function\" == typeof Symbol ? Symbol : {}, n = r.iterator || \"@@iterator\", o = r.toStringTag || \"@@toStringTag\"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, \"_invoke\", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError(\"Generator is already running\"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = \"next\"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError(\"iterator result is not an object\"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i[\"return\"]) && t.call(i), c < 2 && (u = TypeError(\"The iterator does not provide a '\" + o + \"' method\"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, \"GeneratorFunction\")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, \"constructor\", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction), GeneratorFunction.displayName = \"GeneratorFunction\", _regeneratorDefine2(GeneratorFunctionPrototype, o, \"GeneratorFunction\"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, \"Generator\"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, \"toString\", function () { return \"[object Generator]\"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }\nfunction _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, \"\", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o(\"next\", 0), o(\"throw\", 1), o(\"return\", 2)); }, _regeneratorDefine2(e, r, n, t); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n); } _next(void 0); }); }; }\nfunction _asyncIterator(r) { var n, t, o, e = 2; for (\"undefined\" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = \"@@asyncIterator\", o = \"@@iterator\"; } throw new TypeError(\"Object is not async iterable\"); }\nfunction AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + \" is not an object.\")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, \"return\": function _return(r) { var n = this.s[\"return\"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, \"throw\": function _throw(r) { var n = this.s[\"return\"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }\n\n\n\n\nfunction createPIF(_x, _x2) {\n return _createPIF.apply(this, arguments);\n}\nfunction _createPIF() {\n _createPIF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(filename, stream) {\n var rl1, writeWithBackpressure, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, _line$split, _line$split2, c1, l1, s1, e1, strand, c2, l2, s2, e2, rest, cigarIdx, CIGAR, _t, _t2;\n return _regenerator().w(function (_context) {\n while (1) switch (_context.p = _context.n) {\n case 0:\n rl1 = filename ? (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.getReadline)(filename) : (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.getStdReadline)();\n writeWithBackpressure = (0,_file_utils__WEBPACK_IMPORTED_MODULE_3__.createWriteWithBackpressure)(stream); // Process the file line by line with backpressure handling\n _context.p = 1;\n _iteratorAbruptCompletion = false;\n _didIteratorError = false;\n _context.p = 2;\n _iterator = _asyncIterator(rl1);\n case 3:\n _context.n = 4;\n return _iterator.next();\n case 4:\n if (!(_iteratorAbruptCompletion = !(_step = _context.v).done)) {\n _context.n = 7;\n break;\n }\n line = _step.value;\n _line$split = line.split('\\t'), _line$split2 = _toArray(_line$split), c1 = _line$split2[0], l1 = _line$split2[1], s1 = _line$split2[2], e1 = _line$split2[3], strand = _line$split2[4], c2 = _line$split2[5], l2 = _line$split2[6], s2 = _line$split2[7], e2 = _line$split2[8], rest = _arrayLikeToArray(_line$split2).slice(9); // Write the first line and handle backpressure\n _context.n = 5;\n return writeWithBackpressure(\"\".concat([\"t\".concat(c2), l2, s2, e2, strand, c1, l1, s1, e1].concat(_toConsumableArray(rest)).join('\\t'), \"\\n\"));\n case 5:\n cigarIdx = rest.findIndex(function (f) {\n return f.startsWith('cg:Z');\n });\n CIGAR = rest[cigarIdx];\n if (CIGAR) {\n rest[cigarIdx] = \"cg:Z:\".concat(strand === '-' ? (0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.flipCigar)((0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.parseCigar)(CIGAR.slice(5))).join('') : (0,_cigar_utils__WEBPACK_IMPORTED_MODULE_2__.swapIndelCigar)(CIGAR.slice(5)));\n }\n\n // Write the second line and handle backpressure\n _context.n = 6;\n return writeWithBackpressure(\"\".concat([\"q\".concat(c1), l1, s1, e1, strand, c2, l2, s2, e2].concat(_toConsumableArray(rest)).join('\\t'), \"\\n\"));\n case 6:\n _iteratorAbruptCompletion = false;\n _context.n = 3;\n break;\n case 7:\n _context.n = 9;\n break;\n case 8:\n _context.p = 8;\n _t = _context.v;\n _didIteratorError = true;\n _iteratorError = _t;\n case 9:\n _context.p = 9;\n _context.p = 10;\n if (!(_iteratorAbruptCompletion && _iterator[\"return\"] != null)) {\n _context.n = 11;\n break;\n }\n _context.n = 11;\n return _iterator[\"return\"]();\n case 11:\n _context.p = 11;\n if (!_didIteratorError) {\n _context.n = 12;\n break;\n }\n throw _iteratorError;\n case 12:\n return _context.f(11);\n case 13:\n return _context.f(9);\n case 14:\n _context.n = 16;\n break;\n case 15:\n _context.p = 15;\n _t2 = _context.v;\n console.error('Error processing PAF file:', _t2);\n throw _t2;\n case 16:\n _context.p = 16;\n rl1.close();\n return _context.f(16);\n case 17:\n return _context.a(2);\n }\n }, _callee, null, [[10,, 11, 13], [2, 8, 9, 14], [1, 15, 16, 17]]);\n }));\n return _createPIF.apply(this, arguments);\n}\nfunction spawnSortProcess(outputFile, useCsi) {\n // Use a more portable approach to avoid E2BIG errors\n\n var sortCmd = \"sort -t\\\"`printf '\\\\t'`\\\" -k1,1 -k3,3n\";\n var bgzipCommand = \"bgzip > \\\"\".concat(outputFile, \"\\\"\");\n var tabixCommand = \"tabix \".concat(useCsi ? '-C ' : '', \"-s1 -b3 -e4 -0 \\\"\").concat(outputFile, \"\\\"\");\n var fullCommand = \"\".concat(sortCmd, \" | \").concat(bgzipCommand, \"; \").concat(tabixCommand);\n var minimalEnv = _objectSpread(_objectSpread({}, process.env), {}, {\n LC_ALL: 'C'\n });\n return (0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)('sh', ['-c', fullCommand], {\n env: minimalEnv,\n stdio: ['pipe', process.stdout, process.stderr]\n });\n}\nfunction getOutputFilename(file, out) {\n return out || \"\".concat(path__WEBPACK_IMPORTED_MODULE_1___default().basename(file || 'output', '.paf'), \".pif.gz\");\n}\nfunction waitForProcessClose(_x3) {\n return _waitForProcessClose.apply(this, arguments);\n}\nfunction _waitForProcessClose() {\n _waitForProcessClose = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(child) {\n return _regenerator().w(function (_context2) {\n while (1) switch (_context2.n) {\n case 0:\n return _context2.a(2, new Promise(function (resolve) {\n child.on('close', resolve);\n }));\n }\n }, _callee2);\n }));\n return _waitForProcessClose.apply(this, arguments);\n}\n\n//# sourceURL=webpack://@jbrowse/cli/./src/commands/make-pif-utils/pif-generator.ts?\n}");
3453
3453
 
3454
3454
  /***/ }),
3455
3455
 
@@ -128,7 +128,7 @@ async function run(args) {
128
128
  }
129
129
  const configType = type || determineConnectionType(url);
130
130
  const id = connectionId ||
131
- [configType, assemblyNames, +Date.now()].filter(f => !!f).join('-');
131
+ [configType, assemblyNames, Date.now()].filter(f => !!f).join('-');
132
132
  const connectionConfig = {
133
133
  type: configType,
134
134
  name: name || id,
@@ -8,14 +8,10 @@ exports.parsePort = parsePort;
8
8
  exports.generateKey = generateKey;
9
9
  exports.setupConfigFile = setupConfigFile;
10
10
  exports.setupRoutes = setupRoutes;
11
- exports.setupServer = setupServer;
12
11
  exports.startServer = startServer;
13
12
  const crypto_1 = __importDefault(require("crypto"));
14
13
  const fs_1 = __importDefault(require("fs"));
15
- const os_1 = __importDefault(require("os"));
16
14
  const path_1 = __importDefault(require("path"));
17
- const cors_1 = __importDefault(require("cors"));
18
- const express_1 = __importDefault(require("express"));
19
15
  const utils_1 = require("../utils");
20
16
  /**
21
17
  * Validates if a port number is in the valid range
@@ -176,44 +172,6 @@ function setupRoutes({ app, baseDir, outFile, key, serverRef, }) {
176
172
  });
177
173
  });
178
174
  }
179
- /**
180
- * Sets up the Express server with routes
181
- */
182
- function setupServer({ baseDir, outFile, bodySizeLimit, }) {
183
- // Create Express application
184
- const app = (0, express_1.default)();
185
- // Configure middleware
186
- app.use(express_1.default.static(baseDir));
187
- app.use((0, cors_1.default)());
188
- app.use(express_1.default.json({ limit: bodySizeLimit }));
189
- // Add error handling middleware
190
- app.use((err, _req, res, next) => {
191
- if (err) {
192
- console.error('Server error:', err);
193
- res.status(500).setHeader('Content-Type', 'text/plain');
194
- res.send('Internal Server Error');
195
- }
196
- else {
197
- next();
198
- }
199
- });
200
- // Generate admin key and store it
201
- const key = generateKey();
202
- const keyPath = path_1.default.join(os_1.default.tmpdir(), `jbrowse-admin-${key}`);
203
- try {
204
- fs_1.default.writeFileSync(keyPath, key);
205
- (0, utils_1.debug)(`Admin key stored at ${keyPath}`);
206
- }
207
- catch (error) {
208
- console.error(`Failed to write admin key to ${keyPath}:`, error.message);
209
- // Continue anyway, as this is not critical
210
- }
211
- // Create server reference for shutdown route
212
- const serverRef = { current: null };
213
- // Set up routes
214
- setupRoutes({ app, baseDir, outFile, key, serverRef });
215
- return { app, key, keyPath, serverRef };
216
- }
217
175
  /**
218
176
  * Starts the server and sets up shutdown handlers
219
177
  */
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.run = run;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
4
10
  const util_1 = require("util");
5
- const utils_1 = require("../utils");
11
+ const cors_1 = __importDefault(require("cors"));
12
+ const express_1 = __importDefault(require("express"));
6
13
  const admin_server_utils_1 = require("./admin-server-utils");
14
+ const utils_1 = require("../utils");
7
15
  async function run(args) {
8
16
  const options = {
9
17
  help: {
@@ -45,10 +53,47 @@ async function run(args) {
45
53
  // Parse and validate port
46
54
  const port = (0, admin_server_utils_1.parsePort)({ portStr: flags.port });
47
55
  // Set up the Express server
48
- const { app, key, keyPath, serverRef } = (0, admin_server_utils_1.setupServer)({
56
+ // const { app, key, keyPath, serverRef } = setupServer({
57
+ // baseDir,
58
+ // outFile,
59
+ // bodySizeLimit,
60
+ // })
61
+ const app = (0, express_1.default)();
62
+ // Configure middleware
63
+ app.use(express_1.default.static(baseDir));
64
+ app.use((0, cors_1.default)());
65
+ app.use(express_1.default.json({ limit: bodySizeLimit }));
66
+ // Add error handling middleware
67
+ app.use((err, _req, res, next) => {
68
+ if (err) {
69
+ console.error('Server error:', err);
70
+ res.status(500).setHeader('Content-Type', 'text/plain');
71
+ res.send('Internal Server Error');
72
+ }
73
+ else {
74
+ next();
75
+ }
76
+ });
77
+ // Generate admin key and store it
78
+ const key = (0, admin_server_utils_1.generateKey)();
79
+ const keyPath = path_1.default.join(os_1.default.tmpdir(), `jbrowse-admin-${key}`);
80
+ try {
81
+ fs_1.default.writeFileSync(keyPath, key);
82
+ (0, utils_1.debug)(`Admin key stored at ${keyPath}`);
83
+ }
84
+ catch (error) {
85
+ console.error(`Failed to write admin key to ${keyPath}:`, error.message);
86
+ // Continue anyway, as this is not critical
87
+ }
88
+ // Create server reference for shutdown route
89
+ const serverRef = { current: null };
90
+ // Set up routes
91
+ (0, admin_server_utils_1.setupRoutes)({
92
+ app,
49
93
  baseDir,
50
94
  outFile,
51
- bodySizeLimit,
95
+ key,
96
+ serverRef,
52
97
  });
53
98
  // Start the server and set up shutdown handlers
54
99
  (0, admin_server_utils_1.startServer)({ app, port, key, outFile, keyPath, serverRef });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/cli",
3
- "version": "3.6.5",
3
+ "version": "3.7.0",
4
4
  "description": "A command line tool for working with JBrowse 2",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -43,10 +43,11 @@
43
43
  "express": "^5.1.0",
44
44
  "ixixx": "^2.0.1",
45
45
  "json-parse-better-errors": "^1.0.2",
46
- "node-fetch-native": "^1.6.4"
46
+ "node-fetch-native": "^1.6.4",
47
+ "tmp": "^0.2.1"
47
48
  },
48
49
  "publishConfig": {
49
50
  "access": "public"
50
51
  },
51
- "gitHead": "354d0a87b757b4d84f824b47507662f6f3a1693f"
52
+ "gitHead": "85bdd0d58286b7adbfd408146b15847676317635"
52
53
  }