@difizen/libro-search-code-cell 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/es/code-cell-search-protocol.d.ts +26 -0
- package/es/code-cell-search-protocol.d.ts.map +1 -0
- package/es/code-cell-search-protocol.js +3 -0
- package/es/code-cell-search-provider-contribution.d.ts +18 -0
- package/es/code-cell-search-provider-contribution.d.ts.map +1 -0
- package/es/code-cell-search-provider-contribution.js +64 -0
- package/es/code-cell-search-provider.d.ts +52 -0
- package/es/code-cell-search-provider.d.ts.map +1 -0
- package/es/code-cell-search-provider.js +423 -0
- package/es/code-editor-cell-search-provider.d.ts +138 -0
- package/es/code-editor-cell-search-provider.d.ts.map +1 -0
- package/es/code-editor-cell-search-provider.js +563 -0
- package/es/index.d.ts +5 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +4 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +30 -0
- package/es/search-highlighter.d.ts +58 -0
- package/es/search-highlighter.d.ts.map +1 -0
- package/es/search-highlighter.js +241 -0
- package/package.json +57 -0
- package/src/code-cell-search-protocol.ts +40 -0
- package/src/code-cell-search-provider-contribution.ts +39 -0
- package/src/code-cell-search-provider.ts +227 -0
- package/src/code-editor-cell-search-provider.ts +377 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +4 -0
- package/src/module.ts +46 -0
- package/src/search-highlighter.ts +207 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Difizen Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LibroCodeCellView } from '@difizen/libro-code-cell';
|
|
2
|
+
import type { IEditor, SearchMatch } from '@difizen/libro-code-editor';
|
|
3
|
+
import type { CellSearchProvider } from '@difizen/libro-search';
|
|
4
|
+
export type CodeEditorSearchHighlighterFactory = (editor: IEditor | undefined) => CodeEditorSearchHighlighter;
|
|
5
|
+
export declare const CodeEditorSearchHighlighterFactory: unique symbol;
|
|
6
|
+
export declare const CodeCellSearchOption: unique symbol;
|
|
7
|
+
export interface CodeCellSearchOption {
|
|
8
|
+
cell: LibroCodeCellView;
|
|
9
|
+
}
|
|
10
|
+
export declare const CodeCellSearchProviderFactory: unique symbol;
|
|
11
|
+
export type CodeCellSearchProviderFactory = (option: CodeCellSearchOption) => CellSearchProvider;
|
|
12
|
+
export interface CodeEditorSearchHighlighter {
|
|
13
|
+
/**
|
|
14
|
+
* The list of matches
|
|
15
|
+
*/
|
|
16
|
+
get matches(): SearchMatch[];
|
|
17
|
+
set matches(v: SearchMatch[]);
|
|
18
|
+
get currentIndex(): number | undefined;
|
|
19
|
+
set currentIndex(v: number | undefined);
|
|
20
|
+
setEditor: (editor: IEditor) => void;
|
|
21
|
+
clearHighlight: () => void;
|
|
22
|
+
endQuery: () => Promise<void>;
|
|
23
|
+
highlightNext: () => Promise<SearchMatch | undefined>;
|
|
24
|
+
highlightPrevious: () => Promise<SearchMatch | undefined>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=code-cell-search-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-cell-search-protocol.d.ts","sourceRoot":"","sources":["../src/code-cell-search-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,MAAM,kCAAkC,GAAG,CAC/C,MAAM,EAAE,OAAO,GAAG,SAAS,KACxB,2BAA2B,CAAC;AACjC,eAAO,MAAM,kCAAkC,eAE9C,CAAC;AAEF,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,MAAM,6BAA6B,GAAG,CAC1C,MAAM,EAAE,oBAAoB,KACzB,kBAAkB,CAAC;AAExB,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE;IAE9B,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IACvC,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE;IAExC,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAErC,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,aAAa,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IACtD,iBAAiB,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CellView } from '@difizen/libro-core';
|
|
2
|
+
import { CellSearchProviderContribution } from '@difizen/libro-search';
|
|
3
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
4
|
+
import { CodeCellSearchProviderFactory } from './code-cell-search-protocol.js';
|
|
5
|
+
export declare class CodeCellSearchProviderContribution implements CellSearchProviderContribution {
|
|
6
|
+
viewManager: ViewManager;
|
|
7
|
+
providerfactory: CodeCellSearchProviderFactory;
|
|
8
|
+
canHandle: (cell: CellView) => 100 | 0;
|
|
9
|
+
factory(cell: CellView): import("@difizen/libro-search").CellSearchProvider;
|
|
10
|
+
/**
|
|
11
|
+
* Get an initial query value if applicable so that it can be entered
|
|
12
|
+
* into the search box as an initial query
|
|
13
|
+
*
|
|
14
|
+
* @returns Initial value used to populate the search box.
|
|
15
|
+
*/
|
|
16
|
+
getInitialQuery: (cell: CellView) => string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=code-cell-search-provider-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-cell-search-provider-contribution.d.ts","sourceRoot":"","sources":["../src/code-cell-search-provider-contribution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAE/E,qBACa,kCACX,YAAW,8BAA8B;IAEpB,WAAW,EAAE,WAAW,CAAC;IAE9C,eAAe,EAAE,6BAA6B,CAAC;IAC/C,SAAS,SAAU,QAAQ,aAKzB;IACF,OAAO,CAAC,IAAI,EAAE,QAAQ;IAGtB;;;;;OAKG;IACH,eAAe,SAAU,QAAQ,KAAG,MAAM,CAOxC;CACH"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
3
|
+
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 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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.'); }
|
|
11
|
+
import { LibroCodeCellView } from '@difizen/libro-code-cell';
|
|
12
|
+
import { CellSearchProviderContribution } from '@difizen/libro-search';
|
|
13
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
14
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
15
|
+
import { CodeCellSearchProviderFactory } from "./code-cell-search-protocol.js";
|
|
16
|
+
export var CodeCellSearchProviderContribution = (_dec = singleton({
|
|
17
|
+
contrib: CellSearchProviderContribution
|
|
18
|
+
}), _dec2 = inject(ViewManager), _dec3 = inject(CodeCellSearchProviderFactory), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
19
|
+
function CodeCellSearchProviderContribution() {
|
|
20
|
+
_classCallCheck(this, CodeCellSearchProviderContribution);
|
|
21
|
+
_initializerDefineProperty(this, "viewManager", _descriptor, this);
|
|
22
|
+
_initializerDefineProperty(this, "providerfactory", _descriptor2, this);
|
|
23
|
+
this.canHandle = function (cell) {
|
|
24
|
+
if (cell instanceof LibroCodeCellView) {
|
|
25
|
+
return 100;
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get an initial query value if applicable so that it can be entered
|
|
31
|
+
* into the search box as an initial query
|
|
32
|
+
*
|
|
33
|
+
* @returns Initial value used to populate the search box.
|
|
34
|
+
*/
|
|
35
|
+
this.getInitialQuery = function (cell) {
|
|
36
|
+
if (cell instanceof LibroCodeCellView) {
|
|
37
|
+
var _cell$editor;
|
|
38
|
+
var selection = (_cell$editor = cell.editor) === null || _cell$editor === void 0 ? void 0 : _cell$editor.getSelectionValue();
|
|
39
|
+
// if there are newlines, just return empty string
|
|
40
|
+
return (selection === null || selection === void 0 ? void 0 : selection.search(/\r?\n|\r/g)) === -1 ? selection : '';
|
|
41
|
+
}
|
|
42
|
+
return '';
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
_createClass(CodeCellSearchProviderContribution, [{
|
|
46
|
+
key: "factory",
|
|
47
|
+
value: function factory(cell) {
|
|
48
|
+
return this.providerfactory({
|
|
49
|
+
cell: cell
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}]);
|
|
53
|
+
return CodeCellSearchProviderContribution;
|
|
54
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
|
|
55
|
+
configurable: true,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
initializer: null
|
|
59
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "providerfactory", [_dec3], {
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
initializer: null
|
|
64
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SearchMatch } from '@difizen/libro-code-editor';
|
|
2
|
+
import type { GenericSearchProvider, SearchFilters } from '@difizen/libro-search';
|
|
3
|
+
import { GenericSearchProviderFactory } from '@difizen/libro-search';
|
|
4
|
+
import { CodeCellSearchOption, CodeEditorSearchHighlighterFactory } from './code-cell-search-protocol.js';
|
|
5
|
+
import { CodeEditorCellSearchProvider } from './code-editor-cell-search-provider.js';
|
|
6
|
+
export declare class CodeCellSearchProvider extends CodeEditorCellSearchProvider {
|
|
7
|
+
protected genericSearchProviderFactory: GenericSearchProviderFactory;
|
|
8
|
+
protected outputsProvider: GenericSearchProvider[];
|
|
9
|
+
protected currentProviderIndex: number;
|
|
10
|
+
/**
|
|
11
|
+
* Constructor
|
|
12
|
+
*
|
|
13
|
+
* @param cell Cell widget
|
|
14
|
+
*/
|
|
15
|
+
constructor(highlighterFactory: CodeEditorSearchHighlighterFactory, genericSearchProviderFactory: GenericSearchProviderFactory, option: CodeCellSearchOption);
|
|
16
|
+
/**
|
|
17
|
+
* Number of matches in the cell.
|
|
18
|
+
*/
|
|
19
|
+
get matchesCount(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Clear currently highlighted match.
|
|
22
|
+
*/
|
|
23
|
+
clearHighlight(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Dispose the search provider
|
|
26
|
+
*/
|
|
27
|
+
dispose(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Highlight the next match.
|
|
30
|
+
*
|
|
31
|
+
* @returns The next match if there is one.
|
|
32
|
+
*/
|
|
33
|
+
highlightNext(): Promise<SearchMatch | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Highlight the previous match.
|
|
36
|
+
*
|
|
37
|
+
* @returns The previous match if there is one.
|
|
38
|
+
*/
|
|
39
|
+
highlightPrevious(): Promise<SearchMatch | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the search using the provided options. Should update the UI to highlight
|
|
42
|
+
* all matches and "select" the first match.
|
|
43
|
+
*
|
|
44
|
+
* @param query A RegExp to be use to perform the search
|
|
45
|
+
* @param filters Filter parameters to pass to provider
|
|
46
|
+
*/
|
|
47
|
+
startQuery(query: RegExp | null, filters?: SearchFilters): Promise<void>;
|
|
48
|
+
endQuery(): Promise<void>;
|
|
49
|
+
refresh(): Promise<void>;
|
|
50
|
+
protected setupOutputProvider: () => Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=code-cell-search-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-cell-search-provider.d.ts","sourceRoot":"","sources":["../src/code-cell-search-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EACL,oBAAoB,EACpB,kCAAkC,EACnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAErF,qBACa,sBAAuB,SAAQ,4BAA4B;IACtE,SAAS,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAC7D,SAAS,CAAC,eAAe,EAAE,qBAAqB,EAAE,CAAC;IACnD,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAC/C;;;;OAIG;gBAGD,kBAAkB,EAAE,kCAAkC,EAEtD,4BAA4B,EAAE,4BAA4B,EAC5B,MAAM,EAAE,oBAAoB;IAuB5D;;OAEG;IACH,IAAa,YAAY,IAAI,MAAM,CAYlC;IAED;;OAEG;IACY,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9C;;OAEG;IACM,OAAO,IAAI,IAAI;IAWxB;;;;OAIG;IACY,aAAa,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAqChE;;;;OAIG;IACY,iBAAiB,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAqCpE;;;;;;OAMG;IACY,UAAU,CACvB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC;IAYD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC,OAAO;IAMb,SAAS,CAAC,mBAAmB,sBAc3B;CACH"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
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); } }
|
|
5
|
+
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); }); }; }
|
|
6
|
+
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 }); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
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); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); }
|
|
12
|
+
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); }
|
|
13
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
14
|
+
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); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
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); }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
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; } }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
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; }
|
|
22
|
+
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.'); }
|
|
23
|
+
/* eslint-disable no-param-reassign */
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
+
|
|
26
|
+
import { GenericSearchProviderFactory } from '@difizen/libro-search';
|
|
27
|
+
import { inject, prop, transient, watch } from '@difizen/mana-app';
|
|
28
|
+
import { CodeCellSearchOption, CodeEditorSearchHighlighterFactory } from "./code-cell-search-protocol.js";
|
|
29
|
+
import { CodeEditorCellSearchProvider } from "./code-editor-cell-search-provider.js";
|
|
30
|
+
export var CodeCellSearchProvider = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_CodeEditorCellSearch) {
|
|
31
|
+
_inherits(CodeCellSearchProvider, _CodeEditorCellSearch);
|
|
32
|
+
var _super = _createSuper(CodeCellSearchProvider);
|
|
33
|
+
/**
|
|
34
|
+
* Constructor
|
|
35
|
+
*
|
|
36
|
+
* @param cell Cell widget
|
|
37
|
+
*/
|
|
38
|
+
function CodeCellSearchProvider(highlighterFactory, genericSearchProviderFactory, option) {
|
|
39
|
+
var _this;
|
|
40
|
+
_classCallCheck(this, CodeCellSearchProvider);
|
|
41
|
+
_this = _super.call(this, highlighterFactory, option.cell);
|
|
42
|
+
_initializerDefineProperty(_this, "outputsProvider", _descriptor, _assertThisInitialized(_this));
|
|
43
|
+
_initializerDefineProperty(_this, "currentProviderIndex", _descriptor2, _assertThisInitialized(_this));
|
|
44
|
+
_this.setupOutputProvider = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
45
|
+
var _this$filters;
|
|
46
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
_this.outputsProvider.forEach(function (provider) {
|
|
50
|
+
provider.dispose();
|
|
51
|
+
});
|
|
52
|
+
_this.outputsProvider.length = 0;
|
|
53
|
+
_this.currentProviderIndex = -1;
|
|
54
|
+
_this.outputsProvider = _this.cell.outputArea.outputs.map(function (output) {
|
|
55
|
+
return _this.genericSearchProviderFactory({
|
|
56
|
+
view: output
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
if (_this.isActive && _this.query && ((_this$filters = _this.filters) === null || _this$filters === void 0 ? void 0 : _this$filters.searchCellOutput) !== false) {
|
|
60
|
+
_this.refresh();
|
|
61
|
+
}
|
|
62
|
+
_this.stateChangedEmitter.fire();
|
|
63
|
+
case 6:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context.stop();
|
|
66
|
+
}
|
|
67
|
+
}, _callee);
|
|
68
|
+
}));
|
|
69
|
+
_this.genericSearchProviderFactory = genericSearchProviderFactory;
|
|
70
|
+
_this.currentProviderIndex = -1;
|
|
71
|
+
_this.outputsProvider = [];
|
|
72
|
+
_this.setupOutputProvider();
|
|
73
|
+
_this.cell.outputArea.onUpdate(function () {
|
|
74
|
+
_this.setupOutputProvider();
|
|
75
|
+
});
|
|
76
|
+
_this.toDispose.push(watch(_this.cell.model, 'hasOutputHidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
77
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
78
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context2.next = 2;
|
|
81
|
+
return _this.refresh();
|
|
82
|
+
case 2:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context2.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee2);
|
|
87
|
+
}))));
|
|
88
|
+
_this.toDispose.push(watch(_this.cell, 'hasInputHidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
90
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
_context3.next = 2;
|
|
93
|
+
return _this.refresh();
|
|
94
|
+
case 2:
|
|
95
|
+
case "end":
|
|
96
|
+
return _context3.stop();
|
|
97
|
+
}
|
|
98
|
+
}, _callee3);
|
|
99
|
+
}))));
|
|
100
|
+
return _this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Number of matches in the cell.
|
|
105
|
+
*/
|
|
106
|
+
CodeCellSearchProvider = inject(CodeCellSearchOption)(CodeCellSearchProvider, undefined, 2) || CodeCellSearchProvider;
|
|
107
|
+
CodeCellSearchProvider = inject(GenericSearchProviderFactory)(CodeCellSearchProvider, undefined, 1) || CodeCellSearchProvider;
|
|
108
|
+
CodeCellSearchProvider = inject(CodeEditorSearchHighlighterFactory)(CodeCellSearchProvider, undefined, 0) || CodeCellSearchProvider;
|
|
109
|
+
_createClass(CodeCellSearchProvider, [{
|
|
110
|
+
key: "matchesCount",
|
|
111
|
+
get: function get() {
|
|
112
|
+
if (!this.isActive) {
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "matchesCount", this) + this.outputsProvider.reduce(function (sum, provider) {
|
|
116
|
+
var _provider$matchesCoun;
|
|
117
|
+
return sum + ((_provider$matchesCoun = provider.matchesCount) !== null && _provider$matchesCoun !== void 0 ? _provider$matchesCoun : 0);
|
|
118
|
+
}, 0);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Clear currently highlighted match.
|
|
123
|
+
*/
|
|
124
|
+
}, {
|
|
125
|
+
key: "clearHighlight",
|
|
126
|
+
value: function () {
|
|
127
|
+
var _clearHighlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
128
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
129
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
_context4.next = 2;
|
|
132
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "clearHighlight", this).call(this);
|
|
133
|
+
case 2:
|
|
134
|
+
_context4.next = 4;
|
|
135
|
+
return Promise.all(this.outputsProvider.map(function (provider) {
|
|
136
|
+
return provider.clearHighlight();
|
|
137
|
+
}));
|
|
138
|
+
case 4:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context4.stop();
|
|
141
|
+
}
|
|
142
|
+
}, _callee4, this);
|
|
143
|
+
}));
|
|
144
|
+
function clearHighlight() {
|
|
145
|
+
return _clearHighlight.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
return clearHighlight;
|
|
148
|
+
}()
|
|
149
|
+
/**
|
|
150
|
+
* Dispose the search provider
|
|
151
|
+
*/
|
|
152
|
+
}, {
|
|
153
|
+
key: "dispose",
|
|
154
|
+
value: function dispose() {
|
|
155
|
+
if (this.isDisposed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
_get(_getPrototypeOf(CodeCellSearchProvider.prototype), "dispose", this).call(this);
|
|
159
|
+
this.outputsProvider.map(function (provider) {
|
|
160
|
+
provider.dispose();
|
|
161
|
+
});
|
|
162
|
+
this.outputsProvider.length = 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Highlight the next match.
|
|
167
|
+
*
|
|
168
|
+
* @returns The next match if there is one.
|
|
169
|
+
*/
|
|
170
|
+
}, {
|
|
171
|
+
key: "highlightNext",
|
|
172
|
+
value: function () {
|
|
173
|
+
var _highlightNext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
174
|
+
var match, provider, _match;
|
|
175
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
176
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
177
|
+
case 0:
|
|
178
|
+
if (!(this.matchesCount === 0 || !this.isActive)) {
|
|
179
|
+
_context5.next = 4;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
this.currentIndex = undefined;
|
|
183
|
+
_context5.next = 30;
|
|
184
|
+
break;
|
|
185
|
+
case 4:
|
|
186
|
+
if (!(this.currentProviderIndex === -1)) {
|
|
187
|
+
_context5.next = 14;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
_context5.next = 7;
|
|
191
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "highlightNext", this).call(this);
|
|
192
|
+
case 7:
|
|
193
|
+
match = _context5.sent;
|
|
194
|
+
if (!match) {
|
|
195
|
+
_context5.next = 13;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
this.currentIndex = this.editorHighlighter.currentIndex;
|
|
199
|
+
return _context5.abrupt("return", match);
|
|
200
|
+
case 13:
|
|
201
|
+
this.currentProviderIndex = 0;
|
|
202
|
+
case 14:
|
|
203
|
+
if (!(this.currentProviderIndex < this.outputsProvider.length)) {
|
|
204
|
+
_context5.next = 27;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
provider = this.outputsProvider[this.currentProviderIndex];
|
|
208
|
+
_context5.next = 18;
|
|
209
|
+
return provider.highlightNext(false);
|
|
210
|
+
case 18:
|
|
211
|
+
_match = _context5.sent;
|
|
212
|
+
if (!_match) {
|
|
213
|
+
_context5.next = 24;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
this.currentIndex = _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "matchesCount", this) + this.outputsProvider.slice(0, this.currentProviderIndex).reduce(function (sum, p) {
|
|
217
|
+
var _p$matchesCount;
|
|
218
|
+
return sum += (_p$matchesCount = p.matchesCount) !== null && _p$matchesCount !== void 0 ? _p$matchesCount : 0;
|
|
219
|
+
}, 0) + provider.currentMatchIndex;
|
|
220
|
+
return _context5.abrupt("return", _match);
|
|
221
|
+
case 24:
|
|
222
|
+
this.currentProviderIndex += 1;
|
|
223
|
+
case 25:
|
|
224
|
+
_context5.next = 14;
|
|
225
|
+
break;
|
|
226
|
+
case 27:
|
|
227
|
+
this.currentProviderIndex = -1;
|
|
228
|
+
this.currentIndex = undefined;
|
|
229
|
+
return _context5.abrupt("return", undefined);
|
|
230
|
+
case 30:
|
|
231
|
+
return _context5.abrupt("return");
|
|
232
|
+
case 31:
|
|
233
|
+
case "end":
|
|
234
|
+
return _context5.stop();
|
|
235
|
+
}
|
|
236
|
+
}, _callee5, this);
|
|
237
|
+
}));
|
|
238
|
+
function highlightNext() {
|
|
239
|
+
return _highlightNext.apply(this, arguments);
|
|
240
|
+
}
|
|
241
|
+
return highlightNext;
|
|
242
|
+
}()
|
|
243
|
+
/**
|
|
244
|
+
* Highlight the previous match.
|
|
245
|
+
*
|
|
246
|
+
* @returns The previous match if there is one.
|
|
247
|
+
*/
|
|
248
|
+
}, {
|
|
249
|
+
key: "highlightPrevious",
|
|
250
|
+
value: function () {
|
|
251
|
+
var _highlightPrevious = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
252
|
+
var provider, _match2, match;
|
|
253
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
254
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
255
|
+
case 0:
|
|
256
|
+
if (!(this.matchesCount === 0 || !this.isActive)) {
|
|
257
|
+
_context6.next = 4;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
this.currentIndex = undefined;
|
|
261
|
+
_context6.next = 28;
|
|
262
|
+
break;
|
|
263
|
+
case 4:
|
|
264
|
+
if (this.currentIndex === undefined) {
|
|
265
|
+
this.currentProviderIndex = this.outputsProvider.length - 1;
|
|
266
|
+
}
|
|
267
|
+
case 5:
|
|
268
|
+
if (!(this.currentProviderIndex >= 0)) {
|
|
269
|
+
_context6.next = 18;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
provider = this.outputsProvider[this.currentProviderIndex];
|
|
273
|
+
_context6.next = 9;
|
|
274
|
+
return provider.highlightPrevious(false);
|
|
275
|
+
case 9:
|
|
276
|
+
_match2 = _context6.sent;
|
|
277
|
+
if (!_match2) {
|
|
278
|
+
_context6.next = 15;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
this.currentIndex = _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "matchesCount", this) + this.outputsProvider.slice(0, this.currentProviderIndex).reduce(function (sum, p) {
|
|
282
|
+
var _p$matchesCount2;
|
|
283
|
+
return sum += (_p$matchesCount2 = p.matchesCount) !== null && _p$matchesCount2 !== void 0 ? _p$matchesCount2 : 0;
|
|
284
|
+
}, 0) + provider.currentMatchIndex;
|
|
285
|
+
return _context6.abrupt("return", _match2);
|
|
286
|
+
case 15:
|
|
287
|
+
this.currentProviderIndex -= 1;
|
|
288
|
+
case 16:
|
|
289
|
+
_context6.next = 5;
|
|
290
|
+
break;
|
|
291
|
+
case 18:
|
|
292
|
+
_context6.next = 20;
|
|
293
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "highlightPrevious", this).call(this);
|
|
294
|
+
case 20:
|
|
295
|
+
match = _context6.sent;
|
|
296
|
+
if (!match) {
|
|
297
|
+
_context6.next = 26;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
this.currentIndex = this.editorHighlighter.currentIndex;
|
|
301
|
+
return _context6.abrupt("return", match);
|
|
302
|
+
case 26:
|
|
303
|
+
this.currentIndex = undefined;
|
|
304
|
+
return _context6.abrupt("return", undefined);
|
|
305
|
+
case 28:
|
|
306
|
+
return _context6.abrupt("return");
|
|
307
|
+
case 29:
|
|
308
|
+
case "end":
|
|
309
|
+
return _context6.stop();
|
|
310
|
+
}
|
|
311
|
+
}, _callee6, this);
|
|
312
|
+
}));
|
|
313
|
+
function highlightPrevious() {
|
|
314
|
+
return _highlightPrevious.apply(this, arguments);
|
|
315
|
+
}
|
|
316
|
+
return highlightPrevious;
|
|
317
|
+
}()
|
|
318
|
+
/**
|
|
319
|
+
* Initialize the search using the provided options. Should update the UI to highlight
|
|
320
|
+
* all matches and "select" the first match.
|
|
321
|
+
*
|
|
322
|
+
* @param query A RegExp to be use to perform the search
|
|
323
|
+
* @param filters Filter parameters to pass to provider
|
|
324
|
+
*/
|
|
325
|
+
}, {
|
|
326
|
+
key: "startQuery",
|
|
327
|
+
value: function () {
|
|
328
|
+
var _startQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(query, filters) {
|
|
329
|
+
var _this2 = this;
|
|
330
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
331
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
332
|
+
case 0:
|
|
333
|
+
_context7.next = 2;
|
|
334
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "startQuery", this).call(this, query, filters);
|
|
335
|
+
case 2:
|
|
336
|
+
if (!(filters !== null && filters !== void 0 && filters.searchCellOutput)) {
|
|
337
|
+
_context7.next = 5;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
_context7.next = 5;
|
|
341
|
+
return Promise.all(this.outputsProvider.map(function (provider) {
|
|
342
|
+
provider.startQuery(query, _this2.filters);
|
|
343
|
+
}));
|
|
344
|
+
case 5:
|
|
345
|
+
case "end":
|
|
346
|
+
return _context7.stop();
|
|
347
|
+
}
|
|
348
|
+
}, _callee7, this);
|
|
349
|
+
}));
|
|
350
|
+
function startQuery(_x, _x2) {
|
|
351
|
+
return _startQuery.apply(this, arguments);
|
|
352
|
+
}
|
|
353
|
+
return startQuery;
|
|
354
|
+
}()
|
|
355
|
+
}, {
|
|
356
|
+
key: "endQuery",
|
|
357
|
+
value: function () {
|
|
358
|
+
var _endQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
359
|
+
var _this$filters2;
|
|
360
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
361
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
362
|
+
case 0:
|
|
363
|
+
_context8.next = 2;
|
|
364
|
+
return _get(_getPrototypeOf(CodeCellSearchProvider.prototype), "endQuery", this).call(this);
|
|
365
|
+
case 2:
|
|
366
|
+
if (!(((_this$filters2 = this.filters) === null || _this$filters2 === void 0 ? void 0 : _this$filters2.searchCellOutput) !== false && this.isActive)) {
|
|
367
|
+
_context8.next = 5;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
_context8.next = 5;
|
|
371
|
+
return Promise.all(this.outputsProvider.map(function (provider) {
|
|
372
|
+
return provider.endQuery();
|
|
373
|
+
}));
|
|
374
|
+
case 5:
|
|
375
|
+
case "end":
|
|
376
|
+
return _context8.stop();
|
|
377
|
+
}
|
|
378
|
+
}, _callee8, this);
|
|
379
|
+
}));
|
|
380
|
+
function endQuery() {
|
|
381
|
+
return _endQuery.apply(this, arguments);
|
|
382
|
+
}
|
|
383
|
+
return endQuery;
|
|
384
|
+
}()
|
|
385
|
+
}, {
|
|
386
|
+
key: "refresh",
|
|
387
|
+
value: function () {
|
|
388
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
389
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
390
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
391
|
+
case 0:
|
|
392
|
+
_context9.next = 2;
|
|
393
|
+
return this.endQuery();
|
|
394
|
+
case 2:
|
|
395
|
+
_context9.next = 4;
|
|
396
|
+
return this.clearHighlight();
|
|
397
|
+
case 4:
|
|
398
|
+
_context9.next = 6;
|
|
399
|
+
return this.startQuery(this.query, this.filters);
|
|
400
|
+
case 6:
|
|
401
|
+
case "end":
|
|
402
|
+
return _context9.stop();
|
|
403
|
+
}
|
|
404
|
+
}, _callee9, this);
|
|
405
|
+
}));
|
|
406
|
+
function refresh() {
|
|
407
|
+
return _refresh.apply(this, arguments);
|
|
408
|
+
}
|
|
409
|
+
return refresh;
|
|
410
|
+
}()
|
|
411
|
+
}]);
|
|
412
|
+
return CodeCellSearchProvider;
|
|
413
|
+
}(CodeEditorCellSearchProvider), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "outputsProvider", [_dec2], {
|
|
414
|
+
configurable: true,
|
|
415
|
+
enumerable: true,
|
|
416
|
+
writable: true,
|
|
417
|
+
initializer: null
|
|
418
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "currentProviderIndex", [_dec3], {
|
|
419
|
+
configurable: true,
|
|
420
|
+
enumerable: true,
|
|
421
|
+
writable: true,
|
|
422
|
+
initializer: null
|
|
423
|
+
})), _class2)) || _class);
|