@codemirror/language 0.19.3 → 0.19.4
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 +6 -0
- package/dist/index.cjs +13 -6
- package/dist/index.d.ts +8 -2
- package/dist/index.js +14 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -611,16 +611,17 @@ class LanguageDescription {
|
|
|
611
611
|
Optional filename pattern that should be associated with this
|
|
612
612
|
language.
|
|
613
613
|
*/
|
|
614
|
-
filename, loadFunc
|
|
614
|
+
filename, loadFunc,
|
|
615
|
+
/**
|
|
616
|
+
If the language has been loaded, this will hold its value.
|
|
617
|
+
*/
|
|
618
|
+
support = undefined) {
|
|
615
619
|
this.name = name;
|
|
616
620
|
this.alias = alias;
|
|
617
621
|
this.extensions = extensions;
|
|
618
622
|
this.filename = filename;
|
|
619
623
|
this.loadFunc = loadFunc;
|
|
620
|
-
|
|
621
|
-
If the language has been loaded, this will hold its value.
|
|
622
|
-
*/
|
|
623
|
-
this.support = undefined;
|
|
624
|
+
this.support = support;
|
|
624
625
|
this.loading = null;
|
|
625
626
|
}
|
|
626
627
|
/**
|
|
@@ -635,7 +636,13 @@ class LanguageDescription {
|
|
|
635
636
|
Create a language description.
|
|
636
637
|
*/
|
|
637
638
|
static of(spec) {
|
|
638
|
-
|
|
639
|
+
let { load, support } = spec;
|
|
640
|
+
if (!load) {
|
|
641
|
+
if (!support)
|
|
642
|
+
throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
|
|
643
|
+
load = () => Promise.resolve(support);
|
|
644
|
+
}
|
|
645
|
+
return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);
|
|
639
646
|
}
|
|
640
647
|
/**
|
|
641
648
|
Look for a language in the given array of descriptions that
|
package/dist/index.d.ts
CHANGED
|
@@ -298,7 +298,8 @@ declare class LanguageDescription {
|
|
|
298
298
|
*/
|
|
299
299
|
alias?: readonly string[];
|
|
300
300
|
/**
|
|
301
|
-
An optional array of extensions associated with this
|
|
301
|
+
An optional array of filename extensions associated with this
|
|
302
|
+
language.
|
|
302
303
|
*/
|
|
303
304
|
extensions?: readonly string[];
|
|
304
305
|
/**
|
|
@@ -308,7 +309,12 @@ declare class LanguageDescription {
|
|
|
308
309
|
/**
|
|
309
310
|
A function that will asynchronously load the language.
|
|
310
311
|
*/
|
|
311
|
-
load
|
|
312
|
+
load?: () => Promise<LanguageSupport>;
|
|
313
|
+
/**
|
|
314
|
+
Alternatively to `load`, you can provide an already loaded
|
|
315
|
+
support object. Either this or `load` should be provided.
|
|
316
|
+
*/
|
|
317
|
+
support?: LanguageSupport;
|
|
312
318
|
}): LanguageDescription;
|
|
313
319
|
/**
|
|
314
320
|
Look for a language in the given array of descriptions that
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeProp, Tree, TreeFragment, Parser, NodeType } from '@lezer/common';
|
|
2
|
-
import {
|
|
2
|
+
import { StateEffect, StateField, Facet, EditorState } from '@codemirror/state';
|
|
3
3
|
import { ViewPlugin } from '@codemirror/view';
|
|
4
4
|
import { countColumn } from '@codemirror/text';
|
|
5
5
|
|
|
@@ -607,16 +607,17 @@ class LanguageDescription {
|
|
|
607
607
|
Optional filename pattern that should be associated with this
|
|
608
608
|
language.
|
|
609
609
|
*/
|
|
610
|
-
filename, loadFunc
|
|
610
|
+
filename, loadFunc,
|
|
611
|
+
/**
|
|
612
|
+
If the language has been loaded, this will hold its value.
|
|
613
|
+
*/
|
|
614
|
+
support = undefined) {
|
|
611
615
|
this.name = name;
|
|
612
616
|
this.alias = alias;
|
|
613
617
|
this.extensions = extensions;
|
|
614
618
|
this.filename = filename;
|
|
615
619
|
this.loadFunc = loadFunc;
|
|
616
|
-
|
|
617
|
-
If the language has been loaded, this will hold its value.
|
|
618
|
-
*/
|
|
619
|
-
this.support = undefined;
|
|
620
|
+
this.support = support;
|
|
620
621
|
this.loading = null;
|
|
621
622
|
}
|
|
622
623
|
/**
|
|
@@ -631,7 +632,13 @@ class LanguageDescription {
|
|
|
631
632
|
Create a language description.
|
|
632
633
|
*/
|
|
633
634
|
static of(spec) {
|
|
634
|
-
|
|
635
|
+
let { load, support } = spec;
|
|
636
|
+
if (!load) {
|
|
637
|
+
if (!support)
|
|
638
|
+
throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
|
|
639
|
+
load = () => Promise.resolve(support);
|
|
640
|
+
}
|
|
641
|
+
return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);
|
|
635
642
|
}
|
|
636
643
|
/**
|
|
637
644
|
Look for a language in the given array of descriptions that
|