@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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/es/default-worker-contribution.d.ts +9 -0
- package/es/default-worker-contribution.d.ts.map +1 -0
- package/es/default-worker-contribution.js +32 -0
- package/es/e2-editor.d.ts +30 -0
- package/es/e2-editor.d.ts.map +1 -0
- package/es/e2-editor.js +131 -0
- package/es/editor-handler-registry.d.ts +12 -0
- package/es/editor-handler-registry.d.ts.map +1 -0
- package/es/editor-handler-registry.js +59 -0
- package/es/editor-provider.d.ts +15 -0
- package/es/editor-provider.d.ts.map +1 -0
- package/es/editor-provider.js +1 -0
- package/es/editor.worker.d.ts +2 -0
- package/es/editor.worker.d.ts.map +1 -0
- package/es/editor.worker.js +23 -0
- package/es/global.d.ts +7 -0
- package/es/index.d.ts +18 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +23 -0
- package/es/initialize-provider.d.ts +18 -0
- package/es/initialize-provider.d.ts.map +1 -0
- package/es/initialize-provider.js +120 -0
- package/es/mana-export.d.ts +4 -0
- package/es/mana-export.d.ts.map +1 -0
- package/es/mana-export.js +23 -0
- package/es/monaco-compability.esm.d.ts +4 -0
- package/es/monaco-compability.esm.d.ts.map +1 -0
- package/es/monaco-compability.esm.js +10 -0
- package/es/monaco-environment.d.ts +29 -0
- package/es/monaco-environment.d.ts.map +1 -0
- package/es/monaco-environment.js +276 -0
- package/es/monaco-loader.d.ts +22 -0
- package/es/monaco-loader.d.ts.map +1 -0
- package/es/monaco-loader.js +139 -0
- package/es/monaco-module.d.ts +5 -0
- package/es/monaco-module.d.ts.map +1 -0
- package/es/monaco-module.js +71 -0
- package/es/snippets-suggest-registry.d.ts +31 -0
- package/es/snippets-suggest-registry.d.ts.map +1 -0
- package/es/snippets-suggest-registry.js +110 -0
- package/es/theme-registry.d.ts +58 -0
- package/es/theme-registry.d.ts.map +1 -0
- package/es/theme-registry.js +91 -0
- package/package.json +64 -0
- package/src/default-worker-contribution.ts +25 -0
- package/src/e2-editor.ts +161 -0
- package/src/editor-handler-registry.ts +47 -0
- package/src/editor-provider.ts +29 -0
- package/src/editor.worker.ts +25 -0
- package/src/global.d.ts +7 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +46 -0
- package/src/initialize-provider.ts +54 -0
- package/src/mana-export.ts +8 -0
- package/src/monaco-compability.esm.ts +4 -0
- package/src/monaco-environment.ts +115 -0
- package/src/monaco-loader.ts +100 -0
- package/src/monaco-module.ts +101 -0
- package/src/snippets-suggest-registry.ts +101 -0
- package/src/theme-registry.ts +116 -0
|
@@ -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 _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; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
import { MonacoEnvironment } from "./monaco-environment.js";
|
|
6
|
+
export default /*#__PURE__*/(function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(container) {
|
|
8
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
MonacoEnvironment.setContainer(container);
|
|
12
|
+
_context.next = 3;
|
|
13
|
+
return MonacoEnvironment.init();
|
|
14
|
+
case 3:
|
|
15
|
+
case "end":
|
|
16
|
+
return _context.stop();
|
|
17
|
+
}
|
|
18
|
+
}, _callee);
|
|
19
|
+
}));
|
|
20
|
+
return function (_x) {
|
|
21
|
+
return _ref.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
2
|
+
export default monaco;
|
|
3
|
+
export declare const Emitter: typeof monaco.Emitter, MarkerSeverity: typeof monaco.MarkerSeverity, Range: typeof monaco.Range, Uri: typeof monaco.Uri, editor: typeof monaco.editor, languages: typeof monaco.languages;
|
|
4
|
+
//# sourceMappingURL=monaco-compability.esm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-compability.esm.d.ts","sourceRoot":"","sources":["../../src/monaco-compability.esm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,eAAe,MAAM,CAAC;AACtB,eAAO,MAAQ,OAAO,yBAAE,cAAc,gCAAE,KAAK,uBAAE,GAAG,qBAAE,MAAM,wBAAE,SAAS,yBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
2
|
+
export default monaco;
|
|
3
|
+
var _ref = monaco || {},
|
|
4
|
+
Emitter = _ref.Emitter,
|
|
5
|
+
MarkerSeverity = _ref.MarkerSeverity,
|
|
6
|
+
Range = _ref.Range,
|
|
7
|
+
Uri = _ref.Uri,
|
|
8
|
+
editor = _ref.editor,
|
|
9
|
+
languages = _ref.languages;
|
|
10
|
+
export { Emitter, MarkerSeverity, Range, Uri, editor, languages };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Syringe } from '@difizen/mana-app';
|
|
2
|
+
import { Deferred } from '@difizen/mana-app';
|
|
3
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
4
|
+
import { MonacoLoader } from './monaco-loader.js';
|
|
5
|
+
export declare const MonacoEnvironmentBound = "MonacoEnvironmentBound";
|
|
6
|
+
export type ModuleLoader = (container: Syringe.Container) => void;
|
|
7
|
+
type InitType = {
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
cdnUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class MonacoEnvironment {
|
|
12
|
+
static container: Syringe.Container;
|
|
13
|
+
static loaders: ModuleLoader[];
|
|
14
|
+
static preLoaders: ModuleLoader[];
|
|
15
|
+
static monaco: typeof monaco;
|
|
16
|
+
protected static loader?: MonacoLoader;
|
|
17
|
+
protected static moduleLoadStart: boolean;
|
|
18
|
+
protected static moduleInitDeferred: Deferred<void>;
|
|
19
|
+
protected static baseModule?: Syringe.Module;
|
|
20
|
+
static lazy: boolean;
|
|
21
|
+
static setContainer: (container: Syringe.Container) => void;
|
|
22
|
+
static load(cdnUrl?: string): Promise<void>;
|
|
23
|
+
static init({ lazy, cdnUrl }?: InitType | undefined): Promise<void>;
|
|
24
|
+
static initModule(): Promise<void>;
|
|
25
|
+
static loadModule(loader: ModuleLoader): Promise<void>;
|
|
26
|
+
static preLoadModule(loader: ModuleLoader): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=monaco-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-environment.d.ts","sourceRoot":"","sources":["../../src/monaco-environment.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAGtD,OAAO,EAEL,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;AAClE,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;IACpC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,CAAM;IACpC,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,CAAM;IACvC,MAAM,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC;IAC7B,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IACvC,SAAS,CAAC,MAAM,CAAC,eAAe,UAAS;IACzC,SAAS,CAAC,MAAM,CAAC,kBAAkB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAwB;IAC3E,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAC7C,MAAM,CAAC,IAAI,UAAS;IAEpB,MAAM,CAAC,YAAY,cAAe,QAAQ,SAAS,UASjD;WACW,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM;WASpB,IAAI,CACf,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,QAAQ,GAAG,SAAuC,GACnE,OAAO,CAAC,IAAI,CAAC;WA8BH,UAAU;WAoBV,UAAU,CAAC,MAAM,EAAE,YAAY;WAK/B,aAAa,CAAC,MAAM,EAAE,YAAY;CAGhD"}
|
|
@@ -0,0 +1,276 @@
|
|
|
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 _class;
|
|
3
|
+
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; } } }; }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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); } }
|
|
8
|
+
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); }); }; }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
+
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); }
|
|
14
|
+
import { LanguageWorkerRegistry, LazyLoaderRegistry } from '@difizen/libro-cofine-editor-contribution';
|
|
15
|
+
import { Deferred } from '@difizen/mana-app';
|
|
16
|
+
import { GlobalContainer } from '@difizen/mana-app';
|
|
17
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
18
|
+
import { InitializeProvider } from "./initialize-provider.js";
|
|
19
|
+
import { DefaultLoaderConfig, MonacoLoader, MonacoLoaderConfig } from "./monaco-loader.js";
|
|
20
|
+
import BaseModule from "./monaco-module.js";
|
|
21
|
+
export var MonacoEnvironmentBound = 'MonacoEnvironmentBound';
|
|
22
|
+
export var MonacoEnvironment = /*#__PURE__*/function () {
|
|
23
|
+
function MonacoEnvironment() {
|
|
24
|
+
_classCallCheck(this, MonacoEnvironment);
|
|
25
|
+
}
|
|
26
|
+
_createClass(MonacoEnvironment, null, [{
|
|
27
|
+
key: "load",
|
|
28
|
+
value: function () {
|
|
29
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cdnUrl) {
|
|
30
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
if (!MonacoEnvironment.container) {
|
|
34
|
+
MonacoEnvironment.setContainer(GlobalContainer);
|
|
35
|
+
}
|
|
36
|
+
if (!MonacoEnvironment.loader) {
|
|
37
|
+
MonacoEnvironment.loader = MonacoEnvironment.container.get(MonacoLoader);
|
|
38
|
+
}
|
|
39
|
+
_context.next = 4;
|
|
40
|
+
return MonacoEnvironment.loader.load(cdnUrl);
|
|
41
|
+
case 4:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
function load(_x) {
|
|
48
|
+
return _load.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
return load;
|
|
51
|
+
}()
|
|
52
|
+
}, {
|
|
53
|
+
key: "init",
|
|
54
|
+
value: function () {
|
|
55
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
56
|
+
var _ref,
|
|
57
|
+
lazy,
|
|
58
|
+
cdnUrl,
|
|
59
|
+
_iterator,
|
|
60
|
+
_step,
|
|
61
|
+
loader,
|
|
62
|
+
initialize,
|
|
63
|
+
_args2 = arguments;
|
|
64
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
65
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
_ref = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {
|
|
68
|
+
lazy: false,
|
|
69
|
+
cdnUrl: ''
|
|
70
|
+
}, lazy = _ref.lazy, cdnUrl = _ref.cdnUrl;
|
|
71
|
+
if (MonacoEnvironment.monaco) {
|
|
72
|
+
_context2.next = 4;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
_context2.next = 4;
|
|
76
|
+
return MonacoEnvironment.load(cdnUrl);
|
|
77
|
+
case 4:
|
|
78
|
+
window.MonacoEnvironment = {
|
|
79
|
+
getWorkerUrl: function getWorkerUrl(moduleId, label) {
|
|
80
|
+
var workerRegistry = MonacoEnvironment.container.get(LanguageWorkerRegistry);
|
|
81
|
+
return workerRegistry.getLanguageWorker(label, moduleId);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
_context2.prev = 5;
|
|
85
|
+
if (!MonacoEnvironment.baseModule) {
|
|
86
|
+
MonacoEnvironment.baseModule = BaseModule;
|
|
87
|
+
MonacoEnvironment.container.load(MonacoEnvironment.baseModule);
|
|
88
|
+
}
|
|
89
|
+
MonacoEnvironment.lazy = lazy;
|
|
90
|
+
if (lazy) {
|
|
91
|
+
_context2.next = 13;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
_context2.next = 11;
|
|
95
|
+
return MonacoEnvironment.initModule();
|
|
96
|
+
case 11:
|
|
97
|
+
_context2.next = 33;
|
|
98
|
+
break;
|
|
99
|
+
case 13:
|
|
100
|
+
_iterator = _createForOfIteratorHelper(MonacoEnvironment.preLoaders);
|
|
101
|
+
_context2.prev = 14;
|
|
102
|
+
_iterator.s();
|
|
103
|
+
case 16:
|
|
104
|
+
if ((_step = _iterator.n()).done) {
|
|
105
|
+
_context2.next = 22;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
loader = _step.value;
|
|
109
|
+
_context2.next = 20;
|
|
110
|
+
return loader(MonacoEnvironment.container);
|
|
111
|
+
case 20:
|
|
112
|
+
_context2.next = 16;
|
|
113
|
+
break;
|
|
114
|
+
case 22:
|
|
115
|
+
_context2.next = 27;
|
|
116
|
+
break;
|
|
117
|
+
case 24:
|
|
118
|
+
_context2.prev = 24;
|
|
119
|
+
_context2.t0 = _context2["catch"](14);
|
|
120
|
+
_iterator.e(_context2.t0);
|
|
121
|
+
case 27:
|
|
122
|
+
_context2.prev = 27;
|
|
123
|
+
_iterator.f();
|
|
124
|
+
return _context2.finish(27);
|
|
125
|
+
case 30:
|
|
126
|
+
initialize = MonacoEnvironment.container.get(InitializeProvider);
|
|
127
|
+
_context2.next = 33;
|
|
128
|
+
return initialize.initialize(monaco);
|
|
129
|
+
case 33:
|
|
130
|
+
_context2.next = 38;
|
|
131
|
+
break;
|
|
132
|
+
case 35:
|
|
133
|
+
_context2.prev = 35;
|
|
134
|
+
_context2.t1 = _context2["catch"](5);
|
|
135
|
+
console.error(_context2.t1);
|
|
136
|
+
case 38:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context2.stop();
|
|
139
|
+
}
|
|
140
|
+
}, _callee2, null, [[5, 35], [14, 24, 27, 30]]);
|
|
141
|
+
}));
|
|
142
|
+
function init() {
|
|
143
|
+
return _init.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
return init;
|
|
146
|
+
}()
|
|
147
|
+
}, {
|
|
148
|
+
key: "initModule",
|
|
149
|
+
value: function () {
|
|
150
|
+
var _initModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
151
|
+
var _iterator2, _step2, loader, initialize, layzInit;
|
|
152
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
153
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
154
|
+
case 0:
|
|
155
|
+
if (MonacoEnvironment.loaders.length) {
|
|
156
|
+
_context3.next = 2;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return _context3.abrupt("return");
|
|
160
|
+
case 2:
|
|
161
|
+
_iterator2 = _createForOfIteratorHelper(MonacoEnvironment.loaders);
|
|
162
|
+
_context3.prev = 3;
|
|
163
|
+
_iterator2.s();
|
|
164
|
+
case 5:
|
|
165
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
166
|
+
_context3.next = 11;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
loader = _step2.value;
|
|
170
|
+
_context3.next = 9;
|
|
171
|
+
return loader(MonacoEnvironment.container);
|
|
172
|
+
case 9:
|
|
173
|
+
_context3.next = 5;
|
|
174
|
+
break;
|
|
175
|
+
case 11:
|
|
176
|
+
_context3.next = 16;
|
|
177
|
+
break;
|
|
178
|
+
case 13:
|
|
179
|
+
_context3.prev = 13;
|
|
180
|
+
_context3.t0 = _context3["catch"](3);
|
|
181
|
+
_iterator2.e(_context3.t0);
|
|
182
|
+
case 16:
|
|
183
|
+
_context3.prev = 16;
|
|
184
|
+
_iterator2.f();
|
|
185
|
+
return _context3.finish(16);
|
|
186
|
+
case 19:
|
|
187
|
+
MonacoEnvironment.loaders = [];
|
|
188
|
+
_context3.prev = 20;
|
|
189
|
+
initialize = MonacoEnvironment.container.get(InitializeProvider);
|
|
190
|
+
_context3.next = 24;
|
|
191
|
+
return initialize.initialize(monaco);
|
|
192
|
+
case 24:
|
|
193
|
+
if (!MonacoEnvironment.lazy) {
|
|
194
|
+
_context3.next = 28;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
layzInit = MonacoEnvironment.container.get(LazyLoaderRegistry);
|
|
198
|
+
_context3.next = 28;
|
|
199
|
+
return layzInit.handleLazyLoder();
|
|
200
|
+
case 28:
|
|
201
|
+
_context3.next = 33;
|
|
202
|
+
break;
|
|
203
|
+
case 30:
|
|
204
|
+
_context3.prev = 30;
|
|
205
|
+
_context3.t1 = _context3["catch"](20);
|
|
206
|
+
console.error(_context3.t1);
|
|
207
|
+
case 33:
|
|
208
|
+
case "end":
|
|
209
|
+
return _context3.stop();
|
|
210
|
+
}
|
|
211
|
+
}, _callee3, null, [[3, 13, 16, 19], [20, 30]]);
|
|
212
|
+
}));
|
|
213
|
+
function initModule() {
|
|
214
|
+
return _initModule.apply(this, arguments);
|
|
215
|
+
}
|
|
216
|
+
return initModule;
|
|
217
|
+
}()
|
|
218
|
+
}, {
|
|
219
|
+
key: "loadModule",
|
|
220
|
+
value: function () {
|
|
221
|
+
var _loadModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(loader) {
|
|
222
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
223
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
224
|
+
case 0:
|
|
225
|
+
MonacoEnvironment.loaders.push(loader);
|
|
226
|
+
case 1:
|
|
227
|
+
case "end":
|
|
228
|
+
return _context4.stop();
|
|
229
|
+
}
|
|
230
|
+
}, _callee4);
|
|
231
|
+
}));
|
|
232
|
+
function loadModule(_x2) {
|
|
233
|
+
return _loadModule.apply(this, arguments);
|
|
234
|
+
}
|
|
235
|
+
return loadModule;
|
|
236
|
+
}() // 提前加载(懒加载模式下需要提前加载的模块)
|
|
237
|
+
}, {
|
|
238
|
+
key: "preLoadModule",
|
|
239
|
+
value: function () {
|
|
240
|
+
var _preLoadModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(loader) {
|
|
241
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
242
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
243
|
+
case 0:
|
|
244
|
+
MonacoEnvironment.preLoaders.push(loader);
|
|
245
|
+
case 1:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context5.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee5);
|
|
250
|
+
}));
|
|
251
|
+
function preLoadModule(_x3) {
|
|
252
|
+
return _preLoadModule.apply(this, arguments);
|
|
253
|
+
}
|
|
254
|
+
return preLoadModule;
|
|
255
|
+
}()
|
|
256
|
+
}]);
|
|
257
|
+
return MonacoEnvironment;
|
|
258
|
+
}();
|
|
259
|
+
_class = MonacoEnvironment;
|
|
260
|
+
MonacoEnvironment.loaders = [];
|
|
261
|
+
MonacoEnvironment.preLoaders = [];
|
|
262
|
+
MonacoEnvironment.moduleLoadStart = false;
|
|
263
|
+
MonacoEnvironment.moduleInitDeferred = new Deferred();
|
|
264
|
+
MonacoEnvironment.lazy = false;
|
|
265
|
+
MonacoEnvironment.setContainer = function (container) {
|
|
266
|
+
_class.container = container;
|
|
267
|
+
if (!container.isBound(MonacoEnvironmentBound)) {
|
|
268
|
+
container.register(MonacoEnvironmentBound, {
|
|
269
|
+
useValue: true
|
|
270
|
+
});
|
|
271
|
+
_class.container.register(MonacoLoaderConfig, {
|
|
272
|
+
useValue: DefaultLoaderConfig
|
|
273
|
+
});
|
|
274
|
+
container.register(MonacoLoader);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const MonacoLoaderConfig: unique symbol;
|
|
2
|
+
export interface MonacoLoaderConfig {
|
|
3
|
+
requireConfig: {
|
|
4
|
+
paths: {
|
|
5
|
+
vs: string;
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const DefaultLoaderConfig: MonacoLoaderConfig;
|
|
11
|
+
export declare class MonacoLoader {
|
|
12
|
+
loaded: boolean;
|
|
13
|
+
protected start: boolean;
|
|
14
|
+
protected vsRequire: any;
|
|
15
|
+
protected readonly config: MonacoLoaderConfig;
|
|
16
|
+
constructor(config: MonacoLoaderConfig);
|
|
17
|
+
cdnUrl: string;
|
|
18
|
+
load(cdnUrl?: string): Promise<void>;
|
|
19
|
+
protected doLoad(): Promise<void>;
|
|
20
|
+
initMonaco(): Promise<unknown>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=monaco-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-loader.d.ts","sourceRoot":"","sources":["../../src/monaco-loader.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE;QACb,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAMjC,CAAC;AAEF,qBACa,YAAY;IACvB,MAAM,UAAS;IACf,SAAS,CAAC,KAAK,UAAS;IACxB,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;IACzB,SAAS,CAAC,QAAQ,CAAC,MAAM,qBAAC;gBACc,MAAM,EAAE,kBAAkB;IAGlE,MAAM,SAAM;IAEN,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM;cASV,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvC,UAAU;CAoDX"}
|
|
@@ -0,0 +1,139 @@
|
|
|
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 _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; }
|
|
4
|
+
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); } }
|
|
5
|
+
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); }); }; }
|
|
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 { inject, singleton } from '@difizen/mana-app';
|
|
12
|
+
import * as monaco from '@difizen/monaco-editor-core';
|
|
13
|
+
export var MonacoLoaderConfig = Symbol('MonacoLoaderConfig');
|
|
14
|
+
export var DefaultLoaderConfig = {
|
|
15
|
+
requireConfig: {
|
|
16
|
+
paths: {
|
|
17
|
+
vs: 'https://unpkg.com/@difizen/monaco-editor-core@0.39.4/min/vs/'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export var MonacoLoader = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () {
|
|
22
|
+
function MonacoLoader(config) {
|
|
23
|
+
_classCallCheck(this, MonacoLoader);
|
|
24
|
+
this.loaded = false;
|
|
25
|
+
this.start = false;
|
|
26
|
+
this.cdnUrl = '';
|
|
27
|
+
this.config = config;
|
|
28
|
+
}
|
|
29
|
+
MonacoLoader = inject(MonacoLoaderConfig)(MonacoLoader, undefined, 0) || MonacoLoader;
|
|
30
|
+
_createClass(MonacoLoader, [{
|
|
31
|
+
key: "load",
|
|
32
|
+
value: function () {
|
|
33
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cdnUrl) {
|
|
34
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
if (cdnUrl) {
|
|
38
|
+
this.cdnUrl = cdnUrl;
|
|
39
|
+
}
|
|
40
|
+
if (this.start) {
|
|
41
|
+
_context.next = 5;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
this.start = true;
|
|
45
|
+
_context.next = 5;
|
|
46
|
+
return this.doLoad();
|
|
47
|
+
case 5:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}, _callee, this);
|
|
52
|
+
}));
|
|
53
|
+
function load(_x) {
|
|
54
|
+
return _load.apply(this, arguments);
|
|
55
|
+
}
|
|
56
|
+
return load;
|
|
57
|
+
}()
|
|
58
|
+
}, {
|
|
59
|
+
key: "doLoad",
|
|
60
|
+
value: function () {
|
|
61
|
+
var _doLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
63
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
if (this.loaded) {
|
|
66
|
+
_context2.next = 3;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
_context2.next = 3;
|
|
70
|
+
return this.initMonaco();
|
|
71
|
+
case 3:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context2.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee2, this);
|
|
76
|
+
}));
|
|
77
|
+
function doLoad() {
|
|
78
|
+
return _doLoad.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
return doLoad;
|
|
81
|
+
}() // 初始化,将monaco挂在到window上
|
|
82
|
+
}, {
|
|
83
|
+
key: "initMonaco",
|
|
84
|
+
value: function initMonaco() {
|
|
85
|
+
var _this = this;
|
|
86
|
+
return new Promise(function (resolve, reject) {
|
|
87
|
+
if (_this.cdnUrl) {
|
|
88
|
+
var beforeExist = document.getElementById('e2-monaco-id');
|
|
89
|
+
if (beforeExist) {
|
|
90
|
+
if (window._Monaco) {
|
|
91
|
+
var global = window;
|
|
92
|
+
global.monaco = window._Monaco;
|
|
93
|
+
_this.loaded = true;
|
|
94
|
+
resolve(true);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
beforeExist.onload = function () {
|
|
98
|
+
var global = window;
|
|
99
|
+
global.monaco = window._Monaco;
|
|
100
|
+
_this.loaded = true;
|
|
101
|
+
resolve(true);
|
|
102
|
+
};
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var script = document.createElement('script');
|
|
106
|
+
script.id = 'e2-monaco-id';
|
|
107
|
+
script.src = _this.cdnUrl;
|
|
108
|
+
// script.src =
|
|
109
|
+
document.head.appendChild(script);
|
|
110
|
+
script.onload = function () {
|
|
111
|
+
var global = window;
|
|
112
|
+
global.monaco = window._Monaco;
|
|
113
|
+
_this.loaded = true;
|
|
114
|
+
resolve(true);
|
|
115
|
+
};
|
|
116
|
+
script.onerror = function () {
|
|
117
|
+
document.head.removeChild(script);
|
|
118
|
+
// 如果第一次失败的话,就再次加载monaco
|
|
119
|
+
var script2 = document.createElement('script');
|
|
120
|
+
script2.src = _this.cdnUrl;
|
|
121
|
+
document.head.appendChild(script2);
|
|
122
|
+
script2.onload = function () {
|
|
123
|
+
var global = window;
|
|
124
|
+
global.monaco = window._Monaco;
|
|
125
|
+
_this.loaded = true;
|
|
126
|
+
resolve(true);
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
var _global = window;
|
|
131
|
+
_global.monaco = monaco;
|
|
132
|
+
_this.loaded = true;
|
|
133
|
+
resolve(true);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}]);
|
|
138
|
+
return MonacoLoader;
|
|
139
|
+
}()) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-module.d.ts","sourceRoot":"","sources":["../../src/monaco-module.ts"],"names":[],"mappings":"AASA,OAAO,EAAwB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,kBAAkB,CAAC;AA2B1B,eAAO,MAAM,YAAY,2DA4DtB,CAAC;AAEJ,eAAe,YAAY,CAAC"}
|