@monbolc/lowcode-editor-core 2.1.4 → 2.1.5
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/package.json +6 -6
- package/es/di.js +0 -67
- package/es/di.js.map +0 -1
- package/es/editor.js +0 -75
- package/es/editor.js.map +0 -1
- package/es/i18n.js +0 -50
- package/es/i18n.js.map +0 -1
- package/es/index.js +0 -15
- package/es/index.js.map +0 -1
- package/es/plugin.js +0 -107
- package/es/plugin.js.map +0 -1
- package/es/types.js +0 -8
- package/es/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monbolc/lowcode-editor-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Core API: DI container + i18n + plugin registry for SapuLowcodeEngine (L2)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"clean": "rimraf lib es"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@monbolc/lowcode-plugin-command": "^2.1.
|
|
27
|
-
"@monbolc/lowcode-types": "^2.1.
|
|
28
|
-
"@monbolc/lowcode-utils": "^2.1.
|
|
26
|
+
"@monbolc/lowcode-plugin-command": "^2.1.5",
|
|
27
|
+
"@monbolc/lowcode-types": "^2.1.5",
|
|
28
|
+
"@monbolc/lowcode-utils": "^2.1.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"rimraf": "^5.0.5",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "git@github.com:
|
|
40
|
+
"url": "git@github.com:lir-navcoo/lowcode-engine.git",
|
|
41
41
|
"directory": "packages/editor-core"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"i18n",
|
|
49
49
|
"plugin"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b23c688931a9afae9f3fc05308d587a2c053f983"
|
|
52
52
|
}
|
package/es/di.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @monbolc/lowcode-editor-core — DIContainer
|
|
3
|
-
*
|
|
4
|
-
* A tiny, type-friendly dependency injection container. Each entry is
|
|
5
|
-
* keyed by a constructor / factory function. Resolve is async because
|
|
6
|
-
* a factory may itself call `get(...)` to satisfy its own deps.
|
|
7
|
-
*
|
|
8
|
-
* Why a custom container instead of InversifyJS / tsyringe?
|
|
9
|
-
* - The editor's DI surface is small (a few dozen services at most).
|
|
10
|
-
* - We want zero runtime deps and a TS-friendly API.
|
|
11
|
-
* - We do not need scoping / child containers / aspect interception.
|
|
12
|
-
*/
|
|
13
|
-
import { uid } from '@monbolc/lowcode-utils';
|
|
14
|
-
export class DIContainer {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.services = new Map();
|
|
17
|
-
this.id = uid('di');
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Register a service. The `ctor` is the lookup key — call `get(ctor)`
|
|
21
|
-
* to retrieve the instance. The `factory` builds the instance.
|
|
22
|
-
*/
|
|
23
|
-
register(ctor, factory, scope = 'singleton') {
|
|
24
|
-
if (this.services.has(ctor)) {
|
|
25
|
-
throw new Error(`[DIContainer:${this.id}] service already registered for this ctor`);
|
|
26
|
-
}
|
|
27
|
-
this.services.set(ctor, { factory, scope });
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Resolve a service. If a singleton was already built, returns the
|
|
31
|
-
* cached instance; otherwise calls the factory and caches.
|
|
32
|
-
*/
|
|
33
|
-
async get(ctor) {
|
|
34
|
-
const reg = this.services.get(ctor);
|
|
35
|
-
if (!reg) {
|
|
36
|
-
throw new Error(`[DIContainer:${this.id}] no service registered for this ctor`);
|
|
37
|
-
}
|
|
38
|
-
if (reg.instance !== undefined && reg.scope === 'singleton') {
|
|
39
|
-
return reg.instance;
|
|
40
|
-
}
|
|
41
|
-
const instance = await reg.factory(this);
|
|
42
|
-
if (reg.scope === 'singleton')
|
|
43
|
-
reg.instance = instance;
|
|
44
|
-
return instance;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Synchronous lookup. Returns undefined if the service is not yet built
|
|
48
|
-
* (or not registered at all). Useful for non-async consumers.
|
|
49
|
-
*/
|
|
50
|
-
peek(ctor) {
|
|
51
|
-
const reg = this.services.get(ctor);
|
|
52
|
-
return reg?.instance;
|
|
53
|
-
}
|
|
54
|
-
/** True if a factory is registered for this key. */
|
|
55
|
-
has(ctor) {
|
|
56
|
-
return this.services.has(ctor);
|
|
57
|
-
}
|
|
58
|
-
/** Drop all registrations and cached instances. */
|
|
59
|
-
clear() {
|
|
60
|
-
this.services.clear();
|
|
61
|
-
}
|
|
62
|
-
/** Number of registered services. */
|
|
63
|
-
size() {
|
|
64
|
-
return this.services.size;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=di.js.map
|
package/es/di.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"di.js","sourceRoot":"","sources":["../src/di.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAa7C,MAAM,OAAO,WAAW;IAAxB;QACmB,aAAQ,GAAG,IAAI,GAAG,EAA2C,CAAC;QAC9D,OAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IAqDlC,CAAC;IAnDC;;;OAGG;IACH,QAAQ,CAAI,IAAgB,EAAE,OAAmB,EAAE,QAAmC,WAAW;QAC/F,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAwB,CAAC,EAAE,CAAC;YAChD,MAAM,IAAI,KAA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"}
|
package/es/editor.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @monbolc/lowcode-editor-core — Editor (composition root)
|
|
3
|
-
*
|
|
4
|
-
* The `Editor` class wires DI, i18n, the plugin manager, and the command
|
|
5
|
-
* manager into a single object. Subclasses (e.g. a future
|
|
6
|
-
* `BrowserEditor`) can override `init` to also mount UI.
|
|
7
|
-
*/
|
|
8
|
-
import { Emitter } from '@monbolc/lowcode-utils';
|
|
9
|
-
import { CommandManager } from '@monbolc/lowcode-plugin-command';
|
|
10
|
-
import { DIContainer } from './di.js';
|
|
11
|
-
import { I18nImpl } from './i18n.js';
|
|
12
|
-
import { PluginManager } from './plugin.js';
|
|
13
|
-
export class Editor {
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
this.events = new Emitter();
|
|
16
|
-
this.i18n = new I18nImpl();
|
|
17
|
-
this.di = new DIContainer();
|
|
18
|
-
this.commands = new CommandManager();
|
|
19
|
-
this._ready = false;
|
|
20
|
-
this.id = `editor_${Math.random().toString(36).slice(2, 10)}`;
|
|
21
|
-
this.plugins = new PluginManager(this.events);
|
|
22
|
-
this.initialPlugins = options.plugins ?? [];
|
|
23
|
-
if (options.locale)
|
|
24
|
-
this.i18n.setLocale(options.locale);
|
|
25
|
-
}
|
|
26
|
-
get ready() {
|
|
27
|
-
return this._ready;
|
|
28
|
-
}
|
|
29
|
-
async init(extraPlugins = []) {
|
|
30
|
-
if (this._ready) {
|
|
31
|
-
throw new Error(`[Editor:${this.id}] init() called twice`);
|
|
32
|
-
}
|
|
33
|
-
this.events.emit('phase', { name: 'init' });
|
|
34
|
-
for (const p of this.initialPlugins)
|
|
35
|
-
this.plugins.register(p);
|
|
36
|
-
for (const p of extraPlugins)
|
|
37
|
-
this.plugins.register(p);
|
|
38
|
-
this.events.emit('phase', { name: 'register' });
|
|
39
|
-
const ctx = {
|
|
40
|
-
editor: this,
|
|
41
|
-
i18n: this.i18n,
|
|
42
|
-
di: this.di,
|
|
43
|
-
events: this.events,
|
|
44
|
-
plugins: this.plugins,
|
|
45
|
-
commands: this.commands,
|
|
46
|
-
};
|
|
47
|
-
await this.plugins.initAll(ctx);
|
|
48
|
-
this._ready = true;
|
|
49
|
-
this.events.emit('phase', { name: 'ready' });
|
|
50
|
-
}
|
|
51
|
-
async destroy() {
|
|
52
|
-
if (!this._ready)
|
|
53
|
-
return;
|
|
54
|
-
this.events.emit('phase', { name: 'destroy' });
|
|
55
|
-
const ctx = {
|
|
56
|
-
editor: this,
|
|
57
|
-
i18n: this.i18n,
|
|
58
|
-
di: this.di,
|
|
59
|
-
events: this.events,
|
|
60
|
-
plugins: this.plugins,
|
|
61
|
-
commands: this.commands,
|
|
62
|
-
};
|
|
63
|
-
await this.plugins.destroyAll(ctx);
|
|
64
|
-
this.di.clear();
|
|
65
|
-
this.commands.clearHistory();
|
|
66
|
-
this._ready = false;
|
|
67
|
-
}
|
|
68
|
-
async get(ctor) {
|
|
69
|
-
return this.di.get(ctor);
|
|
70
|
-
}
|
|
71
|
-
peek(ctor) {
|
|
72
|
-
return this.di.peek(ctor);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=editor.js.map
|
package/es/editor.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBzC,MAAM,OAAO,MAAM;IAWjB,YAAY,UAAyB,EAAE;QAV9B,WAAM,GAAG,IAAI,OAAO,EAAgB,CAAC;QACrC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AAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
package/es/i18n.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @monbolc/lowcode-editor-core — I18n
|
|
3
|
-
*
|
|
4
|
-
* Tiny internationalization helper. Plugins call `i18n.register({...})`
|
|
5
|
-
* to add strings; consumers call `i18n.t('pluginName.someKey')` to get
|
|
6
|
-
* a string in the active locale (or the default if missing).
|
|
7
|
-
*
|
|
8
|
-
* Shape: { default: string, byLocale?: Record<locale, string> }
|
|
9
|
-
* Example:
|
|
10
|
-
* i18n.register({ 'designer.duplicate': { default: 'Duplicate', byLocale: { zh_CN: '复制' } } });
|
|
11
|
-
* i18n.t('designer.duplicate'); // 'Duplicate' (or '复制' if locale='zh_CN')
|
|
12
|
-
*/
|
|
13
|
-
export class I18nImpl {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.messages = new Map();
|
|
16
|
-
this._locale = '';
|
|
17
|
-
}
|
|
18
|
-
get locale() {
|
|
19
|
-
return this._locale;
|
|
20
|
-
}
|
|
21
|
-
setLocale(locale) {
|
|
22
|
-
this._locale = locale ?? '';
|
|
23
|
-
}
|
|
24
|
-
register(messages) {
|
|
25
|
-
for (const [id, value] of Object.entries(messages)) {
|
|
26
|
-
// Allow shorthand: `'foo': 'Hello'` instead of `{ default: 'Hello' }`.
|
|
27
|
-
const normalized = typeof value === 'string' ? { default: value } : value;
|
|
28
|
-
this.messages.set(id, normalized);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
t(id, locale, fallback) {
|
|
32
|
-
const msg = this.messages.get(id);
|
|
33
|
-
if (!msg) {
|
|
34
|
-
if (fallback !== undefined)
|
|
35
|
-
return fallback;
|
|
36
|
-
// Last resort: return the id itself so missing translations are visible.
|
|
37
|
-
return id;
|
|
38
|
-
}
|
|
39
|
-
const activeLocale = locale ?? this._locale;
|
|
40
|
-
if (activeLocale && msg.byLocale?.[activeLocale] !== undefined) {
|
|
41
|
-
return msg.byLocale[activeLocale];
|
|
42
|
-
}
|
|
43
|
-
return msg.default;
|
|
44
|
-
}
|
|
45
|
-
/** Number of registered message ids. */
|
|
46
|
-
size() {
|
|
47
|
-
return this.messages.size;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=i18n.js.map
|
package/es/i18n.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,OAAO,QAAQ;IAArB;QACmB,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;QACnD,YAAO,GAAW,EAAE,CAAC;IAqC/B,CAAC;IAnCC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,QAAQ,CAAC,QAA8C;QACrD,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnD,uEAAuE;YACvE,MAAM,UAAU,GACd,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACzD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,CAAC,CAAC,EAAU,EAAE,MAAe,EAAE,QAAiB;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAC;YAC5C,yEAAyE;YACzE,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC;QAC5C,IAAI,YAAY,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;YAC/D,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,wCAAwC;IACxC,IAAI;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
package/es/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @monbolc/lowcode-editor-core — barrel export
|
|
3
|
-
*
|
|
4
|
-
* SapuLowcodeEngine core API surface (L2). DI + i18n + plugin registry +
|
|
5
|
-
* command manager + event bus. No React, no mobx — that's L3+.
|
|
6
|
-
*/
|
|
7
|
-
// --- DI ---
|
|
8
|
-
export { DIContainer } from './di.js';
|
|
9
|
-
// --- i18n ---
|
|
10
|
-
export { I18nImpl } from './i18n.js';
|
|
11
|
-
// --- plugin manager ---
|
|
12
|
-
export { PluginManager } from './plugin.js';
|
|
13
|
-
// --- editor (composition root) ---
|
|
14
|
-
export { Editor } from './editor.js';
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,aAAa;AACb,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGnC,eAAe;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,yBAAyB;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,oCAAoC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/es/plugin.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @monbolc/lowcode-editor-core — PluginManager
|
|
3
|
-
*
|
|
4
|
-
* Validates plugin names, topologically sorts by `dependencies`,
|
|
5
|
-
* and exposes registration APIs.
|
|
6
|
-
*/
|
|
7
|
-
export class PluginManager {
|
|
8
|
-
constructor(eventBus) {
|
|
9
|
-
this.plugins = new Map();
|
|
10
|
-
this.sortedCache = null;
|
|
11
|
-
this.eventBus = eventBus;
|
|
12
|
-
}
|
|
13
|
-
register(plugin) {
|
|
14
|
-
if (this.plugins.has(plugin.name)) {
|
|
15
|
-
throw new Error(`[PluginManager] plugin "${plugin.name}" is already registered`);
|
|
16
|
-
}
|
|
17
|
-
if (!/^[A-Za-z0-9_@./\-]+$/.test(plugin.name)) {
|
|
18
|
-
throw new Error(`[PluginManager] plugin name "${plugin.name}" contains invalid characters`);
|
|
19
|
-
}
|
|
20
|
-
this.plugins.set(plugin.name, plugin);
|
|
21
|
-
this.sortedCache = null; // invalidate sort cache
|
|
22
|
-
this.eventBus.emit('pluginRegistered', { name: plugin.name });
|
|
23
|
-
}
|
|
24
|
-
unregister(name) {
|
|
25
|
-
const existed = this.plugins.delete(name);
|
|
26
|
-
if (existed)
|
|
27
|
-
this.sortedCache = null;
|
|
28
|
-
return existed;
|
|
29
|
-
}
|
|
30
|
-
has(name) {
|
|
31
|
-
return this.plugins.has(name);
|
|
32
|
-
}
|
|
33
|
-
get(name) {
|
|
34
|
-
return this.plugins.get(name);
|
|
35
|
-
}
|
|
36
|
-
list() {
|
|
37
|
-
return Array.from(this.plugins.values());
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Return plugins in dependency order: deps first, then dependents.
|
|
41
|
-
* Throws on circular or missing deps.
|
|
42
|
-
*/
|
|
43
|
-
sortedByDeps() {
|
|
44
|
-
if (this.sortedCache)
|
|
45
|
-
return this.sortedCache;
|
|
46
|
-
const result = [];
|
|
47
|
-
const visited = new Set();
|
|
48
|
-
const visiting = new Set();
|
|
49
|
-
const visit = (plugin) => {
|
|
50
|
-
if (visited.has(plugin.name))
|
|
51
|
-
return;
|
|
52
|
-
if (visiting.has(plugin.name)) {
|
|
53
|
-
throw new Error(`[PluginManager] circular dependency at "${plugin.name}"`);
|
|
54
|
-
}
|
|
55
|
-
visiting.add(plugin.name);
|
|
56
|
-
for (const dep of plugin.dependencies ?? []) {
|
|
57
|
-
const sub = this.plugins.get(dep);
|
|
58
|
-
if (!sub) {
|
|
59
|
-
throw new Error(`[PluginManager] plugin "${plugin.name}" depends on missing plugin "${dep}"`);
|
|
60
|
-
}
|
|
61
|
-
visit(sub);
|
|
62
|
-
}
|
|
63
|
-
visiting.delete(plugin.name);
|
|
64
|
-
visited.add(plugin.name);
|
|
65
|
-
result.push(plugin);
|
|
66
|
-
};
|
|
67
|
-
for (const plugin of this.plugins.values())
|
|
68
|
-
visit(plugin);
|
|
69
|
-
this.sortedCache = result;
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Run init() for each plugin in dep order. If any throws, the error
|
|
74
|
-
* is rethrown but earlier plugins remain initialized.
|
|
75
|
-
*/
|
|
76
|
-
async initAll(ctx) {
|
|
77
|
-
for (const plugin of this.sortedByDeps()) {
|
|
78
|
-
if (!plugin.init)
|
|
79
|
-
continue;
|
|
80
|
-
try {
|
|
81
|
-
await plugin.init(ctx);
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
this.eventBus.emit('error', { plugin: plugin.name, error: err });
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Run destroy() in reverse init order. Errors are swallowed and emitted
|
|
91
|
-
* so one bad plugin doesn't prevent others from cleaning up.
|
|
92
|
-
*/
|
|
93
|
-
async destroyAll(ctx) {
|
|
94
|
-
const plugins = [...this.sortedByDeps()].reverse();
|
|
95
|
-
for (const plugin of plugins) {
|
|
96
|
-
if (!plugin.destroy)
|
|
97
|
-
continue;
|
|
98
|
-
try {
|
|
99
|
-
await plugin.destroy(ctx);
|
|
100
|
-
}
|
|
101
|
-
catch (err) {
|
|
102
|
-
this.eventBus.emit('error', { plugin: plugin.name, error: err });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=plugin.js.map
|
package/es/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,OAAO,aAAa;IAKxB,YAAY,QAA+B;QAJ1B,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC9C,gBAAW,GAAqB,IAAI,CAAC;QAI3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,MAAe;QACtB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,yBAAyB,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,CAAC,IAAI,+BAA+B,CAC3E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,wBAAwB;QACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,C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C;YAC7B,IAAI,CAAC,MAAM,CAAC,OAAO;gBAAE,SAAS;YAC9B,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/es/types.js
DELETED
package/es/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|