diff --git a/NOTICE.txt b/NOTICE.txt index 80d49de19e5db..bdd6a95e57b04 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -68,37 +68,6 @@ Author Tobias Koppers @sokra --- This product has relied on ASTExplorer that is licensed under MIT. ---- -This product includes code that is based on Ace editor, which was available -under a "BSD" license. - -Distributed under the BSD license: - -Copyright (c) 2010, Ajax.org B.V. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Ajax.org B.V. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --- This product includes code that is based on flot-charts, which was available under a "MIT" license. diff --git a/api_docs/kbn_ace.devdocs.json b/api_docs/kbn_ace.devdocs.json deleted file mode 100644 index 31b9c39264e4d..0000000000000 --- a/api_docs/kbn_ace.devdocs.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "id": "@kbn/ace", - "client": { - "classes": [], - "functions": [], - "interfaces": [], - "enums": [], - "misc": [], - "objects": [] - }, - "server": { - "classes": [], - "functions": [], - "interfaces": [], - "enums": [], - "misc": [], - "objects": [] - }, - "common": { - "classes": [], - "functions": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.addToRules", - "type": "Function", - "tags": [], - "label": "addToRules", - "description": [], - "signature": [ - "(otherRules: any, embedUnder: any) => void" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "children": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.addToRules.$1", - "type": "Any", - "tags": [], - "label": "otherRules", - "description": [], - "signature": [ - "any" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "isRequired": true - }, - { - "parentPluginId": "@kbn/ace", - "id": "def-common.addToRules.$2", - "type": "Any", - "tags": [], - "label": "embedUnder", - "description": [], - "signature": [ - "any" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "isRequired": true - } - ], - "returnComment": [], - "initialIsOpen": false - }, - { - "parentPluginId": "@kbn/ace", - "id": "def-common.ElasticsearchSqlHighlightRules", - "type": "Function", - "tags": [], - "label": "ElasticsearchSqlHighlightRules", - "description": [], - "signature": [ - "(this: any) => void" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/elasticsearch_sql_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "returnComment": [], - "children": [], - "initialIsOpen": false - }, - { - "parentPluginId": "@kbn/ace", - "id": "def-common.installXJsonMode", - "type": "Function", - "tags": [], - "label": "installXJsonMode", - "description": [], - "signature": [ - "(editor: ", - "Editor", - ") => void" - ], - "path": "packages/kbn-ace/src/ace/modes/x_json/x_json.ts", - "deprecated": false, - "trackAdoption": false, - "children": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.installXJsonMode.$1", - "type": "Object", - "tags": [], - "label": "editor", - "description": [], - "signature": [ - "Editor" - ], - "path": "packages/kbn-ace/src/ace/modes/x_json/x_json.ts", - "deprecated": false, - "trackAdoption": false, - "isRequired": true - } - ], - "returnComment": [], - "initialIsOpen": false - }, - { - "parentPluginId": "@kbn/ace", - "id": "def-common.ScriptHighlightRules", - "type": "Function", - "tags": [], - "label": "ScriptHighlightRules", - "description": [], - "signature": [ - "(this: any) => void" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/script_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "children": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.ScriptHighlightRules.$1", - "type": "Any", - "tags": [], - "label": "this", - "description": [], - "signature": [ - "any" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/script_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "isRequired": true - } - ], - "returnComment": [], - "initialIsOpen": false - }, - { - "parentPluginId": "@kbn/ace", - "id": "def-common.XJsonHighlightRules", - "type": "Function", - "tags": [], - "label": "XJsonHighlightRules", - "description": [], - "signature": [ - "(this: any) => void" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "children": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.XJsonHighlightRules.$1", - "type": "Any", - "tags": [], - "label": "this", - "description": [], - "signature": [ - "any" - ], - "path": "packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts", - "deprecated": false, - "trackAdoption": false, - "isRequired": true - } - ], - "returnComment": [], - "initialIsOpen": false - } - ], - "interfaces": [], - "enums": [], - "misc": [ - { - "parentPluginId": "@kbn/ace", - "id": "def-common.XJsonMode", - "type": "Any", - "tags": [], - "label": "XJsonMode", - "description": [], - "signature": [ - "any" - ], - "path": "packages/kbn-ace/src/ace/modes/x_json/x_json.ts", - "deprecated": false, - "trackAdoption": false, - "initialIsOpen": false - } - ], - "objects": [] - } -} \ No newline at end of file diff --git a/api_docs/kbn_ace.mdx b/api_docs/kbn_ace.mdx deleted file mode 100644 index 810f590fdd2a4..0000000000000 --- a/api_docs/kbn_ace.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -#### -#### This document is auto-generated and is meant to be viewed inside our experimental, new docs system. -#### Reach out in #docs-engineering for more info. -#### -id: kibKbnAcePluginApi -slug: /kibana-dev-docs/api/kbn-ace -title: "@kbn/ace" -image: https://source.unsplash.com/400x175/?github -description: API docs for the @kbn/ace plugin -date: 2024-09-12 -tags: ['contributor', 'dev', 'apidocs', 'kibana', '@kbn/ace'] ---- -import kbnAceObj from './kbn_ace.devdocs.json'; - - - -Contact [@elastic/kibana-management](https://github.com/orgs/elastic/teams/kibana-management) for questions regarding this plugin. - -**Code health stats** - -| Public API count | Any count | Items lacking comments | Missing exports | -|-------------------|-----------|------------------------|-----------------| -| 11 | 5 | 11 | 0 | - -## Common - -### Functions - - -### Consts, variables and types - - diff --git a/api_docs/plugin_directory.mdx b/api_docs/plugin_directory.mdx index 2f197f4d93ada..45da6cb04cb87 100644 --- a/api_docs/plugin_directory.mdx +++ b/api_docs/plugin_directory.mdx @@ -240,7 +240,6 @@ tags: ['contributor', 'dev', 'apidocs', 'kibana'] | Package name           | Maintaining team | Description | API Cnt | Any Cnt | Missing
comments | Missing
exports | |--------------|----------------|-----------|--------------|----------|---------------|--------| -| | [@elastic/kibana-management](https://github.com/orgs/elastic/teams/kibana-management) | - | 11 | 5 | 11 | 0 | | | [@elastic/response-ops](https://github.com/orgs/elastic/teams/response-ops) | - | 14 | 0 | 14 | 0 | | | [@elastic/ml-ui](https://github.com/orgs/elastic/teams/ml-ui) | - | 36 | 0 | 0 | 0 | | | [@elastic/ml-ui](https://github.com/orgs/elastic/teams/ml-ui) | - | 2 | 0 | 0 | 0 | @@ -778,4 +777,3 @@ tags: ['contributor', 'dev', 'apidocs', 'kibana'] | | [@elastic/kibana-operations](https://github.com/orgs/elastic/teams/kibana-operations) | - | 9 | 0 | 4 | 0 | | | [@elastic/kibana-core](https://github.com/orgs/elastic/teams/kibana-core) | - | 1254 | 0 | 4 | 0 | | | [@elastic/security-detection-rule-management](https://github.com/orgs/elastic/teams/security-detection-rule-management) | - | 20 | 0 | 10 | 0 | - diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index 50095f8b7018f..0b97a425001ec 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -41,7 +41,6 @@ yarn kbn watch [discrete] === List of Already Migrated Packages to Bazel -- @kbn/ace - @kbn/analytics - @kbn/apm-config-loader - @kbn/apm-utils @@ -93,4 +92,4 @@ yarn kbn watch - @kbn/ui-shared-deps-npm - @kbn/ui-shared-deps-src - @kbn/utility-types -- @kbn/utils +- @kbn/utils \ No newline at end of file diff --git a/package.json b/package.json index 81f049e91953d..6164f5dc812d6 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,6 @@ "@hapi/wreck": "^18.1.0", "@hello-pangea/dnd": "16.6.0", "@kbn/aad-fixtures-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/aad", - "@kbn/ace": "link:packages/kbn-ace", "@kbn/actions-plugin": "link:x-pack/plugins/actions", "@kbn/actions-simulators-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/actions_simulators", "@kbn/actions-types": "link:packages/kbn-actions-types", @@ -1066,7 +1065,6 @@ "bitmap-sdf": "^1.0.3", "blurhash": "^2.0.1", "borc": "3.0.0", - "brace": "0.11.1", "brok": "^6.0.0", "byte-size": "^8.1.0", "cacheable-lookup": "6", @@ -1204,7 +1202,6 @@ "re-resizable": "^6.9.9", "re2js": "0.4.2", "react": "^17.0.2", - "react-ace": "^7.0.5", "react-diff-view": "^3.2.1", "react-dom": "^17.0.2", "react-dropzone": "^4.2.9", diff --git a/packages/kbn-ace/README.md b/packages/kbn-ace/README.md deleted file mode 100644 index c11d5cc2f24b8..0000000000000 --- a/packages/kbn-ace/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# @kbn/ace - -This package contains the XJSON mode for brace. This is an extension of the `brace/mode/json` mode. - -This package also contains an import of the entire brace editor which is used for creating the custom XJSON worker. - -## Note to plugins -_This code should not be eagerly loaded_. - -Make sure imports of this package are behind a lazy-load `import()` statement. - -Your plugin should already be loading application code this way in the `mount` function. - -## Deprecated - -This package is considered deprecated and will be removed in future. - -New and existing editor functionality should use Monaco. - -_Do not add new functionality to this package_. Build new functionality for Monaco and use it instead. diff --git a/packages/kbn-ace/index.ts b/packages/kbn-ace/index.ts deleted file mode 100644 index c9cc0b7a73e86..0000000000000 --- a/packages/kbn-ace/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { - ElasticsearchSqlHighlightRules, - ScriptHighlightRules, - XJsonHighlightRules, - addXJsonToRules, - XJsonMode, - installXJsonMode, -} from './src/ace/modes'; diff --git a/packages/kbn-ace/kibana.jsonc b/packages/kbn-ace/kibana.jsonc deleted file mode 100644 index 0a01d96a6b1c6..0000000000000 --- a/packages/kbn-ace/kibana.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "shared-common", - "id": "@kbn/ace", - "owner": "@elastic/kibana-management" -} diff --git a/packages/kbn-ace/package.json b/packages/kbn-ace/package.json deleted file mode 100644 index 3d3ed36941978..0000000000000 --- a/packages/kbn-ace/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "@kbn/ace", - "version": "1.0.0", - "private": true, - "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" -} \ No newline at end of file diff --git a/packages/kbn-ace/src/ace/modes/index.ts b/packages/kbn-ace/src/ace/modes/index.ts deleted file mode 100644 index ffbb385663e48..0000000000000 --- a/packages/kbn-ace/src/ace/modes/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { - ElasticsearchSqlHighlightRules, - ScriptHighlightRules, - XJsonHighlightRules, - addXJsonToRules, -} from './lexer_rules'; - -export { installXJsonMode, XJsonMode } from './x_json'; diff --git a/packages/kbn-ace/src/ace/modes/lexer_rules/elasticsearch_sql_highlight_rules.ts b/packages/kbn-ace/src/ace/modes/lexer_rules/elasticsearch_sql_highlight_rules.ts deleted file mode 100644 index a4cb60529281d..0000000000000 --- a/packages/kbn-ace/src/ace/modes/lexer_rules/elasticsearch_sql_highlight_rules.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import ace from 'brace'; - -const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules'); -const oop = ace.acequire('ace/lib/oop'); - -export const ElasticsearchSqlHighlightRules = function (this: any) { - // See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-commands.html - const keywords = - 'describe|between|in|like|not|and|or|desc|select|from|where|having|group|by|order' + - 'asc|desc|pivot|for|in|as|show|columns|include|frozen|tables|escape|limit|rlike|all|distinct|is'; - - const builtinConstants = 'true|false'; - - // See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-show-functions.html - const builtinFunctions = - 'avg|count|first|first_value|last|last_value|max|min|sum|kurtosis|mad|percentile|percentile_rank|skewness' + - '|stddev_pop|sum_of_squares|var_pop|histogram|case|coalesce|greatest|ifnull|iif|isnull|least|nullif|nvl' + - '|curdate|current_date|current_time|current_timestamp|curtime|dateadd|datediff|datepart|datetrunc|date_add' + - '|date_diff|date_part|date_trunc|day|dayname|dayofmonth|dayofweek|dayofyear|day_name|day_of_month|day_of_week' + - '|day_of_year|dom|dow|doy|hour|hour_of_day|idow|isodayofweek|isodow|isoweek|isoweekofyear|iso_day_of_week|iso_week_of_year' + - '|iw|iwoy|minute|minute_of_day|minute_of_hour|month|monthname|month_name|month_of_year|now|quarter|second|second_of_minute' + - '|timestampadd|timestampdiff|timestamp_add|timestamp_diff|today|week|week_of_year|year|abs|acos|asin|atan|atan2|cbrt' + - '|ceil|ceiling|cos|cosh|cot|degrees|e|exp|expm1|floor|log|log10|mod|pi|power|radians|rand|random|round|sign|signum|sin' + - '|sinh|sqrt|tan|truncate|ascii|bit_length|char|character_length|char_length|concat|insert|lcase|left|length|locate' + - '|ltrim|octet_length|position|repeat|replace|right|rtrim|space|substring|ucase|cast|convert|database|user|st_astext|st_aswkt' + - '|st_distance|st_geometrytype|st_geomfromtext|st_wkttosql|st_x|st_y|st_z|score'; - - // See https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-data-types.html - const dataTypes = - 'null|boolean|byte|short|integer|long|double|float|half_float|scaled_float|keyword|text|binary|date|ip|object|nested|time' + - '|interval_year|interval_month|interval_day|interval_hour|interval_minute|interval_second|interval_year_to_month' + - 'inteval_day_to_hour|interval_day_to_minute|interval_day_to_second|interval_hour_to_minute|interval_hour_to_second' + - 'interval_minute_to_second|geo_point|geo_shape|shape'; - - const keywordMapper = this.createKeywordMapper( - { - keyword: [keywords, builtinFunctions, builtinConstants, dataTypes].join('|'), - }, - 'identifier', - true - ); - - this.$rules = { - start: [ - { - token: 'comment', - regex: '--.*$', - }, - { - token: 'comment', - start: '/\\*', - end: '\\*/', - }, - { - token: 'string', // " string - regex: '".*?"', - }, - { - token: 'constant', // ' string - regex: "'.*?'", - }, - { - token: 'string', // ` string (apache drill) - regex: '`.*?`', - }, - { - token: 'entity.name.function', // float - regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b', - }, - { - token: keywordMapper, - regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\b', - }, - { - token: 'keyword.operator', - regex: '⇐|<⇒|\\*|\\.|\\:\\:|\\+|\\-|\\/|\\/\\/|%|&|\\^|~|<|>|<=|=>|==|!=|<>|=', - }, - { - token: 'paren.lparen', - regex: '[\\(]', - }, - { - token: 'paren.rparen', - regex: '[\\)]', - }, - { - token: 'text', - regex: '\\s+', - }, - ], - }; - this.normalizeRules(); -}; - -oop.inherits(ElasticsearchSqlHighlightRules, TextHighlightRules); diff --git a/packages/kbn-ace/src/ace/modes/lexer_rules/index.ts b/packages/kbn-ace/src/ace/modes/lexer_rules/index.ts deleted file mode 100644 index aa8c6af19c10f..0000000000000 --- a/packages/kbn-ace/src/ace/modes/lexer_rules/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { ElasticsearchSqlHighlightRules } from './elasticsearch_sql_highlight_rules'; -export { ScriptHighlightRules } from './script_highlight_rules'; -export { XJsonHighlightRules, addToRules as addXJsonToRules } from './x_json_highlight_rules'; diff --git a/packages/kbn-ace/src/ace/modes/lexer_rules/script_highlight_rules.ts b/packages/kbn-ace/src/ace/modes/lexer_rules/script_highlight_rules.ts deleted file mode 100644 index 64e8a1a6594bd..0000000000000 --- a/packages/kbn-ace/src/ace/modes/lexer_rules/script_highlight_rules.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import ace from 'brace'; -const oop = ace.acequire('ace/lib/oop'); -const { TextHighlightRules } = ace.acequire('ace/mode/text_highlight_rules'); -const painlessKeywords = - 'def|int|long|byte|String|float|double|char|null|if|else|while|do|for|continue|break|new|try|catch|throw|this|instanceof|return|ctx'; - -export function ScriptHighlightRules(this: any) { - this.name = 'ScriptHighlightRules'; - this.$rules = { - start: [ - { - token: 'script.comment', - regex: '\\/\\/.*$', - }, - { - token: 'script.string.regexp', - regex: '[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)', - }, - { - token: 'script.string', // single line - regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']", - }, - { - token: 'script.constant.numeric', // hex - regex: '0[xX][0-9a-fA-F]+\\b', - }, - { - token: 'script.constant.numeric', // float - regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b', - }, - { - token: 'script.constant.language.boolean', - regex: '(?:true|false)\\b', - }, - { - token: 'script.keyword', - regex: painlessKeywords, - }, - { - token: 'script.text', - regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\b', - }, - { - token: 'script.keyword.operator', - regex: - '\\?\\.|\\*\\.|=~|==~|!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|->|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|typeof|void)', - }, - { - token: 'script.lparen', - regex: '[[({]', - }, - { - token: 'script.rparen', - regex: '[\\])}]', - }, - { - token: 'script.text', - regex: '\\s+', - }, - ], - }; -} - -oop.inherits(ScriptHighlightRules, TextHighlightRules); diff --git a/packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts b/packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts deleted file mode 100644 index f69e2fbbf5d8a..0000000000000 --- a/packages/kbn-ace/src/ace/modes/lexer_rules/x_json_highlight_rules.ts +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import { defaultsDeep } from 'lodash'; -import ace from 'brace'; -import 'brace/mode/json'; - -import { ElasticsearchSqlHighlightRules } from './elasticsearch_sql_highlight_rules'; -import { ScriptHighlightRules } from './script_highlight_rules'; - -const { JsonHighlightRules } = ace.acequire('ace/mode/json_highlight_rules'); -const oop = ace.acequire('ace/lib/oop'); - -const jsonRules = function (root: any) { - root = root ? root : 'json'; - const rules: any = {}; - const xJsonRules = [ - { - token: [ - 'variable', - 'whitespace', - 'ace.punctuation.colon', - 'whitespace', - 'punctuation.start_triple_quote', - ], - regex: '("(?:[^"]*_)?script"|"inline"|"source")(\\s*?)(:)(\\s*?)(""")', - next: 'script-start', - merge: false, - push: true, - }, - { - token: 'variable', // single line - regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)', - }, - { - token: 'punctuation.start_triple_quote', - regex: '"""', - next: 'string_literal', - merge: false, - push: true, - }, - { - token: 'string', // single line - regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]', - }, - { - token: 'constant.numeric', // hex - regex: '0[xX][0-9a-fA-F]+\\b', - }, - { - token: 'constant.numeric', // float - regex: '[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b', - }, - { - token: 'constant.language.boolean', - regex: '(?:true|false)\\b', - }, - { - token: 'invalid.illegal', // single quoted strings are not allowed - regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']", - }, - { - token: 'invalid.illegal', // comments are not allowed - regex: '\\/\\/.*$', - }, - { - token: 'paren.lparen', - merge: false, - regex: '{', - next: root, - push: true, - }, - { - token: 'paren.lparen', - merge: false, - regex: '[[(]', - }, - { - token: 'paren.rparen', - merge: false, - regex: '[\\])]', - }, - { - token: 'paren.rparen', - regex: '}', - merge: false, - next: 'pop', - }, - { - token: 'punctuation.comma', - regex: ',', - }, - { - token: 'punctuation.colon', - regex: ':', - }, - { - token: 'whitespace', - regex: '\\s+', - }, - { - token: 'text', - regex: '.+?', - }, - ]; - - rules[root] = xJsonRules; - rules[root + '-sql'] = [ - { - token: [ - 'variable', - 'whitespace', - 'ace.punctuation.colon', - 'whitespace', - 'punctuation.start_triple_quote', - ], - regex: '("query")(\\s*?)(:)(\\s*?)(""")', - next: 'sql-start', - merge: false, - push: true, - }, - ].concat(xJsonRules as any); - - rules.string_literal = [ - { - token: 'punctuation.end_triple_quote', - regex: '"""', - next: 'pop', - }, - { - token: 'multi_string', - regex: '.', - }, - ]; - return rules; -}; - -export function XJsonHighlightRules(this: any) { - this.$rules = { - ...jsonRules('start'), - }; - - this.embedRules(ScriptHighlightRules, 'script-', [ - { - token: 'punctuation.end_triple_quote', - regex: '"""', - next: 'pop', - }, - ]); - - this.embedRules(ElasticsearchSqlHighlightRules, 'sql-', [ - { - token: 'punctuation.end_triple_quote', - regex: '"""', - next: 'pop', - }, - ]); -} - -oop.inherits(XJsonHighlightRules, JsonHighlightRules); - -export function addToRules(otherRules: any, embedUnder: any) { - otherRules.$rules = defaultsDeep(otherRules.$rules, jsonRules(embedUnder)); - otherRules.embedRules(ScriptHighlightRules, 'script-', [ - { - token: 'punctuation.end_triple_quote', - regex: '"""', - next: 'pop', - }, - ]); - otherRules.embedRules(ElasticsearchSqlHighlightRules, 'sql-', [ - { - token: 'punctuation.end_triple_quote', - regex: '"""', - next: 'pop', - }, - ]); -} diff --git a/packages/kbn-ace/src/ace/modes/x_json/index.ts b/packages/kbn-ace/src/ace/modes/x_json/index.ts deleted file mode 100644 index a1651c9e06979..0000000000000 --- a/packages/kbn-ace/src/ace/modes/x_json/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { installXJsonMode, XJsonMode } from './x_json'; diff --git a/packages/kbn-ace/src/ace/modes/x_json/worker/index.ts b/packages/kbn-ace/src/ace/modes/x_json/worker/index.ts deleted file mode 100644 index b09099ed9ad01..0000000000000 --- a/packages/kbn-ace/src/ace/modes/x_json/worker/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -// @ts-ignore -import src from '!!raw-loader!./x_json.ace.worker'; - -export const workerModule = { - id: 'ace/mode/json_worker', - src, -}; diff --git a/packages/kbn-ace/src/ace/modes/x_json/worker/worker.d.ts b/packages/kbn-ace/src/ace/modes/x_json/worker/worker.d.ts deleted file mode 100644 index 34598ea61003b..0000000000000 --- a/packages/kbn-ace/src/ace/modes/x_json/worker/worker.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -// Satisfy TS's requirements that the module be declared per './index.ts'. -declare module '!!raw-loader!./worker.js' { - const content: string; - // eslint-disable-next-line import/no-default-export - export default content; -} diff --git a/packages/kbn-ace/src/ace/modes/x_json/worker/x_json.ace.worker.js b/packages/kbn-ace/src/ace/modes/x_json/worker/x_json.ace.worker.js deleted file mode 100644 index 63ca258e524d4..0000000000000 --- a/packages/kbn-ace/src/ace/modes/x_json/worker/x_json.ace.worker.js +++ /dev/null @@ -1,1265 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -/* @notice - * - * This product includes code that is based on Ace editor, which was available - * under a "BSD" license. - * - * Distributed under the BSD license: - * - * Copyright (c) 2010, Ajax.org B.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Ajax.org B.V. nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* eslint-disable prettier/prettier,no-var,eqeqeq,no-use-before-define,block-scoped-var,no-undef, - guard-for-in,one-var,strict,no-redeclare,no-sequences,no-proto,new-cap,no-nested-ternary,no-unused-vars, - prefer-const,no-empty,no-extend-native,camelcase */ -/* - This file is loaded up as a blob by Brace to hand to Ace to load as Jsonp - (hence the redefining of everything). It is based on the json - mode from the brace distro. - - It is very likely that this file will be removed in future but for now it enables - extended JSON parsing, like e.g. """{}""" (triple quotes) -*/ -// @internal -// @ts-nocheck -"no use strict"; -! function(window) { - function resolveModuleId(id, paths) { - for (var testPath = id, tail = ""; testPath;) { - var alias = paths[testPath]; - if ("string" == typeof alias) return alias + tail; - if (alias) return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name); - if (alias === !1) return ""; - var i = testPath.lastIndexOf("/"); - if (-1 === i) break; - tail = testPath.substr(i) + tail, testPath = testPath.slice(0, i) - } - return id - } - if (!(void 0 !== window.window && window.document || window.acequire && window.define)) { - window.console || (window.console = function() { - var msgs = Array.prototype.slice.call(arguments, 0); - postMessage({ - type: "log", - data: msgs - }) - }, window.console.error = window.console.warn = window.console.log = window.console.trace = window.console), window.window = window, window.ace = window, window.onerror = function(message, file, line, col, err) { - postMessage({ - type: "error", - data: { - message: message, - data: err.data, - file: file, - line: line, - col: col, - stack: err.stack - } - }) - }, window.normalizeModule = function(parentId, moduleName) { - if (-1 !== moduleName.indexOf("!")) { - var chunks = moduleName.split("!"); - return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]) - } - if ("." == moduleName.charAt(0)) { - var base = parentId.split("/").slice(0, -1).join("/"); - for (moduleName = (base ? base + "/" : "") + moduleName; - 1 !== moduleName.indexOf(".") && previous != moduleName;) { - var previous = moduleName; - moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "") - } - } - return moduleName - }, window.acequire = function acequire(parentId, id) { - if (id || (id = parentId, parentId = null), !id.charAt) throw Error("worker.js acequire() accepts only (parentId, id) as arguments"); - id = window.normalizeModule(parentId, id); - var module = window.acequire.modules[id]; - if (module) return module.initialized || (module.initialized = !0, module.exports = module.factory().exports), module.exports; - if (!window.acequire.tlns) return console.log("unable to load " + id); - var path = resolveModuleId(id, window.acequire.tlns); - return ".js" != path.slice(-3) && (path += ".js"), window.acequire.id = id, window.acequire.modules[id] = {}, importScripts(path), window.acequire(parentId, id) - }, window.acequire.modules = {}, window.acequire.tlns = {}, window.define = function(id, deps, factory) { - if (2 == arguments.length ? (factory = deps, "string" != typeof id && (deps = id, id = window.acequire.id)) : 1 == arguments.length && (factory = id, deps = [], id = window.acequire.id), "function" != typeof factory) return window.acequire.modules[id] = { - exports: factory, - initialized: !0 - }, void 0; - deps.length || (deps = ["require", "exports", "module"]); - var req = function(childId) { - return window.acequire(id, childId) - }; - window.acequire.modules[id] = { - exports: {}, - factory: function() { - var module = this, - returnExports = factory.apply(this, deps.map(function(dep) { - switch (dep) { - case "require": - return req; - case "exports": - return module.exports; - case "module": - return module; - default: - return req(dep) - } - })); - return returnExports && (module.exports = returnExports), module - } - } - }, window.define.amd = {}, acequire.tlns = {}, window.initBaseUrls = function(topLevelNamespaces) { - for (var i in topLevelNamespaces) acequire.tlns[i] = topLevelNamespaces[i] - }, window.initSender = function() { - var EventEmitter = window.acequire("ace/lib/event_emitter").EventEmitter, - oop = window.acequire("ace/lib/oop"), - Sender = function() {}; - return function() { - oop.implement(this, EventEmitter), this.callback = function(data, callbackId) { - postMessage({ - type: "call", - id: callbackId, - data: data - }) - }, this.emit = function(name, data) { - postMessage({ - type: "event", - name: name, - data: data - }) - } - }.call(Sender.prototype), new Sender - }; - var main = window.main = null, - sender = window.sender = null; - window.onmessage = function(e) { - var msg = e.data; - if (msg.event && sender) sender._signal(msg.event, msg.data); - else if (msg.command) - if (main[msg.command]) main[msg.command].apply(main, msg.args); - else { - if (!window[msg.command]) throw Error("Unknown command:" + msg.command); - window[msg.command].apply(window, msg.args) - } - else if (msg.init) { - window.initBaseUrls(msg.tlns), acequire("ace/lib/es5-shim"), sender = window.sender = window.initSender(); - var clazz = acequire(msg.module)[msg.classname]; - main = window.main = new clazz(sender) - } - } - } -}(this), ace.define("ace/lib/oop", ["require", "exports", "module"], function(acequire, exports) { - "use strict"; - exports.inherits = function(ctor, superCtor) { - ctor.super_ = superCtor, ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: !1, - writable: !0, - configurable: !0 - } - }) - }, exports.mixin = function(obj, mixin) { - for (var key in mixin) obj[key] = mixin[key]; - return obj - }, exports.implement = function(proto, mixin) { - exports.mixin(proto, mixin) - } -}), ace.define("ace/range", ["require", "exports", "module"], function(acequire, exports) { - "use strict"; - var comparePoints = function(p1, p2) { - return p1.row - p2.row || p1.column - p2.column - }, - Range = function(startRow, startColumn, endRow, endColumn) { - this.start = { - row: startRow, - column: startColumn - }, this.end = { - row: endRow, - column: endColumn - } - }; - (function() { - this.isEqual = function(range) { - return this.start.row === range.start.row && this.end.row === range.end.row && this.start.column === range.start.column && this.end.column === range.end.column - }, this.toString = function() { - return "Range: [" + this.start.row + "/" + this.start.column + "] -> [" + this.end.row + "/" + this.end.column + "]" - }, this.contains = function(row, column) { - return 0 == this.compare(row, column) - }, this.compareRange = function(range) { - var cmp, end = range.end, - start = range.start; - return cmp = this.compare(end.row, end.column), 1 == cmp ? (cmp = this.compare(start.row, start.column), 1 == cmp ? 2 : 0 == cmp ? 1 : 0) : -1 == cmp ? -2 : (cmp = this.compare(start.row, start.column), -1 == cmp ? -1 : 1 == cmp ? 42 : 0) - }, this.comparePoint = function(p) { - return this.compare(p.row, p.column) - }, this.containsRange = function(range) { - return 0 == this.comparePoint(range.start) && 0 == this.comparePoint(range.end) - }, this.intersects = function(range) { - var cmp = this.compareRange(range); - return -1 == cmp || 0 == cmp || 1 == cmp - }, this.isEnd = function(row, column) { - return this.end.row == row && this.end.column == column - }, this.isStart = function(row, column) { - return this.start.row == row && this.start.column == column - }, this.setStart = function(row, column) { - "object" == typeof row ? (this.start.column = row.column, this.start.row = row.row) : (this.start.row = row, this.start.column = column) - }, this.setEnd = function(row, column) { - "object" == typeof row ? (this.end.column = row.column, this.end.row = row.row) : (this.end.row = row, this.end.column = column) - }, this.inside = function(row, column) { - return 0 == this.compare(row, column) ? this.isEnd(row, column) || this.isStart(row, column) ? !1 : !0 : !1 - }, this.insideStart = function(row, column) { - return 0 == this.compare(row, column) ? this.isEnd(row, column) ? !1 : !0 : !1 - }, this.insideEnd = function(row, column) { - return 0 == this.compare(row, column) ? this.isStart(row, column) ? !1 : !0 : !1 - }, this.compare = function(row, column) { - return this.isMultiLine() || row !== this.start.row ? this.start.row > row ? -1 : row > this.end.row ? 1 : this.start.row === row ? column >= this.start.column ? 0 : -1 : this.end.row === row ? this.end.column >= column ? 0 : 1 : 0 : this.start.column > column ? -1 : column > this.end.column ? 1 : 0 - }, this.compareStart = function(row, column) { - return this.start.row == row && this.start.column == column ? -1 : this.compare(row, column) - }, this.compareEnd = function(row, column) { - return this.end.row == row && this.end.column == column ? 1 : this.compare(row, column) - }, this.compareInside = function(row, column) { - return this.end.row == row && this.end.column == column ? 1 : this.start.row == row && this.start.column == column ? -1 : this.compare(row, column) - }, this.clipRows = function(firstRow, lastRow) { - if (this.end.row > lastRow) var end = { - row: lastRow + 1, - column: 0 - }; - else if (firstRow > this.end.row) var end = { - row: firstRow, - column: 0 - }; - if (this.start.row > lastRow) var start = { - row: lastRow + 1, - column: 0 - }; - else if (firstRow > this.start.row) var start = { - row: firstRow, - column: 0 - }; - return Range.fromPoints(start || this.start, end || this.end) - }, this.extend = function(row, column) { - var cmp = this.compare(row, column); - if (0 == cmp) return this; - if (-1 == cmp) var start = { - row: row, - column: column - }; - else var end = { - row: row, - column: column - }; - return Range.fromPoints(start || this.start, end || this.end) - }, this.isEmpty = function() { - return this.start.row === this.end.row && this.start.column === this.end.column - }, this.isMultiLine = function() { - return this.start.row !== this.end.row - }, this.clone = function() { - return Range.fromPoints(this.start, this.end) - }, this.collapseRows = function() { - return 0 == this.end.column ? new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0) : new Range(this.start.row, 0, this.end.row, 0) - }, this.toScreenRange = function(session) { - var screenPosStart = session.documentToScreenPosition(this.start), - screenPosEnd = session.documentToScreenPosition(this.end); - return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column) - }, this.moveBy = function(row, column) { - this.start.row += row, this.start.column += column, this.end.row += row, this.end.column += column - } - }).call(Range.prototype), Range.fromPoints = function(start, end) { - return new Range(start.row, start.column, end.row, end.column) - }, Range.comparePoints = comparePoints, Range.comparePoints = function(p1, p2) { - return p1.row - p2.row || p1.column - p2.column - }, exports.Range = Range -}), ace.define("ace/apply_delta", ["require", "exports", "module"], function(acequire, exports) { - "use strict"; - exports.applyDelta = function(docLines, delta) { - var row = delta.start.row, - startColumn = delta.start.column, - line = docLines[row] || ""; - switch (delta.action) { - case "insert": - var lines = delta.lines; - if (1 === lines.length) docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn); - else { - var args = [row, 1].concat(delta.lines); - docLines.splice.apply(docLines, args), docLines[row] = line.substring(0, startColumn) + docLines[row], docLines[row + delta.lines.length - 1] += line.substring(startColumn) - } - break; - case "remove": - var endColumn = delta.end.column, - endRow = delta.end.row; - row === endRow ? docLines[row] = line.substring(0, startColumn) + line.substring(endColumn) : docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn)) - } - } -}), ace.define("ace/lib/event_emitter", ["require", "exports", "module"], function(acequire, exports) { - "use strict"; - var EventEmitter = {}, - stopPropagation = function() { - this.propagationStopped = !0 - }, - preventDefault = function() { - this.defaultPrevented = !0 - }; - EventEmitter._emit = EventEmitter._dispatchEvent = function(eventName, e) { - this._eventRegistry || (this._eventRegistry = {}), this._defaultHandlers || (this._defaultHandlers = {}); - var listeners = this._eventRegistry[eventName] || [], - defaultHandler = this._defaultHandlers[eventName]; - if (listeners.length || defaultHandler) { - "object" == typeof e && e || (e = {}), e.type || (e.type = eventName), e.stopPropagation || (e.stopPropagation = stopPropagation), e.preventDefault || (e.preventDefault = preventDefault), listeners = listeners.slice(); - for (var i = 0; listeners.length > i && (listeners[i](e, this), !e.propagationStopped); i++); - return defaultHandler && !e.defaultPrevented ? defaultHandler(e, this) : void 0 - } - }, EventEmitter._signal = function(eventName, e) { - var listeners = (this._eventRegistry || {})[eventName]; - if (listeners) { - listeners = listeners.slice(); - for (var i = 0; listeners.length > i; i++) listeners[i](e, this) - } - }, EventEmitter.once = function(eventName, callback) { - var _self = this; - callback && this.addEventListener(eventName, function newCallback() { - _self.removeEventListener(eventName, newCallback), callback.apply(null, arguments) - }) - }, EventEmitter.setDefaultHandler = function(eventName, callback) { - var handlers = this._defaultHandlers; - if (handlers || (handlers = this._defaultHandlers = { - _disabled_: {} - }), handlers[eventName]) { - var old = handlers[eventName], - disabled = handlers._disabled_[eventName]; - disabled || (handlers._disabled_[eventName] = disabled = []), disabled.push(old); - var i = disabled.indexOf(callback); - 1 != i && disabled.splice(i, 1) - } - handlers[eventName] = callback - }, EventEmitter.removeDefaultHandler = function(eventName, callback) { - var handlers = this._defaultHandlers; - if (handlers) { - var disabled = handlers._disabled_[eventName]; - if (handlers[eventName] == callback) handlers[eventName], disabled && this.setDefaultHandler(eventName, disabled.pop()); - else if (disabled) { - var i = disabled.indexOf(callback); - 1 != i && disabled.splice(i, 1) - } - } - }, EventEmitter.on = EventEmitter.addEventListener = function(eventName, callback, capturing) { - this._eventRegistry = this._eventRegistry || {}; - var listeners = this._eventRegistry[eventName]; - return listeners || (listeners = this._eventRegistry[eventName] = []), -1 == listeners.indexOf(callback) && listeners[capturing ? "unshift" : "push"](callback), callback - }, EventEmitter.off = EventEmitter.removeListener = EventEmitter.removeEventListener = function(eventName, callback) { - this._eventRegistry = this._eventRegistry || {}; - var listeners = this._eventRegistry[eventName]; - if (listeners) { - var index = listeners.indexOf(callback); - 1 !== index && listeners.splice(index, 1) - } - }, EventEmitter.removeAllListeners = function(eventName) { - this._eventRegistry && (this._eventRegistry[eventName] = []) - }, exports.EventEmitter = EventEmitter -}), ace.define("ace/anchor", ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter"], function(acequire, exports) { - "use strict"; - var oop = acequire("./lib/oop"), - EventEmitter = acequire("./lib/event_emitter").EventEmitter, - Anchor = exports.Anchor = function(doc, row, column) { - this.$onChange = this.onChange.bind(this), this.attach(doc), column === void 0 ? this.setPosition(row.row, row.column) : this.setPosition(row, column) - }; - (function() { - function $pointsInOrder(point1, point2, equalPointsInOrder) { - var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; - return point1.row < point2.row || point1.row == point2.row && bColIsAfter - } - - function $getTransformedPoint(delta, point, moveIfEqual) { - var deltaIsInsert = "insert" == delta.action, - deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row), - deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column), - deltaStart = delta.start, - deltaEnd = deltaIsInsert ? deltaStart : delta.end; - return $pointsInOrder(point, deltaStart, moveIfEqual) ? { - row: point.row, - column: point.column - } : $pointsInOrder(deltaEnd, point, !moveIfEqual) ? { - row: point.row + deltaRowShift, - column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) - } : { - row: deltaStart.row, - column: deltaStart.column - } - } - oop.implement(this, EventEmitter), this.getPosition = function() { - return this.$clipPositionToDocument(this.row, this.column) - }, this.getDocument = function() { - return this.document - }, this.$insertRight = !1, this.onChange = function(delta) { - if (!(delta.start.row == delta.end.row && delta.start.row != this.row || delta.start.row > this.row)) { - var point = $getTransformedPoint(delta, { - row: this.row, - column: this.column - }, this.$insertRight); - this.setPosition(point.row, point.column, !0) - } - }, this.setPosition = function(row, column, noClip) { - var pos; - if (pos = noClip ? { - row: row, - column: column - } : this.$clipPositionToDocument(row, column), this.row != pos.row || this.column != pos.column) { - var old = { - row: this.row, - column: this.column - }; - this.row = pos.row, this.column = pos.column, this._signal("change", { - old: old, - value: pos - }) - } - }, this.detach = function() { - this.document.removeEventListener("change", this.$onChange) - }, this.attach = function(doc) { - this.document = doc || this.document, this.document.on("change", this.$onChange) - }, this.$clipPositionToDocument = function(row, column) { - var pos = {}; - return row >= this.document.getLength() ? (pos.row = Math.max(0, this.document.getLength() - 1), pos.column = this.document.getLine(pos.row).length) : 0 > row ? (pos.row = 0, pos.column = 0) : (pos.row = row, pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column))), 0 > column && (pos.column = 0), pos - } - }).call(Anchor.prototype) -}), ace.define("ace/document", ["require", "exports", "module", "ace/lib/oop", "ace/apply_delta", "ace/lib/event_emitter", "ace/range", "ace/anchor"], function(acequire, exports) { - "use strict"; - var oop = acequire("./lib/oop"), - applyDelta = acequire("./apply_delta").applyDelta, - EventEmitter = acequire("./lib/event_emitter").EventEmitter, - Range = acequire("./range").Range, - Anchor = acequire("./anchor").Anchor, - Document = function(textOrLines) { - this.$lines = [""], 0 === textOrLines.length ? this.$lines = [""] : Array.isArray(textOrLines) ? this.insertMergedLines({ - row: 0, - column: 0 - }, textOrLines) : this.insert({ - row: 0, - column: 0 - }, textOrLines) - }; - (function() { - oop.implement(this, EventEmitter), this.setValue = function(text) { - var len = this.getLength() - 1; - this.remove(new Range(0, 0, len, this.getLine(len).length)), this.insert({ - row: 0, - column: 0 - }, text) - }, this.getValue = function() { - return this.getAllLines().join(this.getNewLineCharacter()) - }, this.createAnchor = function(row, column) { - return new Anchor(this, row, column) - }, this.$split = 0 === "aaa".split(/a/).length ? function(text) { - return text.replace(/\r\n|\r/g, "\n").split("\n"); - } : function(text) { - return text.split(/\r\n|\r|\n/); - }, this.$detectNewLine = function(text) { - var match = text.match(/^.*?(\r\n|\r|\n)/m); - this.$autoNewLine = match ? match[1] : "\n", this._signal("changeNewLineMode") - }, this.getNewLineCharacter = function() { - switch (this.$newLineMode) { - case "windows": - return "\r\n"; - case "unix": - return "\n"; - default: - return this.$autoNewLine || "\n" - } - }, this.$autoNewLine = "", this.$newLineMode = "auto", this.setNewLineMode = function(newLineMode) { - this.$newLineMode !== newLineMode && (this.$newLineMode = newLineMode, this._signal("changeNewLineMode")) - }, this.getNewLineMode = function() { - return this.$newLineMode - }, this.isNewLine = function(text) { - return "\r\n" == text || "\r" == text || "\n" == text - }, this.getLine = function(row) { - return this.$lines[row] || "" - }, this.getLines = function(firstRow, lastRow) { - return this.$lines.slice(firstRow, lastRow + 1) - }, this.getAllLines = function() { - return this.getLines(0, this.getLength()) - }, this.getLength = function() { - return this.$lines.length - }, this.getTextRange = function(range) { - return this.getLinesForRange(range).join(this.getNewLineCharacter()) - }, this.getLinesForRange = function(range) { - var lines; - if (range.start.row === range.end.row) lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)]; - else { - lines = this.getLines(range.start.row, range.end.row), lines[0] = (lines[0] || "").substring(range.start.column); - var l = lines.length - 1; - range.end.row - range.start.row == l && (lines[l] = lines[l].substring(0, range.end.column)) - } - return lines - }, this.insertLines = function(row, lines) { - return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."), this.insertFullLines(row, lines) - }, this.removeLines = function(firstRow, lastRow) { - return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."), this.removeFullLines(firstRow, lastRow) - }, this.insertNewLine = function(position) { - return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."), this.insertMergedLines(position, ["", ""]) - }, this.insert = function(position, text) { - return 1 >= this.getLength() && this.$detectNewLine(text), this.insertMergedLines(position, this.$split(text)) - }, this.insertInLine = function(position, text) { - var start = this.clippedPos(position.row, position.column), - end = this.pos(position.row, position.column + text.length); - return this.applyDelta({ - start: start, - end: end, - action: "insert", - lines: [text] - }, !0), this.clonePos(end) - }, this.clippedPos = function(row, column) { - var length = this.getLength(); - void 0 === row ? row = length : 0 > row ? row = 0 : row >= length && (row = length - 1, column = void 0); - var line = this.getLine(row); - return void 0 == column && (column = line.length), column = Math.min(Math.max(column, 0), line.length), { - row: row, - column: column - } - }, this.clonePos = function(pos) { - return { - row: pos.row, - column: pos.column - } - }, this.pos = function(row, column) { - return { - row: row, - column: column - } - }, this.$clipPosition = function(position) { - var length = this.getLength(); - return position.row >= length ? (position.row = Math.max(0, length - 1), position.column = this.getLine(length - 1).length) : (position.row = Math.max(0, position.row), position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length)), position - }, this.insertFullLines = function(row, lines) { - row = Math.min(Math.max(row, 0), this.getLength()); - var column = 0; - this.getLength() > row ? (lines = lines.concat([""]), column = 0) : (lines = [""].concat(lines), row--, column = this.$lines[row].length), this.insertMergedLines({ - row: row, - column: column - }, lines) - }, this.insertMergedLines = function(position, lines) { - var start = this.clippedPos(position.row, position.column), - end = { - row: start.row + lines.length - 1, - column: (1 == lines.length ? start.column : 0) + lines[lines.length - 1].length - }; - return this.applyDelta({ - start: start, - end: end, - action: "insert", - lines: lines - }), this.clonePos(end) - }, this.remove = function(range) { - var start = this.clippedPos(range.start.row, range.start.column), - end = this.clippedPos(range.end.row, range.end.column); - return this.applyDelta({ - start: start, - end: end, - action: "remove", - lines: this.getLinesForRange({ - start: start, - end: end - }) - }), this.clonePos(start) - }, this.removeInLine = function(row, startColumn, endColumn) { - var start = this.clippedPos(row, startColumn), - end = this.clippedPos(row, endColumn); - return this.applyDelta({ - start: start, - end: end, - action: "remove", - lines: this.getLinesForRange({ - start: start, - end: end - }) - }, !0), this.clonePos(start) - }, this.removeFullLines = function(firstRow, lastRow) { - firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1), lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1); - var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0, - deleteLastNewLine = this.getLength() - 1 > lastRow, - startRow = deleteFirstNewLine ? firstRow - 1 : firstRow, - startCol = deleteFirstNewLine ? this.getLine(startRow).length : 0, - endRow = deleteLastNewLine ? lastRow + 1 : lastRow, - endCol = deleteLastNewLine ? 0 : this.getLine(endRow).length, - range = new Range(startRow, startCol, endRow, endCol), - deletedLines = this.$lines.slice(firstRow, lastRow + 1); - return this.applyDelta({ - start: range.start, - end: range.end, - action: "remove", - lines: this.getLinesForRange(range) - }), deletedLines - }, this.removeNewLine = function(row) { - this.getLength() - 1 > row && row >= 0 && this.applyDelta({ - start: this.pos(row, this.getLine(row).length), - end: this.pos(row + 1, 0), - action: "remove", - lines: ["", ""] - }) - }, this.replace = function(range, text) { - if (range instanceof Range || (range = Range.fromPoints(range.start, range.end)), 0 === text.length && range.isEmpty()) return range.start; - if (text == this.getTextRange(range)) return range.end; - this.remove(range); - var end; - return end = text ? this.insert(range.start, text) : range.start - }, this.applyDeltas = function(deltas) { - for (var i = 0; deltas.length > i; i++) this.applyDelta(deltas[i]) - }, this.revertDeltas = function(deltas) { - for (var i = deltas.length - 1; i >= 0; i--) this.revertDelta(deltas[i]) - }, this.applyDelta = function(delta, doNotValidate) { - var isInsert = "insert" == delta.action; - (isInsert ? 1 >= delta.lines.length && !delta.lines[0] : !Range.comparePoints(delta.start, delta.end)) || (isInsert && delta.lines.length > 2e4 && this.$splitAndapplyLargeDelta(delta, 2e4), applyDelta(this.$lines, delta, doNotValidate), this._signal("change", delta)) - }, this.$splitAndapplyLargeDelta = function(delta, MAX) { - for (var lines = delta.lines, l = lines.length, row = delta.start.row, column = delta.start.column, from = 0, to = 0;;) { - from = to, to += MAX - 1; - var chunk = lines.slice(from, to); - if (to > l) { - delta.lines = chunk, delta.start.row = row + from, delta.start.column = column; - break - } - chunk.push(""), this.applyDelta({ - start: this.pos(row + from, column), - end: this.pos(row + to, column = 0), - action: delta.action, - lines: chunk - }, !0) - } - }, this.revertDelta = function(delta) { - this.applyDelta({ - start: this.clonePos(delta.start), - end: this.clonePos(delta.end), - action: "insert" == delta.action ? "remove" : "insert", - lines: delta.lines.slice() - }) - }, this.indexToPosition = function(index, startRow) { - for (var lines = this.$lines || this.getAllLines(), newlineLength = this.getNewLineCharacter().length, i = startRow || 0, l = lines.length; l > i; i++) - if (index -= lines[i].length + newlineLength, 0 > index) return { - row: i, - column: index + lines[i].length + newlineLength - }; - return { - row: l - 1, - column: lines[l - 1].length - } - }, this.positionToIndex = function(pos, startRow) { - for (var lines = this.$lines || this.getAllLines(), newlineLength = this.getNewLineCharacter().length, index = 0, row = Math.min(pos.row, lines.length), i = startRow || 0; row > i; ++i) index += lines[i].length + newlineLength; - return index + pos.column - } - }).call(Document.prototype), exports.Document = Document -}), ace.define("ace/lib/lang", ["require", "exports", "module"], function(acequire, exports) { - "use strict"; - exports.last = function(a) { - return a[a.length - 1] - }, exports.stringReverse = function(string) { - return string.split("").reverse().join("") - }, exports.stringRepeat = function(string, count) { - for (var result = ""; count > 0;) 1 & count && (result += string), (count >>= 1) && (string += string); - return result - }; - var trimBeginRegexp = /^\s\s*/, - trimEndRegexp = /\s\s*$/; - exports.stringTrimLeft = function(string) { - return string.replace(trimBeginRegexp, "") - }, exports.stringTrimRight = function(string) { - return string.replace(trimEndRegexp, "") - }, exports.copyObject = function(obj) { - var copy = {}; - for (var key in obj) copy[key] = obj[key]; - return copy - }, exports.copyArray = function(array) { - for (var copy = [], i = 0, l = array.length; l > i; i++) copy[i] = array[i] && "object" == typeof array[i] ? this.copyObject(array[i]) : array[i]; - return copy - }, exports.deepCopy = function deepCopy(obj) { - if ("object" != typeof obj || !obj) return obj; - var copy; - if (Array.isArray(obj)) { - copy = []; - for (var key = 0; obj.length > key; key++) copy[key] = deepCopy(obj[key]); - return copy - } - if ("[object Object]" !== Object.prototype.toString.call(obj)) return obj; - copy = {}; - for (var key in obj) copy[key] = deepCopy(obj[key]); - return copy - }, exports.arrayToMap = function(arr) { - for (var map = {}, i = 0; arr.length > i; i++) map[arr[i]] = 1; - return map - }, exports.createMap = function(props) { - var map = Object.create(null); - for (var i in props) map[i] = props[i]; - return map - }, exports.arrayRemove = function(array, value) { - for (var i = 0; array.length >= i; i++) value === array[i] && array.splice(i, 1) - }, exports.escapeRegExp = function(str) { - return str.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1"); - }, exports.escapeHTML = function(str) { - return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/ i; i += 2) { - if (Array.isArray(data[i + 1])) var d = { - action: "insert", - start: data[i], - lines: data[i + 1] - }; - else var d = { - action: "remove", - start: data[i], - end: data[i + 1] - }; - doc.applyDelta(d, !0) - } - return _self.$timeout ? deferredUpdate.schedule(_self.$timeout) : (_self.onUpdate(), void 0) - }) - }; - (function() { - this.$timeout = 500, this.setTimeout = function(timeout) { - this.$timeout = timeout - }, this.setValue = function(value) { - this.doc.setValue(value), this.deferredUpdate.schedule(this.$timeout) - }, this.getValue = function(callbackId) { - this.sender.callback(this.doc.getValue(), callbackId) - }, this.onUpdate = function() {}, this.isPending = function() { - return this.deferredUpdate.isPending() - } - }).call(Mirror.prototype) -}), ace.define("ace/mode/json/json_parse", ["require", "exports", "module"], function() { - "use strict"; - var at, ch, text, value, escapee = { - '"': '"', - "\\": "\\", - "/": "/", - b: "\b", - f: "\f", - n: "\n", - r: "\r", - t: " " - }, - error = function(m) { - throw { - name: "SyntaxError", - message: m, - at: at, - text: text - } - }, - reset = function (newAt) { - ch = text.charAt(newAt); - at = newAt + 1; - }, - next = function(c) { - return c && c !== ch && error("Expected '" + c + "' instead of '" + ch + "'"), ch = text.charAt(at), at += 1, ch - }, - nextUpTo = function (upTo, errorMessage) { - let currentAt = at, - i = text.indexOf(upTo, currentAt); - if (i < 0) { - error(errorMessage || 'Expected \'' + upTo + '\''); - } - reset(i + upTo.length); - return text.substring(currentAt, i); - }, - peek = function (c) { - return text.substr(at, c.length) === c; // nocommit - double check - }, - number = function() { - var number, string = ""; - for ("-" === ch && (string = "-", next("-")); ch >= "0" && "9" >= ch;) string += ch, next(); - if ("." === ch) - for (string += "."; next() && ch >= "0" && "9" >= ch;) string += ch; - if ("e" === ch || "E" === ch) - for (string += ch, next(), ("-" === ch || "+" === ch) && (string += ch, next()); ch >= "0" && "9" >= ch;) string += ch, next(); - return number = +string, isNaN(number) ? (error("Bad number"), void 0) : number - }, - string = function() { - var hex, i, uffff, string = ""; - if ('"' === ch) { - if (peek('""')) { - // literal - next('"'); - next('"'); - return nextUpTo('"""', 'failed to find closing \'"""\''); - } else { - for (; next();) { - if ('"' === ch) return next(), string; - if ("\\" === ch) - if (next(), "u" === ch) { - for (uffff = 0, i = 0; 4 > i && (hex = parseInt(next(), 16), isFinite(hex)); i += 1) uffff = 16 * uffff + hex; - string += String.fromCharCode(uffff) - } else { - if ("string" != typeof escapee[ch]) break; - string += escapee[ch] - } - else string += ch - } - } - } - error("Bad string") - }, - white = function() { - for (; ch && " " >= ch;) next() - }, - word = function() { - switch (ch) { - case "t": - return next("t"), next("r"), next("u"), next("e"), !0; - case "f": - return next("f"), next("a"), next("l"), next("s"), next("e"), !1; - case "n": - return next("n"), next("u"), next("l"), next("l"), null - } - error("Unexpected '" + ch + "'") - }, - array = function() { - var array = []; - if ("[" === ch) { - if (next("["), white(), "]" === ch) return next("]"), array; - for (; ch;) { - if (array.push(value()), white(), "]" === ch) return next("]"), array; - next(","), white() - } - } - error("Bad array") - }, - object = function() { - var key, object = {}; - if ("{" === ch) { - if (next("{"), white(), "}" === ch) return next("}"), object; - for (; ch;) { - if (key = string(), white(), next(":"), Object.hasOwnProperty.call(object, key) && error('Duplicate key "' + key + '"'), object[key] = value(), white(), "}" === ch) return next("}"), object; - next(","), white() - } - } - error("Bad object") - }; - return value = function() { - switch (white(), ch) { - case "{": - return object(); - case "[": - return array(); - case '"': - return string(); - case "-": - return number(); - default: - return ch >= "0" && "9" >= ch ? number() : word() - } - }, - function(source, reviver) { - var result; - return text = source, at = 0, ch = " ", result = value(), white(), ch && error("Syntax error"), "function" == typeof reviver ? function walk(holder, key) { - var k, v, value = holder[key]; - if (value && "object" == typeof value) - for (k in value) Object.hasOwnProperty.call(value, k) && (v = walk(value, k), void 0 !== v ? value[k] = v : delete value[k]); - return reviver.call(holder, key, value) - }({ - "": result - }, "") : result - } -}), ace.define("ace/mode/json_worker", ["require", "exports", "module", "ace/lib/oop", "ace/worker/mirror", "ace/mode/json/json_parse"], function(acequire, exports) { - "use strict"; - var oop = acequire("../lib/oop"), - Mirror = acequire("../worker/mirror").Mirror, - parse = acequire("./json/json_parse"), - JsonWorker = exports.JsonWorker = function(sender) { - Mirror.call(this, sender), this.setTimeout(200) - }; - oop.inherits(JsonWorker, Mirror), - function() { - this.onUpdate = function() { - var value = this.doc.getValue(), - errors = []; - try { - value && parse(value) - } catch (e) { - var pos = this.doc.indexToPosition(e.at - 1); - errors.push({ - row: pos.row, - column: pos.column, - text: e.message, - type: "error" - }) - } - this.sender.emit("annotate", errors) - } - }.call(JsonWorker.prototype) -}), ace.define("ace/lib/es5-shim", ["require", "exports", "module"], function() { - function Empty() {} - - function doesDefinePropertyWork(object) { - try { - return Object.defineProperty(object, "sentinel", {}), "sentinel" in object - } catch (exception) {} - } - - function toInteger(n) { - return n = +n, n !== n ? n = 0 : 0 !== n && n !== 1 / 0 && n !== -(1 / 0) && (n = (n > 0 || -1) * Math.floor(Math.abs(n))), n - } - Function.prototype.bind || (Function.prototype.bind = function(that) { - var target = this; - if ("function" != typeof target) throw new TypeError("Function.prototype.bind called on incompatible " + target); - var args = slice.call(arguments, 1), - bound = function() { - if (this instanceof bound) { - var result = target.apply(this, args.concat(slice.call(arguments))); - return Object(result) === result ? result : this - } - return target.apply(that, args.concat(slice.call(arguments))) - }; - return target.prototype && (Empty.prototype = target.prototype, bound.prototype = new Empty, Empty.prototype = null), bound - }); - var defineGetter, defineSetter, lookupGetter, lookupSetter, supportsAccessors, call = Function.prototype.call, - prototypeOfArray = Array.prototype, - prototypeOfObject = Object.prototype, - slice = prototypeOfArray.slice, - _toString = call.bind(prototypeOfObject.toString), - owns = call.bind(prototypeOfObject.hasOwnProperty); - if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__")) && (defineGetter = call.bind(prototypeOfObject.__defineGetter__), defineSetter = call.bind(prototypeOfObject.__defineSetter__), lookupGetter = call.bind(prototypeOfObject.__lookupGetter__), lookupSetter = call.bind(prototypeOfObject.__lookupSetter__)), 2 != [1, 2].splice(0).length) - if (function() { - function makeArray(l) { - var a = Array(l + 2); - return a[0] = a[1] = 0, a - } - var lengthBefore, array = []; - return array.splice.apply(array, makeArray(20)), array.splice.apply(array, makeArray(26)), lengthBefore = array.length, array.splice(5, 0, "XXX"), lengthBefore + 1 == array.length, lengthBefore + 1 == array.length ? !0 : void 0 - }()) { - var array_splice = Array.prototype.splice; - Array.prototype.splice = function(start, deleteCount) { - return arguments.length ? array_splice.apply(this, [void 0 === start ? 0 : start, void 0 === deleteCount ? this.length - start : deleteCount].concat(slice.call(arguments, 2))) : [] - } - } else Array.prototype.splice = function(pos, removeCount) { - var length = this.length; - pos > 0 ? pos > length && (pos = length) : void 0 == pos ? pos = 0 : 0 > pos && (pos = Math.max(length + pos, 0)), length > pos + removeCount || (removeCount = length - pos); - var removed = this.slice(pos, pos + removeCount), - insert = slice.call(arguments, 2), - add = insert.length; - if (pos === length) add && this.push.apply(this, insert); - else { - var remove = Math.min(removeCount, length - pos), - tailOldPos = pos + remove, - tailNewPos = tailOldPos + add - remove, - tailCount = length - tailOldPos, - lengthAfterRemove = length - remove; - if (tailOldPos > tailNewPos) - for (var i = 0; tailCount > i; ++i) this[tailNewPos + i] = this[tailOldPos + i]; - else if (tailNewPos > tailOldPos) - for (i = tailCount; i--;) this[tailNewPos + i] = this[tailOldPos + i]; - if (add && pos === lengthAfterRemove) this.length = lengthAfterRemove, this.push.apply(this, insert); - else - for (this.length = lengthAfterRemove + add, i = 0; add > i; ++i) this[pos + i] = insert[i] - } - return removed - }; - Array.isArray || (Array.isArray = function(obj) { - return "[object Array]" == _toString(obj) - }); - var boxedString = Object("a"), - splitString = "a" != boxedString[0] || !(0 in boxedString); - if (Array.prototype.forEach || (Array.prototype.forEach = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - thisp = arguments[1], - i = -1, - length = self.length >>> 0; - if ("[object Function]" != _toString(fun)) throw new TypeError; - for (; length > ++i;) i in self && fun.call(thisp, self[i], i, object) - }), Array.prototype.map || (Array.prototype.map = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0, - result = Array(length), - thisp = arguments[1]; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - for (var i = 0; length > i; i++) i in self && (result[i] = fun.call(thisp, self[i], i, object)); - return result - }), Array.prototype.filter || (Array.prototype.filter = function(fun) { - var value, object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0, - result = [], - thisp = arguments[1]; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - for (var i = 0; length > i; i++) i in self && (value = self[i], fun.call(thisp, value, i, object) && result.push(value)); - return result - }), Array.prototype.every || (Array.prototype.every = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0, - thisp = arguments[1]; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - for (var i = 0; length > i; i++) - if (i in self && !fun.call(thisp, self[i], i, object)) return !1; - return !0 - }), Array.prototype.some || (Array.prototype.some = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0, - thisp = arguments[1]; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - for (var i = 0; length > i; i++) - if (i in self && fun.call(thisp, self[i], i, object)) return !0; - return !1 - }), Array.prototype.reduce || (Array.prototype.reduce = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - if (!length && 1 == arguments.length) throw new TypeError("reduce of empty array with no initial value"); - var result, i = 0; - if (arguments.length >= 2) result = arguments[1]; - else - for (;;) { - if (i in self) { - result = self[i++]; - break - } - if (++i >= length) throw new TypeError("reduce of empty array with no initial value") - } - for (; length > i; i++) i in self && (result = fun.call(void 0, result, self[i], i, object)); - return result - }), Array.prototype.reduceRight || (Array.prototype.reduceRight = function(fun) { - var object = toObject(this), - self = splitString && "[object String]" == _toString(this) ? this.split("") : object, - length = self.length >>> 0; - if ("[object Function]" != _toString(fun)) throw new TypeError(fun + " is not a function"); - if (!length && 1 == arguments.length) throw new TypeError("reduceRight of empty array with no initial value"); - var result, i = length - 1; - if (arguments.length >= 2) result = arguments[1]; - else - for (;;) { - if (i in self) { - result = self[i--]; - break - } - if (0 > --i) throw new TypeError("reduceRight of empty array with no initial value") - } - do i in this && (result = fun.call(void 0, result, self[i], i, object)); while (i--); - return result - }), Array.prototype.indexOf && -1 == [0, 1].indexOf(1, 2) || (Array.prototype.indexOf = function(sought) { - var self = splitString && "[object String]" == _toString(this) ? this.split("") : toObject(this), - length = self.length >>> 0; - if (!length) return -1; - var i = 0; - for (arguments.length > 1 && (i = toInteger(arguments[1])), i = i >= 0 ? i : Math.max(0, length + i); length > i; i++) - if (i in self && self[i] === sought) return i; - return -1 - }), Array.prototype.lastIndexOf && -1 == [0, 1].lastIndexOf(0, -3) || (Array.prototype.lastIndexOf = function(sought) { - var self = splitString && "[object String]" == _toString(this) ? this.split("") : toObject(this), - length = self.length >>> 0; - if (!length) return -1; - var i = length - 1; - for (arguments.length > 1 && (i = Math.min(i, toInteger(arguments[1]))), i = i >= 0 ? i : length - Math.abs(i); i >= 0; i--) - if (i in self && sought === self[i]) return i; - return -1 - }), Object.getPrototypeOf || (Object.getPrototypeOf = function(object) { - return object.__proto__ || (object.constructor ? object.constructor.prototype : prototypeOfObject) - }), !Object.getOwnPropertyDescriptor) { - var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: "; - Object.getOwnPropertyDescriptor = function(object, property) { - if ("object" != typeof object && "function" != typeof object || null === object) throw new TypeError(ERR_NON_OBJECT + object); - if (owns(object, property)) { - var descriptor, getter, setter; - if (descriptor = { - enumerable: !0, - configurable: !0 - }, supportsAccessors) { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject; - var getter = lookupGetter(object, property), - setter = lookupSetter(object, property); - if (object.__proto__ = prototype, getter || setter) return getter && (descriptor.get = getter), setter && (descriptor.set = setter), descriptor - } - return descriptor.value = object[property], descriptor - } - } - } - if (Object.getOwnPropertyNames || (Object.getOwnPropertyNames = function(object) { - return Object.keys(object) - }), !Object.create) { - var createEmpty; - createEmpty = null === Object.prototype.__proto__ ? function() { - return { - __proto__: null - } - } : function() { - var empty = {}; - for (var i in empty) empty[i] = null; - return empty.constructor = empty.hasOwnProperty = empty.propertyIsEnumerable = empty.isPrototypeOf = empty.toLocaleString = empty.toString = empty.valueOf = empty.__proto__ = null, empty - }, Object.create = function(prototype, properties) { - var object; - if (null === prototype) object = createEmpty(); - else { - if ("object" != typeof prototype) throw new TypeError("typeof prototype[" + typeof prototype + "] != 'object'"); - var Type = function() {}; - Type.prototype = prototype, object = new Type, object.__proto__ = prototype - } - return void 0 !== properties && Object.defineProperties(object, properties), object - } - } - if (Object.defineProperty) { - var definePropertyWorksOnObject = doesDefinePropertyWork({}), - definePropertyWorksOnDom = "undefined" == typeof document || doesDefinePropertyWork(document.createElement("div")); - if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) var definePropertyFallback = Object.defineProperty - } - if (!Object.defineProperty || definePropertyFallback) { - var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ", - ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: ", - ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined on this javascript engine"; - Object.defineProperty = function(object, property, descriptor) { - if ("object" != typeof object && "function" != typeof object || null === object) throw new TypeError(ERR_NON_OBJECT_TARGET + object); - if ("object" != typeof descriptor && "function" != typeof descriptor || null === descriptor) throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); - if (definePropertyFallback) try { - return definePropertyFallback.call(Object, object, property, descriptor) - } catch (exception) {} - if (owns(descriptor, "value")) - if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) { - var prototype = object.__proto__; - object.__proto__ = prototypeOfObject, delete object[property], object[property] = descriptor.value, object.__proto__ = prototype - } else object[property] = descriptor.value; - else { - if (!supportsAccessors) throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); - owns(descriptor, "get") && defineGetter(object, property, descriptor.get), owns(descriptor, "set") && defineSetter(object, property, descriptor.set) - } - return object - } - } - Object.defineProperties || (Object.defineProperties = function(object, properties) { - for (var property in properties) owns(properties, property) && Object.defineProperty(object, property, properties[property]); - return object - }), Object.seal || (Object.seal = function(object) { - return object - }), Object.freeze || (Object.freeze = function(object) { - return object - }); - try { - Object.freeze(function() {}) - } catch (exception) { - Object.freeze = function(freezeObject) { - return function(object) { - return "function" == typeof object ? object : freezeObject(object) - } - }(Object.freeze) - } - if (Object.preventExtensions || (Object.preventExtensions = function(object) { - return object - }), Object.isSealed || (Object.isSealed = function() { - return !1 - }), Object.isFrozen || (Object.isFrozen = function() { - return !1 - }), Object.isExtensible || (Object.isExtensible = function(object) { - if (Object(object) === object) throw new TypeError; - for (var name = ""; owns(object, name);) name += "?"; - object[name] = !0; - var returnValue = owns(object, name); - return delete object[name], returnValue - }), !Object.keys) { - var hasDontEnumBug = !0, - dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], - dontEnumsLength = dontEnums.length; - for (var key in { - toString: null - }) hasDontEnumBug = !1; - Object.keys = function(object) { - if ("object" != typeof object && "function" != typeof object || null === object) throw new TypeError("Object.keys called on a non-object"); - var keys = []; - for (var name in object) owns(object, name) && keys.push(name); - if (hasDontEnumBug) - for (var i = 0, ii = dontEnumsLength; ii > i; i++) { - var dontEnum = dontEnums[i]; - owns(object, dontEnum) && keys.push(dontEnum) - } - return keys - } - } - Date.now || (Date.now = function() { - return (new Date).getTime() - }); - var ws = " \n \f\r   ᠎              \u2028\u2029"; - if (!String.prototype.trim || ws.trim()) { - ws = "[" + ws + "]"; - var trimBeginRegexp = RegExp("^" + ws + ws + "*"), - trimEndRegexp = RegExp(ws + ws + "*$"); - String.prototype.trim = function() { - return (this + "").replace(trimBeginRegexp, "").replace(trimEndRegexp, "") - } - } - var toObject = function(o) { - if (null == o) throw new TypeError("can't convert " + o + " to object"); - return Object(o) - } -}); diff --git a/packages/kbn-ace/src/ace/modes/x_json/x_json.ts b/packages/kbn-ace/src/ace/modes/x_json/x_json.ts deleted file mode 100644 index 5a535e237a327..0000000000000 --- a/packages/kbn-ace/src/ace/modes/x_json/x_json.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import ace from 'brace'; -import { XJsonHighlightRules } from '..'; -import { workerModule } from './worker'; - -const { WorkerClient } = ace.acequire('ace/worker/worker_client'); - -const oop = ace.acequire('ace/lib/oop'); - -const { Mode: JSONMode } = ace.acequire('ace/mode/json'); -const { Tokenizer: AceTokenizer } = ace.acequire('ace/tokenizer'); -const { MatchingBraceOutdent } = ace.acequire('ace/mode/matching_brace_outdent'); -const { CstyleBehaviour } = ace.acequire('ace/mode/behaviour/cstyle'); -const { FoldMode: CStyleFoldMode } = ace.acequire('ace/mode/folding/cstyle'); - -const XJsonMode: any = function XJsonMode(this: any) { - const ruleset: any = new (XJsonHighlightRules as any)(); - ruleset.normalizeRules(); - this.$tokenizer = new AceTokenizer(ruleset.getRules()); - this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); - this.foldingRules = new CStyleFoldMode(); -}; - -oop.inherits(XJsonMode, JSONMode); - -// Then clobber `createWorker` method to install our worker source. Per ace's wiki: https://github.com/ajaxorg/ace/wiki/Syntax-validation -(XJsonMode.prototype as any).createWorker = function (session: ace.IEditSession) { - const xJsonWorker = new WorkerClient(['ace'], workerModule, 'JsonWorker'); - - xJsonWorker.attachToDocument(session.getDocument()); - - xJsonWorker.on('annotate', function (e: { data: any }) { - session.setAnnotations(e.data); - }); - - xJsonWorker.on('terminate', function () { - session.clearAnnotations(); - }); - - return xJsonWorker; -}; - -export { XJsonMode }; - -export function installXJsonMode(editor: ace.Editor) { - const session = editor.getSession(); - session.setMode(new XJsonMode()); -} diff --git a/packages/kbn-ace/tsconfig.json b/packages/kbn-ace/tsconfig.json deleted file mode 100644 index a545abd7d65a6..0000000000000 --- a/packages/kbn-ace/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "allowJs": false, - "outDir": "target/types", - "stripInternal": true, - "types": ["node"] - }, - "include": [ - "**/*.ts", - "src/ace/modes/x_json/worker/x_json.ace.worker.js" - ], - "exclude": [ - "target/**/*", - ] -} diff --git a/packages/kbn-import-resolver/src/import_resolver.ts b/packages/kbn-import-resolver/src/import_resolver.ts index 1b41418a5cb24..9ca16981b2afc 100644 --- a/packages/kbn-import-resolver/src/import_resolver.ts +++ b/packages/kbn-import-resolver/src/import_resolver.ts @@ -122,11 +122,6 @@ export class ImportResolver { return true; } - // ignore amd require done by ace syntax plugin - if (req === 'ace/lib/dom') { - return true; - } - // typescript validates these imports fine and they're purely virtual thanks to ambient type definitions in @elastic/eui so /shrug if ( req.startsWith('@elastic/eui/src/components/') || diff --git a/packages/kbn-import-resolver/src/integration_tests/import_resolver.test.ts b/packages/kbn-import-resolver/src/integration_tests/import_resolver.test.ts index f484de7904f06..1089f811b6e98 100644 --- a/packages/kbn-import-resolver/src/integration_tests/import_resolver.test.ts +++ b/packages/kbn-import-resolver/src/integration_tests/import_resolver.test.ts @@ -99,12 +99,6 @@ describe('#resolve()', () => { } `); - expect(resolver.resolve('ace/lib/dom', FIXTURES_DIR)).toMatchInlineSnapshot(` - Object { - "type": "ignore", - } - `); - expect(resolver.resolve('@elastic/eui/src/components/foo', FIXTURES_DIR)) .toMatchInlineSnapshot(` Object { diff --git a/packages/kbn-test/src/jest/resolver.js b/packages/kbn-test/src/jest/resolver.js index 27e0b14876587..8f985e9463962 100644 --- a/packages/kbn-test/src/jest/resolver.js +++ b/packages/kbn-test/src/jest/resolver.js @@ -70,7 +70,7 @@ module.exports = (request, options) => { return FILE_MOCK; } - if (reqExt === '.worker' && (reqBasename.endsWith('.ace') || reqBasename.endsWith('.editor'))) { + if (reqExt === '.worker' && reqBasename.endsWith('.editor')) { return WORKER_MOCK; } } diff --git a/packages/kbn-ui-shared-deps-npm/BUILD.bazel b/packages/kbn-ui-shared-deps-npm/BUILD.bazel index 48f234b0bfe10..ad3f3474f1b4e 100644 --- a/packages/kbn-ui-shared-deps-npm/BUILD.bazel +++ b/packages/kbn-ui-shared-deps-npm/BUILD.bazel @@ -53,7 +53,6 @@ RUNTIME_DEPS = [ "@npm//jquery", "@npm//lodash", "@npm//moment-timezone", - "@npm//react-ace", "@npm//react-dom", "@npm//react-router-dom", "@npm//react-router-dom-v5-compat", diff --git a/packages/kbn-ui-shared-deps-npm/webpack.config.js b/packages/kbn-ui-shared-deps-npm/webpack.config.js index 3b16430aeb724..926a041a72c3d 100644 --- a/packages/kbn-ui-shared-deps-npm/webpack.config.js +++ b/packages/kbn-ui-shared-deps-npm/webpack.config.js @@ -88,7 +88,6 @@ module.exports = (_, argv) => { 'moment-timezone/moment-timezone', 'moment-timezone/data/packed/latest.json', 'moment', - 'react-ace', 'react-dom', 'react-dom/server', 'react-router-dom', diff --git a/src/core/public/styles/_ace_overrides.scss b/src/core/public/styles/_ace_overrides.scss deleted file mode 100644 index ca5230b46acd3..0000000000000 --- a/src/core/public/styles/_ace_overrides.scss +++ /dev/null @@ -1,202 +0,0 @@ -// SASSTODO: Replace with an EUI editor -// Intentionally not using the EuiCodeBlock colors here because they actually change -// hue from light to dark theme. So some colors would change while others wouldn't. -// Seemed weird, so just hexing all the colors but using the `makeHighContrastColor()` -// function to ensure accessible contrast. - -// In order to override the TM (Textmate) theme of Ace/Brace, everywhere, -// it is being scoped by a known outer selector -.kbnBody { - .ace-tm { - $aceBackground: tintOrShade($euiColorLightShade, 50%, 0); - - background-color: $euiColorLightestShade; - color: $euiTextColor; - - .ace_scrollbar { - @include euiScrollBar; - } - - .ace_gutter-active-line, - .ace_marker-layer .ace_active-line { - background-color: transparentize($euiColorLightShade, .3); - } - - .ace_snippet-marker { - width: 100%; - background-color: $aceBackground; - border: none; - } - - .ace_indent-guide { - background: linear-gradient(to left, $euiColorMediumShade 0%, $euiColorMediumShade 1px, transparent 1px, transparent 100%); - } - - .ace_search { - z-index: $euiZLevel1 + 1; - } - - .ace_layer.ace_marker-layer { - overflow: visible; - } - - .ace_warning { - color: $euiColorDanger; - } - - .ace_method { - color: makeHighContrastColor(#DD0A73, $aceBackground); - } - - .ace_url, - .ace_start_triple_quote, - .ace_end_triple_quote { - color: makeHighContrastColor(#00A69B, $aceBackground); - } - - .ace_multi_string { - color: makeHighContrastColor(#009926, $aceBackground); - font-style: italic; - } - - .ace_gutter { - background-color: $euiColorEmptyShade; - color: $euiColorDarkShade; - border-left: 1px solid $aceBackground; - } - - .ace_print-margin { - width: 1px; - background: $euiColorLightShade; - } - - .ace_fold { - background-color: #6B72E6; - } - - .ace_cursor { - color: $euiColorFullShade; - } - - .ace_invisible { - color: $euiColorLightShade; - } - - .ace_storage, - .ace_keyword { - color: makeHighContrastColor(#0079A5, $aceBackground); - } - - .ace_constant { - color: makeHighContrastColor(#900, $aceBackground); - } - - .ace_constant.ace_buildin { - color: makeHighContrastColor(rgb(88, 72, 246), $aceBackground); - } - - .ace_constant.ace_language { - color: makeHighContrastColor(rgb(88, 92, 246), $aceBackground); - } - - .ace_constant.ace_library { - color: makeHighContrastColor(#009926, $aceBackground); - } - - .ace_invalid { - background-color: euiCallOutColor('danger', 'background'); - color: euiCallOutColor('danger', 'foreground'); - } - - .ace_support.ace_function { - color: makeHighContrastColor(rgb(60, 76, 114), $aceBackground); - } - - .ace_support.ace_constant { - color: makeHighContrastColor(#009926, $aceBackground); - } - - .ace_support.ace_type, - .ace_support.ace_class { - color: makeHighContrastColor(rgb(109, 121, 222), $aceBackground); - } - - .ace_keyword.ace_operator { - color: makeHighContrastColor($euiColorDarkShade, $aceBackground); - } - - .ace_string { - color: makeHighContrastColor(#009926, $aceBackground); - } - - .ace_comment { - color: makeHighContrastColor(rgb(76, 136, 107), $aceBackground); - } - - .ace_comment.ace_doc { - color: makeHighContrastColor(#0079A5, $aceBackground); - } - - .ace_comment.ace_doc.ace_tag { - color: makeHighContrastColor($euiColorMediumShade, $aceBackground); - } - - .ace_constant.ace_numeric { - color: makeHighContrastColor(#0079A5, $aceBackground); - } - - .ace_variable { - color: makeHighContrastColor(#0079A5, $aceBackground); - } - - .ace_xml-pe { - color: makeHighContrastColor($euiColorDarkShade, $aceBackground); - } - - .ace_entity.ace_name.ace_function { - color: makeHighContrastColor(#0000A2, $aceBackground); - } - - .ace_heading { - color: makeHighContrastColor(rgb(12, 7, 255), $aceBackground); - } - - .ace_list { - color: makeHighContrastColor(rgb(185, 6, 144), $aceBackground); - } - - .ace_meta.ace_tag { - color: makeHighContrastColor(rgb(0, 22, 142), $aceBackground); - } - - .ace_string.ace_regex { - color: makeHighContrastColor(rgb(255, 0, 0), $aceBackground); - } - - .ace_marker-layer .ace_selection { - background: tintOrShade($euiColorPrimary, 70%, 70%); - } - - &.ace_multiselect .ace_selection.ace_start { - box-shadow: 0 0 3px 0 $euiColorEmptyShade; - } - - .ace_marker-layer .ace_step { - background: tintOrShade($euiColorWarning, 80%, 80%); - } - - .ace_marker-layer .ace_stack { - background: tintOrShade($euiColorSuccess, 80%, 80%); - } - - .ace_marker-layer .ace_bracket { - margin: -1px 0 0 -1px; - border: $euiBorderThin; - } - - .ace_marker-layer .ace_selected-word { - background: $euiColorLightestShade; - border: $euiBorderThin; - } - } -} diff --git a/src/core/public/styles/_index.scss b/src/core/public/styles/_index.scss index 42981c7e07398..cfdb1c7192dcd 100644 --- a/src/core/public/styles/_index.scss +++ b/src/core/public/styles/_index.scss @@ -1,4 +1,3 @@ @import './base'; -@import './ace_overrides'; @import './chrome/index'; @import './rendering/index'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/_ui_ace_keyboard_mode.scss b/src/plugins/es_ui_shared/__packages_do_not_import__/ace/_ui_ace_keyboard_mode.scss deleted file mode 100644 index 2ad92f3506b20..0000000000000 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/_ui_ace_keyboard_mode.scss +++ /dev/null @@ -1,24 +0,0 @@ -.kbnUiAceKeyboardHint { - position: absolute; - top: 0; - bottom: 0; - right: 0; - left: 0; - background: transparentize($euiColorEmptyShade, .3); - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - text-align: center; - opacity: 0; - - &:focus { - opacity: 1; - border: 2px solid $euiColorPrimary; - z-index: $euiZLevel1; - } - - &.kbnUiAceKeyboardHint-isInactive { - display: none; - } -} diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/ace/index.ts deleted file mode 100644 index 6214a2609462c..0000000000000 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/use_ui_ace_keyboard_mode.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/ace/use_ui_ace_keyboard_mode.tsx deleted file mode 100644 index f1fe888104783..0000000000000 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/ace/use_ui_ace_keyboard_mode.tsx +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import React, { useEffect, useRef } from 'react'; -import * as ReactDOM from 'react-dom'; -import { keys, EuiText } from '@elastic/eui'; -import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; - -import './_ui_ace_keyboard_mode.scss'; -import type { AnalyticsServiceStart, I18nStart, ThemeServiceStart } from '@kbn/core/public'; - -interface StartServices { - analytics: Pick; - i18n: I18nStart; - theme: Pick; -} - -const OverlayText = (startServices: StartServices) => ( - // The point of this element is for accessibility purposes, so ignore eslint error - // in this case - // - - - Press Enter to start editing. - - When you’re done, press Escape to stop editing. - -); - -export function useUIAceKeyboardMode( - aceTextAreaElement: HTMLTextAreaElement | null, - startServices: StartServices, - isAccessibilityOverlayEnabled: boolean = true -) { - const overlayMountNode = useRef(null); - const autoCompleteVisibleRef = useRef(false); - useEffect(() => { - function onDismissOverlay(event: KeyboardEvent) { - if (event.key === keys.ENTER) { - event.preventDefault(); - aceTextAreaElement!.focus(); - } - } - - function enableOverlay() { - if (overlayMountNode.current) { - overlayMountNode.current.focus(); - } - } - - const isAutoCompleteVisible = () => { - const autoCompleter = document.querySelector('.ace_autocomplete'); - if (!autoCompleter) { - return false; - } - // The autoComplete is just hidden when it's closed, not removed from the DOM. - return autoCompleter.style.display !== 'none'; - }; - - const documentKeyDownListener = () => { - autoCompleteVisibleRef.current = isAutoCompleteVisible(); - }; - - const aceKeydownListener = (event: KeyboardEvent) => { - if (event.key === keys.ESCAPE && !autoCompleteVisibleRef.current) { - event.preventDefault(); - event.stopPropagation(); - enableOverlay(); - } - }; - if (aceTextAreaElement && isAccessibilityOverlayEnabled) { - // We don't control HTML elements inside of ace so we imperatively create an element - // that acts as a container and insert it just before ace's textarea element - // so that the overlay lives at the correct spot in the DOM hierarchy. - overlayMountNode.current = document.createElement('div'); - overlayMountNode.current.className = 'kbnUiAceKeyboardHint'; - overlayMountNode.current.setAttribute('role', 'application'); - overlayMountNode.current.tabIndex = 0; - overlayMountNode.current.addEventListener('focus', enableOverlay); - overlayMountNode.current.addEventListener('keydown', onDismissOverlay); - - ReactDOM.render(, overlayMountNode.current); - - aceTextAreaElement.parentElement!.insertBefore(overlayMountNode.current, aceTextAreaElement); - aceTextAreaElement.setAttribute('tabindex', '-1'); - - // Order of events: - // 1. Document capture event fires first and we check whether an autocomplete menu is open on keydown - // (not ideal because this is scoped to the entire document). - // 2. Ace changes it's state (like hiding or showing autocomplete menu) - // 3. We check what button was pressed and whether autocomplete was visible then determine - // whether it should act like a dismiss or if we should display an overlay. - document.addEventListener('keydown', documentKeyDownListener, { capture: true }); - aceTextAreaElement.addEventListener('keydown', aceKeydownListener); - } - return () => { - if (aceTextAreaElement && isAccessibilityOverlayEnabled) { - document.removeEventListener('keydown', documentKeyDownListener, { capture: true }); - aceTextAreaElement.removeEventListener('keydown', aceKeydownListener); - const textAreaContainer = aceTextAreaElement.parentElement; - if (textAreaContainer && textAreaContainer.contains(overlayMountNode.current!)) { - textAreaContainer.removeChild(overlayMountNode.current!); - } - } - }; - }, [aceTextAreaElement, startServices, isAccessibilityOverlayEnabled]); -} diff --git a/src/plugins/es_ui_shared/public/ace/index.ts b/src/plugins/es_ui_shared/public/ace/index.ts deleted file mode 100644 index 9d010117e560e..0000000000000 --- a/src/plugins/es_ui_shared/public/ace/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export { useUIAceKeyboardMode } from '../../__packages_do_not_import__/ace'; diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 3b3ccc3fca08f..ddcdb84fa5758 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -12,7 +12,6 @@ * In the future, each top level folder should be exported like that to avoid naming collision */ import * as Forms from './forms'; -import * as ace from './ace'; import * as GlobalFlyout from './global_flyout'; import * as XJson from './xjson'; @@ -47,7 +46,7 @@ export { useAuthorizationContext, } from './authorization'; -export { Forms, ace, GlobalFlyout, XJson }; +export { Forms, GlobalFlyout, XJson }; export { extractQueryParams, attemptToURIDecode } from './url'; diff --git a/src/plugins/es_ui_shared/static/forms/components/index.ts b/src/plugins/es_ui_shared/static/forms/components/index.ts index 4ccfeed19dbfe..2e5dd03390eb7 100644 --- a/src/plugins/es_ui_shared/static/forms/components/index.ts +++ b/src/plugins/es_ui_shared/static/forms/components/index.ts @@ -7,22 +7,6 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -/* -@TODO - -The react-ace and brace/mode/json imports below are loaded eagerly - before this plugin is explicitly loaded by users. This makes -the brace JSON mode, used for JSON syntax highlighting and grammar checking, available across all of Kibana plugins. - -This is not ideal because we are loading JS that is not necessary for Kibana to start, but the alternative -is breaking JSON mode for an unknown number of ace editors across Kibana - not all components reference the underlying -EuiCodeEditor (for instance, explicitly). - -Importing here is a way of preventing a more sophisticated solution to this problem since we want to, eventually, -migrate all code editors over to Monaco. Once that is done, we should remove this import. - */ -import 'react-ace'; -import 'brace/mode/json'; - export * from './field'; export * from './form_row'; export * from './fields'; diff --git a/src/plugins/es_ui_shared/tsconfig.json b/src/plugins/es_ui_shared/tsconfig.json index f3dc3bb39a31d..2747f41b0f370 100644 --- a/src/plugins/es_ui_shared/tsconfig.json +++ b/src/plugins/es_ui_shared/tsconfig.json @@ -24,7 +24,6 @@ "@kbn/storybook", "@kbn/shared-ux-link-redirect-app", "@kbn/code-editor", - "@kbn/react-kibana-context-render", "@kbn/core-application-common", ], "exclude": [ diff --git a/src/plugins/vis_default_editor/public/default_editor.tsx b/src/plugins/vis_default_editor/public/default_editor.tsx index f61450c8e85e0..dc9e83e8c3b43 100644 --- a/src/plugins/vis_default_editor/public/default_editor.tsx +++ b/src/plugins/vis_default_editor/public/default_editor.tsx @@ -8,7 +8,6 @@ */ import './index.scss'; -import 'brace/mode/json'; import React, { useEffect, useRef, useState, useCallback } from 'react'; import { EventEmitter } from 'events'; diff --git a/test/functional/apps/management/data_views/_scripted_fields.ts b/test/functional/apps/management/data_views/_scripted_fields.ts index 172537bf4e73a..f86ae72aa5047 100644 --- a/test/functional/apps/management/data_views/_scripted_fields.ts +++ b/test/functional/apps/management/data_views/_scripted_fields.ts @@ -19,10 +19,6 @@ // 3. Filter in Discover by the scripted field // 4. Visualize with aggregation on the scripted field by clicking unifiedFieldList.clickFieldListItemVisualize -// NOTE: Scripted field input is managed by Ace editor, which automatically -// appends closing braces, for exmaple, if you type opening square brace [ -// it will automatically insert a a closing square brace ], etc. - import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; diff --git a/test/functional/apps/management/data_views/_scripted_fields_classic_table.ts b/test/functional/apps/management/data_views/_scripted_fields_classic_table.ts index 063e0b960d52e..4f3d30222e496 100644 --- a/test/functional/apps/management/data_views/_scripted_fields_classic_table.ts +++ b/test/functional/apps/management/data_views/_scripted_fields_classic_table.ts @@ -19,10 +19,6 @@ // 3. Filter in Discover by the scripted field // 4. Visualize with aggregation on the scripted field by clicking unifiedFieldList.clickFieldListItemVisualize -// NOTE: Scripted field input is managed by Ace editor, which automatically -// appends closing braces, for exmaple, if you type opening square brace [ -// it will automatically insert a a closing square brace ], etc. - import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; diff --git a/tsconfig.base.json b/tsconfig.base.json index d5346f4c53b51..4359a53a4d832 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -6,8 +6,6 @@ // START AUTOMATED PACKAGE LISTING "@kbn/aad-fixtures-plugin": ["x-pack/test/alerting_api_integration/common/plugins/aad"], "@kbn/aad-fixtures-plugin/*": ["x-pack/test/alerting_api_integration/common/plugins/aad/*"], - "@kbn/ace": ["packages/kbn-ace"], - "@kbn/ace/*": ["packages/kbn-ace/*"], "@kbn/actions-plugin": ["x-pack/plugins/actions"], "@kbn/actions-plugin/*": ["x-pack/plugins/actions/*"], "@kbn/actions-simulators-plugin": ["x-pack/test/alerting_api_integration/common/plugins/actions_simulators"], diff --git a/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js b/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js index 351f1bd77592f..c0b6c0f4c9a09 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/detail_panel/detail_panel.js @@ -30,8 +30,6 @@ import { EuiTextColor, EuiTitle, } from '@elastic/eui'; -import 'react-ace'; -import 'brace/theme/textmate'; import { getIndexListUri } from '@kbn/index-management-plugin/public'; import { routing } from '../../../../../services/routing'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx index e74d2f7703f31..63c395b1f4bbc 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx @@ -5,11 +5,6 @@ * 2.0. */ -// brace/ace uses the Worker class, which is not currently provided by JSDOM. -// This is not required for the tests to pass, but it rather suppresses lengthy -// warnings in the console which adds unnecessary noise to the test output. -import '@kbn/web-worker-stub'; - import React from 'react'; import { coreMock, scopedHistoryMock } from '@kbn/core/public/mocks'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx index 64e332bd130bd..9db22a251779b 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx @@ -5,13 +5,6 @@ * 2.0. */ -import 'brace'; -import 'brace/mode/json'; -// brace/ace uses the Worker class, which is not currently provided by JSDOM. -// This is not required for the tests to pass, but it rather suppresses lengthy -// warnings in the console which adds unnecessary noise to the test output. -import '@kbn/web-worker-stub'; - import React from 'react'; import { act } from 'react-dom/test-utils'; import '@kbn/code-editor-mock/jest_helper'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx index 963bbf3a35cfc..121f694517a83 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx @@ -5,10 +5,6 @@ * 2.0. */ -import 'react-ace'; -import 'brace/mode/json'; -import 'brace/theme/github'; - import { EuiButton, EuiFormRow, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; import React, { Fragment, useState } from 'react'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx index d01229cdce8a9..21ece31571ae1 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx @@ -5,11 +5,6 @@ * 2.0. */ -// brace/ace uses the Worker class, which is not currently provided by JSDOM. -// This is not required for the tests to pass, but it rather suppresses lengthy -// warnings in the console which adds unnecessary noise to the test output. -import '@kbn/web-worker-stub'; - import { EuiErrorBoundary } from '@elastic/eui'; import React from 'react'; diff --git a/x-pack/plugins/security/tsconfig.json b/x-pack/plugins/security/tsconfig.json index 21a32edcec212..f9c08c93b2163 100644 --- a/x-pack/plugins/security/tsconfig.json +++ b/x-pack/plugins/security/tsconfig.json @@ -51,7 +51,6 @@ "@kbn/core-saved-objects-api-server-internal", "@kbn/core-saved-objects-api-server-mocks", "@kbn/logging-mocks", - "@kbn/web-worker-stub", "@kbn/core-saved-objects-utils-server", "@kbn/core-saved-objects-api-server", "@kbn/core-saved-objects-base-server-internal", diff --git a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/es_query_expression.test.tsx b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/es_query_expression.test.tsx index 6686d56173de4..e1d17b79e612d 100644 --- a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/es_query_expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/es_query_expression.test.tsx @@ -6,7 +6,6 @@ */ import React from 'react'; -import 'brace'; import { of, Subject } from 'rxjs'; import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.test.tsx b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.test.tsx index 64d075b7ba723..568a8cf226ae2 100644 --- a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.test.tsx @@ -6,7 +6,6 @@ */ import type { DataView } from '@kbn/data-views-plugin/public'; import { mountWithIntl } from '@kbn/test-jest-helpers'; -import 'brace'; import React, { useState } from 'react'; import { docLinksServiceMock } from '@kbn/core/public/mocks'; import { httpServiceMock } from '@kbn/core/public/mocks'; diff --git a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.tsx b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.tsx index 196d138c68964..2f0c46a5e34c5 100644 --- a/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.tsx +++ b/x-pack/plugins/stack_alerts/public/rule_types/es_query/expression/expression.tsx @@ -7,7 +7,6 @@ import React, { memo, PropsWithChildren, useCallback } from 'react'; import deepEqual from 'fast-deep-equal'; -import 'brace/theme/github'; import { EuiCallOut, EuiHorizontalRule, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; diff --git a/yarn.lock b/yarn.lock index c360b2a822b4a..d8f8196230695 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3295,10 +3295,6 @@ version "0.0.0" uid "" -"@kbn/ace@link:packages/kbn-ace": - version "0.0.0" - uid "" - "@kbn/actions-plugin@link:x-pack/plugins/actions": version "0.0.0" uid "" @@ -13575,11 +13571,6 @@ brace-expansion@^2.0.1: dependencies: balanced-match "^1.0.0" -brace@0.11.1, brace@^0.11.1: - version "0.11.1" - resolved "https://registry.yarnpkg.com/brace/-/brace-0.11.1.tgz#4896fcc9d544eef45f4bb7660db320d3b379fe58" - integrity sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg= - braces@^2.3.1: version "2.3.2" resolved "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz" @@ -16317,7 +16308,7 @@ diacritics@^1.3.0: resolved "https://registry.yarnpkg.com/diacritics/-/diacritics-1.3.0.tgz#3efa87323ebb863e6696cebb0082d48ff3d6f7a1" integrity sha1-PvqHMj67hj5mls67AILUj/PW96E= -diff-match-patch@^1.0.0, diff-match-patch@^1.0.4, diff-match-patch@^1.0.5: +diff-match-patch@^1.0.0, diff-match-patch@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.5.tgz#abb584d5f10cd1196dfc55aa03701592ae3f7b37" integrity sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw== @@ -26607,17 +26598,6 @@ re2js@0.4.2: resolved "https://registry.yarnpkg.com/re2js/-/re2js-0.4.2.tgz#e344697e64d128ea65c121d6581e67ee5bfa5feb" integrity sha512-wuv0p0BGbrVIkobV8zh82WjDurXko0QNCgaif6DdRAljgVm2iio4PVYCwjAxGaWen1/QZXWDM67dIslmz7AIbA== -react-ace@^7.0.5: - version "7.0.5" - resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-7.0.5.tgz#798299fd52ddf3a3dcc92afc5865538463544f01" - integrity sha512-3iI+Rg2bZXCn9K984ll2OF4u9SGcJH96Q1KsUgs9v4M2WePS4YeEHfW2nrxuqJrAkE5kZbxaCE79k6kqK0YBjg== - dependencies: - brace "^0.11.1" - diff-match-patch "^1.0.4" - lodash.get "^4.4.2" - lodash.isequal "^4.5.0" - prop-types "^15.7.2" - react-clientside-effect@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/react-clientside-effect/-/react-clientside-effect-1.2.6.tgz#29f9b14e944a376b03fb650eed2a754dd128ea3a"