@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.
Files changed (250) hide show
  1. package/dist/WizardDivider.d.ts +8 -8
  2. package/dist/WizardDivider.js +26 -26
  3. package/dist/Wizarding.js +36 -36
  4. package/dist/Wizarding.js.map +1 -1
  5. package/dist/action-icon.d.ts +25 -25
  6. package/dist/action-icon.js +51 -51
  7. package/dist/action-pane.d.ts +25 -25
  8. package/dist/action-pane.js +86 -86
  9. package/dist/addons/Editor.d.ts +25 -25
  10. package/dist/addons/Editor.js +105 -105
  11. package/dist/addons/Editor.js.map +1 -1
  12. package/dist/addons/History.d.ts +86 -93
  13. package/dist/addons/History.js +301 -302
  14. package/dist/addons/History.js.map +1 -1
  15. package/dist/addons/Layout.d.ts +96 -96
  16. package/dist/addons/Layout.js +448 -448
  17. package/dist/addons/Layout.js.map +1 -1
  18. package/dist/addons/Settings.d.ts +68 -68
  19. package/dist/addons/Settings.js +272 -272
  20. package/dist/addons/Settings.js.map +1 -1
  21. package/dist/addons/Waiter.d.ts +14 -14
  22. package/dist/addons/Waiter.js +40 -40
  23. package/dist/addons/Waiter.js.map +1 -1
  24. package/dist/addons/Wizards.d.ts +15 -15
  25. package/dist/addons/Wizards.js +46 -46
  26. package/dist/addons/editor/edit-action-to-v1-converter.d.ts +3 -3
  27. package/dist/addons/editor/edit-action-to-v1-converter.js +95 -95
  28. package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -1
  29. package/dist/addons/editor/edit-v1-to-v2-converter.d.ts +2 -2
  30. package/dist/addons/editor/edit-v1-to-v2-converter.js +36 -36
  31. package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -1
  32. package/dist/addons/history/get-log-text.d.ts +5 -5
  33. package/dist/addons/history/get-log-text.js +25 -25
  34. package/dist/addons/history/get-log-text.js.map +1 -1
  35. package/dist/addons/menu-tabs/menu-tabs.d.ts +22 -22
  36. package/dist/addons/menu-tabs/menu-tabs.js +59 -59
  37. package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts +28 -28
  38. package/dist/addons/plugin-manager/custom-plugin-dialog.js +71 -71
  39. package/dist/addons/plugin-manager/plugin-manager.d.ts +20 -20
  40. package/dist/addons/plugin-manager/plugin-manager.js +77 -77
  41. package/dist/core/api/api.js +7 -0
  42. package/dist/core/api/api.js.map +1 -0
  43. package/dist/core/api/editor/subject.js +22 -0
  44. package/dist/core/api/editor/subject.js.map +1 -0
  45. package/dist/core/api/editor/xml-editor.js +82 -0
  46. package/dist/core/api/editor/xml-editor.js.map +1 -0
  47. package/dist/core/api/plugin-state-api.js +27 -0
  48. package/dist/core/api/plugin-state-api.js.map +1 -0
  49. package/dist/core/foundation/cyrb64.js +26 -0
  50. package/dist/core/foundation/cyrb64.js.map +1 -0
  51. package/dist/core/foundation/deprecated/edit-event.js +44 -0
  52. package/dist/core/foundation/deprecated/edit-event.js.map +1 -0
  53. package/dist/core/foundation/deprecated/editor.js +94 -0
  54. package/dist/core/foundation/deprecated/editor.js.map +1 -0
  55. package/dist/core/foundation/deprecated/history.js +17 -0
  56. package/dist/core/foundation/deprecated/history.js.map +1 -0
  57. package/dist/core/foundation/deprecated/open-event.js +9 -0
  58. package/dist/core/foundation/deprecated/open-event.js.map +1 -0
  59. package/dist/core/foundation/deprecated/settings.js +19 -0
  60. package/dist/core/foundation/deprecated/settings.js.map +1 -0
  61. package/dist/core/foundation/deprecated/validation.js +8 -0
  62. package/dist/core/foundation/deprecated/validation.js.map +1 -0
  63. package/dist/core/foundation/deprecated/waiter.js +12 -0
  64. package/dist/core/foundation/deprecated/waiter.js.map +1 -0
  65. package/dist/core/foundation/edit-completed-event.js +11 -0
  66. package/dist/core/foundation/edit-completed-event.js.map +1 -0
  67. package/dist/core/foundation/edit-event.js +8 -0
  68. package/dist/core/foundation/edit-event.js.map +1 -0
  69. package/dist/core/foundation/edit.js +31 -0
  70. package/dist/core/foundation/edit.js.map +1 -0
  71. package/dist/core/foundation/handle-edit.js +151 -0
  72. package/dist/core/foundation/handle-edit.js.map +1 -0
  73. package/dist/core/foundation/open-event.js +8 -0
  74. package/dist/core/foundation/open-event.js.map +1 -0
  75. package/dist/core/foundation/plugin.js +2 -0
  76. package/dist/core/foundation/plugin.js.map +1 -0
  77. package/dist/core/foundation.js +14 -0
  78. package/dist/core/foundation.js.map +1 -0
  79. package/dist/core/locales.js +21 -0
  80. package/dist/core/locales.js.map +1 -0
  81. package/dist/filtered-list.d.ts +27 -27
  82. package/dist/filtered-list.js +118 -118
  83. package/dist/finder-list.d.ts +37 -37
  84. package/dist/finder-list.js +153 -153
  85. package/dist/foundation/compare.d.ts +79 -79
  86. package/dist/foundation/compare.js +216 -216
  87. package/dist/foundation/dai.d.ts +30 -30
  88. package/dist/foundation/dai.js +126 -126
  89. package/dist/foundation/generators.d.ts +13 -13
  90. package/dist/foundation/generators.js +66 -66
  91. package/dist/foundation/ied.d.ts +22 -22
  92. package/dist/foundation/ied.js +83 -83
  93. package/dist/foundation/ied.js.map +1 -1
  94. package/dist/foundation/nsd.d.ts +4 -4
  95. package/dist/foundation/nsd.js +12 -12
  96. package/dist/foundation/nsdoc.d.ts +14 -14
  97. package/dist/foundation/nsdoc.js +178 -178
  98. package/dist/foundation/scl.d.ts +1 -1
  99. package/dist/foundation/scl.js +63 -63
  100. package/dist/foundation.d.ts +230 -230
  101. package/dist/foundation.js +1921 -1921
  102. package/dist/foundation.js.map +1 -1
  103. package/dist/icons/compare.d.ts +3 -3
  104. package/dist/icons/compare.js +4 -4
  105. package/dist/icons/icons.d.ts +41 -41
  106. package/dist/icons/icons.js +92 -92
  107. package/dist/icons/ied-icons.d.ts +3 -3
  108. package/dist/icons/ied-icons.js +4 -4
  109. package/dist/icons/lnode.d.ts +16 -16
  110. package/dist/icons/lnode.js +17 -17
  111. package/dist/open-scd.d.ts +131 -131
  112. package/dist/open-scd.js +438 -438
  113. package/dist/open-scd.js.map +1 -1
  114. package/dist/openscd/src/WizardDivider.js +37 -0
  115. package/dist/openscd/src/WizardDivider.js.map +1 -0
  116. package/dist/openscd/src/Wizarding.js +38 -0
  117. package/dist/openscd/src/Wizarding.js.map +1 -0
  118. package/dist/openscd/src/action-icon.js +220 -0
  119. package/dist/openscd/src/action-icon.js.map +1 -0
  120. package/dist/openscd/src/action-pane.js +176 -0
  121. package/dist/openscd/src/action-pane.js.map +1 -0
  122. package/dist/openscd/src/addons/Editor.js +106 -0
  123. package/dist/openscd/src/addons/Editor.js.map +1 -0
  124. package/dist/openscd/src/addons/History.js +490 -0
  125. package/dist/openscd/src/addons/History.js.map +1 -0
  126. package/dist/openscd/src/addons/Layout.js +619 -0
  127. package/dist/openscd/src/addons/Layout.js.map +1 -0
  128. package/dist/openscd/src/addons/Settings.js +465 -0
  129. package/dist/openscd/src/addons/Settings.js.map +1 -0
  130. package/dist/openscd/src/addons/Waiter.js +45 -0
  131. package/dist/openscd/src/addons/Waiter.js.map +1 -0
  132. package/dist/openscd/src/addons/Wizards.js +48 -0
  133. package/dist/openscd/src/addons/Wizards.js.map +1 -0
  134. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +96 -0
  135. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
  136. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
  137. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
  138. package/dist/openscd/src/addons/history/get-log-text.js +26 -0
  139. package/dist/openscd/src/addons/history/get-log-text.js.map +1 -0
  140. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +74 -0
  141. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +1 -0
  142. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
  143. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
  144. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +165 -0
  145. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +1 -0
  146. package/dist/openscd/src/filtered-list.js +168 -0
  147. package/dist/openscd/src/filtered-list.js.map +1 -0
  148. package/dist/openscd/src/finder-list.js +207 -0
  149. package/dist/openscd/src/finder-list.js.map +1 -0
  150. package/dist/openscd/src/foundation/compare.js +273 -0
  151. package/dist/openscd/src/foundation/compare.js.map +1 -0
  152. package/dist/openscd/src/foundation/dai.js +127 -0
  153. package/dist/openscd/src/foundation/dai.js.map +1 -0
  154. package/dist/openscd/src/foundation/generators.js +67 -0
  155. package/dist/openscd/src/foundation/generators.js.map +1 -0
  156. package/dist/openscd/src/foundation/ied.js +84 -0
  157. package/dist/openscd/src/foundation/ied.js.map +1 -0
  158. package/dist/openscd/src/foundation/nsd.js +13 -0
  159. package/dist/openscd/src/foundation/nsd.js.map +1 -0
  160. package/dist/openscd/src/foundation/nsdoc.js +180 -0
  161. package/dist/openscd/src/foundation/nsdoc.js.map +1 -0
  162. package/dist/openscd/src/foundation/scl.js +64 -0
  163. package/dist/openscd/src/foundation/scl.js.map +1 -0
  164. package/dist/openscd/src/foundation.js +1922 -0
  165. package/dist/openscd/src/foundation.js.map +1 -0
  166. package/dist/openscd/src/icons/compare.js +11 -0
  167. package/dist/openscd/src/icons/compare.js.map +1 -0
  168. package/dist/openscd/src/icons/icons.js +611 -0
  169. package/dist/openscd/src/icons/icons.js.map +1 -0
  170. package/dist/openscd/src/icons/ied-icons.js +11 -0
  171. package/dist/openscd/src/icons/ied-icons.js.map +1 -0
  172. package/dist/openscd/src/icons/lnode.js +50 -0
  173. package/dist/openscd/src/icons/lnode.js.map +1 -0
  174. package/dist/openscd/src/open-scd.js +483 -0
  175. package/dist/openscd/src/open-scd.js.map +1 -0
  176. package/dist/openscd/src/oscd-filter-button.js +89 -0
  177. package/dist/openscd/src/oscd-filter-button.js.map +1 -0
  178. package/dist/openscd/src/plain-compare-list.js +132 -0
  179. package/dist/openscd/src/plain-compare-list.js.map +1 -0
  180. package/dist/openscd/src/plugin-tag.js +23 -0
  181. package/dist/openscd/src/plugin-tag.js.map +1 -0
  182. package/dist/openscd/src/plugin.events.js +12 -0
  183. package/dist/openscd/src/plugin.events.js.map +1 -0
  184. package/dist/openscd/src/plugin.js +2 -0
  185. package/dist/openscd/src/plugin.js.map +1 -0
  186. package/dist/openscd/src/plugins.js +256 -0
  187. package/dist/openscd/src/plugins.js.map +1 -0
  188. package/dist/openscd/src/schemas.js +9325 -0
  189. package/dist/openscd/src/schemas.js.map +1 -0
  190. package/dist/openscd/src/themes.js +122 -0
  191. package/dist/openscd/src/themes.js.map +1 -0
  192. package/dist/openscd/src/translations/de.js +954 -0
  193. package/dist/openscd/src/translations/de.js.map +1 -0
  194. package/dist/openscd/src/translations/en.js +950 -0
  195. package/dist/openscd/src/translations/en.js.map +1 -0
  196. package/dist/openscd/src/translations/loader.js +10 -0
  197. package/dist/openscd/src/translations/loader.js.map +1 -0
  198. package/dist/openscd/src/wizard-checkbox.js +152 -0
  199. package/dist/openscd/src/wizard-checkbox.js.map +1 -0
  200. package/dist/openscd/src/wizard-dialog.js +374 -0
  201. package/dist/openscd/src/wizard-dialog.js.map +1 -0
  202. package/dist/openscd/src/wizard-select.js +115 -0
  203. package/dist/openscd/src/wizard-select.js.map +1 -0
  204. package/dist/openscd/src/wizard-textfield.js +191 -0
  205. package/dist/openscd/src/wizard-textfield.js.map +1 -0
  206. package/dist/openscd/src/wizards.js +196 -0
  207. package/dist/openscd/src/wizards.js.map +1 -0
  208. package/dist/oscd-filter-button.d.ts +27 -27
  209. package/dist/oscd-filter-button.js +59 -59
  210. package/dist/plain-compare-list.d.ts +36 -36
  211. package/dist/plain-compare-list.js +70 -70
  212. package/dist/plugin-tag.d.ts +6 -6
  213. package/dist/plugin-tag.js +22 -22
  214. package/dist/plugin.d.ts +23 -23
  215. package/dist/plugin.events.d.ts +15 -15
  216. package/dist/plugin.events.js +11 -11
  217. package/dist/plugin.js +1 -1
  218. package/dist/plugin.js.map +1 -1
  219. package/dist/plugins.d.ts +3 -3
  220. package/dist/plugins.js +255 -255
  221. package/dist/schemas.d.ts +58 -58
  222. package/dist/schemas.js +59 -59
  223. package/dist/themes.d.ts +3 -3
  224. package/dist/themes.js +13 -13
  225. package/dist/themes.js.map +1 -1
  226. package/dist/translations/de.d.ts +2 -2
  227. package/dist/translations/de.js +952 -952
  228. package/dist/translations/en.d.ts +963 -963
  229. package/dist/translations/en.js +948 -948
  230. package/dist/translations/loader.d.ts +12 -12
  231. package/dist/translations/loader.js +9 -9
  232. package/dist/translations/loader.js.map +1 -1
  233. package/dist/wizard-checkbox.d.ts +37 -37
  234. package/dist/wizard-checkbox.js +130 -130
  235. package/dist/wizard-dialog.d.ts +45 -45
  236. package/dist/wizard-dialog.js +235 -235
  237. package/dist/wizard-dialog.js.map +1 -1
  238. package/dist/wizard-select.d.ts +31 -31
  239. package/dist/wizard-select.js +102 -102
  240. package/dist/wizard-textfield.d.ts +50 -50
  241. package/dist/wizard-textfield.js +162 -162
  242. package/dist/wizards.d.ts +23 -23
  243. package/dist/wizards.js +148 -148
  244. package/dist/wizards.js.map +1 -1
  245. package/dist/xml/src/foundation.js +67 -0
  246. package/dist/xml/src/foundation.js.map +1 -0
  247. package/dist/xml/src/index.js +2 -0
  248. package/dist/xml/src/index.js.map +1 -0
  249. package/package.json +29 -127
  250. package/dist/Wizarding.d.ts +0 -10
