@jbrowse/plugin-trix 1.7.0 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1173 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var TextSearchAdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/TextSearchAdapterType'));
8
- var Plugin = _interopDefault(require('@jbrowse/core/Plugin'));
9
- var Trix = _interopDefault(require('@gmod/trix'));
10
- var BaseAdapter = require('@jbrowse/core/data_adapters/BaseAdapter');
11
- var io = require('@jbrowse/core/util/io');
12
- var BaseResult = _interopDefault(require('@jbrowse/core/TextSearch/BaseResults'));
13
- var configuration = require('@jbrowse/core/configuration');
14
-
15
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
- try {
17
- var info = gen[key](arg);
18
- var value = info.value;
19
- } catch (error) {
20
- reject(error);
21
- return;
22
- }
23
-
24
- if (info.done) {
25
- resolve(value);
26
- } else {
27
- Promise.resolve(value).then(_next, _throw);
28
- }
29
- }
30
-
31
- function _asyncToGenerator(fn) {
32
- return function () {
33
- var self = this,
34
- args = arguments;
35
- return new Promise(function (resolve, reject) {
36
- var gen = fn.apply(self, args);
37
-
38
- function _next(value) {
39
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
40
- }
41
-
42
- function _throw(err) {
43
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
44
- }
45
-
46
- _next(undefined);
47
- });
48
- };
49
- }
50
-
51
- function _classCallCheck(instance, Constructor) {
52
- if (!(instance instanceof Constructor)) {
53
- throw new TypeError("Cannot call a class as a function");
54
- }
55
- }
56
-
57
- function _defineProperties(target, props) {
58
- for (var i = 0; i < props.length; i++) {
59
- var descriptor = props[i];
60
- descriptor.enumerable = descriptor.enumerable || false;
61
- descriptor.configurable = true;
62
- if ("value" in descriptor) descriptor.writable = true;
63
- Object.defineProperty(target, descriptor.key, descriptor);
64
- }
65
- }
66
-
67
- function _createClass(Constructor, protoProps, staticProps) {
68
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
69
- if (staticProps) _defineProperties(Constructor, staticProps);
70
- Object.defineProperty(Constructor, "prototype", {
71
- writable: false
72
- });
73
- return Constructor;
74
- }
75
-
76
- function _inherits(subClass, superClass) {
77
- if (typeof superClass !== "function" && superClass !== null) {
78
- throw new TypeError("Super expression must either be null or a function");
79
- }
80
-
81
- subClass.prototype = Object.create(superClass && superClass.prototype, {
82
- constructor: {
83
- value: subClass,
84
- writable: true,
85
- configurable: true
86
- }
87
- });
88
- Object.defineProperty(subClass, "prototype", {
89
- writable: false
90
- });
91
- if (superClass) _setPrototypeOf(subClass, superClass);
92
- }
93
-
94
- function _getPrototypeOf(o) {
95
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
96
- return o.__proto__ || Object.getPrototypeOf(o);
97
- };
98
- return _getPrototypeOf(o);
99
- }
100
-
101
- function _setPrototypeOf(o, p) {
102
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
103
- o.__proto__ = p;
104
- return o;
105
- };
106
-
107
- return _setPrototypeOf(o, p);
108
- }
109
-
110
- function _isNativeReflectConstruct() {
111
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
112
- if (Reflect.construct.sham) return false;
113
- if (typeof Proxy === "function") return true;
114
-
115
- try {
116
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
117
- return true;
118
- } catch (e) {
119
- return false;
120
- }
121
- }
122
-
123
- function _assertThisInitialized(self) {
124
- if (self === void 0) {
125
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
126
- }
127
-
128
- return self;
129
- }
130
-
131
- function _possibleConstructorReturn(self, call) {
132
- if (call && (typeof call === "object" || typeof call === "function")) {
133
- return call;
134
- } else if (call !== void 0) {
135
- throw new TypeError("Derived constructors may only return object or undefined");
136
- }
137
-
138
- return _assertThisInitialized(self);
139
- }
140
-
141
- function _createSuper(Derived) {
142
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
143
-
144
- return function _createSuperInternal() {
145
- var Super = _getPrototypeOf(Derived),
146
- result;
147
-
148
- if (hasNativeReflectConstruct) {
149
- var NewTarget = _getPrototypeOf(this).constructor;
150
-
151
- result = Reflect.construct(Super, arguments, NewTarget);
152
- } else {
153
- result = Super.apply(this, arguments);
154
- }
155
-
156
- return _possibleConstructorReturn(this, result);
157
- };
158
- }
159
-
160
- function _slicedToArray(arr, i) {
161
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
162
- }
163
-
164
- function _toArray(arr) {
165
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
166
- }
167
-
168
- function _arrayWithHoles(arr) {
169
- if (Array.isArray(arr)) return arr;
170
- }
171
-
172
- function _iterableToArray(iter) {
173
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
174
- }
175
-
176
- function _iterableToArrayLimit(arr, i) {
177
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
178
-
179
- if (_i == null) return;
180
- var _arr = [];
181
- var _n = true;
182
- var _d = false;
183
-
184
- var _s, _e;
185
-
186
- try {
187
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
188
- _arr.push(_s.value);
189
-
190
- if (i && _arr.length === i) break;
191
- }
192
- } catch (err) {
193
- _d = true;
194
- _e = err;
195
- } finally {
196
- try {
197
- if (!_n && _i["return"] != null) _i["return"]();
198
- } finally {
199
- if (_d) throw _e;
200
- }
201
- }
202
-
203
- return _arr;
204
- }
205
-
206
- function _unsupportedIterableToArray(o, minLen) {
207
- if (!o) return;
208
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
209
- var n = Object.prototype.toString.call(o).slice(8, -1);
210
- if (n === "Object" && o.constructor) n = o.constructor.name;
211
- if (n === "Map" || n === "Set") return Array.from(o);
212
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
213
- }
214
-
215
- function _arrayLikeToArray(arr, len) {
216
- if (len == null || len > arr.length) len = arr.length;
217
-
218
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
219
-
220
- return arr2;
221
- }
222
-
223
- function _nonIterableRest() {
224
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
225
- }
226
-
227
- function createCommonjsModule(fn, module) {
228
- return module = { exports: {} }, fn(module, module.exports), module.exports;
229
- }
230
-
231
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
232
- /**
233
- * Copyright (c) 2014-present, Facebook, Inc.
234
- *
235
- * This source code is licensed under the MIT license found in the
236
- * LICENSE file in the root directory of this source tree.
237
- */
238
- var runtime = function (exports) {
239
-
240
- var Op = Object.prototype;
241
- var hasOwn = Op.hasOwnProperty;
242
- var undefined$1; // More compressible than void 0.
243
-
244
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
245
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
246
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
247
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
248
-
249
- function define(obj, key, value) {
250
- Object.defineProperty(obj, key, {
251
- value: value,
252
- enumerable: true,
253
- configurable: true,
254
- writable: true
255
- });
256
- return obj[key];
257
- }
258
-
259
- try {
260
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
261
- define({}, "");
262
- } catch (err) {
263
- define = function define(obj, key, value) {
264
- return obj[key] = value;
265
- };
266
- }
267
-
268
- function wrap(innerFn, outerFn, self, tryLocsList) {
269
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
270
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
271
- var generator = Object.create(protoGenerator.prototype);
272
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
273
- // .throw, and .return methods.
274
-
275
- generator._invoke = makeInvokeMethod(innerFn, self, context);
276
- return generator;
277
- }
278
-
279
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
280
- // record like context.tryEntries[i].completion. This interface could
281
- // have been (and was previously) designed to take a closure to be
282
- // invoked without arguments, but in all the cases we care about we
283
- // already have an existing method we want to call, so there's no need
284
- // to create a new function object. We can even get away with assuming
285
- // the method takes exactly one argument, since that happens to be true
286
- // in every case, so we don't have to touch the arguments object. The
287
- // only additional allocation required is the completion record, which
288
- // has a stable shape and so hopefully should be cheap to allocate.
289
-
290
- function tryCatch(fn, obj, arg) {
291
- try {
292
- return {
293
- type: "normal",
294
- arg: fn.call(obj, arg)
295
- };
296
- } catch (err) {
297
- return {
298
- type: "throw",
299
- arg: err
300
- };
301
- }
302
- }
303
-
304
- var GenStateSuspendedStart = "suspendedStart";
305
- var GenStateSuspendedYield = "suspendedYield";
306
- var GenStateExecuting = "executing";
307
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
308
- // breaking out of the dispatch switch statement.
309
-
310
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
311
- // .constructor.prototype properties for functions that return Generator
312
- // objects. For full spec compliance, you may wish to configure your
313
- // minifier not to mangle the names of these two functions.
314
-
315
- function Generator() {}
316
-
317
- function GeneratorFunction() {}
318
-
319
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
320
- // don't natively support it.
321
-
322
-
323
- var IteratorPrototype = {};
324
- define(IteratorPrototype, iteratorSymbol, function () {
325
- return this;
326
- });
327
- var getProto = Object.getPrototypeOf;
328
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
329
-
330
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
331
- // This environment has a native %IteratorPrototype%; use it instead
332
- // of the polyfill.
333
- IteratorPrototype = NativeIteratorPrototype;
334
- }
335
-
336
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
337
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
338
- define(Gp, "constructor", GeneratorFunctionPrototype);
339
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
340
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
341
- // Iterator interface in terms of a single ._invoke method.
342
-
343
- function defineIteratorMethods(prototype) {
344
- ["next", "throw", "return"].forEach(function (method) {
345
- define(prototype, method, function (arg) {
346
- return this._invoke(method, arg);
347
- });
348
- });
349
- }
350
-
351
- exports.isGeneratorFunction = function (genFun) {
352
- var ctor = typeof genFun === "function" && genFun.constructor;
353
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
354
- // do is to check its .name property.
355
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
356
- };
357
-
358
- exports.mark = function (genFun) {
359
- if (Object.setPrototypeOf) {
360
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
361
- } else {
362
- genFun.__proto__ = GeneratorFunctionPrototype;
363
- define(genFun, toStringTagSymbol, "GeneratorFunction");
364
- }
365
-
366
- genFun.prototype = Object.create(Gp);
367
- return genFun;
368
- }; // Within the body of any async function, `await x` is transformed to
369
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
370
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
371
- // meant to be awaited.
372
-
373
-
374
- exports.awrap = function (arg) {
375
- return {
376
- __await: arg
377
- };
378
- };
379
-
380
- function AsyncIterator(generator, PromiseImpl) {
381
- function invoke(method, arg, resolve, reject) {
382
- var record = tryCatch(generator[method], generator, arg);
383
-
384
- if (record.type === "throw") {
385
- reject(record.arg);
386
- } else {
387
- var result = record.arg;
388
- var value = result.value;
389
-
390
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
391
- return PromiseImpl.resolve(value.__await).then(function (value) {
392
- invoke("next", value, resolve, reject);
393
- }, function (err) {
394
- invoke("throw", err, resolve, reject);
395
- });
396
- }
397
-
398
- return PromiseImpl.resolve(value).then(function (unwrapped) {
399
- // When a yielded Promise is resolved, its final value becomes
400
- // the .value of the Promise<{value,done}> result for the
401
- // current iteration.
402
- result.value = unwrapped;
403
- resolve(result);
404
- }, function (error) {
405
- // If a rejected Promise was yielded, throw the rejection back
406
- // into the async generator function so it can be handled there.
407
- return invoke("throw", error, resolve, reject);
408
- });
409
- }
410
- }
411
-
412
- var previousPromise;
413
-
414
- function enqueue(method, arg) {
415
- function callInvokeWithMethodAndArg() {
416
- return new PromiseImpl(function (resolve, reject) {
417
- invoke(method, arg, resolve, reject);
418
- });
419
- }
420
-
421
- return previousPromise = // If enqueue has been called before, then we want to wait until
422
- // all previous Promises have been resolved before calling invoke,
423
- // so that results are always delivered in the correct order. If
424
- // enqueue has not been called before, then it is important to
425
- // call invoke immediately, without waiting on a callback to fire,
426
- // so that the async generator function has the opportunity to do
427
- // any necessary setup in a predictable way. This predictability
428
- // is why the Promise constructor synchronously invokes its
429
- // executor callback, and why async functions synchronously
430
- // execute code before the first await. Since we implement simple
431
- // async functions in terms of async generators, it is especially
432
- // important to get this right, even though it requires care.
433
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
434
- // invocations of the iterator.
435
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
436
- } // Define the unified helper method that is used to implement .next,
437
- // .throw, and .return (see defineIteratorMethods).
438
-
439
-
440
- this._invoke = enqueue;
441
- }
442
-
443
- defineIteratorMethods(AsyncIterator.prototype);
444
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
445
- return this;
446
- });
447
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
448
- // AsyncIterator objects; they just return a Promise for the value of
449
- // the final result produced by the iterator.
450
-
451
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
452
- if (PromiseImpl === void 0) PromiseImpl = Promise;
453
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
454
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
455
- : iter.next().then(function (result) {
456
- return result.done ? result.value : iter.next();
457
- });
458
- };
459
-
460
- function makeInvokeMethod(innerFn, self, context) {
461
- var state = GenStateSuspendedStart;
462
- return function invoke(method, arg) {
463
- if (state === GenStateExecuting) {
464
- throw new Error("Generator is already running");
465
- }
466
-
467
- if (state === GenStateCompleted) {
468
- if (method === "throw") {
469
- throw arg;
470
- } // Be forgiving, per 25.3.3.3.3 of the spec:
471
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
472
-
473
-
474
- return doneResult();
475
- }
476
-
477
- context.method = method;
478
- context.arg = arg;
479
-
480
- while (true) {
481
- var delegate = context.delegate;
482
-
483
- if (delegate) {
484
- var delegateResult = maybeInvokeDelegate(delegate, context);
485
-
486
- if (delegateResult) {
487
- if (delegateResult === ContinueSentinel) continue;
488
- return delegateResult;
489
- }
490
- }
491
-
492
- if (context.method === "next") {
493
- // Setting context._sent for legacy support of Babel's
494
- // function.sent implementation.
495
- context.sent = context._sent = context.arg;
496
- } else if (context.method === "throw") {
497
- if (state === GenStateSuspendedStart) {
498
- state = GenStateCompleted;
499
- throw context.arg;
500
- }
501
-
502
- context.dispatchException(context.arg);
503
- } else if (context.method === "return") {
504
- context.abrupt("return", context.arg);
505
- }
506
-
507
- state = GenStateExecuting;
508
- var record = tryCatch(innerFn, self, context);
509
-
510
- if (record.type === "normal") {
511
- // If an exception is thrown from innerFn, we leave state ===
512
- // GenStateExecuting and loop back for another invocation.
513
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
514
-
515
- if (record.arg === ContinueSentinel) {
516
- continue;
517
- }
518
-
519
- return {
520
- value: record.arg,
521
- done: context.done
522
- };
523
- } else if (record.type === "throw") {
524
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
525
- // context.dispatchException(context.arg) call above.
526
-
527
- context.method = "throw";
528
- context.arg = record.arg;
529
- }
530
- }
531
- };
532
- } // Call delegate.iterator[context.method](context.arg) and handle the
533
- // result, either by returning a { value, done } result from the
534
- // delegate iterator, or by modifying context.method and context.arg,
535
- // setting context.delegate to null, and returning the ContinueSentinel.
536
-
537
-
538
- function maybeInvokeDelegate(delegate, context) {
539
- var method = delegate.iterator[context.method];
540
-
541
- if (method === undefined$1) {
542
- // A .throw or .return when the delegate iterator has no .throw
543
- // method always terminates the yield* loop.
544
- context.delegate = null;
545
-
546
- if (context.method === "throw") {
547
- // Note: ["return"] must be used for ES3 parsing compatibility.
548
- if (delegate.iterator["return"]) {
549
- // If the delegate iterator has a return method, give it a
550
- // chance to clean up.
551
- context.method = "return";
552
- context.arg = undefined$1;
553
- maybeInvokeDelegate(delegate, context);
554
-
555
- if (context.method === "throw") {
556
- // If maybeInvokeDelegate(context) changed context.method from
557
- // "return" to "throw", let that override the TypeError below.
558
- return ContinueSentinel;
559
- }
560
- }
561
-
562
- context.method = "throw";
563
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
564
- }
565
-
566
- return ContinueSentinel;
567
- }
568
-
569
- var record = tryCatch(method, delegate.iterator, context.arg);
570
-
571
- if (record.type === "throw") {
572
- context.method = "throw";
573
- context.arg = record.arg;
574
- context.delegate = null;
575
- return ContinueSentinel;
576
- }
577
-
578
- var info = record.arg;
579
-
580
- if (!info) {
581
- context.method = "throw";
582
- context.arg = new TypeError("iterator result is not an object");
583
- context.delegate = null;
584
- return ContinueSentinel;
585
- }
586
-
587
- if (info.done) {
588
- // Assign the result of the finished delegate to the temporary
589
- // variable specified by delegate.resultName (see delegateYield).
590
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
591
-
592
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
593
- // exception, let the outer generator proceed normally. If
594
- // context.method was "next", forget context.arg since it has been
595
- // "consumed" by the delegate iterator. If context.method was
596
- // "return", allow the original .return call to continue in the
597
- // outer generator.
598
-
599
- if (context.method !== "return") {
600
- context.method = "next";
601
- context.arg = undefined$1;
602
- }
603
- } else {
604
- // Re-yield the result returned by the delegate method.
605
- return info;
606
- } // The delegate iterator is finished, so forget it and continue with
607
- // the outer generator.
608
-
609
-
610
- context.delegate = null;
611
- return ContinueSentinel;
612
- } // Define Generator.prototype.{next,throw,return} in terms of the
613
- // unified ._invoke helper method.
614
-
615
-
616
- defineIteratorMethods(Gp);
617
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
618
- // @@iterator function is called on it. Some browsers' implementations of the
619
- // iterator prototype chain incorrectly implement this, causing the Generator
620
- // object to not be returned from this call. This ensures that doesn't happen.
621
- // See https://github.com/facebook/regenerator/issues/274 for more details.
622
-
623
- define(Gp, iteratorSymbol, function () {
624
- return this;
625
- });
626
- define(Gp, "toString", function () {
627
- return "[object Generator]";
628
- });
629
-
630
- function pushTryEntry(locs) {
631
- var entry = {
632
- tryLoc: locs[0]
633
- };
634
-
635
- if (1 in locs) {
636
- entry.catchLoc = locs[1];
637
- }
638
-
639
- if (2 in locs) {
640
- entry.finallyLoc = locs[2];
641
- entry.afterLoc = locs[3];
642
- }
643
-
644
- this.tryEntries.push(entry);
645
- }
646
-
647
- function resetTryEntry(entry) {
648
- var record = entry.completion || {};
649
- record.type = "normal";
650
- delete record.arg;
651
- entry.completion = record;
652
- }
653
-
654
- function Context(tryLocsList) {
655
- // The root entry object (effectively a try statement without a catch
656
- // or a finally block) gives us a place to store values thrown from
657
- // locations where there is no enclosing try statement.
658
- this.tryEntries = [{
659
- tryLoc: "root"
660
- }];
661
- tryLocsList.forEach(pushTryEntry, this);
662
- this.reset(true);
663
- }
664
-
665
- exports.keys = function (object) {
666
- var keys = [];
667
-
668
- for (var key in object) {
669
- keys.push(key);
670
- }
671
-
672
- keys.reverse(); // Rather than returning an object with a next method, we keep
673
- // things simple and return the next function itself.
674
-
675
- return function next() {
676
- while (keys.length) {
677
- var key = keys.pop();
678
-
679
- if (key in object) {
680
- next.value = key;
681
- next.done = false;
682
- return next;
683
- }
684
- } // To avoid creating an additional object, we just hang the .value
685
- // and .done properties off the next function object itself. This
686
- // also ensures that the minifier will not anonymize the function.
687
-
688
-
689
- next.done = true;
690
- return next;
691
- };
692
- };
693
-
694
- function values(iterable) {
695
- if (iterable) {
696
- var iteratorMethod = iterable[iteratorSymbol];
697
-
698
- if (iteratorMethod) {
699
- return iteratorMethod.call(iterable);
700
- }
701
-
702
- if (typeof iterable.next === "function") {
703
- return iterable;
704
- }
705
-
706
- if (!isNaN(iterable.length)) {
707
- var i = -1,
708
- next = function next() {
709
- while (++i < iterable.length) {
710
- if (hasOwn.call(iterable, i)) {
711
- next.value = iterable[i];
712
- next.done = false;
713
- return next;
714
- }
715
- }
716
-
717
- next.value = undefined$1;
718
- next.done = true;
719
- return next;
720
- };
721
-
722
- return next.next = next;
723
- }
724
- } // Return an iterator with no values.
725
-
726
-
727
- return {
728
- next: doneResult
729
- };
730
- }
731
-
732
- exports.values = values;
733
-
734
- function doneResult() {
735
- return {
736
- value: undefined$1,
737
- done: true
738
- };
739
- }
740
-
741
- Context.prototype = {
742
- constructor: Context,
743
- reset: function reset(skipTempReset) {
744
- this.prev = 0;
745
- this.next = 0; // Resetting context._sent for legacy support of Babel's
746
- // function.sent implementation.
747
-
748
- this.sent = this._sent = undefined$1;
749
- this.done = false;
750
- this.delegate = null;
751
- this.method = "next";
752
- this.arg = undefined$1;
753
- this.tryEntries.forEach(resetTryEntry);
754
-
755
- if (!skipTempReset) {
756
- for (var name in this) {
757
- // Not sure about the optimal order of these conditions:
758
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
759
- this[name] = undefined$1;
760
- }
761
- }
762
- }
763
- },
764
- stop: function stop() {
765
- this.done = true;
766
- var rootEntry = this.tryEntries[0];
767
- var rootRecord = rootEntry.completion;
768
-
769
- if (rootRecord.type === "throw") {
770
- throw rootRecord.arg;
771
- }
772
-
773
- return this.rval;
774
- },
775
- dispatchException: function dispatchException(exception) {
776
- if (this.done) {
777
- throw exception;
778
- }
779
-
780
- var context = this;
781
-
782
- function handle(loc, caught) {
783
- record.type = "throw";
784
- record.arg = exception;
785
- context.next = loc;
786
-
787
- if (caught) {
788
- // If the dispatched exception was caught by a catch block,
789
- // then let that catch block handle the exception normally.
790
- context.method = "next";
791
- context.arg = undefined$1;
792
- }
793
-
794
- return !!caught;
795
- }
796
-
797
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
798
- var entry = this.tryEntries[i];
799
- var record = entry.completion;
800
-
801
- if (entry.tryLoc === "root") {
802
- // Exception thrown outside of any try block that could handle
803
- // it, so set the completion value of the entire function to
804
- // throw the exception.
805
- return handle("end");
806
- }
807
-
808
- if (entry.tryLoc <= this.prev) {
809
- var hasCatch = hasOwn.call(entry, "catchLoc");
810
- var hasFinally = hasOwn.call(entry, "finallyLoc");
811
-
812
- if (hasCatch && hasFinally) {
813
- if (this.prev < entry.catchLoc) {
814
- return handle(entry.catchLoc, true);
815
- } else if (this.prev < entry.finallyLoc) {
816
- return handle(entry.finallyLoc);
817
- }
818
- } else if (hasCatch) {
819
- if (this.prev < entry.catchLoc) {
820
- return handle(entry.catchLoc, true);
821
- }
822
- } else if (hasFinally) {
823
- if (this.prev < entry.finallyLoc) {
824
- return handle(entry.finallyLoc);
825
- }
826
- } else {
827
- throw new Error("try statement without catch or finally");
828
- }
829
- }
830
- }
831
- },
832
- abrupt: function abrupt(type, arg) {
833
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
834
- var entry = this.tryEntries[i];
835
-
836
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
837
- var finallyEntry = entry;
838
- break;
839
- }
840
- }
841
-
842
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
843
- // Ignore the finally entry if control is not jumping to a
844
- // location outside the try/catch block.
845
- finallyEntry = null;
846
- }
847
-
848
- var record = finallyEntry ? finallyEntry.completion : {};
849
- record.type = type;
850
- record.arg = arg;
851
-
852
- if (finallyEntry) {
853
- this.method = "next";
854
- this.next = finallyEntry.finallyLoc;
855
- return ContinueSentinel;
856
- }
857
-
858
- return this.complete(record);
859
- },
860
- complete: function complete(record, afterLoc) {
861
- if (record.type === "throw") {
862
- throw record.arg;
863
- }
864
-
865
- if (record.type === "break" || record.type === "continue") {
866
- this.next = record.arg;
867
- } else if (record.type === "return") {
868
- this.rval = this.arg = record.arg;
869
- this.method = "return";
870
- this.next = "end";
871
- } else if (record.type === "normal" && afterLoc) {
872
- this.next = afterLoc;
873
- }
874
-
875
- return ContinueSentinel;
876
- },
877
- finish: function finish(finallyLoc) {
878
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
879
- var entry = this.tryEntries[i];
880
-
881
- if (entry.finallyLoc === finallyLoc) {
882
- this.complete(entry.completion, entry.afterLoc);
883
- resetTryEntry(entry);
884
- return ContinueSentinel;
885
- }
886
- }
887
- },
888
- "catch": function _catch(tryLoc) {
889
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
890
- var entry = this.tryEntries[i];
891
-
892
- if (entry.tryLoc === tryLoc) {
893
- var record = entry.completion;
894
-
895
- if (record.type === "throw") {
896
- var thrown = record.arg;
897
- resetTryEntry(entry);
898
- }
899
-
900
- return thrown;
901
- }
902
- } // The context.catch method must only be called with a location
903
- // argument that corresponds to a known catch block.
904
-
905
-
906
- throw new Error("illegal catch attempt");
907
- },
908
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
909
- this.delegate = {
910
- iterator: values(iterable),
911
- resultName: resultName,
912
- nextLoc: nextLoc
913
- };
914
-
915
- if (this.method === "next") {
916
- // Deliberately forget the last sent value so that we don't
917
- // accidentally pass it on to the delegate.
918
- this.arg = undefined$1;
919
- }
920
-
921
- return ContinueSentinel;
922
- }
923
- }; // Regardless of whether this script is executing as a CommonJS module
924
- // or not, return the runtime object so that we can declare the variable
925
- // regeneratorRuntime in the outer scope, which allows this module to be
926
- // injected easily by `bin/regenerator --include-runtime script.js`.
927
-
928
- return exports;
929
- }( // If this script is executing as a CommonJS module, use module.exports
930
- // as the regeneratorRuntime namespace. Otherwise create a new empty
931
- // object. Either way, the resulting object will be used to initialize
932
- // the regeneratorRuntime variable at the top of this file.
933
- module.exports );
934
-
935
- try {
936
- regeneratorRuntime = runtime;
937
- } catch (accidentalStrictMode) {
938
- // This module should not be running in strict mode, so the above
939
- // assignment should always work unless something is misconfigured. Just
940
- // in case runtime.js accidentally runs in strict mode, in modern engines
941
- // we can explicitly access globalThis. In older engines we can escape
942
- // strict mode using a global Function call. This could conceivably fail
943
- // if a Content Security Policy forbids using Function, but in that case
944
- // the proper solution is to fix the accidental strict mode problem. If
945
- // you've misconfigured your bundler to force strict mode and applied a
946
- // CSP to forbid Function, and you're not willing to fix either of those
947
- // problems, please detail your unique predicament in a GitHub issue.
948
- if (typeof globalThis === "object") {
949
- globalThis.regeneratorRuntime = runtime;
950
- } else {
951
- Function("r", "regeneratorRuntime = r")(runtime);
952
- }
953
- }
954
- });
955
-
956
- function decodeURIComponentNoThrow(uri) {
957
- try {
958
- return decodeURIComponent(uri);
959
- } catch (e) {
960
- // avoid throwing exception on a failure to decode URI component
961
- return uri;
962
- }
963
- }
964
-
965
- function shorten(str, term) {
966
- var w = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 15;
967
- var tidx = str.toLowerCase().indexOf(term);
968
- return str.length < 40 ? str : (Math.max(0, tidx - w) > 0 ? '...' : '') + str.slice(Math.max(0, tidx - w), tidx + term.length + w).trim() + (tidx + term.length < str.length ? '...' : '');
969
- }
970
-
971
- var TrixTextSearchAdapter = /*#__PURE__*/function (_BaseAdapter) {
972
- _inherits(TrixTextSearchAdapter, _BaseAdapter);
973
-
974
- var _super = /*#__PURE__*/_createSuper(TrixTextSearchAdapter);
975
-
976
- function TrixTextSearchAdapter(config, getSubAdapter, pluginManager) {
977
- var _this;
978
-
979
- _classCallCheck(this, TrixTextSearchAdapter);
980
-
981
- _this = _super.call(this, config, getSubAdapter, pluginManager);
982
- var ixFilePath = configuration.readConfObject(config, 'ixFilePath');
983
- var ixxFilePath = configuration.readConfObject(config, 'ixxFilePath');
984
-
985
- if (!ixFilePath) {
986
- throw new Error('must provide out.ix');
987
- }
988
-
989
- if (!ixxFilePath) {
990
- throw new Error('must provide out.ixx');
991
- }
992
-
993
- _this.trixJs = new Trix(io.openLocation(ixxFilePath), io.openLocation(ixFilePath), 1500);
994
- return _this;
995
- }
996
- /*
997
- * Returns list of results
998
- * @param args - search options/arguments include: search query
999
- * limit of results to return, searchType...prefix | full | exact", etc.
1000
- */
1001
-
1002
-
1003
- _createClass(TrixTextSearchAdapter, [{
1004
- key: "searchIndex",
1005
- value: function () {
1006
- var _searchIndex = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(args) {
1007
- var query, strs, results, formatted;
1008
- return runtime_1.wrap(function _callee$(_context) {
1009
- while (1) {
1010
- switch (_context.prev = _context.next) {
1011
- case 0:
1012
- query = args.queryString.toLowerCase();
1013
- strs = query.split(' ');
1014
- _context.next = 4;
1015
- return this.trixJs.search(query);
1016
-
1017
- case 4:
1018
- results = _context.sent;
1019
- formatted = results // if multi-word search try to filter out relevant items
1020
- .filter(function (_ref) {
1021
- var _ref2 = _slicedToArray(_ref, 2),
1022
- data = _ref2[1];
1023
-
1024
- return strs.every(function (r) {
1025
- return decodeURIComponentNoThrow(data).toLowerCase().includes(r);
1026
- });
1027
- }).map(function (_ref3) {
1028
- var _ref4 = _slicedToArray(_ref3, 2),
1029
- term = _ref4[0],
1030
- data = _ref4[1];
1031
-
1032
- var result = JSON.parse(data.replace(/\|/g, ','));
1033
-
1034
- var _result$map = result.map(function (record) {
1035
- return decodeURIComponentNoThrow(record);
1036
- }),
1037
- _result$map2 = _toArray(_result$map),
1038
- loc = _result$map2[0],
1039
- trackId = _result$map2[1],
1040
- rest = _result$map2.slice(2);
1041
-
1042
- var labelFieldIdx = rest.findIndex(function (elt) {
1043
- return !!elt;
1044
- });
1045
- var contextIdx = rest.map(function (elt) {
1046
- return elt.toLowerCase();
1047
- }).findIndex(function (f) {
1048
- return f.indexOf(term.toLowerCase()) !== -1;
1049
- });
1050
- var labelField = rest[labelFieldIdx];
1051
- var contextField = rest[contextIdx];
1052
- var context = contextIdx !== -1 ? shorten(contextField, term) : undefined;
1053
- var label = shorten(labelField, term);
1054
- var displayString = !context || label.toLowerCase() === context.toLowerCase() ? label : "".concat(label, " (").concat(context, ")");
1055
- return new BaseResult({
1056
- locString: loc,
1057
- label: labelField,
1058
- displayString: displayString,
1059
- matchedObject: result.map(function (record) {
1060
- return decodeURIComponent(record);
1061
- }),
1062
- trackId: trackId
1063
- });
1064
- });
1065
-
1066
- if (!(args.searchType === 'exact')) {
1067
- _context.next = 8;
1068
- break;
1069
- }
1070
-
1071
- return _context.abrupt("return", formatted.filter(function (res) {
1072
- return res.getLabel().toLowerCase() === args.queryString.toLowerCase();
1073
- }));
1074
-
1075
- case 8:
1076
- return _context.abrupt("return", formatted);
1077
-
1078
- case 9:
1079
- case "end":
1080
- return _context.stop();
1081
- }
1082
- }
1083
- }, _callee, this);
1084
- }));
1085
-
1086
- function searchIndex(_x) {
1087
- return _searchIndex.apply(this, arguments);
1088
- }
1089
-
1090
- return searchIndex;
1091
- }()
1092
- }, {
1093
- key: "freeResources",
1094
- value: function freeResources() {}
1095
- }]);
1096
-
1097
- return TrixTextSearchAdapter;
1098
- }(BaseAdapter.BaseAdapter);
1099
-
1100
- var trixAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('TrixTextSearchAdapter', {
1101
- ixFilePath: {
1102
- type: 'fileLocation',
1103
- defaultValue: {
1104
- uri: 'out.ix',
1105
- locationType: 'UriLocation'
1106
- },
1107
- description: 'the location of the trix ix file'
1108
- },
1109
- ixxFilePath: {
1110
- type: 'fileLocation',
1111
- defaultValue: {
1112
- uri: 'out.ixx',
1113
- locationType: 'UriLocation'
1114
- },
1115
- description: 'the location of the trix ixx file'
1116
- },
1117
- metaFilePath: {
1118
- type: 'fileLocation',
1119
- defaultValue: {
1120
- uri: 'meta.json',
1121
- locationType: 'UriLocation'
1122
- },
1123
- description: 'the location of the metadata json file for the trix index'
1124
- },
1125
- tracks: {
1126
- type: 'stringArray',
1127
- defaultValue: [],
1128
- description: 'List of tracks covered by text search adapter'
1129
- },
1130
- assemblyNames: {
1131
- type: 'stringArray',
1132
- defaultValue: [],
1133
- description: 'List of assemblies covered by text search adapter'
1134
- }
1135
- }, {
1136
- explicitlyTyped: true,
1137
- explicitIdentifier: 'textSearchAdapterId'
1138
- });
1139
-
1140
- var _default = /*#__PURE__*/function (_Plugin) {
1141
- _inherits(_default, _Plugin);
1142
-
1143
- var _super = /*#__PURE__*/_createSuper(_default);
1144
-
1145
- function _default() {
1146
- var _this;
1147
-
1148
- _classCallCheck(this, _default);
1149
-
1150
- _this = _super.apply(this, arguments);
1151
- _this.name = 'TrixPlugin';
1152
- return _this;
1153
- }
1154
-
1155
- _createClass(_default, [{
1156
- key: "install",
1157
- value: function install(pluginManager) {
1158
- pluginManager.addTextSearchAdapterType(function () {
1159
- return new TextSearchAdapterType({
1160
- name: 'TrixTextSearchAdapter',
1161
- configSchema: trixAdapterConfigSchema,
1162
- AdapterClass: TrixTextSearchAdapter,
1163
- description: 'Trix adapter'
1164
- });
1165
- });
1166
- }
1167
- }]);
1168
-
1169
- return _default;
1170
- }(Plugin);
1171
-
1172
- exports.default = _default;
1173
- //# sourceMappingURL=plugin-trix.cjs.development.js.map