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
73 changes: 36 additions & 37 deletions LICENSE-3RD-PARTY.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
================================================================================
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/
License name: MIT
License URL: https://github.com/Microsoft/monaco-editor/blob/master/LICENSE.md
License applies to files under the folder lib/_npm/monaco/

Website: https://ace.c9.io/
Source: https://github.com/ajaxorg/ace
Website: https://microsoft.github.io/monaco-editor/
Source: https://github.com/Microsoft/monaco-editor
================================================================================
Copyright (c) 2010, Ajax.org B.V.
All rights reserved.
The MIT License (MIT)

Copyright (c) 2019 Microsoft Corporation

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.
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.
================================================================================

================================================================================
Expand Down Expand Up @@ -1653,25 +1650,27 @@ Apache License
================================================================================

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

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

Source: https://github.com/jeremyfa/yaml.js
Source: https://github.com/nodeca/js-yaml
================================================================================
Copyright (c) 2010 Jeremy Faivre
(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:
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 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,
Expand Down
23 changes: 21 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
<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/loader.js"></script>

<script src="js/autorefresh.js"></script>
<script src="js/extensions.js"></script>
Expand All @@ -37,10 +36,30 @@
["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";

requirejs.config({ baseUrl: "js/v1/", paths: paths });
require(["app.unsupportedBrowser"]);
require(["../../lib/_npm/js-yaml/js-yaml"], (thing) => {
window.YAML = thing;
});
require(["vs/editor/editor.main"], () => {
require(["vs/language/yaml/monaco.contribution", "vs/language/yaml/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>
<body>
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;
}
4 changes: 0 additions & 4 deletions lib/ts-types/kaitai-old.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
declare class YAML {
static parse(yaml: string, exceptionOnInvalidType?: boolean, objectDecoder?: any, saveMeta?: boolean): any;
}

interface IYamlImporter {
importYaml(name: string, mode: string): Promise<any>;
}
Expand Down
6 changes: 0 additions & 6 deletions lib/ts-types/kaitai.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
declare module "yamljs" {
export class YAML {
static parse(yaml: string, exceptionOnInvalidType?: boolean, objectDecoder?: any, saveMeta?: boolean): any;
}
}

interface IYamlImporter {
importYaml(name: string, mode: string): Promise<any>;
}
Expand Down
Loading