Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES UI Shared] Monaco XJSON #67485

Merged
merged 33 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e2bcdc7
First iteration of xjson in monaco
jloleysens May 27, 2020
c584bc5
Throwaway implementation in painless lab - THIS MUST BE REVERTED
jloleysens May 27, 2020
573cb7d
WiP on build process for new kbn-lang package
jloleysens May 28, 2020
86bb6ce
new @kbn/langs package and update ui-shared-deps
jloleysens May 28, 2020
d5f7baa
Update jest config for new work files
jloleysens May 28, 2020
e19dd17
Update painless lab -- REVERT THIS COMMIT
jloleysens May 28, 2020
44a12ea
Create shared useXJson mode hook
jloleysens May 28, 2020
b1ca795
Final update to using the new shared useXJsonMode hook -- REVERT
jloleysens May 28, 2020
bce6a27
Created @kbn/monaco and share through shared deps
jloleysens May 29, 2020
fb4cb4c
Merge branch 'master' of github.com:elastic/kibana into pr/67485
spalger May 29, 2020
a2e2550
always access monaco through `@kbn/monaco`
spalger May 29, 2020
e81c5d2
use path.resolve to create path
spalger May 29, 2020
a81c892
add basic readme
spalger May 29, 2020
9ad8888
remove console.log call
spalger May 29, 2020
b9a2b51
remove typescript support from ui-shared-deps webpack config
spalger May 29, 2020
45d21ee
Merge branch 'master' of github.com:elastic/kibana into pr/67485
spalger May 29, 2020
d0b1668
use `@kbn/babel-preset`
spalger May 29, 2020
6838881
include the monaco styles in the kbn-ui-shared-deps
spalger May 29, 2020
fdf76ec
sort package.json
spalger May 29, 2020
5f83a0e
build worker at bootstrap rather than commiting to repo
spalger May 29, 2020
1b78190
Merge branch 'master' of github.com:elastic/kibana into pr/67485
spalger May 29, 2020
73c33b2
only build worker, don't pre-bundle monaco
spalger May 29, 2020
979c8c6
fix type check errors
spalger May 30, 2020
2ccbc78
remove section from readme about committed dist
spalger May 30, 2020
df9a4ad
keep editor.worker.js postfix
spalger May 30, 2020
7b135b5
forgot to save update to import
spalger May 30, 2020
c18af02
license package as apache-2.0
spalger May 30, 2020
b2b7f20
Merge branch 'master' into monaco-xjson
elasticmachine May 30, 2020
7beb2f4
Merge branch 'master' into monaco-xjson
elasticmachine May 31, 2020
8bb2c29
Merge branch 'master' into monaco-xjson
elasticmachine Jun 2, 2020
ad9f4d2
Added regenerator runtime for worker bundle
jloleysens Jun 2, 2020
6e785d5
Merge branch 'master' into monaco-xjson
elasticmachine Jun 4, 2020
dcbf9c3
revert changes to painless lab
jloleysens Jun 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ module.exports = {
from: 'react-router',
to: 'react-router-dom',
},
{
from: '@kbn/ui-shared-deps/monaco',
to: '@kbn/monaco',
},
{
from: 'monaco-editor',
to: false,
disallowedMessage: `Don't import monaco directly, use or add exports to @kbn/monaco`
},
],
],
},
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-monaco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @kbn/monaco

A customized version of monaco that is automatically configured the way we want it to be when imported as `@kbn/monaco`. Additionally, imports to this package are automatically shared with all plugins using `@kbn/ui-shared-deps`.

Includes custom xjson language support. The `es_ui_shared` plugin has an example of how to use it, in the future we will likely expose helpers from this package to make using it everywhere a little more seamless.
27 changes: 27 additions & 0 deletions packages/kbn-monaco/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@kbn/monaco",
"version": "1.0.0",
"private": true,
"main": "./target/index.js",
"license": "Apache-2.0",
"scripts": {
"build": "node ./scripts/build.js",
"kbn:bootstrap": "yarn build --dev"
},
"dependencies": {
"regenerator-runtime": "^0.13.3",
"monaco-editor": "~0.17.0"
},
"devDependencies": {
"@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.4.2",
"del": "^5.1.0",
"raw-loader": "3.1.0",
"supports-color": "^7.0.0",
"typescript": "3.7.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
}
}
64 changes: 64 additions & 0 deletions packages/kbn-monaco/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const path = require('path');
const del = require('del');
const supportsColor = require('supports-color');
const { run } = require('@kbn/dev-utils');

const TARGET_BUILD_DIR = path.resolve(__dirname, '../target');
const ROOT_DIR = path.resolve(__dirname, '../');
const WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.config.js');

run(
async ({ procRunner, log, flags }) => {
log.info('Deleting old output');

await del(TARGET_BUILD_DIR);

const cwd = ROOT_DIR;
const env = { ...process.env };
if (supportsColor.stdout) {
env.FORCE_COLOR = 'true';
}

await procRunner.run('worker', {
cmd: 'webpack',
args: ['--config', WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'],
wait: true,
env,
cwd,
});

await procRunner.run('tsc ', {
cmd: 'tsc',
args: [],
wait: true,
env,
cwd,
});

log.success('Complete');
},
{
flags: {
boolean: ['dev'],
},
}
);
25 changes: 25 additions & 0 deletions packages/kbn-monaco/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { monaco } from './monaco';
export { XJsonLang } from './xjson';

/* eslint-disable-next-line @kbn/eslint/module_migration */
import * as BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api';
export { BarePluginApi };
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

/* eslint-disable @kbn/eslint/module_migration */

import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';

import 'monaco-editor/esm/vs/base/common/worker/simpleWorker';
Expand Down
28 changes: 28 additions & 0 deletions packages/kbn-monaco/src/xjson/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# README

This folder contains the language definitions for XJSON used by the Monaco editor.

## Summary of contents

Note: All source code.

### ./worker

The worker proxy and worker instantiation code used in both the main thread and the worker thread.

### ./lexer_rules

Contains the Monarch-specific language tokenization rules for XJSON. Each set of rules registers itself against monaco.

### ./constants.ts

Contains the unique language ID.

### ./language

Takes care of global setup steps for the language (like registering it against Monaco) and exports a way to load up
the grammar parser.

### ./worker_proxy_service

A stateful mechanism for holding a reference to the Monaco-provided proxy getter.
20 changes: 20 additions & 0 deletions packages/kbn-monaco/src/xjson/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export const ID = 'xjson';
Loading