@difizen/libro-cofine-editor-core 0.1.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/es/default-worker-contribution.d.ts +9 -0
  4. package/es/default-worker-contribution.d.ts.map +1 -0
  5. package/es/default-worker-contribution.js +32 -0
  6. package/es/e2-editor.d.ts +30 -0
  7. package/es/e2-editor.d.ts.map +1 -0
  8. package/es/e2-editor.js +131 -0
  9. package/es/editor-handler-registry.d.ts +12 -0
  10. package/es/editor-handler-registry.d.ts.map +1 -0
  11. package/es/editor-handler-registry.js +59 -0
  12. package/es/editor-provider.d.ts +15 -0
  13. package/es/editor-provider.d.ts.map +1 -0
  14. package/es/editor-provider.js +1 -0
  15. package/es/editor.worker.d.ts +2 -0
  16. package/es/editor.worker.d.ts.map +1 -0
  17. package/es/editor.worker.js +23 -0
  18. package/es/global.d.ts +7 -0
  19. package/es/index.d.ts +18 -0
  20. package/es/index.d.ts.map +1 -0
  21. package/es/index.js +23 -0
  22. package/es/initialize-provider.d.ts +18 -0
  23. package/es/initialize-provider.d.ts.map +1 -0
  24. package/es/initialize-provider.js +120 -0
  25. package/es/mana-export.d.ts +4 -0
  26. package/es/mana-export.d.ts.map +1 -0
  27. package/es/mana-export.js +23 -0
  28. package/es/monaco-compability.esm.d.ts +4 -0
  29. package/es/monaco-compability.esm.d.ts.map +1 -0
  30. package/es/monaco-compability.esm.js +10 -0
  31. package/es/monaco-environment.d.ts +29 -0
  32. package/es/monaco-environment.d.ts.map +1 -0
  33. package/es/monaco-environment.js +276 -0
  34. package/es/monaco-loader.d.ts +22 -0
  35. package/es/monaco-loader.d.ts.map +1 -0
  36. package/es/monaco-loader.js +139 -0
  37. package/es/monaco-module.d.ts +5 -0
  38. package/es/monaco-module.d.ts.map +1 -0
  39. package/es/monaco-module.js +71 -0
  40. package/es/snippets-suggest-registry.d.ts +31 -0
  41. package/es/snippets-suggest-registry.d.ts.map +1 -0
  42. package/es/snippets-suggest-registry.js +110 -0
  43. package/es/theme-registry.d.ts +58 -0
  44. package/es/theme-registry.d.ts.map +1 -0
  45. package/es/theme-registry.js +91 -0
  46. package/package.json +64 -0
  47. package/src/default-worker-contribution.ts +25 -0
  48. package/src/e2-editor.ts +161 -0
  49. package/src/editor-handler-registry.ts +47 -0
  50. package/src/editor-provider.ts +29 -0
  51. package/src/editor.worker.ts +25 -0
  52. package/src/global.d.ts +7 -0
  53. package/src/index.spec.ts +8 -0
  54. package/src/index.ts +46 -0
  55. package/src/initialize-provider.ts +54 -0
  56. package/src/mana-export.ts +8 -0
  57. package/src/monaco-compability.esm.ts +4 -0
  58. package/src/monaco-environment.ts +115 -0
  59. package/src/monaco-loader.ts +100 -0
  60. package/src/monaco-module.ts +101 -0
  61. package/src/snippets-suggest-registry.ts +101 -0
  62. package/src/theme-registry.ts +116 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Difizen Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # libro-notebook
