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

Moved from Ace editor to Monaco editor #84

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ out/
# Generated file
js/
files/
lib/_npm/
lib/_npm
*.pyc
.serve_files_secret
\.DS_Store
Expand Down
6 changes: 5 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "formats"]
path = formats
url = https://github.com/kaitai-io/kaitai_struct_formats/
url = https://github.com/kaitai-io/kaitai_struct_formats/

[submodule "src/Schema"]
path = src/Schema
url = https://github.com/dar2355/Ksy-Schema.git
132 changes: 66 additions & 66 deletions LICENSE-3RD-PARTY.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
================================================================================
Ace

License name: BSD-3-Clause
License URL: https://raw.githubusercontent.com/ajaxorg/ace/master/LICENSE
License applies to files under the folder lib/_npm/ace/

Website: https://ace.c9.io/
Source: https://github.com/ajaxorg/ace
================================================================================
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.
================================================================================

================================================================================
BigInteger.js

Expand Down Expand Up @@ -1085,6 +1049,39 @@ Apache License
limitations under the License.
================================================================================

================================================================================
Monaco

License name: MIT
License URL: https://raw.githubusercontent.com/Microsoft/monaco-editor/master/LICENSE.md
License applies to files under the folder lib/_npm/monaco/

Website: https://microsoft.github.io/monaco-editor/index.html
Source: https://github.com/Microsoft/monaco-editor
================================================================================
The MIT License (MIT)

Copyright (c) 2016 - present Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================================================

================================================================================
Vue.js

Expand Down Expand Up @@ -1246,6 +1243,39 @@ own licenses; we recommend you read them, as their terms may differ from
the terms above.
================================================================================

================================================================================
js-yaml

License name: MIT
License URL: https://raw.githubusercontent.com/nodeca/js-yaml/master/LICENSE
License applies to files under the folder lib/_npm/js-yaml/

Website: http://nodeca.github.io/js-yaml/
Source: https://github.com/nodeca/js-yaml
================================================================================
(The MIT License)

Copyright (C) 2011-2015 by Vitaly Puzrin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================================================

================================================================================
jsTree

Expand Down Expand Up @@ -1650,34 +1680,4 @@ Apache License
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.
================================================================================

================================================================================
yaml.js

License name: MIT
License URL: https://raw.githubusercontent.com/jeremyfa/yaml.js/develop/LICENSE
License applies to files under the folder lib/_npm/yamljs/

Source: https://github.com/jeremyfa/yaml.js
================================================================================
Copyright (c) 2010 Jeremy Faivre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================================================
2 changes: 1 addition & 1 deletion Playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<script>
loader.paths = {
"yamljs": "lib/_npm/yamljs/yaml",
"yamljs": "lib/_npm/js-yaml/js-yaml",
GreyCat marked this conversation as resolved.
Show resolved Hide resolved
"KaitaiStream": "lib/_npm/kaitai-struct/KaitaiStream",
"kaitai-struct-compiler": "lib/_npm/kaitai-struct-compiler/kaitai-struct-compiler"
};
Expand Down
28 changes: 15 additions & 13 deletions docs/wiki/3rd-party-libraries.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# 3rd-party libraries

## Ace
Website: https://ace.c9.io/

Source: https://github.com/ajaxorg/ace

