vscode-json-languageservice 5.7.2 → 6.0.0-next.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/esm/jsonContributions.d.ts +1 -1
  3. package/lib/esm/jsonLanguageService.d.ts +2 -2
  4. package/lib/esm/jsonLanguageService.js +13 -13
  5. package/lib/esm/jsonLanguageTypes.d.ts +10 -2
  6. package/lib/esm/jsonSchema.d.ts +71 -2
  7. package/lib/esm/parser/jsonParser.js +224 -93
  8. package/lib/esm/services/configuration.js +2 -2
  9. package/lib/esm/services/jsonCompletion.js +5 -5
  10. package/lib/esm/services/jsonDocumentSymbols.js +4 -4
  11. package/lib/esm/services/jsonFolding.js +1 -1
  12. package/lib/esm/services/jsonHover.js +2 -2
  13. package/lib/esm/services/jsonLinks.js +94 -3
  14. package/lib/esm/services/jsonSchemaService.js +639 -100
  15. package/lib/esm/services/jsonSelectionRanges.js +1 -1
  16. package/lib/esm/services/jsonValidation.js +4 -4
  17. package/lib/esm/services/schemas/draft-2019-09-flat.d.ts +1 -1
  18. package/lib/esm/services/schemas/draft-2020-12-flat.d.ts +1 -1
  19. package/lib/esm/services/vocabularies.js +139 -0
  20. package/lib/esm/utils/format.js +1 -1
  21. package/lib/esm/utils/sort.js +3 -3
  22. package/package.json +23 -20
  23. package/lib/umd/jsonContributions.d.ts +0 -21
  24. package/lib/umd/jsonContributions.js +0 -12
  25. package/lib/umd/jsonLanguageService.d.ts +0 -30
  26. package/lib/umd/jsonLanguageService.js +0 -79
  27. package/lib/umd/jsonLanguageTypes.d.ts +0 -305
  28. package/lib/umd/jsonLanguageTypes.js +0 -109
  29. package/lib/umd/jsonSchema.d.ts +0 -92
  30. package/lib/umd/jsonSchema.js +0 -12
  31. package/lib/umd/parser/jsonParser.js +0 -1365
  32. package/lib/umd/services/configuration.js +0 -536
  33. package/lib/umd/services/jsonCompletion.js +0 -982
  34. package/lib/umd/services/jsonDocumentSymbols.js +0 -285
  35. package/lib/umd/services/jsonFolding.js +0 -133
  36. package/lib/umd/services/jsonHover.js +0 -125
  37. package/lib/umd/services/jsonLinks.js +0 -85
  38. package/lib/umd/services/jsonSchemaService.js +0 -631
  39. package/lib/umd/services/jsonSelectionRanges.js +0 -74
  40. package/lib/umd/services/jsonValidation.js +0 -165
  41. package/lib/umd/services/schemas/draft-2019-09-flat.d.ts +0 -278
  42. package/lib/umd/services/schemas/draft-2019-09-flat.js +0 -314
  43. package/lib/umd/services/schemas/draft-2020-12-flat.d.ts +0 -276
  44. package/lib/umd/services/schemas/draft-2020-12-flat.js +0 -307
  45. package/lib/umd/utils/colors.js +0 -83
  46. package/lib/umd/utils/format.js +0 -33
  47. package/lib/umd/utils/glob.js +0 -137
  48. package/lib/umd/utils/json.js +0 -55
  49. package/lib/umd/utils/objects.js +0 -86
  50. package/lib/umd/utils/propertyTree.js +0 -90
  51. package/lib/umd/utils/sort.js +0 -384
  52. package/lib/umd/utils/strings.js +0 -97
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ 6.0.0-next.2 / 2026-07-11
2
+ ================
3
+ - Support $dynamicRef / $dynamicAnchor (JSON Schema 2020-12)
4
+ - Support JSON Schema 2019-09
5
+
6
+ 6.0.0-next.1 / 2026-03-04
7
+ ================
8
+ * Breaking: the package is now ESM-only (`"type": "module"`) and exposes ESM entry points through `exports`.
9
+ * Breaking: CommonJS/UMD output is no longer produced. Build, test and sample scripts now target `lib/esm`.
10
+ * Updated TypeScript configuration to `NodeNext` module settings for Node ESM compatibility.
11
+ * Removed `tsconfig.esm.json` as a separate build target (the main tsconfig now covers ESM output).
12
+ * Converted build scripts in `build/` to ESM and added `npm run bundle-schemas`.
13
+
1
14
  5.7.0 / 2026-01-12
