@codemirror/language
Advanced tools
Comparing version 0.19.3 to 0.19.4
@@ -0,1 +1,7 @@ | ||
## 0.19.4 (2021-11-13) | ||
### New features | ||
`LanguageDescription.of` now takes an optional already-loaded extension. | ||
## 0.19.3 (2021-09-13) | ||
@@ -2,0 +8,0 @@ |
@@ -301,3 +301,4 @@ import { NodeProp, NodeType, Parser, Tree, TreeFragment, Input, PartialParse, SyntaxNode } from '@lezer/common'; | ||
/** | ||
An optional array of extensions associated with this language. | ||
An optional array of filename extensions associated with this | ||
language. | ||
*/ | ||
@@ -312,3 +313,8 @@ extensions?: readonly string[]; | ||
*/ | ||
load: () => Promise<LanguageSupport>; | ||
load?: () => Promise<LanguageSupport>; | ||
/** | ||
Alternatively to `load`, you can provide an already loaded | ||
support object. Either this or `load` should be provided. | ||
*/ | ||
support?: LanguageSupport; | ||
}): LanguageDescription; | ||
@@ -315,0 +321,0 @@ /** |
import { NodeProp, Tree, TreeFragment, Parser, NodeType } from '@lezer/common'; | ||
import { Facet, EditorState, StateEffect, StateField } from '@codemirror/state'; | ||
import { StateEffect, StateField, Facet, EditorState } from '@codemirror/state'; | ||
import { ViewPlugin } from '@codemirror/view'; | ||
@@ -610,3 +610,7 @@ import { countColumn } from '@codemirror/text'; | ||
*/ | ||
filename, loadFunc) { | ||
filename, loadFunc, | ||
/** | ||
If the language has been loaded, this will hold its value. | ||
*/ | ||
support = undefined) { | ||
this.name = name; | ||
@@ -617,6 +621,3 @@ this.alias = alias; | ||
this.loadFunc = loadFunc; | ||
/** | ||
If the language has been loaded, this will hold its value. | ||
*/ | ||
this.support = undefined; | ||
this.support = support; | ||
this.loading = null; | ||
@@ -636,3 +637,9 @@ } | ||
static of(spec) { | ||
return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, spec.load); | ||
let { load, support } = spec; | ||
if (!load) { | ||
if (!support) | ||
throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of"); | ||
load = () => Promise.resolve(support); | ||
} | ||
return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support); | ||
} | ||
@@ -639,0 +646,0 @@ /** |
{ | ||
"name": "@codemirror/language", | ||
"version": "0.19.3", | ||
"version": "0.19.4", | ||
"description": "Language support infrastructure for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110328
2815