modern-monaco 0.3.4 → 0.3.6

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.
package/README.md CHANGED
@@ -309,29 +309,69 @@ You can configure built-in LSPs in the `lazy`, `init`, or `hydrate` functions.
309
309
 
310
310
  ```js
311
311
  lazy({
312
- // configure LSP for each language
313
312
  lsp: {
313
+ // formatting options for all languages
314
+ formatting: {/* ... */},
315
+ // configure LSP for languages
314
316
  html: {/* ... */},
317
+ css: {/* ... */},
315
318
  json: {/* ... */},
316
319
  typescript: {/* ... */},
317
320
  },
318
321
  });
319
322
  ```
320
323
 
321
- The `LSPLanguageConfig` interface is defined as:
324
+ The `LSPConfig` interface is defined as:
322
325
 
323
326
  ```ts
324
- export interface LSPLanguageConfig {
327
+ export interface LSPConfig {
328
+ /** Formatting options. */
329
+ formatting?: {
330
+ /** Size of a tab in spaces. Default: 4. */
331
+ tabSize?: number;
332
+ /** Prefer spaces over tabs. Default: true.*/
333
+ insertSpaces?: boolean;
334
+ /** Trim trailing whitespace on a line. Default: true. */
335
+ trimTrailingWhitespace?: boolean;
336
+ /** Insert a newline character at the end of the file if one does not exist. Default: false. */
337
+ insertFinalNewline?: boolean;
338
+ /** Trim all newlines after the final newline at the end of the file. Default: false. */
339
+ trimFinalNewlines?: boolean;
340
+ /** Semicolon preference for JavaScript and TypeScript. Default: "insert". */
341
+ semicolon?: "ignore" | "insert" | "remove";
342
+ }
343
+ /** HTML language configuration. */
325
344
  html?: {
326
345
  attributeDefaultValue?: "empty" | "singlequotes" | "doublequotes";
327
346
  customTags?: ITagData[];
328
347
  hideAutoCompleteProposals?: boolean;
348
+ hideEndTagSuggestions?: boolean;
329
349
  };
330
- css?: {};
350
+ /** CSS language configuration. */
351
+ css?: {
352
+ /** Defines whether the standard CSS properties, at-directives, pseudoClasses and pseudoElements are shown. */
353
+ useDefaultDataProvider?: boolean;
354
+ /** Provides a set of custom data providers. */
355
+ dataProviders?: { [providerId: string]: CSSDataV1 };
356
+ };
357
+ /** JSON language configuration. */
331
358
  json?: {
332
- /** JSON schemas for JSON language service. */
333
- schemas?: JSONSchemaSource[];
359
+ /** By default, the validator will return syntax and semantic errors. Set to false to disable the validator. */
360
+ validate?: boolean;
361
+ /** Defines whether comments are allowed or not. Default is disallowed. */
362
+ allowComments?: boolean;
363
+ /** A list of known schemas and/or associations of schemas to file names. */
364
+ schemas?: JSONSchemaSource[];
365
+ /** The severity of reported comments. Default is "error". */
366
+ comments?: SeverityLevel;
367
+ /** The severity of reported trailing commas. Default is "error". */
368
+ trailingCommas?: SeverityLevel;
369
+ /** The severity of problems from schema validation. Default is "warning". */
370
+ schemaValidation?: SeverityLevel;
371
+ /** The severity of problems that occurred when resolving and loading schemas. Default is "warning". */
372
+ schemaRequest?: SeverityLevel;
334
373
  };
374
+ /** TypeScript language configuration. */
335
375
  typescript?: {
336
376
  /** The compiler options. */
337
377
  compilerOptions?: ts.CompilerOptions;
package/dist/core.mjs CHANGED
@@ -40,7 +40,7 @@ function isObject(v) {
40
40
  }
41
41
 
42
42
  // package.json
43
- var version = "0.3.4";
43
+ var version = "0.3.6";
44
44
 
45
45
  // src/core.ts
46
46
  import { getExtnameFromLanguageId, getLanguageIdFromPath, grammars, initShiki, setDefaultWasmLoader, themes } from "./shiki.mjs";
@@ -346,8 +346,14 @@ async function loadMonaco(highlighter, workspace, lsp) {
346
346
  }
347
347
  const useBuiltinLSP = globalThis.MonacoEnvironment?.useBuiltinLSP;
348
348
  const [monaco, { builtinLSPProviders }] = await Promise.all([
349
- import(editorCoreModuleUrl),
350
- useBuiltinLSP ? import(lspModuleUrl) : Promise.resolve({ builtinLSPProviders: {} })
349
+ import(
350
+ /* webpackIgnore: true */
351
+ editorCoreModuleUrl
352
+ ),
353
+ useBuiltinLSP ? import(
354
+ /* webpackIgnore: true */
355
+ lspModuleUrl
356
+ ) : Promise.resolve({ builtinLSPProviders: {} })
351
357
  ]);
352
358
  const allLspProviders = { ...builtinLSPProviders, ...lspProviders, ...lsp?.providers };
353
359
  workspace?.setupMonaco(monaco);
@@ -5,8 +5,8 @@ async function setup(monaco, languageId, languageSettings, formattingOptions, wo
5
5
  const createData = {
6
6
  language: languageId,
7
7
  data: {
8
- useDefaultDataProvider: true
9
- // todo: custom data provider
8
+ useDefaultDataProvider: true,
9
+ ...languageSettings
10
10
  },
11
11
  format: {
12
12
  tabSize,
@@ -5,8 +5,9 @@ async function setup(monaco, languageId, languageSettings, formattingOptions, wo
5
5
  const { tabSize, insertSpaces, insertFinalNewline, trimFinalNewlines } = formattingOptions ?? {};
6
6
  const createData = {
7
7
  suggest: {
8
+ attributeDefaultValue: languageSettings?.attributeDefaultValue,
8
9
  hideAutoCompleteProposals: languageSettings?.hideAutoCompleteProposals,
9
- attributeDefaultValue: languageSettings?.attributeDefaultValue
10
+ hideEndTagSuggestions: languageSettings?.hideEndTagSuggestions
10
11
  },
11
12
  format: {
12
13
  tabSize,
@@ -114,15 +114,17 @@ var schemas = [
114
114
  import * as client from "../client.mjs";
115
115
  async function setup(monaco, languageId, languageSettings, formattingOptions, workspace) {
116
116
  const { editor, languages } = monaco;
117
+ const schemas2 = Array.isArray(languageSettings?.schemas) ? schemas.concat(languageSettings.schemas) : schemas;
117
118
  const createData = {
118
119
  settings: {
119
120
  validate: true,
120
121
  allowComments: false,
121
- schemas: Array.isArray(languageSettings?.schemas) ? schemas.concat(languageSettings.schemas) : schemas,
122
122
  comments: "error",
123
123
  trailingCommas: "error",
124
124
  schemaRequest: "warning",
125
- schemaValidation: "warning"
125
+ schemaValidation: "warning",
126
+ ...languageSettings,
127
+ schemas: schemas2
126
128
  },
127
129
  format: {
128
130
  tabSize: 4,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-monaco",
3
3
  "description": "A modern version of Monaco Editor",
4
- "version": "0.3.4",
4
+ "version": "0.3.6",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
7
7
  "module": "./dist/index.mjs",
@@ -68,7 +68,7 @@
68
68
  "process": false,
69
69
  "buffer": false
70
70
  },
71
- "sideEffects": false,
71
+ "sideEffects": ["dist/index.mjs"],
72
72
  "devDependencies": {
73
73
  "@esm.sh/import-map": "0.1.1",
74
74
  "@shikijs/core": "3.17.0",
package/types/lsp.d.ts CHANGED
@@ -52,15 +52,18 @@ export interface IReference {
52
52
  name: string;
53
53
  url: string;
54
54
  }
55
+
55
56
  export interface IData {
56
57
  name: string;
57
58
  description?: string;
58
59
  references?: IReference[];
59
60
  }
61
+
60
62
  export interface IAttributeData extends IData {
61
63
  valueSet?: string;
62
64
  values?: IData[];
63
65
  }
66
+
64
67
  export interface ITagData extends IData {
65
68
  attributes: IAttributeData[];
66
69
  void?: boolean;
@@ -87,17 +90,45 @@ export interface LSPConfig extends LSPLanguageConfig {
87
90
  formatting?: FormatOptions;
88
91
  }
89
92
 
93
+ export type SeverityLevel = "error" | "warning" | "ignore";
94
+
95
+ export interface CSSDataV1 {
96
+ version: 1 | 1.1;
97
+ properties?: (IData & Record<string, unknown>)[];
98
+ atDirectives?: (IData & Record<string, unknown>)[];
99
+ pseudoClasses?: (IData & Record<string, unknown>)[];
100
+ pseudoElements?: (IData & Record<string, unknown>)[];
101
+ }
102
+
90
103
  declare global {
91
104
  interface LSPLanguageConfig {
92
105
  html?: {
93
106
  attributeDefaultValue?: "empty" | "singlequotes" | "doublequotes";
94
107
  customTags?: ITagData[];
108
+ hideEndTagSuggestions?: boolean;
95
109
  hideAutoCompleteProposals?: boolean;
96
110
  };
97
- css?: {};
111
+ css?: {
112
+ /** Defines whether the standard CSS properties, at-directives, pseudoClasses and pseudoElements are shown. */
113
+ useDefaultDataProvider?: boolean;
114
+ /** Provides a set of custom data providers. */
115
+ dataProviders?: { [providerId: string]: CSSDataV1 };
116
+ };
98
117
  json?: {
99
- /** JSON schemas for JSON language service. */
118
+ /** By default, the validator will return syntax and semantic errors. Set to false to disable the validator. */
119
+ validate?: boolean;
120
+ /** Defines whether comments are allowed or not. Default is disallowed. */
121
+ allowComments?: boolean;
122
+ /** A list of known schemas and/or associations of schemas to file names. */
100
123
  schemas?: JSONSchemaSource[];
124
+ /** The severity of reported comments. Default is "error". */
125
+ comments?: SeverityLevel;
126
+ /** The severity of reported trailing commas. Default is "error". */
127
+ trailingCommas?: SeverityLevel;
128
+ /** The severity of problems from schema validation. Default is "warning". */
129
+ schemaValidation?: SeverityLevel;
130
+ /** The severity of problems that occurred when resolving and loading schemas. Default is "warning". */
131
+ schemaRequest?: SeverityLevel;
101
132
  };
102
133
  typescript?: {
103
134
  /** The compiler options. */