modern-monaco 0.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ import type monacoNS from "./monaco.d.ts";
2
+ import type { LSPConfig } from "./lsp.d.ts";
3
+ import type { TextmateGrammarName, TextmateThemeName } from "./textmate.d.ts";
4
+ import type { Workspace } from "./workspace.d.ts";
5
+
6
+ type Awaitable<T> = T | Promise<T>;
7
+ type MaybeGetter<T> = Awaitable<MaybeModule<T>> | (() => Awaitable<MaybeModule<T>>);
8
+ type MaybeModule<T> = T | { default: T };
9
+ type MaybeArray<T> = T | T[];
10
+ type LanguageInput = MaybeGetter<MaybeArray<NamedObject>>;
11
+ type ThemeInput = MaybeGetter<NamedObject>;
12
+
13
+ interface NamedObject {
14
+ name: string;
15
+ }
16
+
17
+ export interface ShikiInitOptions {
18
+ /**
19
+ * Theme names, or theme registration objects to be loaded upfront.
20
+ */
21
+ theme?: TextmateThemeName | URL | ThemeInput;
22
+ /**
23
+ * Language names, or language registration objects to be loaded upfront.
24
+ */
25
+ langs?: (TextmateGrammarName | URL | LanguageInput)[];
26
+ /**
27
+ * The CDN base URL to download themes and languages from. Default: "https://esm.sh".
28
+ */
29
+ downloadCDN?: string;
30
+ }
31
+
32
+ export interface InitOptions extends ShikiInitOptions {
33
+ /**
34
+ * Virtual file system to be used by the editor.
35
+ */
36
+ workspace?: Workspace;
37
+ /**
38
+ * Language server protocol configuration.
39
+ */
40
+ lsp?: LSPConfig;
41
+ }
42
+
43
+ export function init(options?: InitOptions): Promise<typeof monacoNS>;
44
+ export function lazy(options?: InitOptions): void;
45
+ export function hydrate(options?: InitOptions): void;
46
+
47
+ export { Workspace };
@@ -0,0 +1,90 @@
1
+ export type JSONSchemaRef = JSONSchema | boolean;
2
+ export interface JSONSchema {
3
+ id?: string;
4
+ $id?: string;
5
+ $schema?: string;
6
+ type?: string | string[];
7
+ title?: string;
8
+ default?: any;
9
+ definitions?: {
10
+ [name: string]: JSONSchema;
11
+ };
12
+ description?: string;
13
+ properties?: JSONSchemaMap;
14
+ patternProperties?: JSONSchemaMap;
15
+ additionalProperties?: JSONSchemaRef;
16
+ minProperties?: number;
17
+ maxProperties?: number;
18
+ dependencies?: JSONSchemaMap | {
19
+ [prop: string]: string[];
20
+ };
21
+ items?: JSONSchemaRef | JSONSchemaRef[];
22
+ minItems?: number;
23
+ maxItems?: number;
24
+ uniqueItems?: boolean;
25
+ additionalItems?: JSONSchemaRef;
26
+ pattern?: string;
27
+ minLength?: number;
28
+ maxLength?: number;
29
+ minimum?: number;
30
+ maximum?: number;
31
+ exclusiveMinimum?: boolean | number;
32
+ exclusiveMaximum?: boolean | number;
33
+ multipleOf?: number;
34
+ required?: string[];
35
+ $ref?: string;
36
+ anyOf?: JSONSchemaRef[];
37
+ allOf?: JSONSchemaRef[];
38
+ oneOf?: JSONSchemaRef[];
39
+ not?: JSONSchemaRef;
40
+ enum?: any[];
41
+ format?: string;
42
+ const?: any;
43
+ contains?: JSONSchemaRef;
44
+ propertyNames?: JSONSchemaRef;
45
+ examples?: any[];
46
+ $comment?: string;
47
+ if?: JSONSchemaRef;
48
+ then?: JSONSchemaRef;
49
+ else?: JSONSchemaRef;
50
+ unevaluatedProperties?: boolean | JSONSchemaRef;
51
+ unevaluatedItems?: boolean | JSONSchemaRef;
52
+ minContains?: number;
53
+ maxContains?: number;
54
+ deprecated?: boolean;
55
+ dependentRequired?: {
56
+ [prop: string]: string[];
57
+ };
58
+ dependentSchemas?: JSONSchemaMap;
59
+ $defs?: {
60
+ [name: string]: JSONSchema;
61
+ };
62
+ $anchor?: string;
63
+ $recursiveRef?: string;
64
+ $recursiveAnchor?: string;
65
+ $vocabulary?: any;
66
+ prefixItems?: JSONSchemaRef[];
67
+ $dynamicRef?: string;
68
+ $dynamicAnchor?: string;
69
+ defaultSnippets?: {
70
+ label?: string;
71
+ description?: string;
72
+ markdownDescription?: string;
73
+ body?: any;
74
+ bodyText?: string;
75
+ }[];
76
+ errorMessage?: string;
77
+ patternErrorMessage?: string;
78
+ deprecationMessage?: string;
79
+ enumDescriptions?: string[];
80
+ markdownEnumDescriptions?: string[];
81
+ markdownDescription?: string;
82
+ doNotSuggest?: boolean;
83
+ suggestSortText?: string;
84
+ allowComments?: boolean;
85
+ allowTrailingCommas?: boolean;
86
+ completionDetail?: string;
87
+ }
88
+ export interface JSONSchemaMap {
89
+ [name: string]: JSONSchemaRef;
90
+ }
package/types/lsp.d.ts ADDED
@@ -0,0 +1,106 @@
1
+ import type ts from "typescript";
2
+ import type monacoNS from "./monaco.d.ts";
3
+ import type { ImportMap } from "./import-map.d.ts";
4
+ import type { JSONSchema } from "./jsonSchema.d.ts";
5
+ import type { Workspace } from "./workspace.d.ts";
6
+
7
+ export interface FormatOptions {
8
+ /** Size of a tab in spaces. Default: 4. */
9
+ tabSize?: number;
10
+ /** Prefer spaces over tabs. Default: true.*/
11
+ insertSpaces?: boolean;
12
+ /** Trim trailing whitespace on a line. Default: true. */
13
+ trimTrailingWhitespace?: boolean;
14
+ /** Insert a newline character at the end of the file if one does not exist. Default: false. */
15
+ insertFinalNewline?: boolean;
16
+ /** Trim all newlines after the final newline at the end of the file. Default: false. */
17
+ trimFinalNewlines?: boolean;
18
+ /** Semicolon preference for JavaScript and TypeScript. Default: "insert". */
19
+ semicolon?: "ignore" | "insert" | "remove";
20
+ }
21
+
22
+ export interface JSONSchemaSource {
23
+ /**
24
+ * The URI of the schema, which is also the identifier of the schema.
25
+ */
26
+ uri: string;
27
+ /**
28
+ * A list of glob patterns that describe for which file URIs the JSON schema will be used.
29
+ * '*' and '**' wildcards are supported. Exclusion patterns start with '!'.
30
+ * For example '*.schema.json', 'package.json', '!foo*.schema.json', 'foo/**\/BADRESP.json'.
31
+ * A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
32
+ */
33
+ fileMatch?: string[];
34
+ /**
35
+ * The schema for the given URI.
36
+ * If no schema is provided, the schema will be fetched with the schema request service (if available).
37
+ */
38
+ schema?: JSONSchema;
39
+ /**
40
+ * A parent folder for folder specifc associations. An association that has a folder URI set is only used
41
+ * if the document that is validated has the folderUri as parent
42
+ */
43
+ folderUri?: string;
44
+ }
45
+
46
+ export interface IReference {
47
+ name: string;
48
+ url: string;
49
+ }
50
+ export interface IData {
51
+ name: string;
52
+ description?: string;
53
+ references?: IReference[];
54
+ }
55
+ export interface IAttributeData extends IData {
56
+ valueSet?: string;
57
+ values?: IData[];
58
+ }
59
+ export interface ITagData extends IData {
60
+ attributes: IAttributeData[];
61
+ void?: boolean;
62
+ }
63
+
64
+ export interface LSP {
65
+ setup: (
66
+ monaco: typeof monacoNS,
67
+ languageId: string,
68
+ langaugeSettings?: Record<string, unknown>,
69
+ formattingOptions?: Record<string, unknown>,
70
+ workspace?: Workspace,
71
+ ) => Promise<void>;
72
+ getWorkerUrl: () => URL;
73
+ }
74
+
75
+ export interface LSPProvider {
76
+ aliases?: string[];
77
+ syntaxes?: any[];
78
+ import: () => Promise<LSP>;
79
+ }
80
+
81
+ export interface LSPConfig extends LSPLanguageConfig {
82
+ providers?: Record<string, LSPProvider>;
83
+ formatting?: FormatOptions;
84
+ }
85
+
86
+ declare global {
87
+ interface LSPLanguageConfig {
88
+ html?: {
89
+ attributeDefaultValue?: "empty" | "singlequotes" | "doublequotes";
90
+ customTags?: ITagData[];
91
+ hideAutoCompleteProposals?: boolean;
92
+ };
93
+ css?: {};
94
+ json?: {
95
+ schemas?: JSONSchemaSource[];
96
+ };
97
+ typescript?: {
98
+ /** The compiler options. */
99
+ compilerOptions?: ts.CompilerOptions;
100
+ /** The global import maps. */
101
+ importMap?: ImportMap;
102
+ /** The version of the typescript imported from esm.sh CDN. Default: ">= 5.5.0" */
103
+ tsVersion?: string;
104
+ };
105
+ }
106
+ }