@compas-oscd/open-scd 0.34.17 → 0.34.18
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/dist/WizardDivider.d.ts +8 -8
- package/dist/WizardDivider.js +26 -26
- package/dist/Wizarding.js +36 -36
- package/dist/Wizarding.js.map +1 -1
- package/dist/action-icon.d.ts +25 -25
- package/dist/action-icon.js +51 -51
- package/dist/action-pane.d.ts +25 -25
- package/dist/action-pane.js +86 -86
- package/dist/addons/Editor.d.ts +25 -25
- package/dist/addons/Editor.js +105 -105
- package/dist/addons/Editor.js.map +1 -1
- package/dist/addons/History.d.ts +86 -93
- package/dist/addons/History.js +301 -302
- package/dist/addons/History.js.map +1 -1
- package/dist/addons/Layout.d.ts +96 -96
- package/dist/addons/Layout.js +448 -448
- package/dist/addons/Layout.js.map +1 -1
- package/dist/addons/Settings.d.ts +68 -68
- package/dist/addons/Settings.js +272 -272
- package/dist/addons/Settings.js.map +1 -1
- package/dist/addons/Waiter.d.ts +14 -14
- package/dist/addons/Waiter.js +40 -40
- package/dist/addons/Waiter.js.map +1 -1
- package/dist/addons/Wizards.d.ts +15 -15
- package/dist/addons/Wizards.js +46 -46
- package/dist/addons/editor/edit-action-to-v1-converter.d.ts +3 -3
- package/dist/addons/editor/edit-action-to-v1-converter.js +95 -95
- package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -1
- package/dist/addons/editor/edit-v1-to-v2-converter.d.ts +2 -2
- package/dist/addons/editor/edit-v1-to-v2-converter.js +36 -36
- package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -1
- package/dist/addons/history/get-log-text.d.ts +5 -5
- package/dist/addons/history/get-log-text.js +25 -25
- package/dist/addons/history/get-log-text.js.map +1 -1
- package/dist/addons/menu-tabs/menu-tabs.d.ts +22 -22
- package/dist/addons/menu-tabs/menu-tabs.js +59 -59
- package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts +28 -28
- package/dist/addons/plugin-manager/custom-plugin-dialog.js +71 -71
- package/dist/addons/plugin-manager/plugin-manager.d.ts +20 -20
- package/dist/addons/plugin-manager/plugin-manager.js +77 -77
- package/dist/core/api/api.js +7 -0
- package/dist/core/api/api.js.map +1 -0
- package/dist/core/api/editor/subject.js +22 -0
- package/dist/core/api/editor/subject.js.map +1 -0
- package/dist/core/api/editor/xml-editor.js +82 -0
- package/dist/core/api/editor/xml-editor.js.map +1 -0
- package/dist/core/api/plugin-state-api.js +27 -0
- package/dist/core/api/plugin-state-api.js.map +1 -0
- package/dist/core/foundation/cyrb64.js +26 -0
- package/dist/core/foundation/cyrb64.js.map +1 -0
- package/dist/core/foundation/deprecated/edit-event.js +44 -0
- package/dist/core/foundation/deprecated/edit-event.js.map +1 -0
- package/dist/core/foundation/deprecated/editor.js +94 -0
- package/dist/core/foundation/deprecated/editor.js.map +1 -0
- package/dist/core/foundation/deprecated/history.js +17 -0
- package/dist/core/foundation/deprecated/history.js.map +1 -0
- package/dist/core/foundation/deprecated/open-event.js +9 -0
- package/dist/core/foundation/deprecated/open-event.js.map +1 -0
- package/dist/core/foundation/deprecated/settings.js +19 -0
- package/dist/core/foundation/deprecated/settings.js.map +1 -0
- package/dist/core/foundation/deprecated/validation.js +8 -0
- package/dist/core/foundation/deprecated/validation.js.map +1 -0
- package/dist/core/foundation/deprecated/waiter.js +12 -0
- package/dist/core/foundation/deprecated/waiter.js.map +1 -0
- package/dist/core/foundation/edit-completed-event.js +11 -0
- package/dist/core/foundation/edit-completed-event.js.map +1 -0
- package/dist/core/foundation/edit-event.js +8 -0
- package/dist/core/foundation/edit-event.js.map +1 -0
- package/dist/core/foundation/edit.js +31 -0
- package/dist/core/foundation/edit.js.map +1 -0
- package/dist/core/foundation/handle-edit.js +151 -0
- package/dist/core/foundation/handle-edit.js.map +1 -0
- package/dist/core/foundation/open-event.js +8 -0
- package/dist/core/foundation/open-event.js.map +1 -0
- package/dist/core/foundation/plugin.js +2 -0
- package/dist/core/foundation/plugin.js.map +1 -0
- package/dist/core/foundation.js +14 -0
- package/dist/core/foundation.js.map +1 -0
- package/dist/core/locales.js +21 -0
- package/dist/core/locales.js.map +1 -0
- package/dist/filtered-list.d.ts +27 -27
- package/dist/filtered-list.js +118 -118
- package/dist/finder-list.d.ts +37 -37
- package/dist/finder-list.js +153 -153
- package/dist/foundation/compare.d.ts +79 -79
- package/dist/foundation/compare.js +216 -216
- package/dist/foundation/dai.d.ts +30 -30
- package/dist/foundation/dai.js +126 -126
- package/dist/foundation/generators.d.ts +13 -13
- package/dist/foundation/generators.js +66 -66
- package/dist/foundation/ied.d.ts +22 -22
- package/dist/foundation/ied.js +83 -83
- package/dist/foundation/ied.js.map +1 -1
- package/dist/foundation/nsd.d.ts +4 -4
- package/dist/foundation/nsd.js +12 -12
- package/dist/foundation/nsdoc.d.ts +14 -14
- package/dist/foundation/nsdoc.js +178 -178
- package/dist/foundation/scl.d.ts +1 -1
- package/dist/foundation/scl.js +63 -63
- package/dist/foundation.d.ts +230 -230
- package/dist/foundation.js +1921 -1921
- package/dist/foundation.js.map +1 -1
- package/dist/icons/compare.d.ts +3 -3
- package/dist/icons/compare.js +4 -4
- package/dist/icons/icons.d.ts +41 -41
- package/dist/icons/icons.js +92 -92
- package/dist/icons/ied-icons.d.ts +3 -3
- package/dist/icons/ied-icons.js +4 -4
- package/dist/icons/lnode.d.ts +16 -16
- package/dist/icons/lnode.js +17 -17
- package/dist/open-scd.d.ts +131 -131
- package/dist/open-scd.js +438 -438
- package/dist/open-scd.js.map +1 -1
- package/dist/openscd/src/WizardDivider.js +37 -0
- package/dist/openscd/src/WizardDivider.js.map +1 -0
- package/dist/openscd/src/Wizarding.js +38 -0
- package/dist/openscd/src/Wizarding.js.map +1 -0
- package/dist/openscd/src/action-icon.js +220 -0
- package/dist/openscd/src/action-icon.js.map +1 -0
- package/dist/openscd/src/action-pane.js +176 -0
- package/dist/openscd/src/action-pane.js.map +1 -0
- package/dist/openscd/src/addons/Editor.js +106 -0
- package/dist/openscd/src/addons/Editor.js.map +1 -0
- package/dist/openscd/src/addons/History.js +490 -0
- package/dist/openscd/src/addons/History.js.map +1 -0
- package/dist/openscd/src/addons/Layout.js +619 -0
- package/dist/openscd/src/addons/Layout.js.map +1 -0
- package/dist/openscd/src/addons/Settings.js +465 -0
- package/dist/openscd/src/addons/Settings.js.map +1 -0
- package/dist/openscd/src/addons/Waiter.js +45 -0
- package/dist/openscd/src/addons/Waiter.js.map +1 -0
- package/dist/openscd/src/addons/Wizards.js +48 -0
- package/dist/openscd/src/addons/Wizards.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +96 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
- package/dist/openscd/src/addons/history/get-log-text.js +26 -0
- package/dist/openscd/src/addons/history/get-log-text.js.map +1 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +74 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +165 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +1 -0
- package/dist/openscd/src/filtered-list.js +168 -0
- package/dist/openscd/src/filtered-list.js.map +1 -0
- package/dist/openscd/src/finder-list.js +207 -0
- package/dist/openscd/src/finder-list.js.map +1 -0
- package/dist/openscd/src/foundation/compare.js +273 -0
- package/dist/openscd/src/foundation/compare.js.map +1 -0
- package/dist/openscd/src/foundation/dai.js +127 -0
- package/dist/openscd/src/foundation/dai.js.map +1 -0
- package/dist/openscd/src/foundation/generators.js +67 -0
- package/dist/openscd/src/foundation/generators.js.map +1 -0
- package/dist/openscd/src/foundation/ied.js +84 -0
- package/dist/openscd/src/foundation/ied.js.map +1 -0
- package/dist/openscd/src/foundation/nsd.js +13 -0
- package/dist/openscd/src/foundation/nsd.js.map +1 -0
- package/dist/openscd/src/foundation/nsdoc.js +180 -0
- package/dist/openscd/src/foundation/nsdoc.js.map +1 -0
- package/dist/openscd/src/foundation/scl.js +64 -0
- package/dist/openscd/src/foundation/scl.js.map +1 -0
- package/dist/openscd/src/foundation.js +1922 -0
- package/dist/openscd/src/foundation.js.map +1 -0
- package/dist/openscd/src/icons/compare.js +11 -0
- package/dist/openscd/src/icons/compare.js.map +1 -0
- package/dist/openscd/src/icons/icons.js +611 -0
- package/dist/openscd/src/icons/icons.js.map +1 -0
- package/dist/openscd/src/icons/ied-icons.js +11 -0
- package/dist/openscd/src/icons/ied-icons.js.map +1 -0
- package/dist/openscd/src/icons/lnode.js +50 -0
- package/dist/openscd/src/icons/lnode.js.map +1 -0
- package/dist/openscd/src/open-scd.js +483 -0
- package/dist/openscd/src/open-scd.js.map +1 -0
- package/dist/openscd/src/oscd-filter-button.js +89 -0
- package/dist/openscd/src/oscd-filter-button.js.map +1 -0
- package/dist/openscd/src/plain-compare-list.js +132 -0
- package/dist/openscd/src/plain-compare-list.js.map +1 -0
- package/dist/openscd/src/plugin-tag.js +23 -0
- package/dist/openscd/src/plugin-tag.js.map +1 -0
- package/dist/openscd/src/plugin.events.js +12 -0
- package/dist/openscd/src/plugin.events.js.map +1 -0
- package/dist/openscd/src/plugin.js +2 -0
- package/dist/openscd/src/plugin.js.map +1 -0
- package/dist/openscd/src/plugins.js +256 -0
- package/dist/openscd/src/plugins.js.map +1 -0
- package/dist/openscd/src/schemas.js +9325 -0
- package/dist/openscd/src/schemas.js.map +1 -0
- package/dist/openscd/src/themes.js +122 -0
- package/dist/openscd/src/themes.js.map +1 -0
- package/dist/openscd/src/translations/de.js +954 -0
- package/dist/openscd/src/translations/de.js.map +1 -0
- package/dist/openscd/src/translations/en.js +950 -0
- package/dist/openscd/src/translations/en.js.map +1 -0
- package/dist/openscd/src/translations/loader.js +10 -0
- package/dist/openscd/src/translations/loader.js.map +1 -0
- package/dist/openscd/src/wizard-checkbox.js +152 -0
- package/dist/openscd/src/wizard-checkbox.js.map +1 -0
- package/dist/openscd/src/wizard-dialog.js +374 -0
- package/dist/openscd/src/wizard-dialog.js.map +1 -0
- package/dist/openscd/src/wizard-select.js +115 -0
- package/dist/openscd/src/wizard-select.js.map +1 -0
- package/dist/openscd/src/wizard-textfield.js +191 -0
- package/dist/openscd/src/wizard-textfield.js.map +1 -0
- package/dist/openscd/src/wizards.js +196 -0
- package/dist/openscd/src/wizards.js.map +1 -0
- package/dist/oscd-filter-button.d.ts +27 -27
- package/dist/oscd-filter-button.js +59 -59
- package/dist/plain-compare-list.d.ts +36 -36
- package/dist/plain-compare-list.js +70 -70
- package/dist/plugin-tag.d.ts +6 -6
- package/dist/plugin-tag.js +22 -22
- package/dist/plugin.d.ts +23 -23
- package/dist/plugin.events.d.ts +15 -15
- package/dist/plugin.events.js +11 -11
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +255 -255
- package/dist/schemas.d.ts +58 -58
- package/dist/schemas.js +59 -59
- package/dist/themes.d.ts +3 -3
- package/dist/themes.js +13 -13
- package/dist/themes.js.map +1 -1
- package/dist/translations/de.d.ts +2 -2
- package/dist/translations/de.js +952 -952
- package/dist/translations/en.d.ts +963 -963
- package/dist/translations/en.js +948 -948
- package/dist/translations/loader.d.ts +12 -12
- package/dist/translations/loader.js +9 -9
- package/dist/translations/loader.js.map +1 -1
- package/dist/wizard-checkbox.d.ts +37 -37
- package/dist/wizard-checkbox.js +130 -130
- package/dist/wizard-dialog.d.ts +45 -45
- package/dist/wizard-dialog.js +235 -235
- package/dist/wizard-dialog.js.map +1 -1
- package/dist/wizard-select.d.ts +31 -31
- package/dist/wizard-select.js +102 -102
- package/dist/wizard-textfield.d.ts +50 -50
- package/dist/wizard-textfield.js +162 -162
- package/dist/wizards.d.ts +23 -23
- package/dist/wizards.js +148 -148
- package/dist/wizards.js.map +1 -1
- package/dist/xml/src/foundation.js +67 -0
- package/dist/xml/src/foundation.js.map +1 -0
- package/dist/xml/src/index.js +2 -0
- package/dist/xml/src/index.js.map +1 -0
- package/package.json +29 -127
- package/dist/Wizarding.d.ts +0 -10
package/dist/open-scd.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { customElement, html, LitElement, property, state, } from 'lit-element';
|
|
3
|
-
import { classMap } from 'lit-html/directives/class-map';
|
|
4
|
-
import '@material/mwc-icon';
|
|
5
|
-
import '@material/mwc-icon-button';
|
|
6
|
-
import '@material/mwc-linear-progress';
|
|
7
|
-
import '@material/mwc-list';
|
|
8
|
-
import '@material/mwc-list/mwc-list-item';
|
|
9
|
-
import '@material/mwc-tab';
|
|
10
|
-
import '@material/mwc-tab-bar';
|
|
11
|
-
import '@material/mwc-top-app-bar-fixed';
|
|
12
|
-
import '@material/mwc-drawer';
|
|
13
|
-
import '@material/mwc-button';
|
|
14
|
-
import '@material/mwc-dialog';
|
|
15
|
-
import '@material/mwc-formfield';
|
|
16
|
-
import '@material/mwc-list/mwc-check-list-item';
|
|
17
|
-
import '@material/mwc-list/mwc-radio-list-item';
|
|
18
|
-
import '@material/mwc-select';
|
|
19
|
-
import '@material/mwc-switch';
|
|
20
|
-
import '@material/mwc-textfield';
|
|
21
|
-
import { newOpenDocEvent } from '@
|
|
22
|
-
import { newPendingStateEvent } from '@
|
|
23
|
-
import './addons/Settings.js';
|
|
24
|
-
import './addons/Waiter.js';
|
|
25
|
-
import './addons/Wizards.js';
|
|
26
|
-
import './addons/Editor.js';
|
|
27
|
-
import './addons/History.js';
|
|
28
|
-
import './addons/Layout.js';
|
|
29
|
-
import { officialPlugins as builtinPlugins } from './plugins.js';
|
|
30
|
-
import { initializeNsdoc } from './foundation/nsdoc.js';
|
|
31
|
-
import { OscdApi, XMLEditor } from '@
|
|
32
|
-
import { newConfigurePluginEvent } from './plugin.events.js';
|
|
33
|
-
import { newLogEvent } from '@
|
|
34
|
-
import { pluginTag } from './plugin-tag.js';
|
|
35
|
-
/** The `<open-scd>` custom element is the main entry point of the
|
|
36
|
-
* Open Substation Configuration Designer. */
|
|
37
|
-
let OpenSCD = class OpenSCD extends LitElement {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(...arguments);
|
|
40
|
-
this.doc = null;
|
|
41
|
-
/** The name of the current [[`doc`]] */
|
|
42
|
-
this.docName = '';
|
|
43
|
-
/** The UUID of the current [[`doc`]] */
|
|
44
|
-
this.docId = '';
|
|
45
|
-
this.editor = new XMLEditor();
|
|
46
|
-
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
|
|
47
|
-
this.nsdoc = initializeNsdoc();
|
|
48
|
-
this.currentSrc = '';
|
|
49
|
-
this.storedPlugins = [];
|
|
50
|
-
this.editCount = -1;
|
|
51
|
-
this.unsubscribers = [];
|
|
52
|
-
/**
|
|
53
|
-
* @prop {PluginSet} plugins - Set of plugins that are used by OpenSCD
|
|
54
|
-
*/
|
|
55
|
-
this.plugins = { menu: [], editor: [] };
|
|
56
|
-
this.loadedPlugins = new Set();
|
|
57
|
-
// PLUGGING INTERFACES
|
|
58
|
-
this.pluginTags = new Map();
|
|
59
|
-
}
|
|
60
|
-
render() {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement, html, LitElement, property, state, } from 'lit-element';
|
|
3
|
+
import { classMap } from 'lit-html/directives/class-map';
|
|
4
|
+
import '@material/mwc-icon';
|
|
5
|
+
import '@material/mwc-icon-button';
|
|
6
|
+
import '@material/mwc-linear-progress';
|
|
7
|
+
import '@material/mwc-list';
|
|
8
|
+
import '@material/mwc-list/mwc-list-item';
|
|
9
|
+
import '@material/mwc-tab';
|
|
10
|
+
import '@material/mwc-tab-bar';
|
|
11
|
+
import '@material/mwc-top-app-bar-fixed';
|
|
12
|
+
import '@material/mwc-drawer';
|
|
13
|
+
import '@material/mwc-button';
|
|
14
|
+
import '@material/mwc-dialog';
|
|
15
|
+
import '@material/mwc-formfield';
|
|
16
|
+
import '@material/mwc-list/mwc-check-list-item';
|
|
17
|
+
import '@material/mwc-list/mwc-radio-list-item';
|
|
18
|
+
import '@material/mwc-select';
|
|
19
|
+
import '@material/mwc-switch';
|
|
20
|
+
import '@material/mwc-textfield';
|
|
21
|
+
import { newOpenDocEvent } from '@openscd/core/foundation/deprecated/open-event.js';
|
|
22
|
+
import { newPendingStateEvent } from '@openscd/core/foundation/deprecated/waiter.js';
|
|
23
|
+
import './addons/Settings.js';
|
|
24
|
+
import './addons/Waiter.js';
|
|
25
|
+
import './addons/Wizards.js';
|
|
26
|
+
import './addons/Editor.js';
|
|
27
|
+
import './addons/History.js';
|
|
28
|
+
import './addons/Layout.js';
|
|
29
|
+
import { officialPlugins as builtinPlugins } from './plugins.js';
|
|
30
|
+
import { initializeNsdoc } from './foundation/nsdoc.js';
|
|
31
|
+
import { OscdApi, XMLEditor } from '@openscd/core';
|
|
32
|
+
import { newConfigurePluginEvent } from './plugin.events.js';
|
|
33
|
+
import { newLogEvent } from '@openscd/core/foundation/deprecated/history';
|
|
34
|
+
import { pluginTag } from './plugin-tag.js';
|
|
35
|
+
/** The `<open-scd>` custom element is the main entry point of the
|
|
36
|
+
* Open Substation Configuration Designer. */
|
|
37
|
+
let OpenSCD = class OpenSCD extends LitElement {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.doc = null;
|
|
41
|
+
/** The name of the current [[`doc`]] */
|
|
42
|
+
this.docName = '';
|
|
43
|
+
/** The UUID of the current [[`doc`]] */
|
|
44
|
+
this.docId = '';
|
|
45
|
+
this.editor = new XMLEditor();
|
|
46
|
+
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
|
|
47
|
+
this.nsdoc = initializeNsdoc();
|
|
48
|
+
this.currentSrc = '';
|
|
49
|
+
this.storedPlugins = [];
|
|
50
|
+
this.editCount = -1;
|
|
51
|
+
this.unsubscribers = [];
|
|
52
|
+
/**
|
|
53
|
+
* @prop {PluginSet} plugins - Set of plugins that are used by OpenSCD
|
|
54
|
+
*/
|
|
55
|
+
this.plugins = { menu: [], editor: [] };
|
|
56
|
+
this.loadedPlugins = new Set();
|
|
57
|
+
// PLUGGING INTERFACES
|
|
58
|
+
this.pluginTags = new Map();
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
61
|
return html `<oscd-waiter>
|
|
62
62
|
<oscd-settings .host=${this}>
|
|
63
63
|
<oscd-wizards .host=${this}>
|
|
@@ -89,258 +89,258 @@ let OpenSCD = class OpenSCD extends LitElement {
|
|
|
89
89
|
</oscd-history>
|
|
90
90
|
</oscd-wizards>
|
|
91
91
|
</oscd-settings>
|
|
92
|
-
</oscd-waiter>`;
|
|
93
|
-
}
|
|
94
|
-
/** The current file's URL. `blob:` URLs are *revoked after parsing*! */
|
|
95
|
-
get src() {
|
|
96
|
-
return this.currentSrc;
|
|
97
|
-
}
|
|
98
|
-
set src(value) {
|
|
99
|
-
this.currentSrc = value;
|
|
100
|
-
this.dispatchEvent(newPendingStateEvent(this.loadDoc(value)));
|
|
101
|
-
}
|
|
102
|
-
/** Loads and parses an `XMLDocument` after [[`src`]] has changed. */
|
|
103
|
-
async loadDoc(src) {
|
|
104
|
-
const response = await fetch(src);
|
|
105
|
-
const text = await response.text();
|
|
106
|
-
if (!text)
|
|
107
|
-
return;
|
|
108
|
-
const doc = new DOMParser().parseFromString(text, 'application/xml');
|
|
109
|
-
const docName = src;
|
|
110
|
-
this.dispatchEvent(newOpenDocEvent(doc, docName));
|
|
111
|
-
if (src.startsWith('blob:'))
|
|
112
|
-
URL.revokeObjectURL(src);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @deprecated Use `handleConfigurationPluginEvent` instead
|
|
117
|
-
*/
|
|
118
|
-
handleAddExternalPlugin(e) {
|
|
119
|
-
this.addExternalPlugin(e.detail.plugin);
|
|
120
|
-
const { name, kind } = e.detail.plugin;
|
|
121
|
-
const event = newConfigurePluginEvent(name, kind, e.detail.plugin);
|
|
122
|
-
this.handleConfigurationPluginEvent(event);
|
|
123
|
-
}
|
|
124
|
-
handleConfigurationPluginEvent(e) {
|
|
125
|
-
const { name, kind, config } = e.detail;
|
|
126
|
-
const hasPlugin = this.hasPlugin(name, kind);
|
|
127
|
-
const hasConfig = config !== null;
|
|
128
|
-
const isChangeEvent = hasPlugin && hasConfig;
|
|
129
|
-
const isRemoveEvent = hasPlugin && !hasConfig;
|
|
130
|
-
const isAddEvent = !hasPlugin && hasConfig;
|
|
131
|
-
// the `&& config`is only because typescript
|
|
132
|
-
// cannot infer that `isChangeEvent` and `isAddEvent` implies `config !== null`
|
|
133
|
-
if (isChangeEvent && config) {
|
|
134
|
-
this.changePlugin(config);
|
|
135
|
-
}
|
|
136
|
-
else if (isRemoveEvent) {
|
|
137
|
-
this.removePlugin(name, kind);
|
|
138
|
-
}
|
|
139
|
-
else if (isAddEvent && config) {
|
|
140
|
-
this.addPlugin(config);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
const event = newLogEvent({
|
|
144
|
-
kind: "error",
|
|
145
|
-
title: "Invalid plugin configuration event",
|
|
146
|
-
message: JSON.stringify({ name, kind, config }),
|
|
147
|
-
});
|
|
148
|
-
this.dispatchEvent(event);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
connectedCallback() {
|
|
152
|
-
super.connectedCallback();
|
|
153
|
-
this.loadPlugins();
|
|
154
|
-
this.unsubscribers.push(this.editor.subscribe(e => this.editCount++), this.editor.subscribeUndoRedo(e => this.editCount++));
|
|
155
|
-
// TODO: let Lit handle the event listeners, move to render()
|
|
156
|
-
this.addEventListener('reset-plugins', this.resetPlugins);
|
|
157
|
-
}
|
|
158
|
-
disconnectedCallback() {
|
|
159
|
-
this.unsubscribers.forEach(u => u());
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
*
|
|
163
|
-
* @param name
|
|
164
|
-
* @param kind
|
|
165
|
-
* @returns the index of the plugin in the stored plugin list
|
|
166
|
-
*/
|
|
167
|
-
findPluginIndex(name, kind) {
|
|
168
|
-
return this.storedPlugins.findIndex(p => p.name === name && p.kind === kind);
|
|
169
|
-
}
|
|
170
|
-
hasPlugin(name, kind) {
|
|
171
|
-
return this.findPluginIndex(name, kind) > -1;
|
|
172
|
-
}
|
|
173
|
-
removePlugin(name, kind) {
|
|
174
|
-
const newPlugins = this.storedPlugins.filter(p => p.name !== name || p.kind !== kind);
|
|
175
|
-
this.updateStoredPlugins(newPlugins);
|
|
176
|
-
}
|
|
177
|
-
addPlugin(plugin) {
|
|
178
|
-
const newPlugins = [...this.storedPlugins, plugin];
|
|
179
|
-
this.updateStoredPlugins(newPlugins);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
*
|
|
183
|
-
* @param plugin
|
|
184
|
-
* @throws if the plugin is not found
|
|
185
|
-
*/
|
|
186
|
-
changePlugin(plugin) {
|
|
187
|
-
const storedPlugins = this.storedPlugins;
|
|
188
|
-
const { name, kind } = plugin;
|
|
189
|
-
const pluginIndex = this.findPluginIndex(name, kind);
|
|
190
|
-
if (pluginIndex < 0) {
|
|
191
|
-
const event = newLogEvent({
|
|
192
|
-
kind: "error",
|
|
193
|
-
title: "Plugin not found, stopping change process",
|
|
194
|
-
message: JSON.stringify({ name, kind }),
|
|
195
|
-
});
|
|
196
|
-
this.dispatchEvent(event);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const pluginToChange = storedPlugins[pluginIndex];
|
|
200
|
-
const changedPlugin = { ...pluginToChange, ...plugin };
|
|
201
|
-
const newPlugins = [...storedPlugins];
|
|
202
|
-
newPlugins.splice(pluginIndex, 1, changedPlugin);
|
|
203
|
-
// this.storePlugins(newPlugins);
|
|
204
|
-
this.updateStoredPlugins(newPlugins);
|
|
205
|
-
}
|
|
206
|
-
resetPlugins() {
|
|
207
|
-
const builtInPlugins = this.getBuiltInPlugins();
|
|
208
|
-
const allPlugins = [...builtInPlugins, ...this.parsedPlugins];
|
|
209
|
-
const newPluginConfigs = allPlugins.map(plugin => {
|
|
210
|
-
return {
|
|
211
|
-
...plugin,
|
|
212
|
-
active: plugin.activeByDefault ?? false,
|
|
213
|
-
};
|
|
214
|
-
});
|
|
215
|
-
this.storePlugins(newPluginConfigs);
|
|
216
|
-
}
|
|
217
|
-
get parsedPlugins() {
|
|
218
|
-
const menuPlugins = this.plugins.menu.map((plugin) => {
|
|
219
|
-
let newPosition = plugin.position;
|
|
220
|
-
if (typeof plugin.position === 'number') {
|
|
221
|
-
newPosition = undefined;
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
...plugin,
|
|
225
|
-
position: newPosition,
|
|
226
|
-
kind: 'menu',
|
|
227
|
-
active: plugin.active ?? false,
|
|
228
|
-
};
|
|
229
|
-
});
|
|
230
|
-
const editorPlugins = this.plugins.editor.map((plugin) => {
|
|
231
|
-
const editorPlugin = {
|
|
232
|
-
...plugin,
|
|
233
|
-
position: undefined,
|
|
234
|
-
kind: 'editor',
|
|
235
|
-
active: plugin.active ?? false,
|
|
236
|
-
};
|
|
237
|
-
return editorPlugin;
|
|
238
|
-
});
|
|
239
|
-
const allPlugnis = [...menuPlugins, ...editorPlugins];
|
|
240
|
-
return allPlugnis;
|
|
241
|
-
}
|
|
242
|
-
updateStoredPlugins(newPlugins) {
|
|
243
|
-
//
|
|
244
|
-
// Generate content of each plugin
|
|
245
|
-
//
|
|
246
|
-
const plugins = newPlugins.map(plugin => {
|
|
247
|
-
const isInstalled = plugin.src && plugin.active;
|
|
248
|
-
if (!isInstalled) {
|
|
249
|
-
return plugin;
|
|
250
|
-
}
|
|
251
|
-
return this.addContent(plugin);
|
|
252
|
-
});
|
|
253
|
-
//
|
|
254
|
-
// Merge built-in plugins
|
|
255
|
-
//
|
|
256
|
-
const mergedPlugins = plugins.map(plugin => {
|
|
257
|
-
const isBuiltIn = !plugin?.official;
|
|
258
|
-
if (!isBuiltIn) {
|
|
259
|
-
return plugin;
|
|
260
|
-
}
|
|
261
|
-
;
|
|
262
|
-
const builtInPlugin = [...this.getBuiltInPlugins(), ...this.parsedPlugins]
|
|
263
|
-
.find(p => p.src === plugin.src);
|
|
264
|
-
return {
|
|
265
|
-
...builtInPlugin,
|
|
266
|
-
...plugin,
|
|
267
|
-
};
|
|
268
|
-
});
|
|
269
|
-
this.storePlugins(mergedPlugins);
|
|
270
|
-
}
|
|
271
|
-
storePlugins(plugins) {
|
|
272
|
-
this.storedPlugins = plugins;
|
|
273
|
-
const pluginConfigs = JSON.stringify(plugins.map(withoutContent));
|
|
274
|
-
localStorage.setItem('plugins', pluginConfigs);
|
|
275
|
-
}
|
|
276
|
-
getPluginConfigsFromLocalStorage() {
|
|
277
|
-
const pluginsConfigStr = localStorage.getItem('plugins') ?? '[]';
|
|
278
|
-
return JSON.parse(pluginsConfigStr);
|
|
279
|
-
}
|
|
280
|
-
get locale() {
|
|
281
|
-
return navigator.language || 'en-US';
|
|
282
|
-
}
|
|
283
|
-
get docs() {
|
|
284
|
-
const docs = {};
|
|
285
|
-
if (this.doc) {
|
|
286
|
-
docs[this.docName] = this.doc;
|
|
287
|
-
}
|
|
288
|
-
return docs;
|
|
289
|
-
}
|
|
290
|
-
setPlugins(selectedPlugins) {
|
|
291
|
-
const newPlugins = this.storedPlugins.map((storedPlugin) => {
|
|
292
|
-
const isSelected = selectedPlugins.some((selectedPlugin) => {
|
|
293
|
-
return selectedPlugin.name === storedPlugin.name
|
|
294
|
-
&& selectedPlugin.src === storedPlugin.src;
|
|
295
|
-
});
|
|
296
|
-
return {
|
|
297
|
-
...storedPlugin,
|
|
298
|
-
active: isSelected
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
this.updateStoredPlugins(newPlugins);
|
|
302
|
-
}
|
|
303
|
-
loadPlugins() {
|
|
304
|
-
const localPluginConfigs = this.getPluginConfigsFromLocalStorage();
|
|
305
|
-
const overwritesOfBultInPlugins = localPluginConfigs.filter((p) => {
|
|
306
|
-
return this.getBuiltInPlugins().some(b => b.src === p.src);
|
|
307
|
-
});
|
|
308
|
-
const userInstalledPlugins = localPluginConfigs.filter((p) => {
|
|
309
|
-
return !this.getBuiltInPlugins().some(b => b.src === p.src);
|
|
310
|
-
});
|
|
311
|
-
const mergedBuiltInPlugins = this.getBuiltInPlugins().map((builtInPlugin) => {
|
|
312
|
-
let overwrite = overwritesOfBultInPlugins.find(p => p.src === builtInPlugin.src);
|
|
313
|
-
const mergedPlugin = {
|
|
314
|
-
...builtInPlugin,
|
|
315
|
-
...overwrite,
|
|
316
|
-
active: overwrite?.active ?? builtInPlugin.activeByDefault,
|
|
317
|
-
};
|
|
318
|
-
return mergedPlugin;
|
|
319
|
-
});
|
|
320
|
-
const mergedPlugins = [...mergedBuiltInPlugins, ...userInstalledPlugins];
|
|
321
|
-
this.updateStoredPlugins(mergedPlugins);
|
|
322
|
-
}
|
|
323
|
-
async addExternalPlugin(plugin) {
|
|
324
|
-
if (this.storedPlugins.some(p => p.src === plugin.src))
|
|
325
|
-
return;
|
|
326
|
-
const newPlugins = this.storedPlugins;
|
|
327
|
-
newPlugins.push(plugin);
|
|
328
|
-
this.storePlugins(newPlugins);
|
|
329
|
-
}
|
|
330
|
-
getBuiltInPlugins() {
|
|
331
|
-
return builtinPlugins;
|
|
332
|
-
}
|
|
333
|
-
addContent(plugin) {
|
|
334
|
-
const tag = this.pluginTag(plugin.src);
|
|
335
|
-
if (!this.loadedPlugins.has(tag)) {
|
|
336
|
-
this.loadedPlugins.add(tag);
|
|
337
|
-
import(plugin.src).then((mod) => {
|
|
338
|
-
customElements.define(tag, mod.default);
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
...plugin,
|
|
343
|
-
content: () => {
|
|
92
|
+
</oscd-waiter>`;
|
|
93
|
+
}
|
|
94
|
+
/** The current file's URL. `blob:` URLs are *revoked after parsing*! */
|
|
95
|
+
get src() {
|
|
96
|
+
return this.currentSrc;
|
|
97
|
+
}
|
|
98
|
+
set src(value) {
|
|
99
|
+
this.currentSrc = value;
|
|
100
|
+
this.dispatchEvent(newPendingStateEvent(this.loadDoc(value)));
|
|
101
|
+
}
|
|
102
|
+
/** Loads and parses an `XMLDocument` after [[`src`]] has changed. */
|
|
103
|
+
async loadDoc(src) {
|
|
104
|
+
const response = await fetch(src);
|
|
105
|
+
const text = await response.text();
|
|
106
|
+
if (!text)
|
|
107
|
+
return;
|
|
108
|
+
const doc = new DOMParser().parseFromString(text, 'application/xml');
|
|
109
|
+
const docName = src;
|
|
110
|
+
this.dispatchEvent(newOpenDocEvent(doc, docName));
|
|
111
|
+
if (src.startsWith('blob:'))
|
|
112
|
+
URL.revokeObjectURL(src);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @deprecated Use `handleConfigurationPluginEvent` instead
|
|
117
|
+
*/
|
|
118
|
+
handleAddExternalPlugin(e) {
|
|
119
|
+
this.addExternalPlugin(e.detail.plugin);
|
|
120
|
+
const { name, kind } = e.detail.plugin;
|
|
121
|
+
const event = newConfigurePluginEvent(name, kind, e.detail.plugin);
|
|
122
|
+
this.handleConfigurationPluginEvent(event);
|
|
123
|
+
}
|
|
124
|
+
handleConfigurationPluginEvent(e) {
|
|
125
|
+
const { name, kind, config } = e.detail;
|
|
126
|
+
const hasPlugin = this.hasPlugin(name, kind);
|
|
127
|
+
const hasConfig = config !== null;
|
|
128
|
+
const isChangeEvent = hasPlugin && hasConfig;
|
|
129
|
+
const isRemoveEvent = hasPlugin && !hasConfig;
|
|
130
|
+
const isAddEvent = !hasPlugin && hasConfig;
|
|
131
|
+
// the `&& config`is only because typescript
|
|
132
|
+
// cannot infer that `isChangeEvent` and `isAddEvent` implies `config !== null`
|
|
133
|
+
if (isChangeEvent && config) {
|
|
134
|
+
this.changePlugin(config);
|
|
135
|
+
}
|
|
136
|
+
else if (isRemoveEvent) {
|
|
137
|
+
this.removePlugin(name, kind);
|
|
138
|
+
}
|
|
139
|
+
else if (isAddEvent && config) {
|
|
140
|
+
this.addPlugin(config);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const event = newLogEvent({
|
|
144
|
+
kind: "error",
|
|
145
|
+
title: "Invalid plugin configuration event",
|
|
146
|
+
message: JSON.stringify({ name, kind, config }),
|
|
147
|
+
});
|
|
148
|
+
this.dispatchEvent(event);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
connectedCallback() {
|
|
152
|
+
super.connectedCallback();
|
|
153
|
+
this.loadPlugins();
|
|
154
|
+
this.unsubscribers.push(this.editor.subscribe(e => this.editCount++), this.editor.subscribeUndoRedo(e => this.editCount++));
|
|
155
|
+
// TODO: let Lit handle the event listeners, move to render()
|
|
156
|
+
this.addEventListener('reset-plugins', this.resetPlugins);
|
|
157
|
+
}
|
|
158
|
+
disconnectedCallback() {
|
|
159
|
+
this.unsubscribers.forEach(u => u());
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* @param name
|
|
164
|
+
* @param kind
|
|
165
|
+
* @returns the index of the plugin in the stored plugin list
|
|
166
|
+
*/
|
|
167
|
+
findPluginIndex(name, kind) {
|
|
168
|
+
return this.storedPlugins.findIndex(p => p.name === name && p.kind === kind);
|
|
169
|
+
}
|
|
170
|
+
hasPlugin(name, kind) {
|
|
171
|
+
return this.findPluginIndex(name, kind) > -1;
|
|
172
|
+
}
|
|
173
|
+
removePlugin(name, kind) {
|
|
174
|
+
const newPlugins = this.storedPlugins.filter(p => p.name !== name || p.kind !== kind);
|
|
175
|
+
this.updateStoredPlugins(newPlugins);
|
|
176
|
+
}
|
|
177
|
+
addPlugin(plugin) {
|
|
178
|
+
const newPlugins = [...this.storedPlugins, plugin];
|
|
179
|
+
this.updateStoredPlugins(newPlugins);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @param plugin
|
|
184
|
+
* @throws if the plugin is not found
|
|
185
|
+
*/
|
|
186
|
+
changePlugin(plugin) {
|
|
187
|
+
const storedPlugins = this.storedPlugins;
|
|
188
|
+
const { name, kind } = plugin;
|
|
189
|
+
const pluginIndex = this.findPluginIndex(name, kind);
|
|
190
|
+
if (pluginIndex < 0) {
|
|
191
|
+
const event = newLogEvent({
|
|
192
|
+
kind: "error",
|
|
193
|
+
title: "Plugin not found, stopping change process",
|
|
194
|
+
message: JSON.stringify({ name, kind }),
|
|
195
|
+
});
|
|
196
|
+
this.dispatchEvent(event);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const pluginToChange = storedPlugins[pluginIndex];
|
|
200
|
+
const changedPlugin = { ...pluginToChange, ...plugin };
|
|
201
|
+
const newPlugins = [...storedPlugins];
|
|
202
|
+
newPlugins.splice(pluginIndex, 1, changedPlugin);
|
|
203
|
+
// this.storePlugins(newPlugins);
|
|
204
|
+
this.updateStoredPlugins(newPlugins);
|
|
205
|
+
}
|
|
206
|
+
resetPlugins() {
|
|
207
|
+
const builtInPlugins = this.getBuiltInPlugins();
|
|
208
|
+
const allPlugins = [...builtInPlugins, ...this.parsedPlugins];
|
|
209
|
+
const newPluginConfigs = allPlugins.map(plugin => {
|
|
210
|
+
return {
|
|
211
|
+
...plugin,
|
|
212
|
+
active: plugin.activeByDefault ?? false,
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
this.storePlugins(newPluginConfigs);
|
|
216
|
+
}
|
|
217
|
+
get parsedPlugins() {
|
|
218
|
+
const menuPlugins = this.plugins.menu.map((plugin) => {
|
|
219
|
+
let newPosition = plugin.position;
|
|
220
|
+
if (typeof plugin.position === 'number') {
|
|
221
|
+
newPosition = undefined;
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
...plugin,
|
|
225
|
+
position: newPosition,
|
|
226
|
+
kind: 'menu',
|
|
227
|
+
active: plugin.active ?? false,
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
const editorPlugins = this.plugins.editor.map((plugin) => {
|
|
231
|
+
const editorPlugin = {
|
|
232
|
+
...plugin,
|
|
233
|
+
position: undefined,
|
|
234
|
+
kind: 'editor',
|
|
235
|
+
active: plugin.active ?? false,
|
|
236
|
+
};
|
|
237
|
+
return editorPlugin;
|
|
238
|
+
});
|
|
239
|
+
const allPlugnis = [...menuPlugins, ...editorPlugins];
|
|
240
|
+
return allPlugnis;
|
|
241
|
+
}
|
|
242
|
+
updateStoredPlugins(newPlugins) {
|
|
243
|
+
//
|
|
244
|
+
// Generate content of each plugin
|
|
245
|
+
//
|
|
246
|
+
const plugins = newPlugins.map(plugin => {
|
|
247
|
+
const isInstalled = plugin.src && plugin.active;
|
|
248
|
+
if (!isInstalled) {
|
|
249
|
+
return plugin;
|
|
250
|
+
}
|
|
251
|
+
return this.addContent(plugin);
|
|
252
|
+
});
|
|
253
|
+
//
|
|
254
|
+
// Merge built-in plugins
|
|
255
|
+
//
|
|
256
|
+
const mergedPlugins = plugins.map(plugin => {
|
|
257
|
+
const isBuiltIn = !plugin?.official;
|
|
258
|
+
if (!isBuiltIn) {
|
|
259
|
+
return plugin;
|
|
260
|
+
}
|
|
261
|
+
;
|
|
262
|
+
const builtInPlugin = [...this.getBuiltInPlugins(), ...this.parsedPlugins]
|
|
263
|
+
.find(p => p.src === plugin.src);
|
|
264
|
+
return {
|
|
265
|
+
...builtInPlugin,
|
|
266
|
+
...plugin,
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
this.storePlugins(mergedPlugins);
|
|
270
|
+
}
|
|
271
|
+
storePlugins(plugins) {
|
|
272
|
+
this.storedPlugins = plugins;
|
|
273
|
+
const pluginConfigs = JSON.stringify(plugins.map(withoutContent));
|
|
274
|
+
localStorage.setItem('plugins', pluginConfigs);
|
|
275
|
+
}
|
|
276
|
+
getPluginConfigsFromLocalStorage() {
|
|
277
|
+
const pluginsConfigStr = localStorage.getItem('plugins') ?? '[]';
|
|
278
|
+
return JSON.parse(pluginsConfigStr);
|
|
279
|
+
}
|
|
280
|
+
get locale() {
|
|
281
|
+
return navigator.language || 'en-US';
|
|
282
|
+
}
|
|
283
|
+
get docs() {
|
|
284
|
+
const docs = {};
|
|
285
|
+
if (this.doc) {
|
|
286
|
+
docs[this.docName] = this.doc;
|
|
287
|
+
}
|
|
288
|
+
return docs;
|
|
289
|
+
}
|
|
290
|
+
setPlugins(selectedPlugins) {
|
|
291
|
+
const newPlugins = this.storedPlugins.map((storedPlugin) => {
|
|
292
|
+
const isSelected = selectedPlugins.some((selectedPlugin) => {
|
|
293
|
+
return selectedPlugin.name === storedPlugin.name
|
|
294
|
+
&& selectedPlugin.src === storedPlugin.src;
|
|
295
|
+
});
|
|
296
|
+
return {
|
|
297
|
+
...storedPlugin,
|
|
298
|
+
active: isSelected
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
this.updateStoredPlugins(newPlugins);
|
|
302
|
+
}
|
|
303
|
+
loadPlugins() {
|
|
304
|
+
const localPluginConfigs = this.getPluginConfigsFromLocalStorage();
|
|
305
|
+
const overwritesOfBultInPlugins = localPluginConfigs.filter((p) => {
|
|
306
|
+
return this.getBuiltInPlugins().some(b => b.src === p.src);
|
|
307
|
+
});
|
|
308
|
+
const userInstalledPlugins = localPluginConfigs.filter((p) => {
|
|
309
|
+
return !this.getBuiltInPlugins().some(b => b.src === p.src);
|
|
310
|
+
});
|
|
311
|
+
const mergedBuiltInPlugins = this.getBuiltInPlugins().map((builtInPlugin) => {
|
|
312
|
+
let overwrite = overwritesOfBultInPlugins.find(p => p.src === builtInPlugin.src);
|
|
313
|
+
const mergedPlugin = {
|
|
314
|
+
...builtInPlugin,
|
|
315
|
+
...overwrite,
|
|
316
|
+
active: overwrite?.active ?? builtInPlugin.activeByDefault,
|
|
317
|
+
};
|
|
318
|
+
return mergedPlugin;
|
|
319
|
+
});
|
|
320
|
+
const mergedPlugins = [...mergedBuiltInPlugins, ...userInstalledPlugins];
|
|
321
|
+
this.updateStoredPlugins(mergedPlugins);
|
|
322
|
+
}
|
|
323
|
+
async addExternalPlugin(plugin) {
|
|
324
|
+
if (this.storedPlugins.some(p => p.src === plugin.src))
|
|
325
|
+
return;
|
|
326
|
+
const newPlugins = this.storedPlugins;
|
|
327
|
+
newPlugins.push(plugin);
|
|
328
|
+
this.storePlugins(newPlugins);
|
|
329
|
+
}
|
|
330
|
+
getBuiltInPlugins() {
|
|
331
|
+
return builtinPlugins;
|
|
332
|
+
}
|
|
333
|
+
addContent(plugin) {
|
|
334
|
+
const tag = this.pluginTag(plugin.src);
|
|
335
|
+
if (!this.loadedPlugins.has(tag)) {
|
|
336
|
+
this.loadedPlugins.add(tag);
|
|
337
|
+
import(plugin.src).then((mod) => {
|
|
338
|
+
customElements.define(tag, mod.default);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
...plugin,
|
|
343
|
+
content: () => {
|
|
344
344
|
return staticTagHtml `<${tag}
|
|
345
345
|
.doc=${this.doc}
|
|
346
346
|
.docName=${this.docName}
|
|
@@ -353,131 +353,131 @@ let OpenSCD = class OpenSCD extends LitElement {
|
|
|
353
353
|
.locale=${this.locale}
|
|
354
354
|
.oscdApi=${new OscdApi(tag)}
|
|
355
355
|
.editor=${this.editor}
|
|
356
|
-
class="${classMap({
|
|
357
|
-
plugin: true,
|
|
358
|
-
menu: plugin.kind === 'menu',
|
|
359
|
-
validator: plugin.kind === 'validator',
|
|
360
|
-
editor: plugin.kind === 'editor',
|
|
356
|
+
class="${classMap({
|
|
357
|
+
plugin: true,
|
|
358
|
+
menu: plugin.kind === 'menu',
|
|
359
|
+
validator: plugin.kind === 'validator',
|
|
360
|
+
editor: plugin.kind === 'editor',
|
|
361
361
|
})}"
|
|
362
|
-
></${tag}>`;
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
pluginTag(uri) {
|
|
367
|
-
if (!this.pluginTags.has(uri)) {
|
|
368
|
-
const tag = pluginTag(uri);
|
|
369
|
-
this.pluginTags.set(uri, tag);
|
|
370
|
-
}
|
|
371
|
-
return this.pluginTags.get(uri);
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
__decorate([
|
|
375
|
-
property({ attribute: false })
|
|
376
|
-
], OpenSCD.prototype, "doc", void 0);
|
|
377
|
-
__decorate([
|
|
378
|
-
property({ type: String })
|
|
379
|
-
], OpenSCD.prototype, "docName", void 0);
|
|
380
|
-
__decorate([
|
|
381
|
-
property({ type: String })
|
|
382
|
-
], OpenSCD.prototype, "docId", void 0);
|
|
383
|
-
__decorate([
|
|
384
|
-
property({ attribute: false })
|
|
385
|
-
], OpenSCD.prototype, "nsdoc", void 0);
|
|
386
|
-
__decorate([
|
|
387
|
-
property({ type: String })
|
|
388
|
-
], OpenSCD.prototype, "src", null);
|
|
389
|
-
__decorate([
|
|
390
|
-
state()
|
|
391
|
-
], OpenSCD.prototype, "storedPlugins", void 0);
|
|
392
|
-
__decorate([
|
|
393
|
-
state()
|
|
394
|
-
], OpenSCD.prototype, "editCount", void 0);
|
|
395
|
-
__decorate([
|
|
396
|
-
property({ type: Object })
|
|
397
|
-
], OpenSCD.prototype, "plugins", void 0);
|
|
398
|
-
__decorate([
|
|
399
|
-
state()
|
|
400
|
-
], OpenSCD.prototype, "loadedPlugins", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
state()
|
|
403
|
-
], OpenSCD.prototype, "pluginTags", void 0);
|
|
404
|
-
OpenSCD = __decorate([
|
|
405
|
-
customElement('open-scd')
|
|
406
|
-
], OpenSCD);
|
|
407
|
-
export { OpenSCD };
|
|
408
|
-
export function newResetPluginsEvent() {
|
|
409
|
-
return new CustomEvent('reset-plugins', { bubbles: true, composed: true });
|
|
410
|
-
}
|
|
411
|
-
export function newAddExternalPluginEvent(plugin) {
|
|
412
|
-
return new CustomEvent('add-external-plugin', {
|
|
413
|
-
bubbles: true,
|
|
414
|
-
composed: true,
|
|
415
|
-
detail: { plugin },
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
export function newSetPluginsEvent(selectedPlugins) {
|
|
419
|
-
return new CustomEvent('set-plugins', {
|
|
420
|
-
bubbles: true,
|
|
421
|
-
composed: true,
|
|
422
|
-
detail: { selectedPlugins },
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* This is a template literal tag function. See:
|
|
427
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
|
|
428
|
-
*
|
|
429
|
-
* Passes its arguments to LitElement's `html` tag after combining the first and
|
|
430
|
-
* last expressions with the first two and last two static strings.
|
|
431
|
-
* Throws unless the first and last expressions are identical strings.
|
|
432
|
-
*
|
|
433
|
-
* We need this to get around the expression location limitations documented in
|
|
434
|
-
* https://lit.dev/docs/templates/expressions/#expression-locations
|
|
435
|
-
*
|
|
436
|
-
* After upgrading to Lit 2 we can use their static HTML functions instead:
|
|
437
|
-
* https://lit.dev/docs/api/static-html/
|
|
438
|
-
*/
|
|
439
|
-
function staticTagHtml(oldStrings, ...oldArgs) {
|
|
440
|
-
const args = [...oldArgs];
|
|
441
|
-
const firstArg = args.shift();
|
|
442
|
-
const lastArg = args.pop();
|
|
443
|
-
if (firstArg !== lastArg)
|
|
444
|
-
throw new Error(`Opening tag <${firstArg}> does not match closing tag </${lastArg}>.`);
|
|
445
|
-
const strings = [...oldStrings];
|
|
446
|
-
const firstString = strings.shift();
|
|
447
|
-
const secondString = strings.shift();
|
|
448
|
-
const lastString = strings.pop();
|
|
449
|
-
const penultimateString = strings.pop();
|
|
450
|
-
strings.unshift(`${firstString}${firstArg}${secondString}`);
|
|
451
|
-
strings.push(`${penultimateString}${lastArg}${lastString}`);
|
|
452
|
-
return html(strings, ...args);
|
|
453
|
-
}
|
|
454
|
-
function withoutContent(plugin) {
|
|
455
|
-
return { ...plugin, content: undefined };
|
|
456
|
-
}
|
|
457
|
-
export const pluginIcons = {
|
|
458
|
-
editor: 'tab',
|
|
459
|
-
menu: 'play_circle',
|
|
460
|
-
validator: 'rule_folder',
|
|
461
|
-
top: 'play_circle',
|
|
462
|
-
middle: 'play_circle',
|
|
463
|
-
bottom: 'play_circle',
|
|
464
|
-
};
|
|
465
|
-
const menuOrder = [
|
|
466
|
-
'editor',
|
|
467
|
-
'top',
|
|
468
|
-
'validator',
|
|
469
|
-
'middle',
|
|
470
|
-
'bottom',
|
|
471
|
-
];
|
|
472
|
-
function menuCompare(a, b) {
|
|
473
|
-
if (a.kind === b.kind && a.position === b.position)
|
|
474
|
-
return 0;
|
|
475
|
-
const earlier = menuOrder.find(kind => [a.kind, b.kind, a.position, b.position].includes(kind));
|
|
476
|
-
return [a.kind, a.position].includes(earlier) ? -1 : 1;
|
|
477
|
-
}
|
|
478
|
-
function compareNeedsDoc(a, b) {
|
|
479
|
-
if (a.requireDoc === b.requireDoc)
|
|
480
|
-
return 0;
|
|
481
|
-
return a.requireDoc ? 1 : -1;
|
|
482
|
-
}
|
|
362
|
+
></${tag}>`;
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
pluginTag(uri) {
|
|
367
|
+
if (!this.pluginTags.has(uri)) {
|
|
368
|
+
const tag = pluginTag(uri);
|
|
369
|
+
this.pluginTags.set(uri, tag);
|
|
370
|
+
}
|
|
371
|
+
return this.pluginTags.get(uri);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
__decorate([
|
|
375
|
+
property({ attribute: false })
|
|
376
|
+
], OpenSCD.prototype, "doc", void 0);
|
|
377
|
+
__decorate([
|
|
378
|
+
property({ type: String })
|
|
379
|
+
], OpenSCD.prototype, "docName", void 0);
|
|
380
|
+
__decorate([
|
|
381
|
+
property({ type: String })
|
|
382
|
+
], OpenSCD.prototype, "docId", void 0);
|
|
383
|
+
__decorate([
|
|
384
|
+
property({ attribute: false })
|
|
385
|
+
], OpenSCD.prototype, "nsdoc", void 0);
|
|
386
|
+
__decorate([
|
|
387
|
+
property({ type: String })
|
|
388
|
+
], OpenSCD.prototype, "src", null);
|
|
389
|
+
__decorate([
|
|
390
|
+
state()
|
|
391
|
+
], OpenSCD.prototype, "storedPlugins", void 0);
|
|
392
|
+
__decorate([
|
|
393
|
+
state()
|
|
394
|
+
], OpenSCD.prototype, "editCount", void 0);
|
|
395
|
+
__decorate([
|
|
396
|
+
property({ type: Object })
|
|
397
|
+
], OpenSCD.prototype, "plugins", void 0);
|
|
398
|
+
__decorate([
|
|
399
|
+
state()
|
|
400
|
+
], OpenSCD.prototype, "loadedPlugins", void 0);
|
|
401
|
+
__decorate([
|
|
402
|
+
state()
|
|
403
|
+
], OpenSCD.prototype, "pluginTags", void 0);
|
|
404
|
+
OpenSCD = __decorate([
|
|
405
|
+
customElement('open-scd')
|
|
406
|
+
], OpenSCD);
|
|
407
|
+
export { OpenSCD };
|
|
408
|
+
export function newResetPluginsEvent() {
|
|
409
|
+
return new CustomEvent('reset-plugins', { bubbles: true, composed: true });
|
|
410
|
+
}
|
|
411
|
+
export function newAddExternalPluginEvent(plugin) {
|
|
412
|
+
return new CustomEvent('add-external-plugin', {
|
|
413
|
+
bubbles: true,
|
|
414
|
+
composed: true,
|
|
415
|
+
detail: { plugin },
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
export function newSetPluginsEvent(selectedPlugins) {
|
|
419
|
+
return new CustomEvent('set-plugins', {
|
|
420
|
+
bubbles: true,
|
|
421
|
+
composed: true,
|
|
422
|
+
detail: { selectedPlugins },
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* This is a template literal tag function. See:
|
|
427
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
|
|
428
|
+
*
|
|
429
|
+
* Passes its arguments to LitElement's `html` tag after combining the first and
|
|
430
|
+
* last expressions with the first two and last two static strings.
|
|
431
|
+
* Throws unless the first and last expressions are identical strings.
|
|
432
|
+
*
|
|
433
|
+
* We need this to get around the expression location limitations documented in
|
|
434
|
+
* https://lit.dev/docs/templates/expressions/#expression-locations
|
|
435
|
+
*
|
|
436
|
+
* After upgrading to Lit 2 we can use their static HTML functions instead:
|
|
437
|
+
* https://lit.dev/docs/api/static-html/
|
|
438
|
+
*/
|
|
439
|
+
function staticTagHtml(oldStrings, ...oldArgs) {
|
|
440
|
+
const args = [...oldArgs];
|
|
441
|
+
const firstArg = args.shift();
|
|
442
|
+
const lastArg = args.pop();
|
|
443
|
+
if (firstArg !== lastArg)
|
|
444
|
+
throw new Error(`Opening tag <${firstArg}> does not match closing tag </${lastArg}>.`);
|
|
445
|
+
const strings = [...oldStrings];
|
|
446
|
+
const firstString = strings.shift();
|
|
447
|
+
const secondString = strings.shift();
|
|
448
|
+
const lastString = strings.pop();
|
|
449
|
+
const penultimateString = strings.pop();
|
|
450
|
+
strings.unshift(`${firstString}${firstArg}${secondString}`);
|
|
451
|
+
strings.push(`${penultimateString}${lastArg}${lastString}`);
|
|
452
|
+
return html(strings, ...args);
|
|
453
|
+
}
|
|
454
|
+
function withoutContent(plugin) {
|
|
455
|
+
return { ...plugin, content: undefined };
|
|
456
|
+
}
|
|
457
|
+
export const pluginIcons = {
|
|
458
|
+
editor: 'tab',
|
|
459
|
+
menu: 'play_circle',
|
|
460
|
+
validator: 'rule_folder',
|
|
461
|
+
top: 'play_circle',
|
|
462
|
+
middle: 'play_circle',
|
|
463
|
+
bottom: 'play_circle',
|
|
464
|
+
};
|
|
465
|
+
const menuOrder = [
|
|
466
|
+
'editor',
|
|
467
|
+
'top',
|
|
468
|
+
'validator',
|
|
469
|
+
'middle',
|
|
470
|
+
'bottom',
|
|
471
|
+
];
|
|
472
|
+
function menuCompare(a, b) {
|
|
473
|
+
if (a.kind === b.kind && a.position === b.position)
|
|
474
|
+
return 0;
|
|
475
|
+
const earlier = menuOrder.find(kind => [a.kind, b.kind, a.position, b.position].includes(kind));
|
|
476
|
+
return [a.kind, a.position].includes(earlier) ? -1 : 1;
|
|
477
|
+
}
|
|
478
|
+
function compareNeedsDoc(a, b) {
|
|
479
|
+
if (a.requireDoc === b.requireDoc)
|
|
480
|
+
return 0;
|
|
481
|
+
return a.requireDoc ? 1 : -1;
|
|
482
|
+
}
|
|
483
483
|
//# sourceMappingURL=open-scd.js.map
|