@difizen/libro-code-editor 0.2.29 → 0.2.31
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/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -1
- package/es/language-specs.d.ts +38 -0
- package/es/language-specs.d.ts.map +1 -0
- package/es/language-specs.js +58 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +2 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/language-specs.ts +69 -0
- package/src/module.ts +3 -1
package/es/index.d.ts
CHANGED
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
package/es/index.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Contribution } from '@difizen/mana-app';
|
|
2
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
3
|
+
import { Syringe } from '@difizen/mana-app';
|
|
4
|
+
export declare const LanguageSpecContribution: Syringe.DefinedToken;
|
|
5
|
+
export interface LanguageSpecContribution {
|
|
6
|
+
registerLanguageSpec: (register: LanguageSpecRegistry) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface LanguageSpec {
|
|
9
|
+
/**
|
|
10
|
+
* language name
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* https://code.visualstudio.com/docs/languages/identifiers
|
|
15
|
+
*/
|
|
16
|
+
language: string;
|
|
17
|
+
/**
|
|
18
|
+
* https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
19
|
+
*/
|
|
20
|
+
mime: string;
|
|
21
|
+
/**
|
|
22
|
+
* file extension
|
|
23
|
+
*/
|
|
24
|
+
ext: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare class LanguageSpecRegistry implements ApplicationContribution {
|
|
27
|
+
get languageSpecs(): LanguageSpec[];
|
|
28
|
+
protected languageSpecsData: LanguageSpec[];
|
|
29
|
+
protected readonly languageSpecProvider: Contribution.Provider<LanguageSpecContribution>;
|
|
30
|
+
constructor(languageSpecProvider: Contribution.Provider<LanguageSpecContribution>);
|
|
31
|
+
initialize(): void;
|
|
32
|
+
/**
|
|
33
|
+
* 注册语言元信息,代码编辑器根据这些信息来设置语言;使用代码编辑器的cell一般需要注册语言元信息
|
|
34
|
+
*/
|
|
35
|
+
registerLanguageSpec(spec: LanguageSpec): void;
|
|
36
|
+
hasLanguage(spec: LanguageSpec): boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=language-specs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-specs.d.ts","sourceRoot":"","sources":["../src/language-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAsB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,eAAO,MAAM,wBAAwB,sBAAkD,CAAC;AACxF,MAAM,WAAW,wBAAwB;IACvC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAChE;AACD,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,qBACa,oBAAqB,YAAW,uBAAuB;IAClE,IAAI,aAAa,IAAI,YAAY,EAAE,CAElC;IACD,SAAS,CAAC,iBAAiB,EAAE,YAAY,EAAE,CAAM;IAEjD,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,YAAY,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;gBAIvF,oBAAoB,EAAE,YAAY,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAKvE,UAAU;IAMV;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,YAAY;IAWvC,WAAW,CAAC,IAAI,EAAE,YAAY;CAK/B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
9
|
+
import { contrib, singleton, Syringe } from '@difizen/mana-app';
|
|
10
|
+
export var LanguageSpecContribution = Syringe.defineToken('LanguageSpecContribution');
|
|
11
|
+
export var LanguageSpecRegistry = (_dec = singleton({
|
|
12
|
+
contrib: [ApplicationContribution]
|
|
13
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
14
|
+
function LanguageSpecRegistry(languageSpecProvider) {
|
|
15
|
+
_classCallCheck(this, LanguageSpecRegistry);
|
|
16
|
+
this.languageSpecsData = [];
|
|
17
|
+
this.languageSpecProvider = languageSpecProvider;
|
|
18
|
+
}
|
|
19
|
+
LanguageSpecRegistry = contrib(LanguageSpecContribution)(LanguageSpecRegistry, undefined, 0) || LanguageSpecRegistry;
|
|
20
|
+
_createClass(LanguageSpecRegistry, [{
|
|
21
|
+
key: "languageSpecs",
|
|
22
|
+
get: function get() {
|
|
23
|
+
return this.languageSpecsData;
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
key: "initialize",
|
|
27
|
+
value: function initialize() {
|
|
28
|
+
var _this = this;
|
|
29
|
+
this.languageSpecProvider.getContributions().forEach(function (item) {
|
|
30
|
+
item.registerLanguageSpec(_this);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 注册语言元信息,代码编辑器根据这些信息来设置语言;使用代码编辑器的cell一般需要注册语言元信息
|
|
36
|
+
*/
|
|
37
|
+
}, {
|
|
38
|
+
key: "registerLanguageSpec",
|
|
39
|
+
value: function registerLanguageSpec(spec) {
|
|
40
|
+
var index = this.languageSpecsData.findIndex(function (item) {
|
|
41
|
+
return item.language === spec.language;
|
|
42
|
+
});
|
|
43
|
+
if (index >= 0) {
|
|
44
|
+
this.languageSpecsData.splice(index, 1, spec);
|
|
45
|
+
} else {
|
|
46
|
+
this.languageSpecsData.push(spec);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "hasLanguage",
|
|
51
|
+
value: function hasLanguage(spec) {
|
|
52
|
+
return this.languageSpecsData.findIndex(function (item) {
|
|
53
|
+
return item.language === spec.language;
|
|
54
|
+
}) > 0;
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
return LanguageSpecRegistry;
|
|
58
|
+
}()) || _class);
|
package/es/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAW/C,eAAO,MAAM,gBAAgB,YAUoC,CAAC"}
|
package/es/module.js
CHANGED
|
@@ -6,4 +6,5 @@ import { CodeEditorContribution } from "./code-editor-protocol.js";
|
|
|
6
6
|
import { CodeEditorSettings } from "./code-editor-settings.js";
|
|
7
7
|
import { CodeEditorStateManager } from "./code-editor-state-manager.js";
|
|
8
8
|
import { CodeEditorView } from "./code-editor-view.js";
|
|
9
|
-
|
|
9
|
+
import { LanguageSpecContribution, LanguageSpecRegistry } from "./language-specs.js";
|
|
10
|
+
export var CodeEditorModule = ManaModule.create().register(CodeEditorInfoManager, CodeEditorView, CodeEditorManager, Model, CodeEditorSettings, CodeEditorStateManager, LanguageSpecRegistry).contribution(CodeEditorContribution, LanguageSpecContribution);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-code-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@difizen/mana-app": "latest",
|
|
36
36
|
"@difizen/mana-l10n": "latest",
|
|
37
|
-
"@difizen/libro-common": "^0.2.
|
|
37
|
+
"@difizen/libro-common": "^0.2.31",
|
|
38
38
|
"uuid": "^9.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Contribution } from '@difizen/mana-app';
|
|
2
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
3
|
+
import { contrib, singleton, Syringe } from '@difizen/mana-app';
|
|
4
|
+
|
|
5
|
+
export const LanguageSpecContribution = Syringe.defineToken('LanguageSpecContribution');
|
|
6
|
+
export interface LanguageSpecContribution {
|
|
7
|
+
registerLanguageSpec: (register: LanguageSpecRegistry) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface LanguageSpec {
|
|
10
|
+
/**
|
|
11
|
+
* language name
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* https://code.visualstudio.com/docs/languages/identifiers
|
|
16
|
+
*/
|
|
17
|
+
language: string;
|
|
18
|
+
/**
|
|
19
|
+
* https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
20
|
+
*/
|
|
21
|
+
mime: string;
|
|
22
|
+
/**
|
|
23
|
+
* file extension
|
|
24
|
+
*/
|
|
25
|
+
ext: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@singleton({ contrib: [ApplicationContribution] })
|
|
29
|
+
export class LanguageSpecRegistry implements ApplicationContribution {
|
|
30
|
+
get languageSpecs(): LanguageSpec[] {
|
|
31
|
+
return this.languageSpecsData;
|
|
32
|
+
}
|
|
33
|
+
protected languageSpecsData: LanguageSpec[] = [];
|
|
34
|
+
|
|
35
|
+
protected readonly languageSpecProvider: Contribution.Provider<LanguageSpecContribution>;
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
@contrib(LanguageSpecContribution)
|
|
39
|
+
languageSpecProvider: Contribution.Provider<LanguageSpecContribution>,
|
|
40
|
+
) {
|
|
41
|
+
this.languageSpecProvider = languageSpecProvider;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
initialize() {
|
|
45
|
+
this.languageSpecProvider.getContributions().forEach((item) => {
|
|
46
|
+
item.registerLanguageSpec(this);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 注册语言元信息,代码编辑器根据这些信息来设置语言;使用代码编辑器的cell一般需要注册语言元信息
|
|
52
|
+
*/
|
|
53
|
+
registerLanguageSpec(spec: LanguageSpec) {
|
|
54
|
+
const index = this.languageSpecsData.findIndex(
|
|
55
|
+
(item) => item.language === spec.language,
|
|
56
|
+
);
|
|
57
|
+
if (index >= 0) {
|
|
58
|
+
this.languageSpecsData.splice(index, 1, spec);
|
|
59
|
+
} else {
|
|
60
|
+
this.languageSpecsData.push(spec);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
hasLanguage(spec: LanguageSpec) {
|
|
65
|
+
return (
|
|
66
|
+
this.languageSpecsData.findIndex((item) => item.language === spec.language) > 0
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/module.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { CodeEditorContribution } from './code-editor-protocol.js';
|
|
|
7
7
|
import { CodeEditorSettings } from './code-editor-settings.js';
|
|
8
8
|
import { CodeEditorStateManager } from './code-editor-state-manager.js';
|
|
9
9
|
import { CodeEditorView } from './code-editor-view.js';
|
|
10
|
+
import { LanguageSpecContribution, LanguageSpecRegistry } from './language-specs.js';
|
|
10
11
|
|
|
11
12
|
export const CodeEditorModule = ManaModule.create()
|
|
12
13
|
.register(
|
|
@@ -16,5 +17,6 @@ export const CodeEditorModule = ManaModule.create()
|
|
|
16
17
|
Model,
|
|
17
18
|
CodeEditorSettings,
|
|
18
19
|
CodeEditorStateManager,
|
|
20
|
+
LanguageSpecRegistry,
|
|
19
21
|
)
|
|
20
|
-
.contribution(CodeEditorContribution);
|
|
22
|
+
.contribution(CodeEditorContribution, LanguageSpecContribution);
|