@@ -1,192 +1,191 @@
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
- export const historyStateEvent = 'history-state';
16
- const icons = {
17
- info: 'info',
18
- warning: 'warning',
19
- error: 'report',
20
- };
21
- function getPluginName(src) {
22
- let storedPluginsString = localStorage.getItem('plugins');
23
- if (!storedPluginsString) {
24
- storedPluginsString = '[]';
25
- }
26
- const storedPlugins = JSON.parse(storedPluginsString);
27
- const wantedPlugin = storedPlugins.find((p) => p.src === src);
28
- if (!wantedPlugin) {
29
- return `pluginnotfound: ${src} in ${storedPluginsString}`;
30
- }
31
- const name = wantedPlugin.name;
32
- if (!name) {
33
- return `pluginhasnoname:${src}`;
34
- }
35
- return name;
36
- }
37
- export var HistoryUIKind;
38
- (function (HistoryUIKind) {
39
- HistoryUIKind["log"] = "log";
40
- HistoryUIKind["history"] = "history";
41
- HistoryUIKind["diagnostic"] = "diagnostic";
42
- })(HistoryUIKind || (HistoryUIKind = {}));
43
- export function newHistoryUIEvent(show, kind, eventInitDict) {
44
- return new CustomEvent('history-dialog-ui', {
45
- bubbles: true,
46
- composed: true,
47
- ...eventInitDict,
48
- detail: {
49
- show,
50
- kind,
51
- ...eventInitDict?.detail,
52
- },
53
- });
54
- }
55
- export function newEmptyIssuesEvent(pluginSrc, eventInitDict) {
56
- return new CustomEvent('empty-issues', {
57
- bubbles: true,
58
- composed: true,
59
- ...eventInitDict,
60
- detail: { pluginSrc, ...eventInitDict?.detail },
61
- });
62
- }
63
- let OscdHistory = class OscdHistory extends LitElement {
64
- onIssue(de) {
65
- const issues = this.diagnoses.get(de.detail.validatorId);
66
- if (!issues)
67
- this.diagnoses.set(de.detail.validatorId, [de.detail]);
68
- else
69
- issues?.push(de.detail);
70
- this.latestIssue = de.detail;
71
- this.issueUI.close();
72
- this.issueUI.show();
73
- }
74
- undo() {
75
- this.editor.undo();
76
- }
77
- redo() {
78
- this.editor.redo();
79
- }
80
- onReset() {
81
- this.log = [];
82
- this.editor.reset();
83
- this.updateHistory();
84
- }
85
- onInfo(detail) {
86
- const entry = {
87
- time: new Date(),
88
- ...detail,
89
- };
90
- this.log.push(entry);
91
- if (!this.logUI.open) {
92
- const ui = {
93
- error: this.errorUI,
94
- warning: this.warningUI,
95
- info: this.infoUI,
96
- }[detail.kind];
97
- ui.close();
98
- ui.show();
99
- }
100
- if (detail.kind == 'error') {
101
- this.errorUI.close(); // hack to reset timeout
102
- this.errorUI.show();
103
- }
104
- this.requestUpdate('log', []);
105
- }
106
- onLog(le) {
107
- switch (le.detail.kind) {
108
- case 'reset':
109
- this.onReset();
110
- break;
111
- case 'action':
112
- // No longer needed
113
- break;
114
- default:
115
- this.onInfo(le.detail);
116
- break;
117
- }
118
- }
119
- historyUIHandler(e) {
120
- const ui = {
121
- log: this.logUI,
122
- history: this.historyUI,
123
- diagnostic: this.diagnosticUI,
124
- }[e.detail.kind];
125
- if (e.detail.show)
126
- ui.show();
127
- else
128
- ui.close();
129
- }
130
- emptyIssuesHandler(e) {
131
- if (this.diagnoses.get(e.detail.pluginSrc))
132
- this.diagnoses.get(e.detail.pluginSrc).length = 0;
133
- }
134
- handleKeyPress(e) {
135
- const ctrlAnd = (key) => e.key === key && e.ctrlKey;
136
- if (ctrlAnd('y'))
137
- this.redo();
138
- if (ctrlAnd('z'))
139
- this.undo();
140
- if (ctrlAnd('l'))
141
- this.logUI.open ? this.logUI.close() : this.logUI.show();
142
- if (ctrlAnd('d'))
143
- this.diagnosticUI.open
144
- ? this.diagnosticUI.close()
145
- : this.diagnosticUI.show();
146
- }
147
- updateHistory() {
148
- const { past, future } = this.editor;
149
- const activeIndex = past.length - 1;
150
- const allEntries = [...past, ...future];
151
- this.history = allEntries.map((e, index) => {
152
- const { title, message } = getLogText(e.redo);
153
- return {
154
- isActive: index === activeIndex,
155
- time: e.time,
156
- title: e.title ?? title,
157
- message
158
- };
159
- });
160
- }
161
- constructor() {
162
- super();
163
- /** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
164
- this.log = [];
165
- this.diagnoses = new Map();
166
- this.history = [];
167
- this.unsubscribers = [];
168
- this.undo = this.undo.bind(this);
169
- this.redo = this.redo.bind(this);
170
- this.onLog = this.onLog.bind(this);
171
- this.onIssue = this.onIssue.bind(this);
172
- this.historyUIHandler = this.historyUIHandler.bind(this);
173
- this.emptyIssuesHandler = this.emptyIssuesHandler.bind(this);
174
- this.handleKeyPress = this.handleKeyPress.bind(this);
175
- document.onkeydown = this.handleKeyPress;
176
- }
177
- connectedCallback() {
178
- super.connectedCallback();
179
- this.unsubscribers.push(this.editor.subscribe(e => this.updateHistory()), this.editor.subscribeUndoRedo(e => this.updateHistory()));
180
- this.host.addEventListener('log', this.onLog);
181
- this.host.addEventListener('issue', this.onIssue);
182
- this.host.addEventListener('history-dialog-ui', this.historyUIHandler);
183
- this.host.addEventListener('empty-issues', this.emptyIssuesHandler);
184
- this.diagnoses.clear();
185
- }
186
- disconnectedCallback() {
187
- this.unsubscribers.forEach(u => u());
188
- }
189
- renderLogEntry(entry, index, log) {
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) {
190
189
  return html ` <abbr title="${entry.title}">
191
190
  <mwc-list-item
192
191
  class="${entry.kind}"
@@ -205,9 +204,9 @@ let OscdHistory = class OscdHistory extends LitElement {
205
204
  >${icons[entry.kind]}</mwc-icon
206
205
  >
207
206
  </mwc-list-item></abbr
208
- >`;
209
- }
210
- renderHistoryEntry(entry) {
207
+ >`;
208
+ }
209
+ renderHistoryEntry(entry) {
211
210
  return html ` <abbr title="${entry.title}">
212
211
  <mwc-list-item
213
212
  ?twoline=${!!entry.message}
@@ -219,81 +218,81 @@ let OscdHistory = class OscdHistory extends LitElement {
219
218
  </span>
220
219
  <span slot="secondary">${entry.message}</span>
221
220
  </mwc-list-item>
222
- </abbr>`;
223
- }
224
- formatTime(time) {
225
- const date = new Date(time);
226
- const hours = date.getHours();
227
- const minutes = date.getMinutes();
228
- return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
229
- }
230
- renderLog() {
231
- if (this.log.length > 0)
232
- return this.log.slice().reverse().map(this.renderLogEntry, this);
233
- else
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
234
233
  return html `<mwc-list-item disabled graphic="icon">
235
234
  <span>${get('log.placeholder')}</span>
236
235
  <mwc-icon slot="graphic">info</mwc-icon>
237
- </mwc-list-item>`;
238
- }
239
- renderHistory() {
240
- if (this.history.length > 0)
241
- return this.history.slice().reverse().map(e => this.renderHistoryEntry(e));
242
- else
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
243
242
  return html `<mwc-list-item disabled graphic="icon">
244
243
  <span>${get('history.placeholder')}</span>
245
244
  <mwc-icon slot="graphic">info</mwc-icon>
246
- </mwc-list-item>`;
247
- }
248
- renderIssueEntry(issue) {
245
+ </mwc-list-item>`;
246
+ }
247
+ renderIssueEntry(issue) {
249
248
  return html ` <abbr title="${issue.title + '\n' + issue.message}"
250
249
  ><mwc-list-item ?twoline=${!!issue.message}>
251
250
  <span> ${issue.title}</span>
252
251
  <span slot="secondary">${issue.message}</span>
253
252
  </mwc-list-item></abbr
254
- >`;
255
- }
256
- renderValidatorsIssues(issues) {
257
- if (issues.length === 0)
258
- return [html ``];
259
- return [
253
+ >`;
254
+ }
255
+ renderValidatorsIssues(issues) {
256
+ if (issues.length === 0)
257
+ return [html ``];
258
+ return [
260
259
  html `
261
260
  <mwc-list-item noninteractive>
262
261
  ${getPluginName(issues[0].validatorId)}
263
262
  </mwc-list-item>
264
- `,
265
- html `<li divider padded role="separator"></li>`,
266
- ...issues.map(issue => this.renderIssueEntry(issue)),
267
- ];
268
- }
269
- renderIssues() {
270
- const issueItems = [];
271
- this.diagnoses.forEach(issues => {
272
- this.renderValidatorsIssues(issues).forEach(issueItem => issueItems.push(issueItem));
273
- });
274
- return issueItems.length
275
- ? issueItems
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
276
275
  : html `<mwc-list-item disabled graphic="icon">
277
276
  <span>${get('diag.placeholder')}</span>
278
277
  <mwc-icon slot="graphic">info</mwc-icon>
279
- </mwc-list-item>`;
280
- }
281
- renderFilterButtons() {
278
+ </mwc-list-item>`;
279
+ }
280
+ renderFilterButtons() {
282
281
  return Object.keys(icons).map(kind => html `<mwc-icon-button-toggle id="${kind}filter" on
283
282
  >${getFilterIcon(kind, false)}
284
283
  ${getFilterIcon(kind, true)}</mwc-icon-button-toggle
285
- >`);
286
- }
287
- renderLogDialog() {
284
+ >`);
285
+ }
286
+ renderLogDialog() {
288
287
  return html ` <mwc-dialog id="log" heading="${get('log.name')}">
289
288
  ${this.renderFilterButtons()}
290
289
  <mwc-list id="content" wrapFocus>${this.renderLog()}</mwc-list>
291
290
  <mwc-button slot="primaryAction" dialogaction="close"
292
291
  >${get('close')}</mwc-button
293
292
  >
294
- </mwc-dialog>`;
295
- }
296
- renderHistoryUI() {
293
+ </mwc-dialog>`;
294
+ }
295
+ renderHistoryUI() {
297
296
  return html ` <mwc-dialog id="history" heading="${get('history.name')}">
298
297
  <mwc-list id="content" wrapFocus>${this.renderHistory()}</mwc-list>
299
298
  <mwc-button
@@ -313,9 +312,9 @@ let OscdHistory = class OscdHistory extends LitElement {
313
312
  <mwc-button slot="primaryAction" dialogaction="close"
314
313
  >${get('close')}</mwc-button
315
314
  >
316
- </mwc-dialog>`;
317
- }
318
- render() {
315
+ </mwc-dialog>`;
316
+ }
317
+ render() {
319
318
  return html `<slot></slot>
320
319
  <style>
321
320
  #log > mwc-icon-button-toggle {
@@ -387,10 +386,10 @@ let OscdHistory = class OscdHistory extends LitElement {
387
386
  <mwc-snackbar
388
387
  id="info"
389
388
  timeoutMs="4000"
390
- labelText="${this.log
391
- .slice()
392
- .reverse()
393
- .find(le => le.kind === 'info')?.title ??
389
+ labelText="${this.log
390
+ .slice()
391
+ .reverse()
392
+ .find(le => le.kind === 'info')?.title ??
394
393
  get('log.snackbar.placeholder')}"
395
394
  >
396
395
  <mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
@@ -398,10 +397,10 @@ let OscdHistory = class OscdHistory extends LitElement {
398
397
  <mwc-snackbar
399
398
  id="warning"
400
399
  timeoutMs="6000"
401
- labelText="${this.log
402
- .slice()
403
- .reverse()
404
- .find(le => le.kind === 'warning')?.title ??
400
+ labelText="${this.log
401
+ .slice()
402
+ .reverse()
403
+ .find(le => le.kind === 'warning')?.title ??
405
404
  get('log.snackbar.placeholder')}"
406
405
  >
407
406
  <mwc-button
@@ -415,10 +414,10 @@ let OscdHistory = class OscdHistory extends LitElement {
415
414
  <mwc-snackbar
416
415
  id="error"
417
416
  timeoutMs="10000"
418
- labelText="${this.log
419
- .slice()
420
- .reverse()
421
- .find(le => le.kind === 'error')?.title ??
417
+ labelText="${this.log
418
+ .slice()
419
+ .reverse()
420
+ .find(le => le.kind === 'error')?.title ??
422
421
  get('log.snackbar.placeholder')}"
423
422
  >
424
423
  <mwc-button
@@ -432,7 +431,7 @@ let OscdHistory = class OscdHistory extends LitElement {
432
431
  <mwc-snackbar
433
432
  id="issue"
434
433
  timeoutMs="10000"
435
- labelText="${this.latestIssue?.title ??
434
+ labelText="${this.latestIssue?.title ??
436
435
  get('log.snackbar.placeholder')}"
437
436
  >
438
437
  <mwc-button
@@ -442,50 +441,50 @@ let OscdHistory = class OscdHistory extends LitElement {
442
441
  >${get('log.snackbar.show')}</mwc-button
443
442
  >
444
443
  <mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
445
- </mwc-snackbar>`;
446
- }
447
- };
448
- __decorate([
449
- property({ type: Array })
450
- ], OscdHistory.prototype, "log", void 0);
451
- __decorate([
452
- property({ type: Object })
453
- ], OscdHistory.prototype, "editor", void 0);
454
- __decorate([
455
- property()
456
- ], OscdHistory.prototype, "diagnoses", void 0);
457
- __decorate([
458
- property({ type: Object })
459
- ], OscdHistory.prototype, "host", void 0);
460
- __decorate([
461
- state()
462
- ], OscdHistory.prototype, "latestIssue", void 0);
463
- __decorate([
464
- state()
465
- ], OscdHistory.prototype, "history", void 0);
466
- __decorate([
467
- query('#log')
468
- ], OscdHistory.prototype, "logUI", void 0);
469
- __decorate([
470
- query('#history')
471
- ], OscdHistory.prototype, "historyUI", void 0);
472
- __decorate([
473
- query('#diagnostic')
474
- ], OscdHistory.prototype, "diagnosticUI", void 0);
475
- __decorate([
476
- query('#error')
477
- ], OscdHistory.prototype, "errorUI", void 0);
478
- __decorate([
479
- query('#warning')
480
- ], OscdHistory.prototype, "warningUI", void 0);
481
- __decorate([
482
- query('#info')
483
- ], OscdHistory.prototype, "infoUI", void 0);
484
- __decorate([
485
- query('#issue')
486
- ], OscdHistory.prototype, "issueUI", void 0);
487
- OscdHistory = __decorate([
488
- customElement('oscd-history')
489
- ], OscdHistory);
490
- export { OscdHistory };
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 };
491
490
  //# sourceMappingURL=History.js.map