2
15
  ================
3
16
  * the error code for `SchemaResolveError` is now 0x10000 plus the error code returned by the request service.
@@ -1,4 +1,4 @@
1
- import { MarkedString, CompletionItem } from './jsonLanguageService';
1
+ import { MarkedString, CompletionItem } from './jsonLanguageService.js';
2
2
  export interface JSONWorkerContribution {
3
3
  getInfoContribution(uri: string, location: JSONPath): PromiseLike<MarkedString[]>;
4
4
  collectPropertyCompletions(uri: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): PromiseLike<any>;
@@ -1,10 +1,10 @@
1
- import { ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus, SortOptions } from './jsonLanguageTypes';
1
+ import { ASTNode, Color, ColorInformation, ColorPresentation, LanguageServiceParams, LanguageSettings, DocumentLanguageSettings, FoldingRange, JSONSchema, SelectionRange, FoldingRangesContext, DocumentSymbolsContext, ColorInformationContext as DocumentColorsContext, TextDocument, Position, CompletionItem, CompletionList, Hover, Range, SymbolInformation, Diagnostic, TextEdit, FormattingOptions, DocumentSymbol, DefinitionLink, MatchingSchema, JSONLanguageStatus, SortOptions } from './jsonLanguageTypes.js';
2
2
  import { DocumentLink } from 'vscode-languageserver-types';
3
3
  export type JSONDocument = {
4
4
  root: ASTNode | undefined;
5
5
  getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
6
6
  };
7
- export * from './jsonLanguageTypes';
7
+ export * from './jsonLanguageTypes.js';
8
8
  export interface LanguageService {
9
9
  configure(settings: LanguageSettings): void;
10
10
  doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): PromiseLike<Diagnostic[]>;
@@ -2,19 +2,19 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { JSONCompletion } from './services/jsonCompletion';
6
- import { JSONHover } from './services/jsonHover';
7
- import { JSONValidation } from './services/jsonValidation';
8
- import { JSONDocumentSymbols } from './services/jsonDocumentSymbols';
9
- import { parse as parseJSON, newJSONDocument } from './parser/jsonParser';
10
- import { schemaContributions } from './services/configuration';
11
- import { JSONSchemaService } from './services/jsonSchemaService';
12
- import { getFoldingRanges } from './services/jsonFolding';
13
- import { getSelectionRanges } from './services/jsonSelectionRanges';
14
- import { sort } from './utils/sort';
15
- import { format } from './utils/format';
16
- import { findLinks } from './services/jsonLinks';
17
- export * from './jsonLanguageTypes';
5
+ import { JSONCompletion } from './services/jsonCompletion.js';
6
+ import { JSONHover } from './services/jsonHover.js';
7
+ import { JSONValidation } from './services/jsonValidation.js';
8
+ import { JSONDocumentSymbols } from './services/jsonDocumentSymbols.js';
9
+ import { parse as parseJSON, newJSONDocument } from './parser/jsonParser.js';
10
+ import { schemaContributions } from './services/configuration.js';
11
+ import { JSONSchemaService } from './services/jsonSchemaService.js';
12
+ import { getFoldingRanges } from './services/jsonFolding.js';
13
+ import { getSelectionRanges } from './services/jsonSelectionRanges.js';
14
+ import { sort } from './utils/sort.js';
15
+ import { format } from './utils/format.js';
16
+ import { findLinks } from './services/jsonLinks.js';
17
+ export * from './jsonLanguageTypes.js';
18
18
  export function getLanguageService(params) {
19
19
  const promise = params.promiseConstructor || Promise;
20
20
  const jsonSchemaService = new JSONSchemaService(params.schemaRequestService, params.workspaceContext, promise);
@@ -1,8 +1,16 @@
1
- import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
2
- import { JSONSchema } from './jsonSchema';
1
+ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions.js';
2
+ import { JSONSchema } from './jsonSchema.js';
3
3
  import { Range, Position, DocumentUri, MarkupContent, MarkupKind, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, FormattingOptions as LSPFormattingOptions, DefinitionLink, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind } from 'vscode-languageserver-types';
4
4
  import { TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument';
5
5
  export { TextDocument, TextDocumentContentChangeEvent, Range, Position, DocumentUri, MarkupContent, MarkupKind, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, SelectionRange, Diagnostic, DiagnosticSeverity, CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag, InsertTextFormat, DefinitionLink, SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString, CodeActionContext, Command, CodeAction, DocumentHighlight, DocumentLink, WorkspaceEdit, TextEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind };
6
+ /**
7
+ * Represents active JSON Schema vocabularies with their required/optional status.
8
+ * Key = vocabulary URI, Value = true if required, false if optional.
9
+ * Both required and optional vocabularies are active; the boolean indicates
10
+ * whether the validator must understand it (true) or should understand it (false).
11
+ * @since 2019-09
12
+ */
13
+ export type Vocabularies = Map<string, boolean>;
6
14
  /**
7
15
  * Error codes used by diagnostics
8
16
  */
@@ -61,8 +61,10 @@ export interface JSONSchema {
61
61
  };
62
62
  $anchor?: string;
63
63
  $recursiveRef?: string;
64
- $recursiveAnchor?: string;
65
- $vocabulary?: any;
64
+ $recursiveAnchor?: boolean;
65
+ $vocabulary?: {
66
+ [uri: string]: boolean;
67
+ };
66
68
  prefixItems?: JSONSchemaRef[];
67
69
  $dynamicRef?: string;
68
70
  $dynamicAnchor?: string;
@@ -90,3 +92,70 @@ export interface JSONSchema {
90
92
  export interface JSONSchemaMap {
91
93
  [name: string]: JSONSchemaRef;
92
94
  }
95
+ /**
96
+ * Internal extension of {@link JSONSchema} used when one schema is merged into
97
+ * another (e.g. when resolving `$ref`). The `$originalId` field preserves the
98
+ * `$id`/`id` of the referenced schema so features like `$recursiveRef` can
99
+ * still identify schema resource roots after the merge.
100
+ *
101
+ * `$originalId` is set as a non-enumerable property to keep it out of
102
+ * `for..in` iteration and JSON serialization.
103
+ */
104
+ export interface MergedJSONSchema extends JSONSchema {
105
+ $originalId?: string;
106
+ /**
107
+ * Non-enumerable metadata attached to a `$dynamicRef` node while resolving it.
108
+ * Held off the enumerable keywords so it stays invisible to schema traversal,
109
+ * merging and consumers, but available to the validator.
110
+ */
111
+ $dynamicRefInfo?: DynamicRefInfo;
112
+ /**
113
+ * Non-enumerable per-resource anchor maps, attached to resource-root schemas
114
+ * (a node with its own `$id`, or the document root) for 2020-12 `$dynamicRef`
115
+ * resolution.
116
+ */
117
+ $anchorMaps?: AnchorMaps;
118
+ }
119
+ /**
120
+ * Internal, non-enumerable metadata recorded for a single `$dynamicRef` occurrence.
121
+ */
122
+ export interface DynamicRefInfo {
123
+ /**
124
+ * The statically resolved initial target (resolved like a plain `$ref`, against
125
+ * the reference's own base URI).
126
+ */
127
+ target?: JSONSchema;
128
+ /**
129
+ * The plain-name fragment of the `$dynamicRef` (set whenever the fragment is a
130
+ * plain name rather than a JSON pointer). The validator uses it, together with
131
+ * the initial target, to decide at validation time whether the 2020-12
132
+ * "bookending" requirement holds (i.e. the initial target is a `$dynamicAnchor`
133
+ * of that name) and therefore whether to perform dynamic-scope resolution
134
+ * instead of behaving like a plain `$ref`.
135
+ */
136
+ name?: string;
137
+ /**
138
+ * The schema resource (nearest enclosing `$id` scope) that lexically contains
139
+ * the `$dynamicRef`. Recorded before `$ref` merging flattens resource
140
+ * boundaries so an internal `#name` reference resolves against its own
141
+ * resource's anchors, not a sibling's.
142
+ */
143
+ scope?: MergedJSONSchema;
144
+ }
145
+ /**
146
+ * Internal, non-enumerable per-resource anchor maps used for 2020-12 `$dynamicRef`
147
+ * resolution. Attached to resource-root schemas.
148
+ */
149
+ export interface AnchorMaps {
150
+ /**
151
+ * `$dynamicAnchor` names → sub-schemas within the resource, used by the
152
+ * validator to walk the dynamic scope (outermost resource first).
153
+ */
154
+ dynamic: Map<string, JSONSchema>;
155
+ /**
156
+ * Both `$anchor` and `$dynamicAnchor` names → sub-schemas within the resource,
157
+ * used to resolve an internal `$dynamicRef`'s initial target within its own
158
+ * resource.
159
+ */
160
+ local: Map<string, JSONSchema>;
161
+ }