@compas-oscd/open-scd 0.34.0 → 0.34.1

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 (233) hide show
  1. package/dist/WizardDivider.js +37 -0
  2. package/dist/WizardDivider.js.map +1 -0
  3. package/dist/Wizarding.js +38 -0
  4. package/dist/Wizarding.js.map +1 -0
  5. package/dist/action-icon.js +220 -0
  6. package/dist/action-icon.js.map +1 -0
  7. package/dist/action-pane.js +176 -0
  8. package/dist/action-pane.js.map +1 -0
  9. package/dist/addons/Editor.js +106 -0
  10. package/dist/addons/Editor.js.map +1 -0
  11. package/dist/addons/History.js +490 -0
  12. package/dist/addons/History.js.map +1 -0
  13. package/dist/addons/Layout.js +619 -0
  14. package/dist/addons/Layout.js.map +1 -0
  15. package/dist/addons/Settings.js +465 -0
  16. package/dist/addons/Settings.js.map +1 -0
  17. package/dist/addons/Waiter.js +45 -0
  18. package/dist/addons/Waiter.js.map +1 -0
  19. package/dist/addons/Wizards.js +48 -0
  20. package/dist/addons/Wizards.js.map +1 -0
  21. package/dist/addons/editor/edit-action-to-v1-converter.js +96 -0
  22. package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -0
  23. package/dist/addons/editor/edit-v1-to-v2-converter.js +37 -0
  24. package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
  25. package/dist/addons/history/get-log-text.js +26 -0
  26. package/dist/addons/history/get-log-text.js.map +1 -0
  27. package/dist/addons/menu-tabs/menu-tabs.js +74 -0
  28. package/dist/addons/menu-tabs/menu-tabs.js.map +1 -0
  29. package/dist/addons/plugin-manager/custom-plugin-dialog.js +177 -0
  30. package/dist/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
  31. package/dist/addons/plugin-manager/plugin-manager.js +165 -0
  32. package/dist/addons/plugin-manager/plugin-manager.js.map +1 -0
  33. package/dist/core/api/api.js +7 -0
  34. package/dist/core/api/api.js.map +1 -0
  35. package/dist/core/api/editor/subject.js +22 -0
  36. package/dist/core/api/editor/subject.js.map +1 -0
  37. package/dist/core/api/editor/xml-editor.js +82 -0
  38. package/dist/core/api/editor/xml-editor.js.map +1 -0
  39. package/dist/core/api/plugin-state-api.js +27 -0
  40. package/dist/core/api/plugin-state-api.js.map +1 -0
  41. package/dist/core/foundation/cyrb64.js +26 -0
  42. package/dist/core/foundation/cyrb64.js.map +1 -0
  43. package/dist/core/foundation/deprecated/edit-event.js +44 -0
  44. package/dist/core/foundation/deprecated/edit-event.js.map +1 -0
  45. package/dist/core/foundation/deprecated/editor.js +94 -0
  46. package/dist/core/foundation/deprecated/editor.js.map +1 -0
  47. package/dist/core/foundation/deprecated/history.js +17 -0
  48. package/dist/core/foundation/deprecated/history.js.map +1 -0
  49. package/dist/core/foundation/deprecated/open-event.js +9 -0
  50. package/dist/core/foundation/deprecated/open-event.js.map +1 -0
  51. package/dist/core/foundation/deprecated/settings.js +19 -0
  52. package/dist/core/foundation/deprecated/settings.js.map +1 -0
  53. package/dist/core/foundation/deprecated/validation.js +8 -0
  54. package/dist/core/foundation/deprecated/validation.js.map +1 -0
  55. package/dist/core/foundation/deprecated/waiter.js +12 -0
  56. package/dist/core/foundation/deprecated/waiter.js.map +1 -0
  57. package/dist/core/foundation/edit-completed-event.js +11 -0
  58. package/dist/core/foundation/edit-completed-event.js.map +1 -0
  59. package/dist/core/foundation/edit-event.js +8 -0
  60. package/dist/core/foundation/edit-event.js.map +1 -0
  61. package/dist/core/foundation/edit.js +31 -0
  62. package/dist/core/foundation/edit.js.map +1 -0
  63. package/dist/core/foundation/handle-edit.js +151 -0
  64. package/dist/core/foundation/handle-edit.js.map +1 -0
  65. package/dist/core/foundation/open-event.js +8 -0
  66. package/dist/core/foundation/open-event.js.map +1 -0
  67. package/dist/core/foundation/plugin.js +2 -0
  68. package/dist/core/foundation/plugin.js.map +1 -0
  69. package/dist/core/foundation.js +14 -0
  70. package/dist/core/foundation.js.map +1 -0
  71. package/dist/core/locales.js +21 -0
  72. package/dist/core/locales.js.map +1 -0
  73. package/dist/filtered-list.js +168 -0
  74. package/dist/filtered-list.js.map +1 -0
  75. package/dist/finder-list.js +207 -0
  76. package/dist/finder-list.js.map +1 -0
  77. package/dist/foundation/compare.js +273 -0
  78. package/dist/foundation/compare.js.map +1 -0
  79. package/dist/foundation/dai.js +127 -0
  80. package/dist/foundation/dai.js.map +1 -0
  81. package/dist/foundation/generators.js +67 -0
  82. package/dist/foundation/generators.js.map +1 -0
  83. package/dist/foundation/ied.js +84 -0
  84. package/dist/foundation/ied.js.map +1 -0
  85. package/dist/foundation/nsd.js +13 -0
  86. package/dist/foundation/nsd.js.map +1 -0
  87. package/dist/foundation/nsdoc.js +180 -0
  88. package/dist/foundation/nsdoc.js.map +1 -0
  89. package/dist/foundation/scl.js +64 -0
  90. package/dist/foundation/scl.js.map +1 -0
  91. package/dist/foundation.js +1922 -0
  92. package/dist/foundation.js.map +1 -0
  93. package/dist/icons/compare.js +11 -0
  94. package/dist/icons/compare.js.map +1 -0
  95. package/dist/icons/icons.js +611 -0
  96. package/dist/icons/icons.js.map +1 -0
  97. package/dist/icons/ied-icons.js +11 -0
  98. package/dist/icons/ied-icons.js.map +1 -0
  99. package/dist/icons/lnode.js +50 -0
  100. package/dist/icons/lnode.js.map +1 -0
  101. package/dist/open-scd.js +483 -0
  102. package/dist/open-scd.js.map +1 -0
  103. package/dist/openscd/src/WizardDivider.js +37 -0
  104. package/dist/openscd/src/WizardDivider.js.map +1 -0
  105. package/dist/openscd/src/Wizarding.js +38 -0
  106. package/dist/openscd/src/Wizarding.js.map +1 -0
  107. package/dist/openscd/src/action-icon.js +220 -0
  108. package/dist/openscd/src/action-icon.js.map +1 -0
  109. package/dist/openscd/src/action-pane.js +176 -0
  110. package/dist/openscd/src/action-pane.js.map +1 -0
  111. package/dist/openscd/src/addons/Editor.js +106 -0
  112. package/dist/openscd/src/addons/Editor.js.map +1 -0
  113. package/dist/openscd/src/addons/History.js +490 -0
  114. package/dist/openscd/src/addons/History.js.map +1 -0
  115. package/dist/openscd/src/addons/Layout.js +619 -0
  116. package/dist/openscd/src/addons/Layout.js.map +1 -0
  117. package/dist/openscd/src/addons/Settings.js +465 -0
  118. package/dist/openscd/src/addons/Settings.js.map +1 -0
  119. package/dist/openscd/src/addons/Waiter.js +45 -0
  120. package/dist/openscd/src/addons/Waiter.js.map +1 -0
  121. package/dist/openscd/src/addons/Wizards.js +48 -0
  122. package/dist/openscd/src/addons/Wizards.js.map +1 -0
  123. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +96 -0
  124. package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
  125. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
  126. package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
  127. package/dist/openscd/src/addons/history/get-log-text.js +26 -0
  128. package/dist/openscd/src/addons/history/get-log-text.js.map +1 -0
  129. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +74 -0
  130. package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +1 -0
  131. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
  132. package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
  133. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +165 -0
  134. package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +1 -0
  135. package/dist/openscd/src/filtered-list.js +168 -0
  136. package/dist/openscd/src/filtered-list.js.map +1 -0
  137. package/dist/openscd/src/finder-list.js +207 -0
  138. package/dist/openscd/src/finder-list.js.map +1 -0
  139. package/dist/openscd/src/foundation/compare.js +273 -0
  140. package/dist/openscd/src/foundation/compare.js.map +1 -0
  141. package/dist/openscd/src/foundation/dai.js +127 -0
  142. package/dist/openscd/src/foundation/dai.js.map +1 -0
  143. package/dist/openscd/src/foundation/generators.js +67 -0
  144. package/dist/openscd/src/foundation/generators.js.map +1 -0
  145. package/dist/openscd/src/foundation/ied.js +84 -0
  146. package/dist/openscd/src/foundation/ied.js.map +1 -0
  147. package/dist/openscd/src/foundation/nsd.js +13 -0
  148. package/dist/openscd/src/foundation/nsd.js.map +1 -0
  149. package/dist/openscd/src/foundation/nsdoc.js +180 -0
  150. package/dist/openscd/src/foundation/nsdoc.js.map +1 -0
  151. package/dist/openscd/src/foundation/scl.js +64 -0
  152. package/dist/openscd/src/foundation/scl.js.map +1 -0
  153. package/dist/openscd/src/foundation.js +1922 -0
  154. package/dist/openscd/src/foundation.js.map +1 -0
  155. package/dist/openscd/src/icons/compare.js +11 -0
  156. package/dist/openscd/src/icons/compare.js.map +1 -0
  157. package/dist/openscd/src/icons/icons.js +611 -0
  158. package/dist/openscd/src/icons/icons.js.map +1 -0
  159. package/dist/openscd/src/icons/ied-icons.js +11 -0
  160. package/dist/openscd/src/icons/ied-icons.js.map +1 -0
  161. package/dist/openscd/src/icons/lnode.js +50 -0
  162. package/dist/openscd/src/icons/lnode.js.map +1 -0
  163. package/dist/openscd/src/open-scd.js +483 -0
  164. package/dist/openscd/src/open-scd.js.map +1 -0
  165. package/dist/openscd/src/oscd-filter-button.js +89 -0
  166. package/dist/openscd/src/oscd-filter-button.js.map +1 -0
  167. package/dist/openscd/src/plain-compare-list.js +132 -0
  168. package/dist/openscd/src/plain-compare-list.js.map +1 -0
  169. package/dist/openscd/src/plugin-tag.js +23 -0
  170. package/dist/openscd/src/plugin-tag.js.map +1 -0
  171. package/dist/openscd/src/plugin.events.js +12 -0
  172. package/dist/openscd/src/plugin.events.js.map +1 -0
  173. package/dist/openscd/src/plugin.js +2 -0
  174. package/dist/openscd/src/plugin.js.map +1 -0
  175. package/dist/openscd/src/plugins.js +256 -0
  176. package/dist/openscd/src/plugins.js.map +1 -0
  177. package/dist/openscd/src/schemas.js +9325 -0
  178. package/dist/openscd/src/schemas.js.map +1 -0
  179. package/dist/openscd/src/themes.js +122 -0
  180. package/dist/openscd/src/themes.js.map +1 -0
  181. package/dist/openscd/src/translations/de.js +954 -0
  182. package/dist/openscd/src/translations/de.js.map +1 -0
  183. package/dist/openscd/src/translations/en.js +950 -0
  184. package/dist/openscd/src/translations/en.js.map +1 -0
  185. package/dist/openscd/src/translations/loader.js +10 -0
  186. package/dist/openscd/src/translations/loader.js.map +1 -0
  187. package/dist/openscd/src/wizard-checkbox.js +152 -0
  188. package/dist/openscd/src/wizard-checkbox.js.map +1 -0
  189. package/dist/openscd/src/wizard-dialog.js +374 -0
  190. package/dist/openscd/src/wizard-dialog.js.map +1 -0
  191. package/dist/openscd/src/wizard-select.js +115 -0
  192. package/dist/openscd/src/wizard-select.js.map +1 -0
  193. package/dist/openscd/src/wizard-textfield.js +191 -0
  194. package/dist/openscd/src/wizard-textfield.js.map +1 -0
  195. package/dist/openscd/src/wizards.js +196 -0
  196. package/dist/openscd/src/wizards.js.map +1 -0
  197. package/dist/oscd-filter-button.js +89 -0
  198. package/dist/oscd-filter-button.js.map +1 -0
  199. package/dist/plain-compare-list.js +132 -0
  200. package/dist/plain-compare-list.js.map +1 -0
  201. package/dist/plugin-tag.js +23 -0
  202. package/dist/plugin-tag.js.map +1 -0
  203. package/dist/plugin.events.js +12 -0
  204. package/dist/plugin.events.js.map +1 -0
  205. package/dist/plugin.js +2 -0
  206. package/dist/plugin.js.map +1 -0
  207. package/dist/plugins.js +256 -0
  208. package/dist/plugins.js.map +1 -0
  209. package/dist/schemas.js +9325 -0
  210. package/dist/schemas.js.map +1 -0
  211. package/dist/themes.js +122 -0
  212. package/dist/themes.js.map +1 -0
  213. package/dist/translations/de.js +954 -0
  214. package/dist/translations/de.js.map +1 -0
  215. package/dist/translations/en.js +950 -0
  216. package/dist/translations/en.js.map +1 -0
  217. package/dist/translations/loader.js +10 -0
  218. package/dist/translations/loader.js.map +1 -0
  219. package/dist/wizard-checkbox.js +152 -0
  220. package/dist/wizard-checkbox.js.map +1 -0
  221. package/dist/wizard-dialog.js +374 -0
  222. package/dist/wizard-dialog.js.map +1 -0
  223. package/dist/wizard-select.js +115 -0
  224. package/dist/wizard-select.js.map +1 -0
  225. package/dist/wizard-textfield.js +191 -0
  226. package/dist/wizard-textfield.js.map +1 -0
  227. package/dist/wizards.js +196 -0
  228. package/dist/wizards.js.map +1 -0
  229. package/dist/xml/src/foundation.js +67 -0
  230. package/dist/xml/src/foundation.js.map +1 -0
  231. package/dist/xml/src/index.js +2 -0
  232. package/dist/xml/src/index.js.map +1 -0
  233. package/package.json +99 -4
