@codemirror/language 0.18.1 → 0.18.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +15 -15
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -483,11 +483,11 @@ const parseWorker = view.ViewPlugin.fromClass(class ParseWorker {
|
|
|
483
483
|
}
|
|
484
484
|
this.checkAsyncSchedule(cx);
|
|
485
485
|
}
|
|
486
|
-
scheduleWork(
|
|
486
|
+
scheduleWork() {
|
|
487
487
|
if (this.working > -1)
|
|
488
488
|
return;
|
|
489
|
-
let { state } = this.view, field = state.field(Language.state);
|
|
490
|
-
if (
|
|
489
|
+
let { state } = this.view, field = state.field(Language.state), frags = field.context.fragments;
|
|
490
|
+
if (field.tree.length >= state.doc.length && frags.length && frags[0].from == 0 && frags[0].to >= state.doc.length)
|
|
491
491
|
return;
|
|
492
492
|
this.working = requestIdle(this.work, { timeout: 500 /* Pause */ });
|
|
493
493
|
}
|
|
@@ -516,7 +516,7 @@ const parseWorker = view.ViewPlugin.fromClass(class ParseWorker {
|
|
|
516
516
|
}
|
|
517
517
|
checkAsyncSchedule(cx) {
|
|
518
518
|
if (cx.scheduleOn) {
|
|
519
|
-
cx.scheduleOn.then(() => this.scheduleWork(
|
|
519
|
+
cx.scheduleOn.then(() => this.scheduleWork());
|
|
520
520
|
cx.scheduleOn = null;
|
|
521
521
|
}
|
|
522
522
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ViewPlugin } from '@codemirror/view';
|
|
|
7
7
|
Node prop stored in a grammar's top syntax node to provide the
|
|
8
8
|
facet that stores language data for that language.
|
|
9
9
|
*/
|
|
10
|
-
const languageDataProp = new NodeProp();
|
|
10
|
+
const languageDataProp = /*@__PURE__*/new NodeProp();
|
|
11
11
|
/**
|
|
12
12
|
Helper function to define a facet (to be added to the top syntax
|
|
13
13
|
node(s) for a language via
|
|
@@ -108,7 +108,7 @@ class Language {
|
|
|
108
108
|
/**
|
|
109
109
|
@internal
|
|
110
110
|
*/
|
|
111
|
-
Language.setState = StateEffect.define();
|
|
111
|
+
Language.setState = /*@__PURE__*/StateEffect.define();
|
|
112
112
|
function languageDataFacetAt(state, pos) {
|
|
113
113
|
let topLang = state.facet(language);
|
|
114
114
|
if (!topLang)
|
|
@@ -407,7 +407,7 @@ class EditorParseContext {
|
|
|
407
407
|
/**
|
|
408
408
|
FIXME backwards compatible shim, remove on next major @internal
|
|
409
409
|
*/
|
|
410
|
-
EditorParseContext.skippingParser = EditorParseContext.getSkippingParser();
|
|
410
|
+
EditorParseContext.skippingParser = /*@__PURE__*/EditorParseContext.getSkippingParser();
|
|
411
411
|
function cutFragments(fragments, from, to) {
|
|
412
412
|
return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
|
|
413
413
|
}
|
|
@@ -439,7 +439,7 @@ class LanguageState {
|
|
|
439
439
|
return new LanguageState(parseState);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
Language.state = StateField.define({
|
|
442
|
+
Language.state = /*@__PURE__*/StateField.define({
|
|
443
443
|
create: LanguageState.init,
|
|
444
444
|
update(value, tr) {
|
|
445
445
|
for (let e of tr.effects)
|
|
@@ -453,7 +453,7 @@ Language.state = StateField.define({
|
|
|
453
453
|
let requestIdle = typeof window != "undefined" && window.requestIdleCallback ||
|
|
454
454
|
((callback, { timeout }) => setTimeout(callback, timeout));
|
|
455
455
|
let cancelIdle = typeof window != "undefined" && window.cancelIdleCallback || clearTimeout;
|
|
456
|
-
const parseWorker = ViewPlugin.fromClass(class ParseWorker {
|
|
456
|
+
const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
|
|
457
457
|
constructor(view) {
|
|
458
458
|
this.view = view;
|
|
459
459
|
this.working = -1;
|
|
@@ -479,11 +479,11 @@ const parseWorker = ViewPlugin.fromClass(class ParseWorker {
|
|
|
479
479
|
}
|
|
480
480
|
this.checkAsyncSchedule(cx);
|
|
481
481
|
}
|
|
482
|
-
scheduleWork(
|
|
482
|
+
scheduleWork() {
|
|
483
483
|
if (this.working > -1)
|
|
484
484
|
return;
|
|
485
|
-
let { state } = this.view, field = state.field(Language.state);
|
|
486
|
-
if (
|
|
485
|
+
let { state } = this.view, field = state.field(Language.state), frags = field.context.fragments;
|
|
486
|
+
if (field.tree.length >= state.doc.length && frags.length && frags[0].from == 0 && frags[0].to >= state.doc.length)
|
|
487
487
|
return;
|
|
488
488
|
this.working = requestIdle(this.work, { timeout: 500 /* Pause */ });
|
|
489
489
|
}
|
|
@@ -512,7 +512,7 @@ const parseWorker = ViewPlugin.fromClass(class ParseWorker {
|
|
|
512
512
|
}
|
|
513
513
|
checkAsyncSchedule(cx) {
|
|
514
514
|
if (cx.scheduleOn) {
|
|
515
|
-
cx.scheduleOn.then(() => this.scheduleWork(
|
|
515
|
+
cx.scheduleOn.then(() => this.scheduleWork());
|
|
516
516
|
cx.scheduleOn = null;
|
|
517
517
|
}
|
|
518
518
|
}
|
|
@@ -526,7 +526,7 @@ const parseWorker = ViewPlugin.fromClass(class ParseWorker {
|
|
|
526
526
|
/**
|
|
527
527
|
The facet used to associate a language with an editor state.
|
|
528
528
|
*/
|
|
529
|
-
const language = Facet.define({
|
|
529
|
+
const language = /*@__PURE__*/Facet.define({
|
|
530
530
|
combine(languages) { return languages.length ? languages[0] : null; },
|
|
531
531
|
enables: [Language.state, parseWorker]
|
|
532
532
|
});
|
|
@@ -654,13 +654,13 @@ Facet that defines a way to provide a function that computes the
|
|
|
654
654
|
appropriate indentation depth at the start of a given line, or
|
|
655
655
|
`null` to indicate no appropriate indentation could be determined.
|
|
656
656
|
*/
|
|
657
|
-
const indentService = Facet.define();
|
|
657
|
+
const indentService = /*@__PURE__*/Facet.define();
|
|
658
658
|
/**
|
|
659
659
|
Facet for overriding the unit by which indentation happens.
|
|
660
660
|
Should be a string consisting either entirely of spaces or
|
|
661
661
|
entirely of tabs. When not set, this defaults to 2 spaces.
|
|
662
662
|
*/
|
|
663
|
-
const indentUnit = Facet.define({
|
|
663
|
+
const indentUnit = /*@__PURE__*/Facet.define({
|
|
664
664
|
combine: values => {
|
|
665
665
|
if (!values.length)
|
|
666
666
|
return " ";
|
|
@@ -788,7 +788,7 @@ with node types. Such a strategy is a function from an indentation
|
|
|
788
788
|
context to a column number or null, where null indicates that no
|
|
789
789
|
definitive indentation can be determined.
|
|
790
790
|
*/
|
|
791
|
-
const indentNodeProp = new NodeProp();
|
|
791
|
+
const indentNodeProp = /*@__PURE__*/new NodeProp();
|
|
792
792
|
// Compute the indentation for a given position from the syntax tree.
|
|
793
793
|
function syntaxIndentation(cx, ast, pos) {
|
|
794
794
|
let tree = ast.resolve(pos);
|
|
@@ -1012,14 +1012,14 @@ the extent of a line, such a function should return a foldable
|
|
|
1012
1012
|
range that starts on that line (but continues beyond it), if one
|
|
1013
1013
|
can be found.
|
|
1014
1014
|
*/
|
|
1015
|
-
const foldService = Facet.define();
|
|
1015
|
+
const foldService = /*@__PURE__*/Facet.define();
|
|
1016
1016
|
/**
|
|
1017
1017
|
This node prop is used to associate folding information with
|
|
1018
1018
|
syntax node types. Given a syntax node, it should check whether
|
|
1019
1019
|
that tree is foldable and return the range that can be collapsed
|
|
1020
1020
|
when it is.
|
|
1021
1021
|
*/
|
|
1022
|
-
const foldNodeProp = new NodeProp();
|
|
1022
|
+
const foldNodeProp = /*@__PURE__*/new NodeProp();
|
|
1023
1023
|
/**
|
|
1024
1024
|
[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
|
|
1025
1025
|
the first and the last child of a syntax node. Useful for nodes
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/language",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Language support infrastructure for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "
|
|
6
|
+
"test": "cm-runtests",
|
|
7
7
|
"prepare": "cm-buildhelper src/index.ts"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
@@ -33,11 +33,8 @@
|
|
|
33
33
|
"lezer-tree": "^0.13.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@codemirror/buildhelper": "^0.1.
|
|
37
|
-
"
|
|
38
|
-
"ist": "^1.1.6",
|
|
39
|
-
"lezer-javascript": "^0.13.0",
|
|
40
|
-
"mocha": "^7.1.1"
|
|
36
|
+
"@codemirror/buildhelper": "^0.1.5",
|
|
37
|
+
"lezer-javascript": "^0.13.0"
|
|
41
38
|
},
|
|
42
39
|
"repository": {
|
|
43
40
|
"type": "git",
|