@aws/lsp-yaml 0.1.26 → 0.1.28

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.28](https://github.com/Amazon-Q-Developer/language-servers/compare/lsp-yaml/v0.1.27...lsp-yaml/v0.1.28) (2026-11-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **lsp-yaml:** load the schema once instead of on every request ([#3017](https://github.com/Amazon-Q-Developer/language-servers/issues/3017)) ([86a471c](https://github.com/Amazon-Q-Developer/language-servers/commit/86a471c9c156a18222c0b6cba1e8ceb08ca4718a))
9
+
10
+ ## [0.1.27](https://github.com/Amazon-Q-Developer/language-servers/compare/lsp-yaml/v0.1.26...lsp-yaml/v0.1.27) (2026-08-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * repoint CODEOWNERS and package repository URLs to the new org ([#2838](https://github.com/Amazon-Q-Developer/language-servers/issues/2838)) ([43e44dc](https://github.com/Amazon-Q-Developer/language-servers/commit/43e44dc5af94703f51456cd8a913f0d61af7570e))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * The following workspace dependencies were updated
21
+ * dependencies
22
+ * @aws/lsp-core bumped from ^0.0.21 to ^0.0.22
23
+
3
24
  ## [0.1.26](https://github.com/aws/language-servers/compare/lsp-yaml/v0.1.25...lsp-yaml/v0.1.26) (2026-02-17)
4
25
 
5
26
 
@@ -14,12 +14,16 @@ export type YamlLanguageServiceProps = {
14
14
  export declare class YamlLanguageService implements AwsLanguageService {
15
15
  private readonly props;
16
16
  private yamlService;
17
+ private readonly settings;
18
+ private schemaLoadFailed;
17
19
  constructor(props: YamlLanguageServiceProps);
18
20
  isSupported(document: TextDocument): boolean;
19
21
  doValidation(document: TextDocument): Promise<Diagnostic[]>;
20
22
  doComplete(document: TextDocument, position: Position): Promise<CompletionList>;
21
23
  doHover(document: TextDocument, position: Position): Promise<Hover | null>;
22
24
  format(document: TextDocument, range: Range, options: YamlFormattingOptions): TextEdit[];
23
- private updateSchemaMapping;
25
+ private requestSchema;
26
+ private fetchSchema;
27
+ private retryFailedSchemaLoad;
24
28
  }
25
29
  export declare function create(props: YamlLanguageServiceProps): AwsLanguageService;
@@ -11,6 +11,8 @@ const yaml_language_server_1 = require("yaml-language-server");
11
11
  class YamlLanguageService {
12
12
  props;
13
13
  yamlService;
14
+ settings;
15
+ schemaLoadFailed = false;
14
16
  constructor(props) {
15
17
  this.props = props;
16
18
  let resolveUri;
@@ -18,7 +20,7 @@ class YamlLanguageService {
18
20
  resolveUri = props.uriResolver;
19
21
  }
20
22
  else {
21
- resolveUri = getSchema;
23
+ resolveUri = url => this.fetchSchema(url);
22
24
  }
23
25
  const workspaceContext = {
24
26
  resolveRelativePath(relativePath, resource) {
@@ -26,54 +28,87 @@ class YamlLanguageService {
26
28
  },
27
29
  };
28
30
  this.yamlService = (0, yaml_language_server_1.getLanguageService)({
29
- schemaRequestService: resolveUri,
31
+ schemaRequestService: uri => this.requestSchema(resolveUri, uri),
30
32
  workspaceContext,
31
33
  });
32
- this.yamlService.configure({ schemas: [{ fileMatch: ['*'], uri: this.props.defaultSchemaUri }] });
34
+ this.settings = {
35
+ hover: true,
36
+ hoverSettings: { showSource: false, showTitle: false },
37
+ completion: true,
38
+ format: true,
39
+ validate: true,
40
+ customTags: [],
41
+ schemas: [
42
+ {
43
+ fileMatch: ['*'],
44
+ uri: this.props.defaultSchemaUri,
45
+ name: this.props.displayName,
46
+ description: 'some description,',
47
+ },
48
+ ],
49
+ };
50
+ // Configure once: every configure() call clears the schema cache, so the
51
+ // schema would otherwise be downloaded and parsed again for each request.
52
+ this.yamlService.configure(this.settings);
33
53
  }
34
54
  isSupported(document) {
35
55
  return document.languageId === 'yaml';
36
56
  }
37
57
  doValidation(document) {
38
- this.updateSchemaMapping(document.uri);
58
+ this.retryFailedSchemaLoad();
39
59
  return this.yamlService.doValidation(document, false);
40
60
  }
41
61
  doComplete(document, position) {
42
- this.updateSchemaMapping(document.uri);
62
+ this.retryFailedSchemaLoad();
43
63
  return this.yamlService.doComplete(document, position, false);
44
64
  }
45
65
  doHover(document, position) {
46
- this.updateSchemaMapping(document.uri);
66
+ this.retryFailedSchemaLoad();
47
67
  return this.yamlService.doHover(document, position);
48
68
  }
49
69
  format(document, range, options) {
50
- this.updateSchemaMapping(document.uri);
70
+ this.retryFailedSchemaLoad();
51
71
  return this.yamlService.doFormat(document, options);
52
72
  }
53
- updateSchemaMapping(documentUri) {
54
- this.yamlService.configure({
55
- hover: true,
56
- hoverSettings: { showSource: false, showTitle: false },
57
- completion: true,
58
- format: true,
59
- validate: true,
60
- customTags: [],
61
- schemas: [
62
- {
63
- fileMatch: [documentUri],
64
- uri: this.props.defaultSchemaUri,
65
- name: this.props.displayName,
66
- description: 'some description,',
67
- },
68
- ],
69
- });
73
+ async requestSchema(resolveUri, uri) {
74
+ try {
75
+ const content = await resolveUri(uri);
76
+ if (!isJson(content)) {
77
+ this.schemaLoadFailed = true;
78
+ }
79
+ return content;
80
+ }
81
+ catch (error) {
82
+ this.schemaLoadFailed = true;
83
+ throw error;
84
+ }
85
+ }
86
+ async fetchSchema(url) {
87
+ const response = await fetch(url);
88
+ if (!response.ok) {
89
+ this.schemaLoadFailed = true;
90
+ }
91
+ const schema = await (await response.blob()).text();
92
+ return schema;
93
+ }
94
+ // A failed load stays cached, so clear it the way the per-request configure() used
95
+ // to, letting the next request fetch the schema again.
96
+ retryFailedSchemaLoad() {
97
+ if (this.schemaLoadFailed) {
98
+ this.schemaLoadFailed = false;
99
+ this.yamlService.configure(this.settings);
100
+ }
70
101
  }
71
102
  }
72
103
  exports.YamlLanguageService = YamlLanguageService;
73
- async function getSchema(url) {
74
- const response = await fetch(url);
75
- const schema = await (await response.blob()).text();
76
- return schema;
104
+ function isJson(content) {
105
+ try {
106
+ JSON.parse(content);
107
+ return true;
108
+ }
109
+ catch {
110
+ return false;
111
+ }
77
112
  }
78
113
  function create(props) {
79
114
  const jsonService = new YamlLanguageService(props);
@@ -1 +1 @@
1
- {"version":3,"file":"yamlLanguageService.js","sourceRoot":"","sources":["../../src/language-service/yamlLanguageService.ts"],"names":[],"mappings":";;;AA4FA,wBAIC;AAhGD,iDAA0G;AAG1G,+DAA0E;AAS1E;;;GAGG;AACH,MAAa,mBAAmB;IAGC;IAFrB,WAAW,CAAiB;IAEpC,YAA6B,KAA+B;QAA/B,UAAK,GAAL,KAAK,CAA0B;QACxD,IAAI,UAA4C,CAAA;QAChD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACpB,UAAU,GAAG,KAAK,CAAC,WAAW,CAAA;QAClC,CAAC;aAAM,CAAC;YACJ,UAAU,GAAG,SAAS,CAAA;QAC1B,CAAC;QAED,MAAM,gBAAgB,GAAG;YACrB,mBAAmB,CAAC,YAAoB,EAAE,QAAgB;gBACtD,OAAO,IAAI,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAA;YAC/C,CAAC;SACJ,CAAA;QAED,IAAI,CAAC,WAAW,GAAG,IAAA,yCAAkB,EAAC;YAClC,oBAAoB,EAAE,UAAU;YAChC,gBAAgB;SACnB,CAAC,CAAA;QAEF,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAA;IACrG,CAAC;IAEM,WAAW,CAAC,QAAsB;QACrC,OAAO,QAAQ,CAAC,UAAU,KAAK,MAAM,CAAA;IACzC,CAAC;IAEM,YAAY,CAAC,QAAsB;QACtC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACzD,CAAC;I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AA+B;IAClD,MAAM,WAAW,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAElD,OAAO,IAAI,uCAAgC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AAC9D,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@aws/lsp-yaml",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "YAML Language Server",
5
5
  "main": "out/index.js",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/aws/language-servers"
8
+ "url": "https://github.com/Amazon-Q-Developer/language-servers"
9
9
  },
10
10
  "author": "Amazon Web Services",
11
11
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@aws/language-server-runtimes": "^0.3.14",
30
- "@aws/lsp-core": "^0.0.21",
30
+ "@aws/lsp-core": "^0.0.22",
31
31
  "vscode-languageserver": "^9.0.1",
32
32
  "vscode-languageserver-textdocument": "^1.0.8",
33
33
  "yaml-language-server": "1.13.0"