@compas-oscd/open-scd 0.34.2 → 0.34.3
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/src/WizardDivider.d.ts +8 -0
- package/dist/src/WizardDivider.js +37 -0
- package/dist/src/WizardDivider.js.map +1 -0
- package/dist/src/Wizarding.d.ts +10 -0
- package/dist/src/Wizarding.js +38 -0
- package/dist/src/Wizarding.js.map +1 -0
- package/dist/src/action-icon.d.ts +25 -0
- package/dist/src/action-icon.js +220 -0
- package/dist/src/action-icon.js.map +1 -0
- package/dist/src/action-pane.d.ts +25 -0
- package/dist/src/action-pane.js +176 -0
- package/dist/src/action-pane.js.map +1 -0
- package/dist/src/addons/Editor.d.ts +25 -0
- package/dist/src/addons/Editor.js +106 -0
- package/dist/src/addons/Editor.js.map +1 -0
- package/dist/src/addons/History.d.ts +86 -0
- package/dist/src/addons/History.js +490 -0
- package/dist/src/addons/History.js.map +1 -0
- package/dist/src/addons/Layout.d.ts +96 -0
- package/dist/src/addons/Layout.js +619 -0
- package/dist/src/addons/Layout.js.map +1 -0
- package/dist/src/addons/Settings.d.ts +68 -0
- package/dist/src/addons/Settings.js +465 -0
- package/dist/src/addons/Settings.js.map +1 -0
- package/dist/src/addons/Waiter.d.ts +14 -0
- package/dist/src/addons/Waiter.js +45 -0
- package/dist/src/addons/Waiter.js.map +1 -0
- package/dist/src/addons/Wizards.d.ts +15 -0
- package/dist/src/addons/Wizards.js +48 -0
- package/dist/src/addons/Wizards.js.map +1 -0
- package/dist/src/addons/editor/edit-action-to-v1-converter.d.ts +3 -0
- package/dist/src/addons/editor/edit-action-to-v1-converter.js +96 -0
- package/dist/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
- package/dist/src/addons/editor/edit-v1-to-v2-converter.d.ts +2 -0
- package/dist/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
- package/dist/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
- package/dist/src/addons/history/get-log-text.d.ts +5 -0
- package/dist/src/addons/history/get-log-text.js +26 -0
- package/dist/src/addons/history/get-log-text.js.map +1 -0
- package/dist/src/addons/menu-tabs/menu-tabs.d.ts +22 -0
- package/dist/src/addons/menu-tabs/menu-tabs.js +74 -0
- package/dist/src/addons/menu-tabs/menu-tabs.js.map +1 -0
- package/dist/src/addons/plugin-manager/custom-plugin-dialog.d.ts +28 -0
- package/dist/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
- package/dist/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
- package/dist/src/addons/plugin-manager/plugin-manager.d.ts +20 -0
- package/dist/src/addons/plugin-manager/plugin-manager.js +165 -0
- package/dist/src/addons/plugin-manager/plugin-manager.js.map +1 -0
- package/dist/src/filtered-list.d.ts +27 -0
- package/dist/src/filtered-list.js +168 -0
- package/dist/src/filtered-list.js.map +1 -0
- package/dist/src/finder-list.d.ts +37 -0
- package/dist/src/finder-list.js +207 -0
- package/dist/src/finder-list.js.map +1 -0
- package/dist/src/foundation/compare.d.ts +79 -0
- package/dist/src/foundation/compare.js +273 -0
- package/dist/src/foundation/compare.js.map +1 -0
- package/dist/src/foundation/dai.d.ts +30 -0
- package/dist/src/foundation/dai.js +127 -0
- package/dist/src/foundation/dai.js.map +1 -0
- package/dist/src/foundation/generators.d.ts +13 -0
- package/dist/src/foundation/generators.js +67 -0
- package/dist/src/foundation/generators.js.map +1 -0
- package/dist/src/foundation/ied.d.ts +22 -0
- package/dist/src/foundation/ied.js +84 -0
- package/dist/src/foundation/ied.js.map +1 -0
- package/dist/src/foundation/nsd.d.ts +4 -0
- package/dist/src/foundation/nsd.js +13 -0
- package/dist/src/foundation/nsd.js.map +1 -0
- package/dist/src/foundation/nsdoc.d.ts +14 -0
- package/dist/src/foundation/nsdoc.js +180 -0
- package/dist/src/foundation/nsdoc.js.map +1 -0
- package/dist/src/foundation/scl.d.ts +1 -0
- package/dist/src/foundation/scl.js +64 -0
- package/dist/src/foundation/scl.js.map +1 -0
- package/dist/src/foundation.d.ts +230 -0
- package/dist/src/foundation.js +1922 -0
- package/dist/src/foundation.js.map +1 -0
- package/dist/src/icons/compare.d.ts +3 -0
- package/dist/src/icons/compare.js +11 -0
- package/dist/src/icons/compare.js.map +1 -0
- package/dist/src/icons/icons.d.ts +41 -0
- package/dist/src/icons/icons.js +611 -0
- package/dist/src/icons/icons.js.map +1 -0
- package/dist/src/icons/ied-icons.d.ts +3 -0
- package/dist/src/icons/ied-icons.js +11 -0
- package/dist/src/icons/ied-icons.js.map +1 -0
- package/dist/src/icons/lnode.d.ts +16 -0
- package/dist/src/icons/lnode.js +50 -0
- package/dist/src/icons/lnode.js.map +1 -0
- package/dist/src/open-scd.d.ts +131 -0
- package/dist/src/open-scd.js +483 -0
- package/dist/src/open-scd.js.map +1 -0
- package/dist/src/oscd-filter-button.d.ts +27 -0
- package/dist/src/oscd-filter-button.js +89 -0
- package/dist/src/oscd-filter-button.js.map +1 -0
- package/dist/src/plain-compare-list.d.ts +36 -0
- package/dist/src/plain-compare-list.js +132 -0
- package/dist/src/plain-compare-list.js.map +1 -0
- package/dist/src/plugin-tag.d.ts +6 -0
- package/dist/src/plugin-tag.js +23 -0
- package/dist/src/plugin-tag.js.map +1 -0
- package/dist/src/plugin.d.ts +23 -0
- package/dist/src/plugin.events.d.ts +15 -0
- package/dist/src/plugin.events.js +12 -0
- package/dist/src/plugin.events.js.map +1 -0
- package/dist/src/plugin.js +2 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/plugins.d.ts +3 -0
- package/dist/src/plugins.js +256 -0
- package/dist/src/plugins.js.map +1 -0
- package/dist/src/schemas.d.ts +58 -0
- package/dist/src/schemas.js +9325 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/themes.d.ts +3 -0
- package/dist/src/themes.js +122 -0
- package/dist/src/themes.js.map +1 -0
- package/dist/src/translations/de.d.ts +2 -0
- package/dist/src/translations/de.js +954 -0
- package/dist/src/translations/de.js.map +1 -0
- package/dist/src/translations/en.d.ts +963 -0
- package/dist/src/translations/en.js +950 -0
- package/dist/src/translations/en.js.map +1 -0
- package/dist/src/translations/loader.d.ts +12 -0
- package/dist/src/translations/loader.js +10 -0
- package/dist/src/translations/loader.js.map +1 -0
- package/dist/src/wizard-checkbox.d.ts +37 -0
- package/dist/src/wizard-checkbox.js +152 -0
- package/dist/src/wizard-checkbox.js.map +1 -0
- package/dist/src/wizard-dialog.d.ts +45 -0
- package/dist/src/wizard-dialog.js +374 -0
- package/dist/src/wizard-dialog.js.map +1 -0
- package/dist/src/wizard-select.d.ts +31 -0
- package/dist/src/wizard-select.js +115 -0
- package/dist/src/wizard-select.js.map +1 -0
- package/dist/src/wizard-textfield.d.ts +50 -0
- package/dist/src/wizard-textfield.js +191 -0
- package/dist/src/wizard-textfield.js.map +1 -0
- package/dist/src/wizards.d.ts +23 -0
- package/dist/src/wizards.js +196 -0
- package/dist/src/wizards.js.map +1 -0
- package/dist/test/foundation.d.ts +34 -0
- package/dist/test/foundation.js +55 -0
- package/dist/test/foundation.js.map +1 -0
- package/dist/test/mock-editor-logger.d.ts +16 -0
- package/dist/test/mock-editor-logger.js +53 -0
- package/dist/test/mock-editor-logger.js.map +1 -0
- package/dist/test/mock-edits.d.ts +7 -0
- package/dist/test/mock-edits.js +12 -0
- package/dist/test/mock-edits.js.map +1 -0
- package/dist/test/mock-open-scd.d.ts +22 -0
- package/dist/test/mock-open-scd.js +53 -0
- package/dist/test/mock-open-scd.js.map +1 -0
- package/dist/test/mock-plugins.d.ts +33 -0
- package/dist/test/mock-plugins.js +239 -0
- package/dist/test/mock-plugins.js.map +1 -0
- package/dist/test/mock-wizard-editor.d.ts +15 -0
- package/dist/test/mock-wizard-editor.js +50 -0
- package/dist/test/mock-wizard-editor.js.map +1 -0
- package/package.json +42 -22
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { newEditEvent, newEditEventV2 } from '@openscd/core';
|
|
3
|
+
import { property, LitElement, customElement, html, } from 'lit-element';
|
|
4
|
+
import { get } from 'lit-translate';
|
|
5
|
+
import { newLogEvent } from '@openscd/core/foundation/deprecated/history.js';
|
|
6
|
+
import { newValidateEvent } from '@openscd/core/foundation/deprecated/validation.js';
|
|
7
|
+
import { isComplex, isInsert, isRemove, isUpdate, } from '@openscd/core';
|
|
8
|
+
import { convertEditActiontoV1 } from './editor/edit-action-to-v1-converter.js';
|
|
9
|
+
import { convertEditV1toV2 } from './editor/edit-v1-to-v2-converter.js';
|
|
10
|
+
let OscdEditor = class OscdEditor extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/** The `XMLDocument` to be edited */
|
|
14
|
+
this.doc = null;
|
|
15
|
+
/** The name of the current [[`doc`]] */
|
|
16
|
+
this.docName = '';
|
|
17
|
+
/** The UUID of the current [[`doc`]] */
|
|
18
|
+
this.docId = '';
|
|
19
|
+
}
|
|
20
|
+
onAction(event) {
|
|
21
|
+
const edit = convertEditActiontoV1(event.detail.action);
|
|
22
|
+
const editV2 = convertEditV1toV2(edit);
|
|
23
|
+
this.host.dispatchEvent(newEditEventV2(editV2));
|
|
24
|
+
}
|
|
25
|
+
handleEditEvent(event) {
|
|
26
|
+
/**
|
|
27
|
+
* This is a compatibility fix for plugins based on open energy tools edit events
|
|
28
|
+
* because their edit event look slightly different
|
|
29
|
+
* see https://github.com/OpenEnergyTools/open-scd-core/blob/main/foundation/edit-event-v1.ts for details
|
|
30
|
+
*/
|
|
31
|
+
if (isOpenEnergyEditEvent(event)) {
|
|
32
|
+
event = convertOpenEnergyEditEventToEditEvent(event);
|
|
33
|
+
}
|
|
34
|
+
const edit = event.detail.edit;
|
|
35
|
+
const editV2 = convertEditV1toV2(edit);
|
|
36
|
+
this.host.dispatchEvent(newEditEventV2(editV2));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @deprecated [Move to handleOpenDoc instead]
|
|
41
|
+
*/
|
|
42
|
+
async onOpenDoc(event) {
|
|
43
|
+
this.doc = event.detail.doc;
|
|
44
|
+
this.docName = event.detail.docName;
|
|
45
|
+
this.docId = event.detail.docId ?? '';
|
|
46
|
+
await this.updateComplete;
|
|
47
|
+
this.dispatchEvent(newValidateEvent());
|
|
48
|
+
this.dispatchEvent(newLogEvent({
|
|
49
|
+
kind: 'info',
|
|
50
|
+
title: get('openSCD.loaded', { name: this.docName }),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
handleOpenDoc({ detail: { docName, doc } }) {
|
|
54
|
+
this.doc = doc;
|
|
55
|
+
this.docName = docName;
|
|
56
|
+
}
|
|
57
|
+
connectedCallback() {
|
|
58
|
+
super.connectedCallback();
|
|
59
|
+
// Deprecated editor action API, use 'oscd-edit' instead.
|
|
60
|
+
this.host.addEventListener('editor-action', this.onAction.bind(this));
|
|
61
|
+
// Deprecated edit event API, use 'oscd-edit-v2' instead.
|
|
62
|
+
this.host.addEventListener('oscd-edit', event => this.handleEditEvent(event));
|
|
63
|
+
this.host.addEventListener('oscd-edit-v2', event => this.handleEditEventV2(event));
|
|
64
|
+
this.host.addEventListener('open-doc', this.onOpenDoc);
|
|
65
|
+
this.host.addEventListener('oscd-open', this.handleOpenDoc);
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
return html `<slot></slot>`;
|
|
69
|
+
}
|
|
70
|
+
async handleEditEventV2(event) {
|
|
71
|
+
const { edit, title, squash } = event.detail;
|
|
72
|
+
this.editor.commit(edit, { title, squash });
|
|
73
|
+
await this.updateComplete;
|
|
74
|
+
this.dispatchEvent(newValidateEvent());
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
__decorate([
|
|
78
|
+
property({ attribute: false })
|
|
79
|
+
], OscdEditor.prototype, "doc", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
property({ type: String })
|
|
82
|
+
], OscdEditor.prototype, "docName", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
property({ type: String })
|
|
85
|
+
], OscdEditor.prototype, "docId", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
property({ type: Object })
|
|
88
|
+
], OscdEditor.prototype, "editor", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property({
|
|
91
|
+
type: Object,
|
|
92
|
+
})
|
|
93
|
+
], OscdEditor.prototype, "host", void 0);
|
|
94
|
+
OscdEditor = __decorate([
|
|
95
|
+
customElement('oscd-editor')
|
|
96
|
+
], OscdEditor);
|
|
97
|
+
export { OscdEditor };
|
|
98
|
+
function isOpenEnergyEditEvent(event) {
|
|
99
|
+
const eventDetail = event.detail;
|
|
100
|
+
return isComplex(eventDetail) || isInsert(eventDetail) || isUpdate(eventDetail) || isRemove(eventDetail);
|
|
101
|
+
}
|
|
102
|
+
function convertOpenEnergyEditEventToEditEvent(event) {
|
|
103
|
+
const eventDetail = event.detail;
|
|
104
|
+
return newEditEvent(eventDetail);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=Editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/addons/Editor.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n EditEventV2,\n OpenEvent,\n newEditEvent,\n newEditEventV2,\n XMLEditor\n} from '@openscd/core';\nimport {\n property,\n LitElement,\n customElement,\n TemplateResult,\n html,\n} from 'lit-element';\nimport { get } from 'lit-translate';\n\nimport {\n EditorAction,\n EditorActionEvent,\n} from '@openscd/core/foundation/deprecated/editor.js';\n\nimport { newLogEvent } from '@openscd/core/foundation/deprecated/history.js';\nimport { newValidateEvent } from '@openscd/core/foundation/deprecated/validation.js';\nimport { OpenDocEvent } from '@openscd/core/foundation/deprecated/open-event.js';\n\nimport {\n Edit,\n EditEvent,\n isComplex,\n isInsert,\n isRemove,\n isUpdate,\n} from '@openscd/core';\n\nimport { convertEditActiontoV1 } from './editor/edit-action-to-v1-converter.js';\nimport { convertEditV1toV2 } from './editor/edit-v1-to-v2-converter.js';\n\n@customElement('oscd-editor')\nexport class OscdEditor extends LitElement {\n /** The `XMLDocument` to be edited */\n @property({ attribute: false })\n doc: XMLDocument | null = null;\n /** The name of the current [[`doc`]] */\n @property({ type: String }) docName = '';\n /** The UUID of the current [[`doc`]] */\n @property({ type: String }) docId = '';\n /** XML Editor to apply changes to the scd */\n @property({ type: Object }) editor!: XMLEditor;\n\n @property({\n type: Object,\n })\n host!: HTMLElement;\n\n private onAction(event: EditorActionEvent<EditorAction>) {\n const edit = convertEditActiontoV1(event.detail.action);\n const editV2 = convertEditV1toV2(edit);\n\n this.host.dispatchEvent(newEditEventV2(editV2));\n }\n\n handleEditEvent(event: EditEvent) {\n /**\n * This is a compatibility fix for plugins based on open energy tools edit events\n * because their edit event look slightly different\n * see https://github.com/OpenEnergyTools/open-scd-core/blob/main/foundation/edit-event-v1.ts for details\n */\n if (isOpenEnergyEditEvent(event)) {\n event = convertOpenEnergyEditEventToEditEvent(event);\n }\n\n const edit = event.detail.edit;\n const editV2 = convertEditV1toV2(edit);\n\n this.host.dispatchEvent(newEditEventV2(editV2));\n }\n\n /**\n *\n * @deprecated [Move to handleOpenDoc instead]\n */\n private async onOpenDoc(event: OpenDocEvent) {\n this.doc = event.detail.doc;\n this.docName = event.detail.docName;\n this.docId = event.detail.docId ?? '';\n\n await this.updateComplete;\n\n this.dispatchEvent(newValidateEvent());\n\n this.dispatchEvent(\n newLogEvent({\n kind: 'info',\n title: get('openSCD.loaded', { name: this.docName }),\n })\n );\n }\n\n handleOpenDoc({ detail: { docName, doc } }: OpenEvent) {\n this.doc = doc;\n this.docName = docName;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n // Deprecated editor action API, use 'oscd-edit' instead.\n this.host.addEventListener('editor-action', this.onAction.bind(this));\n // Deprecated edit event API, use 'oscd-edit-v2' instead.\n this.host.addEventListener('oscd-edit', event => this.handleEditEvent(event));\n\n this.host.addEventListener('oscd-edit-v2', event => this.handleEditEventV2(event));\n this.host.addEventListener('open-doc', this.onOpenDoc);\n this.host.addEventListener('oscd-open', this.handleOpenDoc);\n }\n\n render(): TemplateResult {\n return html`<slot></slot>`;\n }\n\n async handleEditEventV2(event: EditEventV2) {\n const { edit, title, squash } = event.detail;\n\n this.editor.commit(edit, { title, squash });\n\n await this.updateComplete;\n this.dispatchEvent(newValidateEvent());\n }\n}\n\nfunction isOpenEnergyEditEvent(event: CustomEvent<unknown>): boolean {\n const eventDetail = event.detail as Edit;\n return isComplex(eventDetail) || isInsert(eventDetail) || isUpdate(eventDetail) || isRemove(eventDetail);\n}\n\nfunction convertOpenEnergyEditEventToEditEvent(event: CustomEvent<unknown>): EditEvent {\n const eventDetail = event.detail as Edit;\n return newEditEvent(eventDetail);\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { TemplateResult, LitElement } from 'lit-element';
|
|
2
|
+
import '@material/mwc-button';
|
|
3
|
+
import '@material/mwc-dialog';
|
|
4
|
+
import '@material/mwc-icon';
|
|
5
|
+
import '@material/mwc-icon-button';
|
|
6
|
+
import '@material/mwc-icon-button-toggle';
|
|
7
|
+
import '@material/mwc-list';
|
|
8
|
+
import '@material/mwc-list/mwc-list-item';
|
|
9
|
+
import '@material/mwc-snackbar';
|
|
10
|
+
import { Dialog } from '@material/mwc-dialog';
|
|
11
|
+
import { Snackbar } from '@material/mwc-snackbar';
|
|
12
|
+
import '../filtered-list.js';
|
|
13
|
+
import { InfoEntry, IssueDetail, LogEntry } from '@openscd/core/foundation/deprecated/history.js';
|
|
14
|
+
import { XMLEditor } from '@openscd/core';
|
|
15
|
+
interface HistoryItem {
|
|
16
|
+
title: string;
|
|
17
|
+
message?: string;
|
|
18
|
+
time: number;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare enum HistoryUIKind {
|
|
22
|
+
log = "log",
|
|
23
|
+
history = "history",
|
|
24
|
+
diagnostic = "diagnostic"
|
|
25
|
+
}
|
|
26
|
+
export interface HistoryUIDetail {
|
|
27
|
+
show: boolean;
|
|
28
|
+
kind: HistoryUIKind;
|
|
29
|
+
}
|
|
30
|
+
export type HistoryUIEvent = CustomEvent<HistoryUIDetail>;
|
|
31
|
+
export declare function newHistoryUIEvent(show: boolean, kind: HistoryUIKind, eventInitDict?: CustomEventInit<Partial<HistoryUIDetail>>): HistoryUIEvent;
|
|
32
|
+
export interface EmptyIssuesDetail {
|
|
33
|
+
pluginSrc: string;
|
|
34
|
+
}
|
|
35
|
+
export type EmptyIssuesEvent = CustomEvent<EmptyIssuesDetail>;
|
|
36
|
+
export declare function newEmptyIssuesEvent(pluginSrc: string, eventInitDict?: CustomEventInit<Partial<EmptyIssuesDetail>>): EmptyIssuesEvent;
|
|
37
|
+
export declare class OscdHistory extends LitElement {
|
|
38
|
+
/** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
|
|
39
|
+
log: InfoEntry[];
|
|
40
|
+
/** XML Editor to apply changes to the scd */
|
|
41
|
+
editor: XMLEditor;
|
|
42
|
+
diagnoses: Map<string, IssueDetail[]>;
|
|
43
|
+
host: HTMLElement;
|
|
44
|
+
latestIssue: IssueDetail;
|
|
45
|
+
history: HistoryItem[];
|
|
46
|
+
logUI: Dialog;
|
|
47
|
+
historyUI: Dialog;
|
|
48
|
+
diagnosticUI: Dialog;
|
|
49
|
+
errorUI: Snackbar;
|
|
50
|
+
warningUI: Snackbar;
|
|
51
|
+
infoUI: Snackbar;
|
|
52
|
+
issueUI: Snackbar;
|
|
53
|
+
private unsubscribers;
|
|
54
|
+
private onIssue;
|
|
55
|
+
undo(): void;
|
|
56
|
+
redo(): void;
|
|
57
|
+
private onReset;
|
|
58
|
+
private onInfo;
|
|
59
|
+
private onLog;
|
|
60
|
+
private historyUIHandler;
|
|
61
|
+
private emptyIssuesHandler;
|
|
62
|
+
private handleKeyPress;
|
|
63
|
+
private updateHistory;
|
|
64
|
+
constructor();
|
|
65
|
+
connectedCallback(): void;
|
|
66
|
+
disconnectedCallback(): void;
|
|
67
|
+
renderLogEntry(entry: InfoEntry, index: number, log: LogEntry[]): TemplateResult;
|
|
68
|
+
renderHistoryEntry(entry: HistoryItem): TemplateResult;
|
|
69
|
+
private formatTime;
|
|
70
|
+
private renderLog;
|
|
71
|
+
private renderHistory;
|
|
72
|
+
private renderIssueEntry;
|
|
73
|
+
renderValidatorsIssues(issues: IssueDetail[]): TemplateResult[];
|
|
74
|
+
private renderIssues;
|
|
75
|
+
private renderFilterButtons;
|
|
76
|
+
private renderLogDialog;
|
|
77
|
+
private renderHistoryUI;
|
|
78
|
+
render(): TemplateResult;
|
|
79
|
+
}
|
|
80
|
+
declare global {
|
|
81
|
+
interface ElementEventMap {
|
|
82
|
+
'history-dialog-ui': CustomEvent<HistoryUIDetail>;
|
|
83
|
+
'empty-issues': CustomEvent<EmptyIssuesDetail>;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, state, property, query, customElement, LitElement, } from 'lit-element';
|
|
3
|
+
import { get } from 'lit-translate';
|
|
4
|
+
import '@material/mwc-button';
|
|
5
|
+
import '@material/mwc-dialog';
|
|
6
|
+
import '@material/mwc-icon';
|
|
7
|
+
import '@material/mwc-icon-button';
|
|
8
|
+
import '@material/mwc-icon-button-toggle';
|
|
9
|
+
import '@material/mwc-list';
|
|
10
|
+
import '@material/mwc-list/mwc-list-item';
|
|
11
|
+
import '@material/mwc-snackbar';
|
|
12
|
+
import '../filtered-list.js';
|
|
13
|
+
import { getFilterIcon, iconColors } from '../icons/icons.js';
|
|
14
|
+
import { getLogText } from './history/get-log-text.js';
|
|
15
|
+
const icons = {
|
|
16
|
+
info: 'info',
|
|
17
|
+
warning: 'warning',
|
|
18
|
+
error: 'report',
|
|
19
|
+
};
|
|
20
|
+
function getPluginName(src) {
|
|
21
|
+
let storedPluginsString = localStorage.getItem('plugins');
|
|
22
|
+
if (!storedPluginsString) {
|
|
23
|
+
storedPluginsString = '[]';
|
|
24
|
+
}
|
|
25
|
+
const storedPlugins = JSON.parse(storedPluginsString);
|
|
26
|
+
const wantedPlugin = storedPlugins.find((p) => p.src === src);
|
|
27
|
+
if (!wantedPlugin) {
|
|
28
|
+
return `pluginnotfound: ${src} in ${storedPluginsString}`;
|
|
29
|
+
}
|
|
30
|
+
const name = wantedPlugin.name;
|
|
31
|
+
if (!name) {
|
|
32
|
+
return `pluginhasnoname:${src}`;
|
|
33
|
+
}
|
|
34
|
+
return name;
|
|
35
|
+
}
|
|
36
|
+
export var HistoryUIKind;
|
|
37
|
+
(function (HistoryUIKind) {
|
|
38
|
+
HistoryUIKind["log"] = "log";
|
|
39
|
+
HistoryUIKind["history"] = "history";
|
|
40
|
+
HistoryUIKind["diagnostic"] = "diagnostic";
|
|
41
|
+
})(HistoryUIKind || (HistoryUIKind = {}));
|
|
42
|
+
export function newHistoryUIEvent(show, kind, eventInitDict) {
|
|
43
|
+
return new CustomEvent('history-dialog-ui', {
|
|
44
|
+
bubbles: true,
|
|
45
|
+
composed: true,
|
|
46
|
+
...eventInitDict,
|
|
47
|
+
detail: {
|
|
48
|
+
show,
|
|
49
|
+
kind,
|
|
50
|
+
...eventInitDict?.detail,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function newEmptyIssuesEvent(pluginSrc, eventInitDict) {
|
|
55
|
+
return new CustomEvent('empty-issues', {
|
|
56
|
+
bubbles: true,
|
|
57
|
+
composed: true,
|
|
58
|
+
...eventInitDict,
|
|
59
|
+
detail: { pluginSrc, ...eventInitDict?.detail },
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
let OscdHistory = class OscdHistory extends LitElement {
|
|
63
|
+
onIssue(de) {
|
|
64
|
+
const issues = this.diagnoses.get(de.detail.validatorId);
|
|
65
|
+
if (!issues)
|
|
66
|
+
this.diagnoses.set(de.detail.validatorId, [de.detail]);
|
|
67
|
+
else
|
|
68
|
+
issues?.push(de.detail);
|
|
69
|
+
this.latestIssue = de.detail;
|
|
70
|
+
this.issueUI.close();
|
|
71
|
+
this.issueUI.show();
|
|
72
|
+
}
|
|
73
|
+
undo() {
|
|
74
|
+
this.editor.undo();
|
|
75
|
+
}
|
|
76
|
+
redo() {
|
|
77
|
+
this.editor.redo();
|
|
78
|
+
}
|
|
79
|
+
onReset() {
|
|
80
|
+
this.log = [];
|
|
81
|
+
this.editor.reset();
|
|
82
|
+
this.updateHistory();
|
|
83
|
+
}
|
|
84
|
+
onInfo(detail) {
|
|
85
|
+
const entry = {
|
|
86
|
+
time: new Date(),
|
|
87
|
+
...detail,
|
|
88
|
+
};
|
|
89
|
+
this.log.push(entry);
|
|
90
|
+
if (!this.logUI.open) {
|
|
91
|
+
const ui = {
|
|
92
|
+
error: this.errorUI,
|
|
93
|
+
warning: this.warningUI,
|
|
94
|
+
info: this.infoUI,
|
|
95
|
+
}[detail.kind];
|
|
96
|
+
ui.close();
|
|
97
|
+
ui.show();
|
|
98
|
+
}
|
|
99
|
+
if (detail.kind == 'error') {
|
|
100
|
+
this.errorUI.close(); // hack to reset timeout
|
|
101
|
+
this.errorUI.show();
|
|
102
|
+
}
|
|
103
|
+
this.requestUpdate('log', []);
|
|
104
|
+
}
|
|
105
|
+
onLog(le) {
|
|
106
|
+
switch (le.detail.kind) {
|
|
107
|
+
case 'reset':
|
|
108
|
+
this.onReset();
|
|
109
|
+
break;
|
|
110
|
+
case 'action':
|
|
111
|
+
// No longer needed
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
this.onInfo(le.detail);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
historyUIHandler(e) {
|
|
119
|
+
const ui = {
|
|
120
|
+
log: this.logUI,
|
|
121
|
+
history: this.historyUI,
|
|
122
|
+
diagnostic: this.diagnosticUI,
|
|
123
|
+
}[e.detail.kind];
|
|
124
|
+
if (e.detail.show)
|
|
125
|
+
ui.show();
|
|
126
|
+
else
|
|
127
|
+
ui.close();
|
|
128
|
+
}
|
|
129
|
+
emptyIssuesHandler(e) {
|
|
130
|
+
if (this.diagnoses.get(e.detail.pluginSrc))
|
|
131
|
+
this.diagnoses.get(e.detail.pluginSrc).length = 0;
|
|
132
|
+
}
|
|
133
|
+
handleKeyPress(e) {
|
|
134
|
+
const ctrlAnd = (key) => e.key === key && e.ctrlKey;
|
|
135
|
+
if (ctrlAnd('y'))
|
|
136
|
+
this.redo();
|
|
137
|
+
if (ctrlAnd('z'))
|
|
138
|
+
this.undo();
|
|
139
|
+
if (ctrlAnd('l'))
|
|
140
|
+
this.logUI.open ? this.logUI.close() : this.logUI.show();
|
|
141
|
+
if (ctrlAnd('d'))
|
|
142
|
+
this.diagnosticUI.open
|
|
143
|
+
? this.diagnosticUI.close()
|
|
144
|
+
: this.diagnosticUI.show();
|
|
145
|
+
}
|
|
146
|
+
updateHistory() {
|
|
147
|
+
const { past, future } = this.editor;
|
|
148
|
+
const activeIndex = past.length - 1;
|
|
149
|
+
const allEntries = [...past, ...future];
|
|
150
|
+
this.history = allEntries.map((e, index) => {
|
|
151
|
+
const { title, message } = getLogText(e.redo);
|
|
152
|
+
return {
|
|
153
|
+
isActive: index === activeIndex,
|
|
154
|
+
time: e.time,
|
|
155
|
+
title: e.title ?? title,
|
|
156
|
+
message
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
constructor() {
|
|
161
|
+
super();
|
|
162
|
+
/** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
|
|
163
|
+
this.log = [];
|
|
164
|
+
this.diagnoses = new Map();
|
|
165
|
+
this.history = [];
|
|
166
|
+
this.unsubscribers = [];
|
|
167
|
+
this.undo = this.undo.bind(this);
|
|
168
|
+
this.redo = this.redo.bind(this);
|
|
169
|
+
this.onLog = this.onLog.bind(this);
|
|
170
|
+
this.onIssue = this.onIssue.bind(this);
|
|
171
|
+
this.historyUIHandler = this.historyUIHandler.bind(this);
|
|
172
|
+
this.emptyIssuesHandler = this.emptyIssuesHandler.bind(this);
|
|
173
|
+
this.handleKeyPress = this.handleKeyPress.bind(this);
|
|
174
|
+
document.onkeydown = this.handleKeyPress;
|
|
175
|
+
}
|
|
176
|
+
connectedCallback() {
|
|
177
|
+
super.connectedCallback();
|
|
178
|
+
this.unsubscribers.push(this.editor.subscribe(e => this.updateHistory()), this.editor.subscribeUndoRedo(e => this.updateHistory()));
|
|
179
|
+
this.host.addEventListener('log', this.onLog);
|
|
180
|
+
this.host.addEventListener('issue', this.onIssue);
|
|
181
|
+
this.host.addEventListener('history-dialog-ui', this.historyUIHandler);
|
|
182
|
+
this.host.addEventListener('empty-issues', this.emptyIssuesHandler);
|
|
183
|
+
this.diagnoses.clear();
|
|
184
|
+
}
|
|
185
|
+
disconnectedCallback() {
|
|
186
|
+
this.unsubscribers.forEach(u => u());
|
|
187
|
+
}
|
|
188
|
+
renderLogEntry(entry, index, log) {
|
|
189
|
+
return html ` <abbr title="${entry.title}">
|
|
190
|
+
<mwc-list-item
|
|
191
|
+
class="${entry.kind}"
|
|
192
|
+
graphic="icon"
|
|
193
|
+
?twoline=${!!entry.message}
|
|
194
|
+
>
|
|
195
|
+
<span>
|
|
196
|
+
<!-- FIXME: replace tt with mwc-chip asap -->
|
|
197
|
+
<tt>${entry.time?.toLocaleString()}</tt>
|
|
198
|
+
${entry.title}</span
|
|
199
|
+
>
|
|
200
|
+
<span slot="secondary">${entry.message}</span>
|
|
201
|
+
<mwc-icon
|
|
202
|
+
slot="graphic"
|
|
203
|
+
style="--mdc-theme-text-icon-on-background:var(${iconColors[entry.kind]})"
|
|
204
|
+
>${icons[entry.kind]}</mwc-icon
|
|
205
|
+
>
|
|
206
|
+
</mwc-list-item></abbr
|
|
207
|
+
>`;
|
|
208
|
+
}
|
|
209
|
+
renderHistoryEntry(entry) {
|
|
210
|
+
return html ` <abbr title="${entry.title}">
|
|
211
|
+
<mwc-list-item
|
|
212
|
+
?twoline=${!!entry.message}
|
|
213
|
+
?activated=${entry.isActive}
|
|
214
|
+
>
|
|
215
|
+
<span>
|
|
216
|
+
<tt>${this.formatTime(entry.time)}</tt>
|
|
217
|
+
${entry.title}
|
|
218
|
+
</span>
|
|
219
|
+
<span slot="secondary">${entry.message}</span>
|
|
220
|
+
</mwc-list-item>
|
|
221
|
+
</abbr>`;
|
|
222
|
+
}
|
|
223
|
+
formatTime(time) {
|
|
224
|
+
const date = new Date(time);
|
|
225
|
+
const hours = date.getHours();
|
|
226
|
+
const minutes = date.getMinutes();
|
|
227
|
+
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
|
228
|
+
}
|
|
229
|
+
renderLog() {
|
|
230
|
+
if (this.log.length > 0)
|
|
231
|
+
return this.log.slice().reverse().map(this.renderLogEntry, this);
|
|
232
|
+
else
|
|
233
|
+
return html `<mwc-list-item disabled graphic="icon">
|
|
234
|
+
<span>${get('log.placeholder')}</span>
|
|
235
|
+
<mwc-icon slot="graphic">info</mwc-icon>
|
|
236
|
+
</mwc-list-item>`;
|
|
237
|
+
}
|
|
238
|
+
renderHistory() {
|
|
239
|
+
if (this.history.length > 0)
|
|
240
|
+
return this.history.slice().reverse().map(e => this.renderHistoryEntry(e));
|
|
241
|
+
else
|
|
242
|
+
return html `<mwc-list-item disabled graphic="icon">
|
|
243
|
+
<span>${get('history.placeholder')}</span>
|
|
244
|
+
<mwc-icon slot="graphic">info</mwc-icon>
|
|
245
|
+
</mwc-list-item>`;
|
|
246
|
+
}
|
|
247
|
+
renderIssueEntry(issue) {
|
|
248
|
+
return html ` <abbr title="${issue.title + '\n' + issue.message}"
|
|
249
|
+
><mwc-list-item ?twoline=${!!issue.message}>
|
|
250
|
+
<span> ${issue.title}</span>
|
|
251
|
+
<span slot="secondary">${issue.message}</span>
|
|
252
|
+
</mwc-list-item></abbr
|
|
253
|
+
>`;
|
|
254
|
+
}
|
|
255
|
+
renderValidatorsIssues(issues) {
|
|
256
|
+
if (issues.length === 0)
|
|
257
|
+
return [html ``];
|
|
258
|
+
return [
|
|
259
|
+
html `
|
|
260
|
+
<mwc-list-item noninteractive>
|
|
261
|
+
${getPluginName(issues[0].validatorId)}
|
|
262
|
+
</mwc-list-item>
|
|
263
|
+
`,
|
|
264
|
+
html `<li divider padded role="separator"></li>`,
|
|
265
|
+
...issues.map(issue => this.renderIssueEntry(issue)),
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
renderIssues() {
|
|
269
|
+
const issueItems = [];
|
|
270
|
+
this.diagnoses.forEach(issues => {
|
|
271
|
+
this.renderValidatorsIssues(issues).forEach(issueItem => issueItems.push(issueItem));
|
|
272
|
+
});
|
|
273
|
+
return issueItems.length
|
|
274
|
+
? issueItems
|
|
275
|
+
: html `<mwc-list-item disabled graphic="icon">
|
|
276
|
+
<span>${get('diag.placeholder')}</span>
|
|
277
|
+
<mwc-icon slot="graphic">info</mwc-icon>
|
|
278
|
+
</mwc-list-item>`;
|
|
279
|
+
}
|
|
280
|
+
renderFilterButtons() {
|
|
281
|
+
return Object.keys(icons).map(kind => html `<mwc-icon-button-toggle id="${kind}filter" on
|
|
282
|
+
>${getFilterIcon(kind, false)}
|
|
283
|
+
${getFilterIcon(kind, true)}</mwc-icon-button-toggle
|
|
284
|
+
>`);
|
|
285
|
+
}
|
|
286
|
+
renderLogDialog() {
|
|
287
|
+
return html ` <mwc-dialog id="log" heading="${get('log.name')}">
|
|
288
|
+
${this.renderFilterButtons()}
|
|
289
|
+
<mwc-list id="content" wrapFocus>${this.renderLog()}</mwc-list>
|
|
290
|
+
<mwc-button slot="primaryAction" dialogaction="close"
|
|
291
|
+
>${get('close')}</mwc-button
|
|
292
|
+
>
|
|
293
|
+
</mwc-dialog>`;
|
|
294
|
+
}
|
|
295
|
+
renderHistoryUI() {
|
|
296
|
+
return html ` <mwc-dialog id="history" heading="${get('history.name')}">
|
|
297
|
+
<mwc-list id="content" wrapFocus>${this.renderHistory()}</mwc-list>
|
|
298
|
+
<mwc-button
|
|
299
|
+
icon="undo"
|
|
300
|
+
label="${get('undo')}"
|
|
301
|
+
?disabled=${!this.editor.canUndo}
|
|
302
|
+
@click=${this.undo}
|
|
303
|
+
slot="secondaryAction"
|
|
304
|
+
></mwc-button>
|
|
305
|
+
<mwc-button
|
|
306
|
+
icon="redo"
|
|
307
|
+
label="${get('redo')}"
|
|
308
|
+
?disabled=${!this.editor.canRedo}
|
|
309
|
+
@click=${this.redo}
|
|
310
|
+
slot="secondaryAction"
|
|
311
|
+
></mwc-button>
|
|
312
|
+
<mwc-button slot="primaryAction" dialogaction="close"
|
|
313
|
+
>${get('close')}</mwc-button
|
|
314
|
+
>
|
|
315
|
+
</mwc-dialog>`;
|
|
316
|
+
}
|
|
317
|
+
render() {
|
|
318
|
+
return html `<slot></slot>
|
|
319
|
+
<style>
|
|
320
|
+
#log > mwc-icon-button-toggle {
|
|
321
|
+
position: absolute;
|
|
322
|
+
top: 8px;
|
|
323
|
+
right: 14px;
|
|
324
|
+
}
|
|
325
|
+
#log > mwc-icon-button-toggle:nth-child(2) {
|
|
326
|
+
right: 62px;
|
|
327
|
+
}
|
|
328
|
+
#log > mwc-icon-button-toggle:nth-child(3) {
|
|
329
|
+
right: 110px;
|
|
330
|
+
}
|
|
331
|
+
#log > mwc-icon-button-toggle:nth-child(4) {
|
|
332
|
+
right: 158px;
|
|
333
|
+
}
|
|
334
|
+
#content mwc-list-item.info,
|
|
335
|
+
#content mwc-list-item.warning,
|
|
336
|
+
#content mwc-list-item.error {
|
|
337
|
+
display: none;
|
|
338
|
+
}
|
|
339
|
+
#infofilter[on] ~ #content mwc-list-item.info {
|
|
340
|
+
display: flex;
|
|
341
|
+
}
|
|
342
|
+
#warningfilter[on] ~ #content mwc-list-item.warning {
|
|
343
|
+
display: flex;
|
|
344
|
+
}
|
|
345
|
+
#errorfilter[on] ~ #content mwc-list-item.error {
|
|
346
|
+
display: flex;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
#infofilter[on] {
|
|
350
|
+
color: var(--cyan);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
#warningfilter[on] {
|
|
354
|
+
color: var(--yellow);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#errorfilter[on] {
|
|
358
|
+
color: var(--red);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
#actionfilter[on] {
|
|
362
|
+
color: var(--blue);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
#log,
|
|
366
|
+
#history {
|
|
367
|
+
--mdc-dialog-min-width: 92vw;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
#log > #filterContainer {
|
|
371
|
+
position: absolute;
|
|
372
|
+
top: 14px;
|
|
373
|
+
right: 14px;
|
|
374
|
+
}
|
|
375
|
+
</style>
|
|
376
|
+
${this.renderLogDialog()} ${this.renderHistoryUI()}
|
|
377
|
+
<mwc-dialog id="diagnostic" heading="${get('diag.name')}">
|
|
378
|
+
<filtered-list id="content" wrapFocus>
|
|
379
|
+
${this.renderIssues()}
|
|
380
|
+
</filtered-list>
|
|
381
|
+
<mwc-button slot="primaryAction" dialogaction="close">
|
|
382
|
+
${get('close')}
|
|
383
|
+
</mwc-button>
|
|
384
|
+
</mwc-dialog>
|
|
385
|
+
|
|
386
|
+
<mwc-snackbar
|
|
387
|
+
id="info"
|
|
388
|
+
timeoutMs="4000"
|
|
389
|
+
labelText="${this.log
|
|
390
|
+
.slice()
|
|
391
|
+
.reverse()
|
|
392
|
+
.find(le => le.kind === 'info')?.title ??
|
|
393
|
+
get('log.snackbar.placeholder')}"
|
|
394
|
+
>
|
|
395
|
+
<mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
|
|
396
|
+
</mwc-snackbar>
|
|
397
|
+
<mwc-snackbar
|
|
398
|
+
id="warning"
|
|
399
|
+
timeoutMs="6000"
|
|
400
|
+
labelText="${this.log
|
|
401
|
+
.slice()
|
|
402
|
+
.reverse()
|
|
403
|
+
.find(le => le.kind === 'warning')?.title ??
|
|
404
|
+
get('log.snackbar.placeholder')}"
|
|
405
|
+
>
|
|
406
|
+
<mwc-button
|
|
407
|
+
slot="action"
|
|
408
|
+
icon="history"
|
|
409
|
+
@click=${() => this.logUI.show()}
|
|
410
|
+
>${get('log.snackbar.show')}</mwc-button
|
|
411
|
+
>
|
|
412
|
+
<mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
|
|
413
|
+
</mwc-snackbar>
|
|
414
|
+
<mwc-snackbar
|
|
415
|
+
id="error"
|
|
416
|
+
timeoutMs="10000"
|
|
417
|
+
labelText="${this.log
|
|
418
|
+
.slice()
|
|
419
|
+
.reverse()
|
|
420
|
+
.find(le => le.kind === 'error')?.title ??
|
|
421
|
+
get('log.snackbar.placeholder')}"
|
|
422
|
+
>
|
|
423
|
+
<mwc-button
|
|
424
|
+
slot="action"
|
|
425
|
+
icon="history"
|
|
426
|
+
@click=${() => this.logUI.show()}
|
|
427
|
+
>${get('log.snackbar.show')}</mwc-button
|
|
428
|
+
>
|
|
429
|
+
<mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
|
|
430
|
+
</mwc-snackbar>
|
|
431
|
+
<mwc-snackbar
|
|
432
|
+
id="issue"
|
|
433
|
+
timeoutMs="10000"
|
|
434
|
+
labelText="${this.latestIssue?.title ??
|
|
435
|
+
get('log.snackbar.placeholder')}"
|
|
436
|
+
>
|
|
437
|
+
<mwc-button
|
|
438
|
+
slot="action"
|
|
439
|
+
icon="rule"
|
|
440
|
+
@click=${() => this.diagnosticUI.show()}
|
|
441
|
+
>${get('log.snackbar.show')}</mwc-button
|
|
442
|
+
>
|
|
443
|
+
<mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
|
|
444
|
+
</mwc-snackbar>`;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
__decorate([
|
|
448
|
+
property({ type: Array })
|
|
449
|
+
], OscdHistory.prototype, "log", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
property({ type: Object })
|
|
452
|
+
], OscdHistory.prototype, "editor", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
property()
|
|
455
|
+
], OscdHistory.prototype, "diagnoses", void 0);
|
|
456
|
+
__decorate([
|
|
457
|
+
property({ type: Object })
|
|
458
|
+
], OscdHistory.prototype, "host", void 0);
|
|
459
|
+
__decorate([
|
|
460
|
+
state()
|
|
461
|
+
], OscdHistory.prototype, "latestIssue", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
state()
|
|
464
|
+
], OscdHistory.prototype, "history", void 0);
|
|
465
|
+
__decorate([
|
|
466
|
+
query('#log')
|
|
467
|
+
], OscdHistory.prototype, "logUI", void 0);
|
|
468
|
+
__decorate([
|
|
469
|
+
query('#history')
|
|
470
|
+
], OscdHistory.prototype, "historyUI", void 0);
|
|
471
|
+
__decorate([
|
|
472
|
+
query('#diagnostic')
|
|
473
|
+
], OscdHistory.prototype, "diagnosticUI", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
query('#error')
|
|
476
|
+
], OscdHistory.prototype, "errorUI", void 0);
|
|
477
|
+
__decorate([
|
|
478
|
+
query('#warning')
|
|
479
|
+
], OscdHistory.prototype, "warningUI", void 0);
|
|
480
|
+
__decorate([
|
|
481
|
+
query('#info')
|
|
482
|
+
], OscdHistory.prototype, "infoUI", void 0);
|
|
483
|
+
__decorate([
|
|
484
|
+
query('#issue')
|
|
485
|
+
], OscdHistory.prototype, "issueUI", void 0);
|
|
486
|
+
OscdHistory = __decorate([
|
|
487
|
+
customElement('oscd-history')
|
|
488
|
+
], OscdHistory);
|
|
489
|
+
export { OscdHistory };
|
|
490
|
+
//# sourceMappingURL=History.js.map
|