@difizen/libro-search 0.0.2-alpha.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/abstract-search-provider.d.ts +113 -0
  4. package/es/abstract-search-provider.d.ts.map +1 -0
  5. package/es/abstract-search-provider.js +126 -0
  6. package/es/index.d.ts +10 -0
  7. package/es/index.d.ts.map +1 -0
  8. package/es/index.js +9 -0
  9. package/es/index.less +107 -0
  10. package/es/libro-cell-search-provider.d.ts +10 -0
  11. package/es/libro-cell-search-provider.d.ts.map +1 -0
  12. package/es/libro-cell-search-provider.js +54 -0
  13. package/es/libro-search-engine-html.d.ts +3 -0
  14. package/es/libro-search-engine-html.d.ts.map +1 -0
  15. package/es/libro-search-engine-html.js +59 -0
  16. package/es/libro-search-engine-text.d.ts +10 -0
  17. package/es/libro-search-engine-text.d.ts.map +1 -0
  18. package/es/libro-search-engine-text.js +32 -0
  19. package/es/libro-search-generic-provider.d.ts +107 -0
  20. package/es/libro-search-generic-provider.d.ts.map +1 -0
  21. package/es/libro-search-generic-provider.js +467 -0
  22. package/es/libro-search-manager.d.ts +22 -0
  23. package/es/libro-search-manager.d.ts.map +1 -0
  24. package/es/libro-search-manager.js +102 -0
  25. package/es/libro-search-model.d.ts +111 -0
  26. package/es/libro-search-model.d.ts.map +1 -0
  27. package/es/libro-search-model.js +395 -0
  28. package/es/libro-search-protocol.d.ts +176 -0
  29. package/es/libro-search-protocol.d.ts.map +1 -0
  30. package/es/libro-search-protocol.js +36 -0
  31. package/es/libro-search-provider.d.ts +138 -0
  32. package/es/libro-search-provider.d.ts.map +1 -0
  33. package/es/libro-search-provider.js +759 -0
  34. package/es/libro-search-utils.d.ts +25 -0
  35. package/es/libro-search-utils.d.ts.map +1 -0
  36. package/es/libro-search-utils.js +85 -0
  37. package/es/libro-search-view.d.ts +59 -0
  38. package/es/libro-search-view.d.ts.map +1 -0
  39. package/es/libro-search-view.js +455 -0
  40. package/es/module.d.ts +4 -0
  41. package/es/module.d.ts.map +1 -0
  42. package/es/module.js +35 -0
  43. package/package.json +66 -0
  44. package/src/abstract-search-provider.ts +160 -0
  45. package/src/index.less +107 -0
  46. package/src/index.ts +9 -0
  47. package/src/libro-cell-search-provider.ts +39 -0
  48. package/src/libro-search-engine-html.ts +74 -0
  49. package/src/libro-search-engine-text.ts +34 -0
  50. package/src/libro-search-generic-provider.ts +303 -0
  51. package/src/libro-search-manager.ts +86 -0
  52. package/src/libro-search-model.ts +266 -0
  53. package/src/libro-search-protocol.ts +209 -0
  54. package/src/libro-search-provider.ts +507 -0
  55. package/src/libro-search-utils.spec.ts +37 -0
  56. package/src/libro-search-utils.ts +83 -0
  57. package/src/libro-search-view.tsx +404 -0
  58. package/src/module.ts +59 -0