2
+
3
+ cell
@@ -0,0 +1,9 @@
1
+ import type { LanguageWorkerRegistry } from '@difizen/libro-cofine-editor-contribution';
2
+ import { LanguageWorkerContribution } from '@difizen/libro-cofine-editor-contribution';
3
+ import { MonacoLoaderConfig } from './monaco-loader.js';
4
+ export declare class DefaultWorkerContribution implements LanguageWorkerContribution {
5
+ config: MonacoLoaderConfig;
6
+ constructor(config: MonacoLoaderConfig);
7
+ registerLanguageWorkers(registry: LanguageWorkerRegistry): void;
8
+ }
9
+ //# sourceMappingURL=default-worker-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-worker-contribution.d.ts","sourceRoot":"","sources":["../../src/default-worker-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAKvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,qBACa,yBAA0B,YAAW,0BAA0B;IAC1E,MAAM,EAAE,kBAAkB,CAAC;gBACa,MAAM,EAAE,kBAAkB;IAGlE,uBAAuB,CAAC,QAAQ,EAAE,sBAAsB;CAUzD"}
@@ -0,0 +1,32 @@
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ import { LanguageWorkerContribution } from '@difizen/libro-cofine-editor-contribution';
9
+ import { inject, singleton } from '@difizen/mana-app';
10
+ import pkg from "../package.json";
11
+ import { MonacoLoaderConfig } from "./monaco-loader.js";
12
+ export var DefaultWorkerContribution = (_dec = singleton({
13
+ contrib: LanguageWorkerContribution
14
+ }), _dec(_class = /*#__PURE__*/function () {
15
+ function DefaultWorkerContribution(config) {
16
+ _classCallCheck(this, DefaultWorkerContribution);
17
+ this.config = config;
18
+ }
19
+ DefaultWorkerContribution = inject(MonacoLoaderConfig)(DefaultWorkerContribution, undefined, 0) || DefaultWorkerContribution;
20
+ _createClass(DefaultWorkerContribution, [{
21
+ key: "registerLanguageWorkers",
22
+ value: function registerLanguageWorkers(registry) {
23
+ registry.registerWorker({
24
+ language: 'editorWorkerService',
25
+ getWorkerUrl: function getWorkerUrl() {
26
+ return "data:text/javascript;charset=utf-8,".concat(encodeURIComponent("importScripts('https://unpkg.com/@difizen/libro-cofine-editor-core@".concat(pkg.version, "/dist/worker/editor.worker.min.js')")));
27
+ }
28
+ });
29
+ }
30
+ }]);
31
+ return DefaultWorkerContribution;
32
+ }()) || _class);
@@ -0,0 +1,30 @@
1
+ import { DisposableCollection } from '@difizen/mana-app';
2
+ import * as monaco from '@difizen/monaco-editor-core';
3
+ import { EditorHanlerRegistry } from './editor-handler-registry.js';
4
+ import type { LazyCallbackType, Options } from './editor-provider.js';
5
+ import { ThemeRegistry } from './theme-registry.js';
6
+ export declare const EditorNode: unique symbol;
7
+ export declare const MonacoOptions: unique symbol;
8
+ export declare const LazyCallback: unique symbol;
9
+ export declare const IsDiff: unique symbol;
10
+ /**
11
+ * E2 Editor
12
+ */
13
+ export declare class E2Editor<T extends monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor> {
14
+ codeEditor: T;
15
+ model: monaco.editor.ITextModel;
16
+ modified: monaco.editor.ITextModel;
17
+ original: monaco.editor.ITextModel;
18
+ language?: string;
19
+ protected toDispose: DisposableCollection;
20
+ node: HTMLElement;
21
+ options: Options;
22
+ editorHandlerRegistry: EditorHanlerRegistry;
23
+ themeRegistry: ThemeRegistry;
24
+ isDiff: boolean;
25
+ lazyCallback?: LazyCallbackType;
26
+ constructor(node: HTMLElement, options: Options, editorHandlerRegistry: EditorHanlerRegistry, themeRegistry: ThemeRegistry, isDiff: boolean, lazycallback?: LazyCallbackType);
27
+ protected handleEditorLanguageFeatureBefore(language: string | undefined): void;
28
+ protected handleEditorLanguageFeatureAfter(): void;
29
+ }
30
+ //# sourceMappingURL=e2-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"e2-editor.d.ts","sourceRoot":"","sources":["../../src/e2-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,UAAU,eAAuB,CAAC;AAC/C,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,MAAM,eAAmB,CAAC;AACvC;;GAEG;AAEH,qBACa,QAAQ,CACnB,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB;IAEnF,UAAU,EAAG,CAAC,CAAC;IACf,KAAK,EAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,EAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACpC,QAAQ,EAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,SAAS,EAAE,oBAAoB,CAA8B;IACvE,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,qBAAqB,EAAE,oBAAoB,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,gBAAgB,CAAC;gBAEV,IAAI,EAAE,WAAW,EACd,OAAO,EAAE,OAAO,EACT,qBAAqB,EAAE,oBAAoB,EAClD,aAAa,EAAE,aAAa,EACnC,MAAM,EAAE,OAAO,EACT,YAAY,CAAC,EAAE,gBAAgB;IA8GvD,SAAS,CAAC,iCAAiC,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS;IAMxE,SAAS,CAAC,gCAAgC;CAK3C"}
@@ -0,0 +1,131 @@
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ 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); } }
8
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ import { DisposableCollection } from '@difizen/mana-app';
12
+ import { inject, singleton } from '@difizen/mana-app';
13
+ import * as monaco from '@difizen/monaco-editor-core';
14
+ import { EditorHanlerRegistry } from "./editor-handler-registry.js";
15
+ import { MonacoEnvironment } from "./monaco-environment.js";
16
+ import { ThemeRegistry } from "./theme-registry.js";
17
+ export var EditorNode = Symbol('EditorNode');
18
+ export var MonacoOptions = Symbol('MonacoOptions');
19
+ export var LazyCallback = Symbol('LazyCallback');
20
+ export var IsDiff = Symbol('IsDiff');
21
+ /**
22
+ * E2 Editor
23
+ */
24
+
25
+ export var E2Editor = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () {
26
+ function E2Editor(node, options, editorHandlerRegistry, themeRegistry, isDiff, lazycallback) {
27
+ var _this = this;
28
+ _classCallCheck(this, E2Editor);
29
+ this.toDispose = new DisposableCollection();
30
+ this.node = node;
31
+ this.options = options;
32
+ this.editorHandlerRegistry = editorHandlerRegistry;
33
+ this.themeRegistry = themeRegistry;
34
+ this.isDiff = isDiff;
35
+ this.lazyCallback = lazycallback;
36
+ if (MonacoEnvironment.lazy) {
37
+ // 资源懒加载场景
38
+ if (!isDiff) {
39
+ this.model = monaco.editor.createModel(options.value || '', options.language, options.uri);
40
+ var language = this.model.getLanguageId();
41
+ this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
42
+ model: this.model
43
+ }));
44
+ this.handleEditorLanguageFeatureBefore(language);
45
+ MonacoEnvironment.initModule().then(function () {
46
+ // 设置方言和主题
47
+ var codeEditor = _this.codeEditor;
48
+ // 为了触发onCreate事件
49
+ codeEditor.setModel(monaco.editor.createModel(codeEditor.getValue() || '', language));
50
+ _this.language = options.language;
51
+ monaco.editor.setTheme(options.theme || '');
52
+ // 调用回调函数
53
+ _this.handleEditorLanguageFeatureAfter();
54
+ if (_this.lazyCallback) {
55
+ _this.lazyCallback(_this.codeEditor);
56
+ }
57
+ return;
58
+ }).catch(console.error);
59
+ } else {
60
+ this.modified = monaco.editor.createModel(options.modified || '');
61
+ this.original = monaco.editor.createModel(options.original || '');
62
+ this.codeEditor = monaco.editor.createDiffEditor(node, _objectSpread({}, options));
63
+ this.codeEditor.setModel({
64
+ original: this.original,
65
+ modified: this.modified
66
+ });
67
+ this.handleEditorLanguageFeatureBefore(options.language);
68
+ MonacoEnvironment.initModule().then(function () {
69
+ monaco.editor.setModelLanguage(_this.modified, options.language);
70
+ monaco.editor.setModelLanguage(_this.original, options.language);
71
+ _this.language = _this.original.getLanguageId();
72
+ monaco.editor.setTheme(options.theme || '');
73
+ // 调用回调函数
74
+ _this.handleEditorLanguageFeatureAfter();
75
+ if (_this.lazyCallback) {
76
+ _this.lazyCallback(_this.codeEditor);
77
+ }
78
+ return;
79
+ }).catch(console.error);
80
+ }
81
+ } else {
82
+ // create前钩子函数调用
83
+ this.handleEditorLanguageFeatureBefore(options.language);
84
+ if (!isDiff) {
85
+ this.model = monaco.editor.createModel(options.value || '', options.language);
86
+ this.codeEditor = monaco.editor.create(node, _objectSpread(_objectSpread({}, options), {}, {
87
+ model: this.model
88
+ }));
89
+ this.toDispose.push(this.model.onDidChangeLanguage(function (e) {
90
+ _this.language = e.newLanguage;
91
+ }));
92
+ this.language = this.model.getLanguageId();
93
+ } else {
94
+ this.modified = monaco.editor.createModel(options.modified || '', options.language);
95
+ this.original = monaco.editor.createModel(options.original || '', options.language);
96
+ this.codeEditor = monaco.editor.createDiffEditor(node, _objectSpread({}, options));
97
+ this.codeEditor.setModel({
98
+ original: this.original,
99
+ modified: this.modified
100
+ });
101
+ this.toDispose.push(this.modified.onDidChangeLanguage(function (e) {
102
+ _this.language = e.newLanguage;
103
+ }));
104
+ this.language = this.modified.getLanguageId();
105
+ }
106
+ this.handleEditorLanguageFeatureAfter();
107
+ }
108
+ }
109
+ E2Editor = inject(LazyCallback)(E2Editor, undefined, 5) || E2Editor;
110
+ E2Editor = inject(IsDiff)(E2Editor, undefined, 4) || E2Editor;
111
+ E2Editor = inject(ThemeRegistry)(E2Editor, undefined, 3) || E2Editor;
112
+ E2Editor = inject(EditorHanlerRegistry)(E2Editor, undefined, 2) || E2Editor;
113
+ E2Editor = inject(MonacoOptions)(E2Editor, undefined, 1) || E2Editor;
114
+ E2Editor = inject(EditorNode)(E2Editor, undefined, 0) || E2Editor;
115
+ _createClass(E2Editor, [{
116
+ key: "handleEditorLanguageFeatureBefore",
117
+ value: function handleEditorLanguageFeatureBefore(language) {
118
+ if (language) {
119
+ this.editorHandlerRegistry.handleBefore(language);
120
+ }
121
+ }
122
+ }, {
123
+ key: "handleEditorLanguageFeatureAfter",
124
+ value: function handleEditorLanguageFeatureAfter() {
125
+ if (this.language) {
126
+ this.editorHandlerRegistry.handleAfter(this.language, this.codeEditor);
127
+ }
128
+ }
129
+ }]);
130
+ return E2Editor;
131
+ }()) || _class);
@@ -0,0 +1,12 @@
1
+ import { EditorHandlerContribution } from '@difizen/libro-cofine-editor-contribution';
2
+ import type { Contribution } from '@difizen/mana-app';
3
+ import * as monaco from '@difizen/monaco-editor-core';
4
+ export declare class EditorHanlerRegistry {
5
+ contributions: EditorHandlerContribution[];
6
+ effected: EditorHandlerContribution[];
7
+ provider: Contribution.Provider<EditorHandlerContribution>;
8
+ constructor(provider: Contribution.Provider<EditorHandlerContribution>);
9
+ handleAfter(languege: string, editor: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor): void;
10
+ handleBefore(languege: string): void;
11
+ }
12
+ //# sourceMappingURL=editor-handler-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-handler-registry.d.ts","sourceRoot":"","sources":["../../src/editor-handler-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,qBACa,oBAAoB;IAC/B,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC3C,QAAQ,EAAE,yBAAyB,EAAE,CAAM;IAC3C,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;gBAGzD,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IAM5D,WAAW,CACT,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAChF,IAAI;IAaP,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAYrC"}
@@ -0,0 +1,59 @@
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ import { EditorHandlerContribution } from '@difizen/libro-cofine-editor-contribution';
9
+ import { contrib, singleton } from '@difizen/mana-app';
10
+ import * as monaco from '@difizen/monaco-editor-core';
11
+ export var EditorHanlerRegistry = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () {
12
+ function EditorHanlerRegistry(provider) {
13
+ _classCallCheck(this, EditorHanlerRegistry);
14
+ this.effected = [];
15
+ this.provider = provider;
16
+ this.contributions = provider.getContributions();
17
+ }
18
+ EditorHanlerRegistry = contrib(EditorHandlerContribution)(EditorHanlerRegistry, undefined, 0) || EditorHanlerRegistry;
19
+ _createClass(EditorHanlerRegistry, [{
20
+ key: "handleAfter",
21
+ value: function handleAfter(languege, editor) {
22
+ var _this = this;
23
+ this.effected.forEach(function (contribution) {
24
+ return contribution.dispose();
25
+ });
26
+ this.effected = [];
27
+ this.contributions = this.provider.getContributions({
28
+ cache: false
29
+ });
30
+ var canHanleList = this.contributions.filter(function (handler) {
31
+ return handler.canHandle(languege);
32
+ });
33
+ canHanleList.forEach(function (contribution) {
34
+ contribution.afterCreate(editor, monaco);
35
+ _this.effected.push(contribution);
36
+ });
37
+ }
38
+ }, {
39
+ key: "handleBefore",
40
+ value: function handleBefore(languege) {
41
+ var _this2 = this;
42
+ this.contributions = this.provider.getContributions({
43
+ cache: false
44
+ });
45
+ this.effected.forEach(function (contribution) {
46
+ return contribution.dispose();
47
+ });
48
+ this.effected = [];
49
+ var canHanleList = this.contributions.filter(function (handler) {
50
+ return handler.canHandle(languege);
51
+ });
52
+ canHanleList.forEach(function (contribution) {
53
+ contribution.beforeCreate(monaco);
54
+ _this2.effected.push(contribution);
55
+ });
56
+ }
57
+ }]);
58
+ return EditorHanlerRegistry;
59
+ }()) || _class);
@@ -0,0 +1,15 @@
1
+ import type monaco from '@difizen/monaco-editor-core';
2
+ import type { E2Editor } from './e2-editor.js';
3
+ export declare const EditorProvider: unique symbol;
4
+ export type Options = monaco.editor.IStandaloneEditorConstructionOptions & monaco.editor.IDiffEditorConstructionOptions & {
5
+ modified?: string;
6
+ original?: string;
7
+ } & {
8
+ uri?: monaco.Uri;
9
+ };
10
+ export interface EditorProvider {
11
+ create: (node: HTMLElement, options: Options, callback?: LazyCallbackType) => E2Editor<monaco.editor.IStandaloneCodeEditor>;
12
+ createDiff: (node: HTMLElement, options: Options, callback?: LazyCallbackType) => E2Editor<monaco.editor.IStandaloneDiffEditor>;
13
+ }
14
+ export type LazyCallbackType = (editor: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor) => void;
15
+ //# sourceMappingURL=editor-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-provider.d.ts","sourceRoot":"","sources":["../../src/editor-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAO,MAAM,cAAc,eAA2B,CAAC;AACvD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,oCAAoC,GACtE,MAAM,CAAC,MAAM,CAAC,8BAA8B,GAAG;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC;CAClB,CAAC;AAEJ,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,CACN,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,gBAAgB,KACxB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACnD,UAAU,EAAE,CACV,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,gBAAgB,KACxB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;CACpD;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,KAC9E,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export var EditorProvider = Symbol('EditorProvider');
@@ -0,0 +1,2 @@
1
+ export declare function initialize(foreignModule: any): void;
2
+ //# sourceMappingURL=editor.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.worker.d.ts","sourceRoot":"","sources":["../../src/editor.worker.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,aAAa,EAAE,GAAG,QAc5C"}
@@ -0,0 +1,23 @@
1
+ import { SimpleWorkerServer } from '@difizen/monaco-editor-core/esm/vs/base/common/worker/simpleWorker.js';
2
+ import { EditorSimpleWorker } from '@difizen/monaco-editor-core/esm/vs/editor/common/services/editorSimpleWorker.js';
3
+ var initialized = false;
4
+ export function initialize(foreignModule) {
5
+ if (initialized) {
6
+ return;
7
+ }
8
+ initialized = true;
9
+ var simpleWorker = new SimpleWorkerServer(function (msg) {
10
+ globalThis.postMessage(msg);
11
+ }, function (host) {
12
+ return new EditorSimpleWorker(host, foreignModule);
13
+ });
14
+ globalThis.onmessage = function (e) {
15
+ simpleWorker.onmessage(e.data);
16
+ };
17
+ }
18
+ globalThis.onmessage = function (e) {
19
+ // Ignore first message in this case and initialize if not yet initialized
20
+ if (!initialized) {
21
+ initialize(null);
22
+ }
23
+ };
package/es/global.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ declare module '@difizen/monaco-editor-core/esm/vs/base/common/worker/simpleWorker.js';
2
+ declare module '@difizen/monaco-editor-core/esm/vs/editor/common/services/editorSimpleWorker.js';
3
+ declare module '*.json';
4
+ interface Window {
5
+ _Monaco: any;
6
+ MonacoEnvironment: any;
7
+ }
package/es/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type monaco from '@difizen/monaco-editor-core';
2
+ import type { E2Editor } from './e2-editor.js';
3
+ export { EditorHandlerContribution, LanguageOptionsRegistry, LanguageWorkerContribution, LanguageWorkerRegistry, } from '@difizen/libro-cofine-editor-contribution';
4
+ export type { E2Editor } from './e2-editor.js';
5
+ export { EditorHanlerRegistry } from './editor-handler-registry.js';
6
+ export { EditorProvider } from './editor-provider.js';
7
+ export { InitializeContribution } from './initialize-provider.js';
8
+ export { MonacoEnvironment } from './monaco-environment.js';
9
+ export { MonacoLoaderConfig } from './monaco-loader.js';
10
+ export { SnippetSuggestContribution, SnippetSuggestRegistry, } from './snippets-suggest-registry.js';
11
+ export { MixedThemeRegistry, ThemeContribution, ThemeRegistry, } from './theme-registry.js';
12
+ export type { MixedTheme, ITextmateThemeSetting, IRawThemeSetting, IRawTheme, } from './theme-registry.js';
13
+ export declare class Editor {
14
+ editor: E2Editor<monaco.editor.IStandaloneCodeEditor>;
15
+ codeEditor: monaco.editor.IStandaloneCodeEditor;
16
+ constructor(node: HTMLElement, options?: monaco.editor.IStandaloneEditorConstructionOptions);
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,qBAAa,MAAM;IACjB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACtD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;gBAE9C,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,MAAM,CAAC,MAAM,CAAC,oCAAyC;CAOnE"}
package/es/index.js ADDED
@@ -0,0 +1,23 @@
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
+ 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); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ import { EditorProvider } from "./editor-provider.js";
8
+ import { MonacoEnvironment } from "./monaco-environment.js";
9
+ export { EditorHandlerContribution, LanguageOptionsRegistry, LanguageWorkerContribution, LanguageWorkerRegistry } from '@difizen/libro-cofine-editor-contribution';
10
+ export { EditorHanlerRegistry } from "./editor-handler-registry.js";
11
+ export { EditorProvider } from "./editor-provider.js";
12
+ export { InitializeContribution } from "./initialize-provider.js";
13
+ export { MonacoEnvironment } from "./monaco-environment.js";
14
+ export { MonacoLoaderConfig } from "./monaco-loader.js";
15
+ export { SnippetSuggestContribution, SnippetSuggestRegistry } from "./snippets-suggest-registry.js";
16
+ export { MixedThemeRegistry, ThemeContribution, ThemeRegistry } from "./theme-registry.js";
17
+ export var Editor = /*#__PURE__*/_createClass(function Editor(node) {
18
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ _classCallCheck(this, Editor);
20
+ var editorProvider = MonacoEnvironment.container.get(EditorProvider);
21
+ this.editor = editorProvider.create(node, options);
22
+ this.codeEditor = this.editor.codeEditor;
23
+ });
@@ -0,0 +1,18 @@
1
+ import type { Contribution } from '@difizen/mana-app';
2
+ import { DefaultContributionProvider, Syringe } from '@difizen/mana-app';
3
+ import type monaco from '@difizen/monaco-editor-core';
4
+ export declare const InitializeContribution: Syringe.DefinedToken;
5
+ export interface InitializeContribution {
6
+ initialized?: boolean;
7
+ onInitialize?: (coreMonaco: typeof monaco) => void | Promise<void>;
8
+ awaysInitialized?: boolean;
9
+ }
10
+ export declare class InitializeProvider {
11
+ provider: Contribution.Provider<InitializeContribution>;
12
+ constructor(provider: Contribution.Provider<InitializeContribution>);
13
+ initialize(coreMonaco: typeof monaco): Promise<void>;
14
+ }
15
+ export declare class InitializeContributionProvider extends DefaultContributionProvider<InitializeContribution> {
16
+ getContributions(): InitializeContribution[];
17
+ }
18
+ //# sourceMappingURL=initialize-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialize-provider.d.ts","sourceRoot":"","sources":["../../src/initialize-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAEL,2BAA2B,EAE3B,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,eAAO,MAAM,sBAAsB,sBAAgD,CAAC;AACpF,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AACD,qBACa,kBAAkB;IAC7B,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;gBAGtD,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAKnD,UAAU,CAAC,UAAU,EAAE,OAAO,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAqB3D;AAED,qBAAa,8BAA+B,SAAQ,2BAA2B,CAAC,sBAAsB,CAAC;IAC5F,gBAAgB;CAI1B"}
@@ -0,0 +1,120 @@
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 _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
4
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
5
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
13
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
+ 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); } }
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
22
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
23
+ import { contrib, DefaultContributionProvider, singleton, Syringe } from '@difizen/mana-app';
24
+ export var InitializeContribution = Syringe.defineToken('InitializeContribution');
25
+ export var InitializeProvider = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () {
26
+ function InitializeProvider(provider) {
27
+ _classCallCheck(this, InitializeProvider);
28
+ this.provider = provider;
29
+ }
30
+ InitializeProvider = contrib(InitializeContribution)(InitializeProvider, undefined, 0) || InitializeProvider;
31
+ _createClass(InitializeProvider, [{
32
+ key: "initialize",
33
+ value: function () {
34
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(coreMonaco) {
35
+ var contributions, _iterator, _step, contribution, inited;
36
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
37
+ while (1) switch (_context.prev = _context.next) {
38
+ case 0:
39
+ contributions = this.provider.getContributions({
40
+ cache: false
41
+ });
42
+ _iterator = _createForOfIteratorHelper(contributions);
43
+ _context.prev = 2;
44
+ _iterator.s();
45
+ case 4:
46
+ if ((_step = _iterator.n()).done) {
47
+ _context.next = 20;
48
+ break;
49
+ }
50
+ contribution = _step.value;
51
+ if (!contribution.onInitialize) {
52
+ _context.next = 18;
53
+ break;
54
+ }
55
+ _context.prev = 7;
56
+ if (contribution.initialized) {
57
+ _context.next = 14;
58
+ break;
59
+ }
60
+ inited = contribution.onInitialize(coreMonaco);
61
+ if (!inited) {
62
+ _context.next = 13;
63
+ break;
64
+ }
65
+ _context.next = 13;
66
+ return inited;
67
+ case 13:
68
+ if (!contribution.awaysInitialized) {
69
+ contribution.initialized = true;
70
+ }
71
+ case 14:
72
+ _context.next = 18;
73
+ break;
74
+ case 16:
75
+ _context.prev = 16;
76
+ _context.t0 = _context["catch"](7);
77
+ case 18:
78
+ _context.next = 4;
79
+ break;
80
+ case 20:
81
+ _context.next = 25;
82
+ break;
83
+ case 22:
84
+ _context.prev = 22;
85
+ _context.t1 = _context["catch"](2);
86
+ _iterator.e(_context.t1);
87
+ case 25:
88
+ _context.prev = 25;
89
+ _iterator.f();
90
+ return _context.finish(25);
91
+ case 28:
92
+ case "end":
93
+ return _context.stop();
94
+ }
95
+ }, _callee, this, [[2, 22, 25, 28], [7, 16]]);
96
+ }));
97
+ function initialize(_x) {
98
+ return _initialize.apply(this, arguments);
99
+ }
100
+ return initialize;
101
+ }()
102
+ }]);
103
+ return InitializeProvider;
104
+ }()) || _class);
105
+ export var InitializeContributionProvider = /*#__PURE__*/function (_DefaultContributionP) {
106
+ _inherits(InitializeContributionProvider, _DefaultContributionP);
107
+ var _super = _createSuper(InitializeContributionProvider);
108
+ function InitializeContributionProvider() {
109
+ _classCallCheck(this, InitializeContributionProvider);
110
+ return _super.apply(this, arguments);
111
+ }
112
+ _createClass(InitializeContributionProvider, [{
113
+ key: "getContributions",
114
+ value: function getContributions() {
115
+ this.services = undefined;
116
+ return _get(_getPrototypeOf(InitializeContributionProvider.prototype), "getContributions", this).call(this);
117
+ }
118
+ }]);
119
+ return InitializeContributionProvider;
120
+ }(DefaultContributionProvider);
@@ -0,0 +1,4 @@
1
+ import type { Container } from '@difizen/mana-app';
2
+ declare const _default: (container: Container) => Promise<void>;
3
+ export default _default;
4
+ //# sourceMappingURL=mana-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mana-export.d.ts","sourceRoot":"","sources":["../../src/mana-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;oCAIlB,SAAS,KAAG,QAAQ,IAAI,CAAC;AAA1D,wBAGE"}