@@ -0,0 +1,165 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, html, LitElement, property, query, css } from 'lit-element';
3
+ import { get } from 'lit-translate';
4
+ import '@material/mwc-dialog';
5
+ import '@material/mwc-list';
6
+ import { newResetPluginsEvent, newSetPluginsEvent, pluginIcons } from '../../open-scd.js';
7
+ let OscdPluginManager = class OscdPluginManager extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ /** The plugins to render the layout. */
11
+ this.plugins = [];
12
+ }
13
+ render() {
14
+ return html `
15
+ <mwc-dialog
16
+ stacked
17
+ id="plugin-manager-root"
18
+ heading="${get('plugins.heading')}"
19
+ >
20
+ <mwc-list
21
+ id="pluginList"
22
+ multi
23
+ @selected=${(e) => {
24
+ const selectedPlugins = this.pluginList.items
25
+ .filter((item, index) => e.detail.index.has(index))
26
+ // @ts-expect-error: we add plugin to the list item
27
+ .map(item => item.plugin);
28
+ this.dispatchEvent(newSetPluginsEvent(selectedPlugins));
29
+ }}
30
+ >
31
+ <mwc-list-item graphic="avatar" noninteractive>
32
+ <strong>${get(`plugins.editor`)}</strong>
33
+ <mwc-icon slot="graphic" class="inverted">
34
+ ${pluginIcons['editor']}
35
+ </mwc-icon>
36
+ </mwc-list-item>
37
+
38
+ <li divider role="separator"></li>
39
+
40
+ ${this.generateEditorListItems()}
41
+
42
+ <mwc-list-item graphic="avatar" noninteractive>
43
+ <strong>${get(`plugins.menu`)}</strong>
44
+ <mwc-icon slot="graphic" class="inverted">
45
+ <strong>${pluginIcons['menu']}</strong></mwc-icon>
46
+ </mwc-list-item>
47
+ <li divider role="separator"></li>
48
+
49
+ ${this.generateMenuListItems('top')}
50
+
51
+ <li divider role="separator" inset></li>
52
+
53
+ ${this.generateValidatorListItems()}
54
+
55
+ <li divider role="separator" inset></li>
56
+
57
+ ${this.generateMenuListItems('middle')}
58
+
59
+ <li divider role="separator" inset></li>
60
+
61
+ ${this.generateMenuListItems('bottom')}
62
+
63
+ </mwc-list>
64
+ <mwc-button
65
+ slot="secondaryAction"
66
+ icon="refresh"
67
+ label="${get('reset')}"
68
+ @click=${async () => {
69
+ this.dispatchEvent(newResetPluginsEvent());
70
+ this.requestUpdate();
71
+ }}
72
+ style="--mdc-theme-primary: var(--mdc-theme-error)"
73
+ >
74
+ </mwc-button>
75
+ <mwc-button
76
+ slot="secondaryAction"
77
+ icon=""
78
+ label="${get('close')}"
79
+ dialogAction="close">
80
+ </mwc-button>
81
+ <mwc-button
82
+ outlined
83
+ trailingIcon
84
+ slot="primaryAction"
85
+ icon="library_add"
86
+ label="${get('plugins.add.heading')}&hellip;"
87
+ @click=${() => this.dispatchOpenCustomPluginDialogEvent()}>
88
+ </mwc-button>
89
+ </mwc-dialog>
90
+ `;
91
+ }
92
+ show() {
93
+ this.root.show();
94
+ }
95
+ generateEditorListItems() {
96
+ return this.plugins
97
+ .filter(p => p.kind === 'editor')
98
+ .map(this.renderPluginListItem);
99
+ }
100
+ generateMenuListItems(position) {
101
+ return this.plugins
102
+ .filter(p => p.kind === 'menu' && p.position === position)
103
+ .map(this.renderPluginListItem);
104
+ }
105
+ generateValidatorListItems() {
106
+ return this.plugins
107
+ .filter(p => p.kind === 'validator')
108
+ .map(this.renderPluginListItem);
109
+ }
110
+ dispatchOpenCustomPluginDialogEvent() {
111
+ const event = new CustomEvent('open-plugin-download', {
112
+ bubbles: true,
113
+ composed: true,
114
+ });
115
+ this.dispatchEvent(event);
116
+ }
117
+ renderPluginListItem(plugin) {
118
+ if (!plugin) {
119
+ return html ``;
120
+ }
121
+ return html `
122
+ <mwc-check-list-item
123
+ class="${plugin.official ? 'official' : 'external'}"
124
+ value="${plugin.src}"
125
+ .plugin=${plugin}
126
+ ?selected=${plugin.active}
127
+ @request-selected=${(e) => {
128
+ if (e.detail.source !== 'interaction') {
129
+ e.preventDefault();
130
+ e.stopPropagation();
131
+ e.stopImmediatePropagation();
132
+ return false;
133
+ }
134
+ }}
135
+ hasMeta
136
+ left
137
+ >
138
+ <mwc-icon slot="meta">
139
+ ${plugin.icon || pluginIcons[plugin.kind]}
140
+ </mwc-icon>
141
+ ${plugin.name}
142
+ </mwc-check-list-item>
143
+
144
+ `;
145
+ }
146
+ };
147
+ OscdPluginManager.styles = css `
148
+ mwc-dialog {
149
+ --mdc-dialog-max-width: 98vw;
150
+ }
151
+ `;
152
+ __decorate([
153
+ property({ type: Array })
154
+ ], OscdPluginManager.prototype, "plugins", void 0);
155
+ __decorate([
156
+ query('#plugin-manager-root')
157
+ ], OscdPluginManager.prototype, "root", void 0);
158
+ __decorate([
159
+ query('#pluginList')
160
+ ], OscdPluginManager.prototype, "pluginList", void 0);
161
+ OscdPluginManager = __decorate([
162
+ customElement('oscd-plugin-manager')
163
+ ], OscdPluginManager);
164
+ export { OscdPluginManager };
165
+ //# sourceMappingURL=plugin-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../../../src/addons/plugin-manager/plugin-manager.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,KAAK,EAEL,GAAG,EACJ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAG5B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAQpB,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAEL,wCAA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c,EAAE,CAAC;gBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;gBACpB,CAAC,CAAC,wBAAwB,EAAE,CAAC;gBAC7B,OAAO,KAAK,CAAC;aACd;QACH,CAAC;;;;;cAKG,MAAM,CAAC,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;;YAEzC,MAAM,CAAC,IAAI;;;KAGlB,CAAC;IACJ,CAAC;;AAjEM,wBAAM,GAAG,GAAG,CAAA;;;;GAIlB,CAAA;AAzF0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAwB;AACnB;IAA9B,KAAK,CAAC,sBAAsB,CAAC;+CAAc;AACtB;IAArB,KAAK,CAAC,aAAa,CAAC;qDAAkB;AAL5B,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CA2J7B;SA3JY,iBAAiB","sourcesContent":["import {\n customElement,\n html,\n LitElement,\n property,\n query,\n TemplateResult,\n css\n} from 'lit-element';\nimport { get } from 'lit-translate';\n\nimport type { ActionDetail } from '@material/mwc-list';\nimport type { MultiSelectedEvent } from '@material/mwc-list/mwc-list-foundation.js';\nimport type { Dialog } from '@material/mwc-dialog';\nimport '@material/mwc-dialog';\nimport '@material/mwc-list';\nimport type {List} from '@material/mwc-list';\n\nimport {\n newResetPluginsEvent,\n newSetPluginsEvent,\n pluginIcons\n} from '../../open-scd.js';\n\nimport {\n MenuPosition,\n Plugin,\n} from \"../../plugin.js\";\n\n@customElement('oscd-plugin-manager')\nexport class OscdPluginManager extends LitElement {\n\n /** The plugins to render the layout. */\n @property({ type: Array }) plugins: Plugin[] = [];\n @query('#plugin-manager-root') root!: Dialog\n @query('#pluginList') pluginList!: List\n\n render(): TemplateResult {\n return html`\n <mwc-dialog\n stacked\n id=\"plugin-manager-root\"\n heading=\"${get('plugins.heading')}\"\n >\n <mwc-list\n id=\"pluginList\"\n multi\n @selected=${(e: MultiSelectedEvent) => {\n const selectedPlugins = this.pluginList.items\n .filter((item, index) => e.detail.index.has(index))\n // @ts-expect-error: we add plugin to the list item\n .map(item => item.plugin) as Plugin[]\n\n this.dispatchEvent(newSetPluginsEvent(selectedPlugins))\n }}\n >\n <mwc-list-item graphic=\"avatar\" noninteractive>\n <strong>${get(`plugins.editor`)}</strong>\n <mwc-icon slot=\"graphic\" class=\"inverted\">\n ${pluginIcons['editor']}\n </mwc-icon>\n </mwc-list-item>\n\n <li divider role=\"separator\"></li>\n\n ${this.generateEditorListItems()}\n\n <mwc-list-item graphic=\"avatar\" noninteractive>\n <strong>${get(`plugins.menu`)}</strong>\n <mwc-icon slot=\"graphic\" class=\"inverted\">\n <strong>${pluginIcons['menu']}</strong></mwc-icon>\n </mwc-list-item>\n <li divider role=\"separator\"></li>\n\n ${this.generateMenuListItems('top')}\n\n <li divider role=\"separator\" inset></li>\n\n ${this.generateValidatorListItems()}\n\n <li divider role=\"separator\" inset></li>\n\n ${this.generateMenuListItems('middle')}\n\n <li divider role=\"separator\" inset></li>\n\n ${this.generateMenuListItems('bottom')}\n\n </mwc-list>\n <mwc-button\n slot=\"secondaryAction\"\n icon=\"refresh\"\n label=\"${get('reset')}\"\n @click=${async () => {\n this.dispatchEvent(newResetPluginsEvent());\n this.requestUpdate();\n }}\n style=\"--mdc-theme-primary: var(--mdc-theme-error)\"\n >\n </mwc-button>\n <mwc-button\n slot=\"secondaryAction\"\n icon=\"\"\n label=\"${get('close')}\"\n dialogAction=\"close\">\n </mwc-button>\n <mwc-button\n outlined\n trailingIcon\n slot=\"primaryAction\"\n icon=\"library_add\"\n label=\"${get('plugins.add.heading')}&hellip;\"\n @click=${() => this.dispatchOpenCustomPluginDialogEvent()}>\n </mwc-button>\n </mwc-dialog>\n `;\n }\n\n static styles = css`\n mwc-dialog {\n --mdc-dialog-max-width: 98vw;\n }\n `\n\n public show(){\n this.root.show()\n }\n\n\n private generateEditorListItems(): TemplateResult[] {\n return this.plugins\n .filter(p => p.kind === 'editor')\n .map(this.renderPluginListItem)\n }\n\n private generateMenuListItems(position: MenuPosition): TemplateResult[] {\n return this.plugins\n .filter(p => p.kind === 'menu' && p.position === position)\n .map(this.renderPluginListItem)\n }\n\n private generateValidatorListItems(): TemplateResult[] {\n return this.plugins\n .filter(p => p.kind === 'validator')\n .map(this.renderPluginListItem)\n }\n\n private dispatchOpenCustomPluginDialogEvent(): void {\n const event = new CustomEvent('open-plugin-download', {\n bubbles: true,\n composed: true,\n });\n\n this.dispatchEvent(event);\n }\n\n private renderPluginListItem(plugin?: Plugin): TemplateResult {\n if(!plugin){ return html`` }\n\n return html`\n <mwc-check-list-item\n class=\"${plugin.official ? 'official' : 'external'}\"\n value=\"${plugin.src}\"\n .plugin=${plugin}\n ?selected=${plugin.active}\n @request-selected=${(e: CustomEvent<{source: string}>) => {\n if(e.detail.source !== 'interaction'){\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n return false;\n }\n }}\n hasMeta\n left\n >\n <mwc-icon slot=\"meta\">\n ${plugin.icon || pluginIcons[plugin.kind]}\n </mwc-icon>\n ${plugin.name}\n </mwc-check-list-item>\n\n `;\n }\n\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { PluginStateApi } from './plugin-state-api.js';
2
+ export class OscdApi {
3
+ constructor(pluginTag) {
4
+ this.pluginState = new PluginStateApi(pluginTag);
5
+ }
6
+ }
7
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../core/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,OAAO,OAAO;IAGlB,YAAY,SAAiB;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["import { PluginStateApi } from './plugin-state-api.js';\n\nexport class OscdApi {\n public pluginState: PluginStateApi;\n\n constructor(pluginTag: string) {\n this.pluginState = new PluginStateApi(pluginTag);\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ export class Subject {
2
+ constructor() {
3
+ this.subscribers = [];
4
+ }
5
+ next(value) {
6
+ this.subscribers.forEach(s => s(value));
7
+ }
8
+ subscribe(subscriber) {
9
+ this.subscribers.push(subscriber);
10
+ return () => {
11
+ this.unsubscribe(subscriber);
12
+ return subscriber;
13
+ };
14
+ }
15
+ unsubscribe(subscriber) {
16
+ const indexToRemove = this.subscribers.findIndex(s => s === subscriber);
17
+ if (indexToRemove > -1) {
18
+ this.subscribers.splice(indexToRemove, 1);
19
+ }
20
+ }
21
+ }
22
+ //# sourceMappingURL=subject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject.js","sourceRoot":"","sources":["../../../../../core/api/editor/subject.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;IAApB;QACU,gBAAW,GAAoB,EAAE,CAAC;IAqB5C,CAAC;IAnBQ,IAAI,CAAC,KAAQ;QAClB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEM,SAAS,CAAC,UAAyB;QACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAC7B,OAAO,UAAU,CAAC;QACpB,CAAC,CAAA;IACH,CAAC;IAEM,WAAW,CAAC,UAAyB;QAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;QACxE,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE;YACtB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF","sourcesContent":["export type Subscriber<T> = (value: T) => void;\nexport type Unsubscriber<T> = () => Subscriber<T>;\n\nexport class Subject<T> {\n private subscribers: Subscriber<T>[] = [];\n\n public next(value: T): void {\n this.subscribers.forEach(s => s(value));\n }\n\n public subscribe(subscriber: Subscriber<T>): Unsubscriber<T> {\n this.subscribers.push(subscriber);\n\n return () => {\n this.unsubscribe(subscriber);\n return subscriber;\n }\n }\n\n public unsubscribe(subscriber: Subscriber<T>): void {\n const indexToRemove = this.subscribers.findIndex(s => s === subscriber);\n if (indexToRemove > -1) {\n this.subscribers.splice(indexToRemove, 1);\n }\n }\n}\n"]}
@@ -0,0 +1,82 @@
1
+ import { Subject } from './subject.js';
2
+ import { handleEditV2 } from '../../foundation.js';
3
+ export class XMLEditor {
4
+ constructor() {
5
+ this.past = [];
6
+ this.future = [];
7
+ this.commitSubject = new Subject();
8
+ this.undoSubject = new Subject();
9
+ this.redoSubject = new Subject();
10
+ }
11
+ get canUndo() {
12
+ return this.past.length > 0;
13
+ }
14
+ get canRedo() {
15
+ return this.future.length > 0;
16
+ }
17
+ reset() {
18
+ this.past = [];
19
+ this.future = [];
20
+ }
21
+ commit(change, { title, squash } = {}) {
22
+ const commit = squash && this.past.length
23
+ ? this.past[this.past.length - 1]
24
+ : { undo: [], redo: [], time: Date.now() };
25
+ // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57
26
+ const undo = handleEditV2(change);
27
+ // typed as per https://github.com/microsoft/TypeScript/issues/49280#issuecomment-1144181818 recommendation:
28
+ commit.undo.unshift(...[undo].flat(Infinity));
29
+ commit.redo.push(...[change].flat(Infinity));
30
+ if (title)
31
+ commit.title = title;
32
+ if (squash && this.past.length)
33
+ this.past.pop();
34
+ this.past.push(commit);
35
+ this.future = [];
36
+ this.commitSubject.next(commit);
37
+ return commit;
38
+ }
39
+ ;
40
+ undo() {
41
+ const commit = this.past.pop();
42
+ if (!commit)
43
+ return;
44
+ // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57
45
+ handleEditV2(commit.undo);
46
+ this.future.unshift(commit);
47
+ this.undoSubject.next(commit);
48
+ return commit;
49
+ }
50
+ ;
51
+ redo() {
52
+ const commit = this.future.shift();
53
+ if (!commit)
54
+ return;
55
+ // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57
56
+ handleEditV2(commit.redo);
57
+ this.past.push(commit);
58
+ this.redoSubject.next(commit);
59
+ return commit;
60
+ }
61
+ ;
62
+ subscribe(txCallback) {
63
+ return this.commitSubject.subscribe(txCallback);
64
+ }
65
+ ;
66
+ subscribeUndo(txCallback) {
67
+ return this.undoSubject.subscribe(txCallback);
68
+ }
69
+ subscribeRedo(txCallback) {
70
+ return this.redoSubject.subscribe(txCallback);
71
+ }
72
+ subscribeUndoRedo(txCallback) {
73
+ const unsubscribeUndo = this.subscribeUndo(txCallback);
74
+ const unsubscribeRedo = this.subscribeRedo(txCallback);
75
+ return () => {
76
+ unsubscribeUndo();
77
+ unsubscribeRedo();
78
+ return txCallback;
79
+ };
80
+ }
81
+ }
82
+ //# sourceMappingURL=xml-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-editor.js","sourceRoot":"","sources":["../../../../../core/api/editor/xml-editor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,MAAM,OAAO,SAAS;IAAtB;QACS,SAAI,GAAyB,EAAE,CAAC;QAChC,WAAM,GAAyB,EAAE,CAAC;QAEjC,kBAAa,GAAG,IAAI,OAAO,EAAsB,CAAC;QAClD,gBAAW,GAAG,IAAI,OAAO,EAAsB,CAAC;QAChD,gBAAW,GAAG,IAAI,OAAO,EAAsB,CAAC;IA2E1D,CAAC;IAzEC,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,C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AA;IACH,CAAC;CACF","sourcesContent":["import { Transactor, TransactedCallback, Commit, CommitOptions } from '@openscd/oscd-api/dist/Transactor.js';\nimport { EditV2 } from '@openscd/oscd-api/dist/editv2.js';\n\nimport { Subject } from './subject.js';\nimport { handleEditV2 } from '../../foundation.js';\n\nexport interface OscdCommit<C> extends Commit<C> {\n time: number;\n}\n\nexport class XMLEditor implements Transactor<EditV2> {\n public past: OscdCommit<EditV2>[] = [];\n public future: OscdCommit<EditV2>[] = [];\n\n private commitSubject = new Subject<OscdCommit<EditV2>>();\n private undoSubject = new Subject<OscdCommit<EditV2>>();\n private redoSubject = new Subject<OscdCommit<EditV2>>();\n\n get canUndo(): boolean {\n return this.past.length > 0;\n }\n\n get canRedo(): boolean {\n return this.future.length > 0;\n }\n\n reset(): void {\n this.past = [];\n this.future = [];\n }\n\n commit(change: EditV2, { title, squash }: CommitOptions = {}): OscdCommit<EditV2> {\n const commit: OscdCommit<EditV2> =\n squash && this.past.length\n ? this.past[this.past.length - 1]\n : { undo: [], redo: [], time: Date.now() };\n // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57\n const undo = handleEditV2(change as any);\n // typed as per https://github.com/microsoft/TypeScript/issues/49280#issuecomment-1144181818 recommendation:\n commit.undo.unshift(...[undo].flat(Infinity as 1));\n commit.redo.push(...[change].flat(Infinity as 1));\n if (title) commit.title = title;\n if (squash && this.past.length) this.past.pop();\n this.past.push(commit);\n this.future = [];\n this.commitSubject.next(commit);\n return commit;\n };\n\n undo(): OscdCommit<EditV2> | undefined {\n const commit = this.past.pop();\n if (!commit) return;\n // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57\n handleEditV2(commit.undo as any);\n this.future.unshift(commit);\n this.undoSubject.next(commit);\n return commit;\n };\n\n redo(): OscdCommit<EditV2> | undefined {\n const commit = this.future.shift();\n if (!commit) return;\n // TODO: Fix type once issue is fixed https://github.com/openscd/oscd-api/issues/57\n handleEditV2(commit.redo as any);\n this.past.push(commit);\n this.redoSubject.next(commit);\n return commit;\n };\n\n subscribe(txCallback: TransactedCallback<EditV2>): () => TransactedCallback<EditV2> {\n return this.commitSubject.subscribe(txCallback) as () => TransactedCallback<EditV2>;\n };\n\n subscribeUndo(txCallback: TransactedCallback<EditV2>): () => TransactedCallback<EditV2> {\n return this.undoSubject.subscribe(txCallback) as () => TransactedCallback<EditV2>;\n }\n\n subscribeRedo(txCallback: TransactedCallback<EditV2>): () => TransactedCallback<EditV2> {\n return this.redoSubject.subscribe(txCallback) as () => TransactedCallback<EditV2>;\n }\n\n subscribeUndoRedo(txCallback: TransactedCallback<EditV2>): () => TransactedCallback<EditV2> {\n const unsubscribeUndo = this.subscribeUndo(txCallback);\n const unsubscribeRedo = this.subscribeRedo(txCallback);\n\n return () => {\n unsubscribeUndo();\n unsubscribeRedo();\n return txCallback;\n }\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ export class PluginStateApi {
2
+ constructor(tag) {
3
+ this.pluginTag = tag;
4
+ }
5
+ setState(state) {
6
+ this.setPluginState(state);
7
+ }
8
+ getState() {
9
+ return this.getPluginState();
10
+ }
11
+ updateState(partialState) {
12
+ const pluginState = this.getPluginState();
13
+ const patchedState = {
14
+ ...pluginState,
15
+ ...partialState
16
+ };
17
+ this.setPluginState(patchedState);
18
+ }
19
+ setPluginState(state) {
20
+ PluginStateApi.state[this.pluginTag] = state;
21
+ }
22
+ getPluginState() {
23
+ return PluginStateApi.state[this.pluginTag] ?? null;
24
+ }
25
+ }
26
+ PluginStateApi.state = {};
27
+ //# sourceMappingURL=plugin-state-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-state-api.js","sourceRoot":"","sources":["../../../../core/api/plugin-state-api.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,cAAc;IAIzB,YAAY,GAAW;QACrB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;IACvB,CAAC;IAEM,QAAQ,CAAC,KAAyB;QACvC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC;IAEM,WAAW,CAAC,YAAkC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,MAAM,YAAY,GAAG;YACnB,GAAG,WAAW;YACd,GAAG,YAAY;SAChB,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAEO,cAAc,CAAC,KAAyB;QAC9C,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IAC/C,CAAC;IAEO,cAAc;QACpB,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IACtD,CAAC;;AA9Bc,oBAAK,GAA0C,EAAE,CAAC","sourcesContent":["type PluginState = {\n [key: string]: unknown\n}\n\nexport class PluginStateApi {\n private static state: { [tag: string]: PluginState | null } = {};\n private pluginTag: string;\n\n constructor(tag: string) {\n this.pluginTag = tag;\n }\n\n public setState(state: PluginState | null): void {\n this.setPluginState(state);\n }\n\n public getState(): PluginState | null {\n return this.getPluginState();\n }\n\n public updateState(partialState: Partial<PluginState>): void {\n const pluginState = this.getPluginState();\n const patchedState = {\n ...pluginState,\n ...partialState\n };\n this.setPluginState(patchedState);\n }\n\n private setPluginState(state: PluginState | null): void {\n PluginStateApi.state[this.pluginTag] = state;\n }\n\n private getPluginState(): PluginState | null {\n return PluginStateApi.state[this.pluginTag] ?? null;\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Hashes `str` using the cyrb64 variant of
3
+ * https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
4
+ * @returns digest - a rather insecure hash, very quickly
5
+ */
6
+ export function cyrb64(str) {
7
+ /* eslint-disable no-bitwise */
8
+ let h1 = 0xdeadbeef;
9
+ let h2 = 0x41c6ce57;
10
+ /* eslint-disable-next-line no-plusplus */
11
+ for (let i = 0, ch; i < str.length; i++) {
12
+ ch = str.charCodeAt(i);
13
+ h1 = Math.imul(h1 ^ ch, 2654435761);
14
+ h2 = Math.imul(h2 ^ ch, 1597334677);
15
+ }
16
+ h1 =
17
+ Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
18
+ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
19
+ h2 =
20
+ Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
21
+ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
22
+ return ((h2 >>> 0).toString(16).padStart(8, '0') +
23
+ (h1 >>> 0).toString(16).padStart(8, '0'));
24
+ /* eslint-enable no-bitwise */
25
+ }
26
+ //# sourceMappingURL=cyrb64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cyrb64.js","sourceRoot":"","sources":["../../../../core/foundation/cyrb64.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,+BAA+B;IAC/B,IAAI,EAAE,GAAG,UAAU,CAAC;IACpB,IAAI,EAAE,GAAG,UAAU,CAAC;IACpB,0CAA0C;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACvB,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACpC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;KACrC;IACD,EAAE;QACA,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1C,EAAE;QACA,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1C,OAAO,CACL,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QACxC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACzC,CAAC;IACF,8BAA8B;AAChC,CAAC","sourcesContent":["/**\n * Hashes `str` using the cyrb64 variant of\n * https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js\n * @returns digest - a rather insecure hash, very quickly\n */\nexport function cyrb64(str: string): string {\n /* eslint-disable no-bitwise */\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n /* eslint-disable-next-line no-plusplus */\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 =\n Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^\n Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 =\n Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^\n Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n return (\n (h2 >>> 0).toString(16).padStart(8, '0') +\n (h1 >>> 0).toString(16).padStart(8, '0')\n );\n /* eslint-enable no-bitwise */\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @deprecated Use the new edit event V2 API instead.
3
+ */
4
+ export function isComplex(edit) {
5
+ return edit instanceof Array;
6
+ }
7
+ /**
8
+ * @deprecated Use the new edit event V2 API instead.
9
+ */
10
+ export function isInsert(edit) {
11
+ return edit.parent !== undefined;
12
+ }
13
+ /**
14
+ * @deprecated Use the new edit event V2 API instead.
15
+ */
16
+ export function isNamespaced(value) {
17
+ return value !== null && typeof value !== 'string';
18
+ }
19
+ /**
20
+ * @deprecated Use the new edit event V2 API instead.
21
+ */
22
+ export function isUpdate(edit) {
23
+ return edit.element !== undefined;
24
+ }
25
+ /**
26
+ * @deprecated Use the new edit event V2 API instead.
27
+ */
28
+ export function isRemove(edit) {
29
+ return (edit.parent === undefined && edit.node !== undefined);
30
+ }
31
+ /**
32
+ * @deprecated Use the new edit event V2 API instead.
33
+ */
34
+ export function newEditEvent(edit, initiator = 'user') {
35
+ return new CustomEvent('oscd-edit', {
36
+ composed: true,
37
+ bubbles: true,
38
+ detail: {
39
+ edit: edit,
40
+ initiator: initiator,
41
+ },
42
+ });
43
+ }
44
+ //# sourceMappingURL=edit-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-event.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/edit-event.ts"],"names":[],"mappings":"AA6CA;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,YAAY,KAAK,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAU;IACjC,OAAQ,IAAe,CAAC,MAAM,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAqB;IAErB,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAU;IACjC,OAAQ,IAAe,CAAC,OAAO,KAAK,SAAS,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAU;IACjC,OAAO,CACJ,IAAe,CAAC,MAAM,KAAK,SAAS,IAAK,IAAe,CAAC,IAAI,KAAK,SAAS,CAC7E,CAAC;AACJ,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAO,EACP,YAAuB,MAAM;IAE7B,OAAO,IAAI,WAAW,CAAkB,WAAW,EAAE;QACnD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;QACb,MAAM,EAAE;YACN,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,SAAS;SACrB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type Initiator = 'user' | 'system' | 'undo' | 'redo' | string;\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type Insert = {\n parent: Node;\n node: Node;\n reference: Node | null;\n};\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type NamespacedAttributeValue = {\n value: string | null;\n namespaceURI: string | null;\n};\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type AttributeValue = string | null | NamespacedAttributeValue;\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type Update = {\n element: Element;\n attributes: Partial<Record<string, AttributeValue>>;\n};\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type Remove = {\n node: Node;\n};\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type Edit = Insert | Update | Remove | Edit[];\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function isComplex(edit: Edit): edit is Edit[] {\n return edit instanceof Array;\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function isInsert(edit: Edit): edit is Insert {\n return (edit as Insert).parent !== undefined;\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function isNamespaced(\n value: AttributeValue\n): value is NamespacedAttributeValue {\n return value !== null && typeof value !== 'string';\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function isUpdate(edit: Edit): edit is Update {\n return (edit as Update).element !== undefined;\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function isRemove(edit: Edit): edit is Remove {\n return (\n (edit as Insert).parent === undefined && (edit as Remove).node !== undefined\n );\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport interface EditEventDetail<E extends Edit = Edit> {\n edit: E;\n initiator: Initiator;\n}\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport type EditEvent = CustomEvent<EditEventDetail>;\n\n/**\n * @deprecated Use the new edit event V2 API instead.\n */\nexport function newEditEvent<E extends Edit>(\n edit: E,\n initiator: Initiator = 'user'\n): EditEvent {\n return new CustomEvent<EditEventDetail>('oscd-edit', {\n composed: true,\n bubbles: true,\n detail: {\n edit: edit,\n initiator: initiator,\n },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['oscd-edit']: EditEvent;\n }\n}\n"]}
@@ -0,0 +1,94 @@
1
+ export function isCreate(action) {
2
+ return (action.old === undefined &&
3
+ action.new?.parent !== undefined &&
4
+ action.new?.element !== undefined);
5
+ }
6
+ export function isDelete(action) {
7
+ return (action.old?.parent !== undefined &&
8
+ action.old?.element !== undefined &&
9
+ action.new === undefined);
10
+ }
11
+ export function isMove(action) {
12
+ return (action.old?.parent !== undefined &&
13
+ action.old?.element !== undefined &&
14
+ action.new?.parent !== undefined &&
15
+ action.new?.element == undefined);
16
+ }
17
+ export function isReplace(action) {
18
+ return (action.old?.parent === undefined &&
19
+ action.old?.element !== undefined &&
20
+ action.new?.parent === undefined &&
21
+ action.new?.element !== undefined);
22
+ }
23
+ export function isUpdate(action) {
24
+ return (action.old === undefined &&
25
+ action.new === undefined &&
26
+ action.element !== undefined &&
27
+ action.newAttributes !== undefined &&
28
+ action.oldAttributes !== undefined);
29
+ }
30
+ export function isSimple(action) {
31
+ return !(action.actions instanceof Array);
32
+ }
33
+ //** return `Update` action for `element` adding `oldAttributes` */
34
+ export function createUpdateAction(element, newAttributes) {
35
+ const oldAttributes = {};
36
+ Array.from(element.attributes).forEach(attr => {
37
+ oldAttributes[attr.name] = attr.value;
38
+ });
39
+ return { element, oldAttributes, newAttributes };
40
+ }
41
+ /** Throws an error bearing `message`, never returning. */
42
+ export function unreachable(message) {
43
+ throw new Error(message);
44
+ }
45
+ /** @returns an [[`EditorAction`]] with opposite effect of `action`. */
46
+ export function invert(action) {
47
+ if (!isSimple(action)) {
48
+ const inverse = {
49
+ title: action.title,
50
+ derived: action.derived,
51
+ actions: [],
52
+ };
53
+ action.actions.forEach(element => inverse.actions.unshift(invert(element)));
54
+ return inverse;
55
+ }
56
+ const metaData = {
57
+ derived: action.derived,
58
+ checkValidity: action.checkValidity,
59
+ };
60
+ if (isCreate(action))
61
+ return { old: action.new, ...metaData };
62
+ else if (isDelete(action))
63
+ return { new: action.old, ...metaData };
64
+ else if (isMove(action))
65
+ return {
66
+ old: {
67
+ parent: action.new.parent,
68
+ element: action.old.element,
69
+ reference: action.new.reference,
70
+ },
71
+ new: { parent: action.old.parent, reference: action.old.reference },
72
+ ...metaData,
73
+ };
74
+ else if (isReplace(action))
75
+ return { new: action.old, old: action.new, ...metaData };
76
+ else if (isUpdate(action))
77
+ return {
78
+ element: action.element,
79
+ oldAttributes: action.newAttributes,
80
+ newAttributes: action.oldAttributes,
81
+ ...metaData,
82
+ };
83
+ else
84
+ return unreachable('Unknown EditorAction type in invert.');
85
+ }
86
+ export function newActionEvent(action, initiator = 'user', eventInitDict) {
87
+ return new CustomEvent('editor-action', {
88
+ bubbles: true,
89
+ composed: true,
90
+ ...eventInitDict,
91
+ detail: { action, initiator, ...eventInitDict?.detail },
92
+ });
93
+ }
94
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/editor.ts"],"names":[],"mappings":"AA8CA,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAC3C,OAAO,CACJ,MAAkB,CAAC,GAAG,KAAK,SAAS;QACpC,MAAiB,CAAC,GAAG,E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IAAI,MAAM,CAAC,MAAM,CAAC;QACrB,OAAO;YACL,GAAG,EAAE;gBACH,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM;gBACzB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO;gBAC3B,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS;aAChC;YACD,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE;YACnE,GAAG,QAAQ;SACZ,CAAC;SACC,IAAI,SAAS,CAAC,MAAM,CAAC;QACxB,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;SACtD,IAAI,QAAQ,CAAC,MAAM,CAAC;QACvB,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,GAAG,QAAQ;SACZ,CAAC;;QACC,OAAO,WAAW,CAAC,sCAAsC,CAAC,CAAC;AAClE,CAAC;AAWD,MAAM,UAAU,cAAc,CAC5B,MAAS,EACT,YAAuB,MAAM,EAC7B,aAA+D;IAE/D,OAAO,IAAI,WAAW,CAAwB,eAAe,EAAE;QAC7D,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KACxD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Initiator } from './edit-event.js';\n\n/** Inserts `new.element` to `new.parent` before `new.reference`. */\nexport interface Create {\n new: { parent: Node; element: Node; reference?: Node | null };\n derived?: boolean;\n checkValidity?: () => boolean;\n}\n/** Removes `old.element` from `old.parent` before `old.reference`. */\nexport interface Delete {\n old: { parent: Node; element: Node; reference?: Node | null };\n derived?: boolean;\n checkValidity?: () => boolean;\n}\n/** Reparents of `old.element` to `new.parent` before `new.reference`. */\nexport interface Move {\n old: { parent: Element; element: Element; reference?: Node | null };\n new: { parent: Element; reference?: Node | null };\n derived?: boolean;\n checkValidity?: () => boolean;\n}\n/** Replaces `old.element` with `new.element`, keeping element children. */\nexport interface Replace {\n old: { element: Element };\n new: { element: Element };\n derived?: boolean;\n checkValidity?: () => boolean;\n}\n/** Swaps `element`s `oldAttributes` with `newAttributes` */\nexport interface Update {\n element: Element;\n oldAttributes: Record<string, string | null>;\n newAttributes: Record<string, string | null>;\n derived?: boolean;\n checkValidity?: () => boolean;\n}\n\nexport type SimpleAction = Update | Create | Replace | Delete | Move;\nexport type ComplexAction = {\n actions: SimpleAction[];\n title: string;\n derived?: boolean;\n};\n/** Represents an intended or committed change to some `Element`. */\nexport type EditorAction = SimpleAction | ComplexAction;\n\nexport function isCreate(action: EditorAction): action is Create {\n return (\n (action as Replace).old === undefined &&\n (action as Create).new?.parent !== undefined &&\n (action as Create).new?.element !== undefined\n );\n}\nexport function isDelete(action: EditorAction): action is Delete {\n return (\n (action as Delete).old?.parent !== undefined &&\n (action as Delete).old?.element !== undefined &&\n (action as Replace).new === undefined\n );\n}\nexport function isMove(action: EditorAction): action is Move {\n return (\n (action as Move).old?.parent !== undefined &&\n (action as Move).old?.element !== undefined &&\n (action as Move).new?.parent !== undefined &&\n (action as Replace).new?.element == undefined\n );\n}\nexport function isReplace(action: EditorAction): action is Replace {\n return (\n (action as Move).old?.parent === undefined &&\n (action as Replace).old?.element !== undefined &&\n (action as Move).new?.parent === undefined &&\n (action as Replace).new?.element !== undefined\n );\n}\nexport function isUpdate(action: EditorAction): action is Update {\n return (\n (action as Replace).old === undefined &&\n (action as Replace).new === undefined &&\n (action as Update).element !== undefined &&\n (action as Update).newAttributes !== undefined &&\n (action as Update).oldAttributes !== undefined\n );\n}\nexport function isSimple(action: EditorAction): action is SimpleAction {\n return !((<ComplexAction>action).actions instanceof Array);\n}\n\n//** return `Update` action for `element` adding `oldAttributes` */\nexport function createUpdateAction(\n element: Element,\n newAttributes: Record<string, string | null>\n): Update {\n const oldAttributes: Record<string, string | null> = {};\n Array.from(element.attributes).forEach(attr => {\n oldAttributes[attr.name] = attr.value;\n });\n\n return { element, oldAttributes, newAttributes };\n}\n\n/** Throws an error bearing `message`, never returning. */\nexport function unreachable(message: string): never {\n throw new Error(message);\n}\n\n/** @returns an [[`EditorAction`]] with opposite effect of `action`. */\nexport function invert(action: EditorAction): EditorAction {\n if (!isSimple(action)) {\n const inverse: ComplexAction = {\n title: action.title,\n derived: action.derived,\n actions: [],\n };\n action.actions.forEach(element =>\n inverse.actions.unshift(<SimpleAction>invert(element))\n );\n return inverse;\n }\n\n const metaData = {\n derived: action.derived,\n checkValidity: action.checkValidity,\n };\n if (isCreate(action)) return { old: action.new, ...metaData };\n else if (isDelete(action)) return { new: action.old, ...metaData };\n else if (isMove(action))\n return {\n old: {\n parent: action.new.parent,\n element: action.old.element,\n reference: action.new.reference,\n },\n new: { parent: action.old.parent, reference: action.old.reference },\n ...metaData,\n };\n else if (isReplace(action))\n return { new: action.old, old: action.new, ...metaData };\n else if (isUpdate(action))\n return {\n element: action.element,\n oldAttributes: action.newAttributes,\n newAttributes: action.oldAttributes,\n ...metaData,\n };\n else return unreachable('Unknown EditorAction type in invert.');\n}\n\n/** Represents some intended modification of a `Document` being edited. */\nexport interface EditorActionDetail<T extends EditorAction> {\n action: T;\n initiator?: Initiator;\n}\nexport type EditorActionEvent<T extends EditorAction> = CustomEvent<\n EditorActionDetail<T>\n>;\n\nexport function newActionEvent<T extends EditorAction>(\n action: T,\n initiator: Initiator = 'user',\n eventInitDict?: CustomEventInit<Partial<EditorActionDetail<T>>>\n): EditorActionEvent<T> {\n return new CustomEvent<EditorActionDetail<T>>('editor-action', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { action, initiator, ...eventInitDict?.detail },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['editor-action']: EditorActionEvent<EditorAction>;\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ export function newLogEvent(detail, eventInitDict) {
2
+ return new CustomEvent('log', {
3
+ bubbles: true,
4
+ composed: true,
5
+ ...eventInitDict,
6
+ detail: { ...detail, ...eventInitDict?.detail },
7
+ });
8
+ }
9
+ export function newIssueEvent(detail, eventInitDict) {
10
+ return new CustomEvent('issue', {
11
+ bubbles: true,
12
+ composed: true,
13
+ ...eventInitDict,
14
+ detail: { ...detail, ...eventInitDict?.detail },
15
+ });
16
+ }
17
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/history.ts"],"names":[],"mappings":"AAgDA,MAAM,UAAU,WAAW,CACzB,MAAiB,EACjB,aAA0C;IAE1C,OAAO,IAAI,WAAW,CAAY,KAAK,EAAE;QACvC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAAmB,EACnB,aAA4C;IAE5C,OAAO,IAAI,WAAW,CAAc,OAAO,EAAE;QAC3C,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { EditV2 } from '../edit.js';\n\ntype InfoEntryKind = 'info' | 'warning' | 'error';\n\nexport type LogEntryType = 'info' | 'warning' | 'error' | 'action' | 'reset';\n\n/** The basic information contained in each [[`LogEntry`]]. */\nexport interface LogDetailBase {\n title: string;\n message?: string;\n}\n/** The [[`LogEntry`]] for a committed [[`EditorAction`]]. */\nexport interface CommitDetail extends LogDetailBase {\n kind: 'action';\n redo: EditV2;\n undo: EditV2;\n squash?: boolean;\n}\n/** A [[`LogEntry`]] for notifying the user. */\nexport interface InfoDetail extends LogDetailBase {\n kind: InfoEntryKind;\n cause?: LogEntry;\n}\n\nexport interface ResetDetail {\n kind: 'reset';\n}\n\nexport type LogDetail = InfoDetail | CommitDetail | ResetDetail;\nexport type LogEvent = CustomEvent<LogDetail>;\n\nexport interface IssueDetail extends LogDetailBase {\n validatorId: string;\n element?: Element;\n}\nexport type IssueEvent = CustomEvent<IssueDetail>;\n\n/** [[`LogEntry`]]s are timestamped upon being committed to the `history`. */\ninterface Timestamped {\n time: Date | null;\n}\n\nexport type CommitEntry = Timestamped & CommitDetail;\nexport type InfoEntry = Timestamped & InfoDetail;\n\nexport type LogEntry = InfoEntry | CommitEntry;\n\n\nexport function newLogEvent(\n detail: LogDetail,\n eventInitDict?: CustomEventInit<LogDetail>\n): LogEvent {\n return new CustomEvent<LogDetail>('log', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\nexport function newIssueEvent(\n detail: IssueDetail,\n eventInitDict?: CustomEventInit<IssueDetail>\n): IssueEvent {\n return new CustomEvent<IssueDetail>('issue', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['log']: LogEvent;\n ['issue']: IssueEvent;\n }\n }\n "]}
@@ -0,0 +1,9 @@
1
+ export function newOpenDocEvent(doc, docName, eventInitDict) {
2
+ return new CustomEvent('open-doc', {
3
+ bubbles: true,
4
+ composed: true,
5
+ ...eventInitDict,
6
+ detail: { doc, docName, ...eventInitDict?.detail },
7
+ });
8
+ }
9
+ //# sourceMappingURL=open-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-event.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/open-event.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,eAAe,CAC7B,GAAgB,EAChB,OAAe,EACf,aAAuD;IAEvD,OAAO,IAAI,WAAW,CAAgB,UAAU,EAAE;QAChD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KACnD,CAAC,CAAC;AACL,CAAC","sourcesContent":["/** Represents a document to be opened. */\nexport interface OpenDocDetail {\n doc: XMLDocument;\n docName: string;\n docId?: string;\n}\nexport type OpenDocEvent = CustomEvent<OpenDocDetail>;\nexport function newOpenDocEvent(\n doc: XMLDocument,\n docName: string,\n eventInitDict?: CustomEventInit<Partial<OpenDocDetail>>\n): OpenDocEvent {\n return new CustomEvent<OpenDocDetail>('open-doc', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { doc, docName, ...eventInitDict?.detail },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['open-doc']: OpenDocEvent;\n }\n }"]}
@@ -0,0 +1,19 @@
1
+ export function newLoadNsdocEvent(nsdoc, filename) {
2
+ return new CustomEvent('load-nsdoc', {
3
+ bubbles: true,
4
+ composed: true,
5
+ detail: { nsdoc, filename },
6
+ });
7
+ }
8
+ export function newSettingsUIEvent(show, eventInitDict) {
9
+ return new CustomEvent('oscd-settings', {
10
+ bubbles: true,
11
+ composed: true,
12
+ ...eventInitDict,
13
+ detail: {
14
+ show,
15
+ ...eventInitDict?.detail,
16
+ },
17
+ });
18
+ }
19
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/settings.ts"],"names":[],"mappings":"AAgCA,MAAM,UAAU,iBAAiB,CAC/B,KAAa,EACb,QAAgB;IAEhB,OAAO,IAAI,WAAW,CAAkB,YAAY,EAAE;QACpD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAQD,MAAM,UAAU,kBAAkB,CAChC,IAAa,EACb,aAA0D;IAE1D,OAAO,IAAI,WAAW,CAAmB,eAAe,EAAE;QACxD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,IAAI;YACJ,GAAG,aAAa,EAAE,MAAM;SACzB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["export type Language = 'en' | 'de';\n\nexport type Settings = {\n language: Language;\n theme: 'light' | 'dark';\n mode: 'safe' | 'pro';\n showieds: 'on' | 'off';\n 'IEC 61850-7-2': string | undefined;\n 'IEC 61850-7-3': string | undefined;\n 'IEC 61850-7-4': string | undefined;\n 'IEC 61850-8-1': string | undefined;\n};\n\nexport type NsdVersion = {\n version: string | undefined;\n revision: string | undefined;\n release: string | undefined;\n};\n\nexport type NsdVersions = {\n 'IEC 61850-7-2': NsdVersion;\n 'IEC 61850-7-3': NsdVersion;\n 'IEC 61850-7-4': NsdVersion;\n 'IEC 61850-8-1': NsdVersion;\n};\n\n/** Represents a document to be opened. */\nexport interface LoadNsdocDetail {\n nsdoc: string;\n filename: string;\n}\nexport type LoadNsdocEvent = CustomEvent<LoadNsdocDetail>;\nexport function newLoadNsdocEvent(\n nsdoc: string,\n filename: string\n): LoadNsdocEvent {\n return new CustomEvent<LoadNsdocDetail>('load-nsdoc', {\n bubbles: true,\n composed: true,\n detail: { nsdoc, filename },\n });\n}\n\nexport interface SettingsUIDetail {\n show: boolean;\n}\n\nexport type SettingsUIEvent = CustomEvent<SettingsUIDetail>;\n\nexport function newSettingsUIEvent(\n show: boolean,\n eventInitDict?: CustomEventInit<Partial<SettingsUIDetail>>\n): SettingsUIEvent {\n return new CustomEvent<SettingsUIDetail>('oscd-settings', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: {\n show,\n ...eventInitDict?.detail,\n },\n });\n}\n\n\ndeclare global {\n interface ElementEventMap {\n ['oscd-settings']: SettingsUIEvent;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export function newValidateEvent(eventInitDict) {
2
+ return new CustomEvent('validate', {
3
+ bubbles: true,
4
+ composed: true,
5
+ ...eventInitDict,
6
+ });
7
+ }
8
+ //# sourceMappingURL=validation.js.map