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