@@ -0,0 +1,107 @@
1
+ import type { View } from '@difizen/mana-app';
2
+ import { AbstractSearchProvider } from './abstract-search-provider.js';
3
+ import type { HTMLSearchMatch } from './libro-search-protocol.js';
4
+ import { SearchProviderOption } from './libro-search-protocol.js';
5
+ export type GenericSearchProviderFactory = (option: SearchProviderOption) => GenericSearchProvider;
6
+ export declare const GenericSearchProviderFactory: unique symbol;
7
+ /**
8
+ * Generic DOM tree search provider.
9
+ */
10
+ export declare class GenericSearchProvider extends AbstractSearchProvider {
11
+ protected _query: RegExp | null;
12
+ protected _currentMatchIndex: number;
13
+ protected _matches: HTMLSearchMatch[];
14
+ protected _mutationObserver: MutationObserver;
15
+ protected _markNodes: HTMLSpanElement[];
16
+ /**
17
+ * Report whether or not this provider has the ability to search on the given object
18
+ */
19
+ static isApplicable(domain: View): boolean;
20
+ /**
21
+ * The current index of the selected match.
22
+ */
23
+ get currentMatchIndex(): number | undefined;
24
+ /**
25
+ * The current match
26
+ */
27
+ get currentMatch(): HTMLSearchMatch | undefined;
28
+ /**
29
+ * The current matches
30
+ */
31
+ get matches(): HTMLSearchMatch[];
32
+ /**
33
+ * The number of matches.
34
+ */
35
+ get matchesCount(): number | undefined;
36
+ /**
37
+ * Set to true if the widget under search is read-only, false
38
+ * if it is editable. Will be used to determine whether to show
39
+ * the replace option.
40
+ */
41
+ readonly isReadOnly = true;
42
+ constructor(option: SearchProviderOption);
43
+ /**
44
+ * Clear currently highlighted match.
45
+ */
46
+ clearHighlight(): Promise<void>;
47
+ /**
48
+ * Dispose of the resources held by the search provider.
49
+ *
50
+ * #### Notes
51
+ * If the object's `dispose` method is called more than once, all
52
+ * calls made after the first will be a no-op.
53
+ *
54
+ * #### Undefined Behavior
55
+ * It is undefined behavior to use any functionality of the object
56
+ * after it has been disposed unless otherwise explicitly noted.
57
+ */
58
+ dispose(): void;
59
+ /**
60
+ * Move the current match indicator to the next match.
61
+ *
62
+ * @param loop Whether to loop within the matches list.
63
+ *
64
+ * @returns A promise that resolves once the action has completed.
65
+ */
66
+ highlightNext(loop?: boolean): Promise<HTMLSearchMatch | undefined>;
67
+ /**
68
+ * Move the current match indicator to the previous match.
69
+ *
70
+ * @param loop Whether to loop within the matches list.
71
+ *
72
+ * @returns A promise that resolves once the action has completed.
73
+ */
74
+ highlightPrevious(loop?: boolean): Promise<HTMLSearchMatch | undefined>;
75
+ /**
76
+ * Replace the currently selected match with the provided text
77
+ *
78
+ * @param newText The replacement text
79
+ * @param loop Whether to loop within the matches list.
80
+ *
81
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
82
+ */
83
+ replaceCurrentMatch(_newText: string, _loop?: boolean): Promise<boolean>;
84
+ /**
85
+ * Replace all matches in the notebook with the provided text
86
+ *
87
+ * @param newText The replacement text
88
+ *
89
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
90
+ */
91
+ replaceAllMatches(_newText: string): Promise<boolean>;
92
+ /**
93
+ * Initialize the search using the provided options. Should update the UI
94
+ * to highlight all matches and "select" whatever the first match should be.
95
+ *
96
+ * @param query A RegExp to be use to perform the search
97
+ * @param filters Filter parameters to pass to provider
98
+ */
99
+ startQuery: (query: RegExp | null, _filters?: {}) => Promise<void>;
100
+ /**
101
+ * Clear the highlighted matches and any internal state.
102
+ */
103
+ endQuery(): Promise<void>;
104
+ protected _highlightNext(reverse: boolean, loop: boolean): HTMLSearchMatch | null;
105
+ protected _onWidgetChanged(_mutations: MutationRecord[], _observer: MutationObserver): Promise<void>;
106
+ }
107
+ //# sourceMappingURL=libro-search-generic-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libro-search-generic-provider.d.ts","sourceRoot":"","sources":["../src/libro-search-generic-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAGL,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,4BAA4B,GAAG,CACzC,MAAM,EAAE,oBAAoB,KACzB,qBAAqB,CAAC;AAC3B,eAAO,MAAM,4BAA4B,eAAyC,CAAC;AACnF;;GAEG;AACH,qBACa,qBAAsB,SAAQ,sBAAsB;IAC/D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAM;IACnD,SAAS,CAAC,iBAAiB,EAAE,gBAAgB,CAE3C;IACF,SAAS,CAAC,UAAU,oBAAgC;IACpD;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO;IAI1C;;OAEG;IACH,IAAa,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEnD;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,eAAe,GAAG,SAAS,CAE9C;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,EAAE,CAM/B;IAED;;OAEG;IACH,IAAa,YAAY,IAAI,MAAM,GAAG,SAAS,CAE9C;IAED;;;;OAIG;IACH,QAAQ,CAAC,UAAU,QAAQ;gBAEe,MAAM,EAAE,oBAAoB;IAGtE;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAU/B;;;;;;;;;;OAUG;IACM,OAAO,IAAI,IAAI;IAWxB;;;;;;OAMG;IACG,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIzE;;;;;;OAMG;IACG,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAI7E;;;;;;;OAOG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9E;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3D;;;;;;OAMG;IACH,UAAU,UAAiB,MAAM,GAAG,IAAI,oBAAkB,QAAQ,IAAI,CAAC,CAuDrE;IAEF;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAY/B,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI;cA0CjE,gBAAgB,CAC9B,UAAU,EAAE,cAAc,EAAE,EAC5B,SAAS,EAAE,gBAAgB;CAO9B"}
@@ -0,0 +1,467 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
+ function _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."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
19
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
20
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
28
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
29
+ /* eslint-disable @typescript-eslint/no-loop-func */
30
+ /* eslint-disable @typescript-eslint/no-unused-vars */
31
+
32
+ import { prop } from '@difizen/mana-app';
33
+ import { inject, transient } from '@difizen/mana-app';
34
+ import { AbstractSearchProvider } from "./abstract-search-provider.js";
35
+ import { searchInHTML } from "./libro-search-engine-html.js";
36
+ import { LIBRO_SEARCH_FOUND_CLASSES, LIBRO_SEARCH_SELECTED_CLASSES, SearchProviderOption } from "./libro-search-protocol.js";
37
+ export var GenericSearchProviderFactory = Symbol('GenericSearchProviderFactory');
38
+ /**
39
+ * Generic DOM tree search provider.
40
+ */
41
+ export var GenericSearchProvider = (_dec = transient(), _dec2 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_AbstractSearchProvid) {
42
+ _inherits(GenericSearchProvider, _AbstractSearchProvid);
43
+ var _super = _createSuper(GenericSearchProvider);
44
+ function GenericSearchProvider(option) {
45
+ var _this;
46
+ _classCallCheck(this, GenericSearchProvider);
47
+ _this = _super.call(this, option);
48
+ _initializerDefineProperty(_this, "_matches", _descriptor, _assertThisInitialized(_this));
49
+ _this._mutationObserver = new MutationObserver(_this._onWidgetChanged.bind(_assertThisInitialized(_this)));
50
+ _this._markNodes = new Array();
51
+ /**
52
+ * Set to true if the widget under search is read-only, false
53
+ * if it is editable. Will be used to determine whether to show
54
+ * the replace option.
55
+ */
56
+ _this.isReadOnly = true;
57
+ /**
58
+ * Initialize the search using the provided options. Should update the UI
59
+ * to highlight all matches and "select" whatever the first match should be.
60
+ *
61
+ * @param query A RegExp to be use to perform the search
62
+ * @param filters Filter parameters to pass to provider
63
+ */
64
+ _this.startQuery = /*#__PURE__*/function () {
65
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(query) {
66
+ var _this$view$container, _this$view$container2, _this$view$container3;
67
+ var _filters,
68
+ matches,
69
+ nodeIdx,
70
+ _loop2,
71
+ _this$view$container4,
72
+ _args2 = arguments;
73
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
74
+ while (1) switch (_context2.prev = _context2.next) {
75
+ case 0:
76
+ _filters = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
77
+ _context2.next = 3;
78
+ return _this.endQuery();
79
+ case 3:
80
+ _this._query = query;
81
+ if (!(query === null)) {
82
+ _context2.next = 6;
83
+ break;
84
+ }
85
+ return _context2.abrupt("return", Promise.resolve());
86
+ case 6:
87
+ if (!((_this$view$container = _this.view.container) !== null && _this$view$container !== void 0 && _this$view$container.current)) {
88
+ _context2.next = 12;
89
+ break;
90
+ }
91
+ _context2.next = 9;
92
+ return searchInHTML(query, (_this$view$container2 = _this.view.container) === null || _this$view$container2 === void 0 ? void 0 : _this$view$container2.current);
93
+ case 9:
94
+ _context2.t0 = _context2.sent;
95
+ _context2.next = 13;
96
+ break;
97
+ case 12:
98
+ _context2.t0 = [];
99
+ case 13:
100
+ matches = _context2.t0;
101
+ // Transform the DOM
102
+ nodeIdx = 0;
103
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
104
+ var activeNode, parent, subMatches, markedNodes, i;
105
+ return _regeneratorRuntime().wrap(function _loop2$(_context) {
106
+ while (1) switch (_context.prev = _context.next) {
107
+ case 0:
108
+ activeNode = matches[nodeIdx].node;
109
+ parent = activeNode.parentNode;
110
+ subMatches = [matches[nodeIdx]];
111
+ while (++nodeIdx < matches.length && matches[nodeIdx].node === activeNode) {
112
+ subMatches.unshift(matches[nodeIdx]);
113
+ }
114
+ markedNodes = subMatches.map(function (match) {
115
+ var _markedNode$classList;
116
+ // TODO: support tspan for svg when svg support is added
117
+ var markedNode = document.createElement('mark');
118
+ (_markedNode$classList = markedNode.classList).add.apply(_markedNode$classList, _toConsumableArray(LIBRO_SEARCH_FOUND_CLASSES));
119
+ markedNode.textContent = match.text;
120
+ var newNode = activeNode.splitText(match.position);
121
+ newNode.textContent = newNode.textContent.slice(match.text.length);
122
+ parent.insertBefore(markedNode, newNode);
123
+ return markedNode;
124
+ }); // Insert node in reverse order as we replace from last to first
125
+ // to maintain match position.
126
+ for (i = markedNodes.length - 1; i >= 0; i--) {
127
+ _this._markNodes.push(markedNodes[i]);
128
+ }
129
+ case 6:
130
+ case "end":
131
+ return _context.stop();
132
+ }
133
+ }, _loop2);
134
+ });
135
+ case 16:
136
+ if (!(nodeIdx < matches.length)) {
137
+ _context2.next = 20;
138
+ break;
139
+ }
140
+ return _context2.delegateYield(_loop2(), "t1", 18);
141
+ case 18:
142
+ _context2.next = 16;
143
+ break;
144
+ case 20:
145
+ if ((_this$view$container3 = _this.view.container) !== null && _this$view$container3 !== void 0 && _this$view$container3.current) {
146
+ // Watch for future changes:
147
+ _this._mutationObserver.observe((_this$view$container4 = _this.view.container) === null || _this$view$container4 === void 0 ? void 0 : _this$view$container4.current,
148
+ // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserverInit
149
+ {
150
+ attributes: false,
151
+ characterData: true,
152
+ childList: true,
153
+ subtree: true
154
+ });
155
+ }
156
+ _this._matches = matches;
157
+ case 22:
158
+ case "end":
159
+ return _context2.stop();
160
+ }
161
+ }, _callee);
162
+ }));
163
+ return function (_x) {
164
+ return _ref.apply(this, arguments);
165
+ };
166
+ }();
167
+ return _this;
168
+ }
169
+ /**
170
+ * Clear currently highlighted match.
171
+ */
172
+ GenericSearchProvider = inject(SearchProviderOption)(GenericSearchProvider, undefined, 0) || GenericSearchProvider;
173
+ _createClass(GenericSearchProvider, [{
174
+ key: "currentMatchIndex",
175
+ get:
176
+ /**
177
+ * The current index of the selected match.
178
+ */
179
+ function get() {
180
+ return this._currentMatchIndex >= 0 ? this._currentMatchIndex : undefined;
181
+ }
182
+
183
+ /**
184
+ * The current match
185
+ */
186
+ }, {
187
+ key: "currentMatch",
188
+ get: function get() {
189
+ var _this$_matches$this$_;
190
+ return (_this$_matches$this$_ = this._matches[this._currentMatchIndex]) !== null && _this$_matches$this$_ !== void 0 ? _this$_matches$this$_ : undefined;
191
+ }
192
+
193
+ /**
194
+ * The current matches
195
+ */
196
+ }, {
197
+ key: "matches",
198
+ get: function get() {
199
+ // Ensure that no other fn can overwrite matches index property
200
+ // We shallow clone each node
201
+ return this._matches ? this._matches.map(function (m) {
202
+ return Object.assign({}, m);
203
+ }) : this._matches;
204
+ }
205
+
206
+ /**
207
+ * The number of matches.
208
+ */
209
+ }, {
210
+ key: "matchesCount",
211
+ get: function get() {
212
+ return this._matches.length;
213
+ }
214
+ }, {
215
+ key: "clearHighlight",
216
+ value: function clearHighlight() {
217
+ if (this._currentMatchIndex >= 0) {
218
+ var _hit$classList;
219
+ var hit = this._markNodes[this._currentMatchIndex];
220
+ (_hit$classList = hit.classList).remove.apply(_hit$classList, _toConsumableArray(LIBRO_SEARCH_SELECTED_CLASSES));
221
+ }
222
+ this._currentMatchIndex = -1;
223
+ return Promise.resolve();
224
+ }
225
+
226
+ /**
227
+ * Dispose of the resources held by the search provider.
228
+ *
229
+ * #### Notes
230
+ * If the object's `dispose` method is called more than once, all
231
+ * calls made after the first will be a no-op.
232
+ *
233
+ * #### Undefined Behavior
234
+ * It is undefined behavior to use any functionality of the object
235
+ * after it has been disposed unless otherwise explicitly noted.
236
+ */
237
+ }, {
238
+ key: "dispose",
239
+ value: function dispose() {
240
+ if (this.isDisposed) {
241
+ return;
242
+ }
243
+ this.endQuery().catch(function (reason) {
244
+ console.error("Failed to end search query.", reason);
245
+ });
246
+ _get(_getPrototypeOf(GenericSearchProvider.prototype), "dispose", this).call(this);
247
+ }
248
+
249
+ /**
250
+ * Move the current match indicator to the next match.
251
+ *
252
+ * @param loop Whether to loop within the matches list.
253
+ *
254
+ * @returns A promise that resolves once the action has completed.
255
+ */
256
+ }, {
257
+ key: "highlightNext",
258
+ value: function () {
259
+ var _highlightNext2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(loop) {
260
+ var _this$_highlightNext;
261
+ return _regeneratorRuntime().wrap(function _callee2$(_context3) {
262
+ while (1) switch (_context3.prev = _context3.next) {
263
+ case 0:
264
+ return _context3.abrupt("return", (_this$_highlightNext = this._highlightNext(false, loop !== null && loop !== void 0 ? loop : true)) !== null && _this$_highlightNext !== void 0 ? _this$_highlightNext : undefined);
265
+ case 1:
266
+ case "end":
267
+ return _context3.stop();
268
+ }
269
+ }, _callee2, this);
270
+ }));
271
+ function highlightNext(_x2) {
272
+ return _highlightNext2.apply(this, arguments);
273
+ }
274
+ return highlightNext;
275
+ }()
276
+ /**
277
+ * Move the current match indicator to the previous match.
278
+ *
279
+ * @param loop Whether to loop within the matches list.
280
+ *
281
+ * @returns A promise that resolves once the action has completed.
282
+ */
283
+ }, {
284
+ key: "highlightPrevious",
285
+ value: function () {
286
+ var _highlightPrevious = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(loop) {
287
+ var _this$_highlightNext2;
288
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
289
+ while (1) switch (_context4.prev = _context4.next) {
290
+ case 0:
291
+ return _context4.abrupt("return", (_this$_highlightNext2 = this._highlightNext(true, loop !== null && loop !== void 0 ? loop : true)) !== null && _this$_highlightNext2 !== void 0 ? _this$_highlightNext2 : undefined);
292
+ case 1:
293
+ case "end":
294
+ return _context4.stop();
295
+ }
296
+ }, _callee3, this);
297
+ }));
298
+ function highlightPrevious(_x3) {
299
+ return _highlightPrevious.apply(this, arguments);
300
+ }
301
+ return highlightPrevious;
302
+ }()
303
+ /**
304
+ * Replace the currently selected match with the provided text
305
+ *
306
+ * @param newText The replacement text
307
+ * @param loop Whether to loop within the matches list.
308
+ *
309
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
310
+ */
311
+ }, {
312
+ key: "replaceCurrentMatch",
313
+ value: function () {
314
+ var _replaceCurrentMatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_newText, _loop) {
315
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
316
+ while (1) switch (_context5.prev = _context5.next) {
317
+ case 0:
318
+ return _context5.abrupt("return", Promise.resolve(false));
319
+ case 1:
320
+ case "end":
321
+ return _context5.stop();
322
+ }
323
+ }, _callee4);
324
+ }));
325
+ function replaceCurrentMatch(_x4, _x5) {
326
+ return _replaceCurrentMatch.apply(this, arguments);
327
+ }
328
+ return replaceCurrentMatch;
329
+ }()
330
+ /**
331
+ * Replace all matches in the notebook with the provided text
332
+ *
333
+ * @param newText The replacement text
334
+ *
335
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
336
+ */
337
+ }, {
338
+ key: "replaceAllMatches",
339
+ value: function () {
340
+ var _replaceAllMatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_newText) {
341
+ return _regeneratorRuntime().wrap(function _callee5$(_context6) {
342
+ while (1) switch (_context6.prev = _context6.next) {
343
+ case 0:
344
+ return _context6.abrupt("return", Promise.resolve(false));
345
+ case 1:
346
+ case "end":
347
+ return _context6.stop();
348
+ }
349
+ }, _callee5);
350
+ }));
351
+ function replaceAllMatches(_x6) {
352
+ return _replaceAllMatches.apply(this, arguments);
353
+ }
354
+ return replaceAllMatches;
355
+ }()
356
+ }, {
357
+ key: "endQuery",
358
+ value:
359
+ /**
360
+ * Clear the highlighted matches and any internal state.
361
+ */
362
+ function () {
363
+ var _endQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
364
+ return _regeneratorRuntime().wrap(function _callee6$(_context7) {
365
+ while (1) switch (_context7.prev = _context7.next) {
366
+ case 0:
367
+ this._mutationObserver.disconnect();
368
+ this._markNodes.forEach(function (el) {
369
+ var parent = el.parentNode;
370
+ parent.replaceChild(document.createTextNode(el.textContent), el);
371
+ parent.normalize();
372
+ });
373
+ this._markNodes = [];
374
+ this._matches = [];
375
+ this._currentMatchIndex = -1;
376
+ case 5:
377
+ case "end":
378
+ return _context7.stop();
379
+ }
380
+ }, _callee6, this);
381
+ }));
382
+ function endQuery() {
383
+ return _endQuery.apply(this, arguments);
384
+ }
385
+ return endQuery;
386
+ }()
387
+ }, {
388
+ key: "_highlightNext",
389
+ value: function _highlightNext(reverse, loop) {
390
+ if (this._matches.length === 0) {
391
+ return null;
392
+ }
393
+ if (this._currentMatchIndex === -1) {
394
+ this._currentMatchIndex = reverse ? this.matches.length - 1 : 0;
395
+ } else {
396
+ var _hit$classList2;
397
+ var hit = this._markNodes[this._currentMatchIndex];
398
+ (_hit$classList2 = hit.classList).remove.apply(_hit$classList2, _toConsumableArray(LIBRO_SEARCH_SELECTED_CLASSES));
399
+ this._currentMatchIndex = reverse ? this._currentMatchIndex - 1 : this._currentMatchIndex + 1;
400
+ if (loop && (this._currentMatchIndex < 0 || this._currentMatchIndex >= this._matches.length)) {
401
+ // Cheap way to make this a circular buffer
402
+ this._currentMatchIndex = (this._currentMatchIndex + this._matches.length) % this._matches.length;
403
+ }
404
+ }
405
+ if (this._currentMatchIndex >= 0 && this._currentMatchIndex < this._matches.length) {
406
+ var _hit$classList3;
407
+ var _hit = this._markNodes[this._currentMatchIndex];
408
+ (_hit$classList3 = _hit.classList).add.apply(_hit$classList3, _toConsumableArray(LIBRO_SEARCH_SELECTED_CLASSES));
409
+ // If not in view, scroll just enough to see it
410
+ if (!elementInViewport(_hit)) {
411
+ _hit.scrollIntoView(reverse);
412
+ }
413
+ _hit.focus();
414
+ return this._matches[this._currentMatchIndex];
415
+ } else {
416
+ this._currentMatchIndex = -1;
417
+ return null;
418
+ }
419
+ }
420
+ }, {
421
+ key: "_onWidgetChanged",
422
+ value: function () {
423
+ var _onWidgetChanged2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_mutations, _observer) {
424
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
425
+ while (1) switch (_context8.prev = _context8.next) {
426
+ case 0:
427
+ this._currentMatchIndex = -1;
428
+ // This is typically cheap, but we do not control the rate of change or size of the output
429
+ _context8.next = 3;
430
+ return this.startQuery(this._query);
431
+ case 3:
432
+ this._stateChanged.fire();
433
+ case 4:
434
+ case "end":
435
+ return _context8.stop();
436
+ }
437
+ }, _callee7, this);
438
+ }));
439
+ function _onWidgetChanged(_x7, _x8) {
440
+ return _onWidgetChanged2.apply(this, arguments);
441
+ }
442
+ return _onWidgetChanged;
443
+ }()
444
+ }], [{
445
+ key: "isApplicable",
446
+ value:
447
+ /**
448
+ * Report whether or not this provider has the ability to search on the given object
449
+ */
450
+ function isApplicable(domain) {
451
+ var _domain$container;
452
+ return !!((_domain$container = domain.container) !== null && _domain$container !== void 0 && _domain$container.current);
453
+ }
454
+ }]);
455
+ return GenericSearchProvider;
456
+ }(AbstractSearchProvider), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "_matches", [_dec2], {
457
+ configurable: true,
458
+ enumerable: true,
459
+ writable: true,
460
+ initializer: function initializer() {
461
+ return [];
462
+ }
463
+ })), _class2)) || _class);
464
+ function elementInViewport(el) {
465
+ var boundingClientRect = el.getBoundingClientRect();
466
+ return boundingClientRect.top >= 0 && boundingClientRect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && boundingClientRect.left >= 0 && boundingClientRect.right <= (window.innerWidth || document.documentElement.clientWidth);
467
+ }
@@ -0,0 +1,22 @@
1
+ import { LibroCommandRegister, LibroExtensionSlotContribution } from '@difizen/libro-core';
2
+ import type { LibroExtensionSlotFactory, LibroSlot, LibroView } from '@difizen/libro-core';
3
+ import type { CommandRegistry, KeybindingRegistry } from '@difizen/mana-app';
4
+ import { ViewManager, CommandContribution, KeybindingContribution } from '@difizen/mana-app';
5
+ import { LibroSearchView } from './libro-search-view.js';
6
+ export declare const LibroSearchToggleCommand: {
7
+ ShowLibroSearch: {
8
+ id: string;
9
+ keybind: string;
10
+ };
11
+ };
12
+ export declare class LibroSearchManager implements CommandContribution, KeybindingContribution, LibroExtensionSlotContribution {
13
+ viewManager: ViewManager;
14
+ libroCommandRegister: LibroCommandRegister;
15
+ protected viewMap: Map<string, LibroSearchView>;
16
+ readonly slot: LibroSlot;
17
+ registerKeybindings(keybindings: KeybindingRegistry): void;
18
+ registerCommands(commands: CommandRegistry): void;
19
+ factory: LibroExtensionSlotFactory;
20
+ showSearchView: (libro: LibroView) => void;
21
+ }
22
+ //# sourceMappingURL=libro-search-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libro-search-manager.d.ts","sourceRoot":"","sources":["../src/libro-search-manager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,yBAAyB,EACzB,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,eAAO,MAAM,wBAAwB;;;;;CASpC,CAAC;AAEF,qBAOa,kBACX,YACE,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B;IAEX,WAAW,EAAE,WAAW,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IACzE,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAa;IAE5D,SAAgB,IAAI,EAAE,SAAS,CAAe;IAC9C,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAQ1D,gBAAgB,CAAC,QAAQ,EAAE,eAAe;IAa1C,OAAO,EAAE,yBAAyB,CAUhC;IAEF,cAAc,UAAW,SAAS,UAEhC;CACH"}