License: BSD-3-Clause (https://raw.githubusercontent.com/ajaxorg/ace/master/LICENSE)

## BigInteger.js
Source: https://github.com/peterolson/BigInteger.js

Expand Down Expand Up @@ -50,6 +43,13 @@ Source: https://github.com/kaitai-io/kaitai_struct_javascript_runtime

License: Apache-2.0 (https://raw.githubusercontent.com/kaitai-io/kaitai_struct_javascript_runtime/master/LICENSE)

## Monaco
Website: https://microsoft.github.io/monaco-editor/index.html

Source: https://github.com/Microsoft/monaco-editor

License: MIT (https://raw.githubusercontent.com/Microsoft/monaco-editor/master/LICENSE.md)

## Vue.js
Source: https://github.com/vuejs/vue

Expand All @@ -72,6 +72,13 @@ Source: https://github.com/jquery/jquery

License: MIT (https://raw.githubusercontent.com/jquery/jquery/master/LICENSE.txt)

## js-yaml
Website: http://nodeca.github.io/js-yaml/

Source: https://github.com/nodeca/js-yaml

License: MIT (https://raw.githubusercontent.com/nodeca/js-yaml/master/LICENSE)

## jsTree
Website: https://www.jstree.com/

Expand Down Expand Up @@ -107,9 +114,4 @@ License: Unlicense (https://raw.githubusercontent.com/inexorabletash/text-encodi
## thenBy.js
Source: https://github.com/Teun/thenBy.js

License: Apache-2.0 (https://raw.githubusercontent.com/Teun/thenBy.js/master/LICENSE.TXT)

## yaml.js
Source: https://github.com/jeremyfa/yaml.js

License: MIT (https://raw.githubusercontent.com/jeremyfa/yaml.js/develop/LICENSE)
License: Apache-2.0 (https://raw.githubusercontent.com/Teun/thenBy.js/master/LICENSE.TXT)
27 changes: 25 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<link rel="stylesheet" type="text/css" href="lib/_npm/font-awesome/css/font-awesome.min.css" />

<script src="lib/_npm/requirejs/require.js"></script>

<script src="lib/_npm/jquery/jquery.min.js"></script>
<script src="lib/_npm/bootstrap/js/bootstrap.min.js"></script>
<script src="lib/_npm/yamljs/yaml.js"></script>
<script src="lib/_npm/ace/ace.js"></script>
<script src="lib/_npm/monaco/vs/loader.js"></script>

<script src="js/autorefresh.js"></script>
<script src="js/extensions.js"></script>
Expand All @@ -37,9 +37,32 @@
["bowser", "jstree", "localforage", "goldenlayout", "vue", "kaitai-struct-compiler", "dateformat"].forEach(
name => paths[name] = `../../lib/_npm/${name}/${name}`);
paths["big-integer"] = "../../lib/_npm/BigInteger/BigInteger";
paths["vs"] = "../../lib/_npm/monaco/vs";
paths["vs/language/yaml"] = "../../../lib/_npm/monaco-yaml"

requirejs.config({ baseUrl: "js/v1/", paths: paths });
require(["app.unsupportedBrowser"]);
require(["../../lib/_npm/js-yaml/js-yaml"], (YAML) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if require.js can be dropped and ECMAScript modules used instead.

window.YAML = YAML;
});
require(["vs/editor/editor.main",], () => {
require([
"vs/language/yaml/monaco.contribution",
"../../js/Schema/ksySchema",
], (...[, {ksySchema}]) => {
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
enableSchemaRequest: true,
validate: true,
schemas: [
{
uri: `http://myserver/ksy-schema.json`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileMatch: [monaco.Uri.parse("inmemory://model/main").toString()],
schema: ksySchema
}
]
});
})
});
require(["jstree", "app"]);
</script>
</head>
Expand Down
113 changes: 113 additions & 0 deletions lib/ts-types/js-yaml.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Type definitions for js-yaml 3.12
// Project: https://github.com/nodeca/js-yaml
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Sebastian Clausen <https://github.com/sclausen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export as namespace jsyaml;

export function safeLoad(str: string, opts?: LoadOptions): any;
export function load(str: string, opts?: LoadOptions): any;

export class Type {
constructor(tag: string, opts?: TypeConstructorOptions);
kind: 'sequence' | 'scalar' | 'mapping' | null;
resolve(data: any): boolean;
construct(data: any): any;
instanceOf: object | null;
predicate: string | null;
represent: ((data: object) => any) | { [x: string]: (data: object) => any; } | null;
defaultStyle: string | null;
styleAliases: { [x: string]: any; };
}

/* tslint:disable-next-line:no-unnecessary-class */
export class Schema implements SchemaDefinition {
constructor(definition: SchemaDefinition);
static create(types: Type[] | Type): Schema;
static create(schemas: Schema[] | Schema, types: Type[] | Type): Schema;
}

export function safeLoadAll(str: string, iterator?: undefined, opts?: LoadOptions): any[];
export function safeLoadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): undefined;

export function loadAll(str: string, iterator?: undefined, opts?: LoadOptions): any[];

export function loadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): undefined;

export function safeDump(obj: any, opts?: DumpOptions): string;
export function dump(obj: any, opts?: DumpOptions): string;

export interface LoadOptions {
/** string to be used as a file path in error/warning messages. */
filename?: string;
/** function to call on warning messages. */
onWarning?(this: null, e: YAMLException): void;
/** specifies a schema to use. */
schema?: SchemaDefinition;
/** compatibility with JSON.parse behaviour. */
json?: boolean;
}

export interface DumpOptions {
/** indentation width to use (in spaces). */
indent?: number;
/** when true, will not add an indentation level to array elements */
noArrayIndent?: boolean;
/** do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. */
skipInvalid?: boolean;
/** specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere */
flowLevel?: number;
/** Each tag may have own set of styles. - "tag" => "style" map. */
styles?: { [x: string]: any; };
/** specifies a schema to use. */
schema?: SchemaDefinition;
/** if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) */
sortKeys?: boolean | ((a: any, b: any) => number);
/** set max line width. (default: 80) */
lineWidth?: number;
/** if true, don't convert duplicate objects into references (default: false) */
noRefs?: boolean;
/** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */
noCompatMode?: boolean;
/**
* if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
* Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
*/
condenseFlow?: boolean;
}

export interface TypeConstructorOptions {
kind?: 'sequence' | 'scalar' | 'mapping';
resolve?: (data: any) => boolean;
construct?: (data: any) => any;
instanceOf?: object;
predicate?: string;
represent?: ((data: object) => any) | { [x: string]: (data: object) => any };
defaultStyle?: string;
styleAliases?: { [x: string]: any; };
}

export interface SchemaDefinition {
implicit?: any[];
explicit?: Type[];
include?: Schema[];
}

/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
export let FAILSAFE_SCHEMA: Schema;
/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
export let JSON_SCHEMA: Schema;
/** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */
export let CORE_SCHEMA: Schema;
/** all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ */
export let DEFAULT_SAFE_SCHEMA: Schema;
/** all supported YAML types. */
export let DEFAULT_FULL_SCHEMA: Schema;
export let MINIMAL_SCHEMA: Schema;
export let SAFE_SCHEMA: Schema;

export class YAMLException extends Error {
constructor(reason?: any, mark?: any);
toString(compact?: boolean): string;
}
Loading