@omicronenergy/oscd-shell 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/foundation/cyrb64.d.ts +6 -0
- package/dist/foundation/cyrb64.js +26 -0
- package/dist/foundation/cyrb64.js.map +1 -0
- package/dist/foundation.d.ts +1 -0
- package/dist/foundation.js +2 -0
- package/dist/foundation.js.map +1 -0
- package/dist/locales/de.d.ts +10 -0
- package/dist/locales/de.js +15 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales.d.ts +13 -0
- package/dist/locales.js +21 -0
- package/dist/locales.js.map +1 -0
- package/dist/oscd-shell.d.ts +119 -0
- package/dist/oscd-shell.js +685 -0
- package/dist/oscd-shell.js.map +1 -0
- package/dist/utils/plugin-utils.d.ts +29 -0
- package/dist/utils/plugin-utils.js +138 -0
- package/dist/utils/plugin-utils.js.map +1 -0
- package/dist/utils/plugin-utils.spec.d.ts +1 -0
- package/dist/utils/plugin-utils.spec.js +115 -0
- package/dist/utils/plugin-utils.spec.js.map +1 -0
- package/package.json +40 -35
- package/.editorconfig +0 -22
- package/.github/actions/setup-node-env/action.yml +0 -49
- package/.github/workflows/release-please.yml +0 -84
- package/.github/workflows/test.yml +0 -18
- package/.github/workflows/update-screenshots.yml +0 -29
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.release-please-manifest.json +0 -1
- package/CHANGELOG.md +0 -73
- package/CONTRIBUTING.md +0 -393
- package/commitlint.config.js +0 -1
- package/demo/AddPlugins.js +0 -42
- package/demo/DemoPluginSrc.js +0 -9
- package/demo/embedded.html +0 -17
- package/demo/index.html +0 -95
- package/foundation/cyrb64.ts +0 -27
- package/foundation/edit-event.ts +0 -273
- package/foundation/open-event.ts +0 -21
- package/foundation.ts +0 -28
- package/lit-localize.json +0 -15
- package/localization/de.xlf +0 -75
- package/oscd-shell.editing.spec.ts +0 -813
- package/oscd-shell.plugging.spec.ts +0 -78
- package/oscd-shell.spec.ts +0 -431
- package/oscd-shell.test.ts +0 -382
- package/oscd-shell.ts +0 -906
- package/release-please-config.json +0 -21
- package/rollup.config.js +0 -51
- package/screenshots/Chromium/baseline/app-bar-de.png +0 -0
- package/screenshots/Chromium/baseline/app-bar-en.png +0 -0
- package/screenshots/Chromium/baseline/document-name-de.png +0 -0
- package/screenshots/Chromium/baseline/document-name-en.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-de.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-en.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-selected-de.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-selected-en.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-with-doc-de.png +0 -0
- package/screenshots/Chromium/baseline/editor-plugins-with-doc-en.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-de.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-en.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-redone-de.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-redone-en.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-undone-de.png +0 -0
- package/screenshots/Chromium/baseline/log-entries-undone-en.png +0 -0
- package/screenshots/Chromium/baseline/log-screen-de.png +0 -0
- package/screenshots/Chromium/baseline/log-screen-en.png +0 -0
- package/screenshots/Chromium/baseline/menu-drawer-de.png +0 -0
- package/screenshots/Chromium/baseline/menu-drawer-en.png +0 -0
- package/screenshots/Chromium/baseline/menu-plugins-de.png +0 -0
- package/screenshots/Chromium/baseline/menu-plugins-en.png +0 -0
- package/screenshots/Chromium/baseline/menu-plugins-triggered-de.png +0 -0
- package/screenshots/Chromium/baseline/menu-plugins-triggered-en.png +0 -0
- package/screenshots/Firefox/baseline/app-bar-de.png +0 -0
- package/screenshots/Firefox/baseline/app-bar-en.png +0 -0
- package/screenshots/Firefox/baseline/document-name-de.png +0 -0
- package/screenshots/Firefox/baseline/document-name-en.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-de.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-en.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-selected-de.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-selected-en.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-with-doc-de.png +0 -0
- package/screenshots/Firefox/baseline/editor-plugins-with-doc-en.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-de.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-en.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-redone-de.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-redone-en.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-undone-de.png +0 -0
- package/screenshots/Firefox/baseline/log-entries-undone-en.png +0 -0
- package/screenshots/Firefox/baseline/log-screen-de.png +0 -0
- package/screenshots/Firefox/baseline/log-screen-en.png +0 -0
- package/screenshots/Firefox/baseline/menu-drawer-de.png +0 -0
- package/screenshots/Firefox/baseline/menu-drawer-en.png +0 -0
- package/screenshots/Firefox/baseline/menu-plugins-de.png +0 -0
- package/screenshots/Firefox/baseline/menu-plugins-en.png +0 -0
- package/screenshots/Firefox/baseline/menu-plugins-triggered-de.png +0 -0
- package/screenshots/Firefox/baseline/menu-plugins-triggered-en.png +0 -0
- package/screenshots/Webkit/baseline/app-bar-de.png +0 -0
- package/screenshots/Webkit/baseline/app-bar-en.png +0 -0
- package/screenshots/Webkit/baseline/document-name-de.png +0 -0
- package/screenshots/Webkit/baseline/document-name-en.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-de.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-en.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-selected-de.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-selected-en.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-with-doc-de.png +0 -0
- package/screenshots/Webkit/baseline/editor-plugins-with-doc-en.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-de.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-en.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-redone-de.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-redone-en.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-undone-de.png +0 -0
- package/screenshots/Webkit/baseline/log-entries-undone-en.png +0 -0
- package/screenshots/Webkit/baseline/log-screen-de.png +0 -0
- package/screenshots/Webkit/baseline/log-screen-en.png +0 -0
- package/screenshots/Webkit/baseline/menu-drawer-de.png +0 -0
- package/screenshots/Webkit/baseline/menu-drawer-en.png +0 -0
- package/screenshots/Webkit/baseline/menu-plugins-de.png +0 -0
- package/screenshots/Webkit/baseline/menu-plugins-en.png +0 -0
- package/screenshots/Webkit/baseline/menu-plugins-triggered-de.png +0 -0
- package/screenshots/Webkit/baseline/menu-plugins-triggered-en.png +0 -0
- package/tsconfig.json +0 -23
- package/utils/testing.spec.ts +0 -210
- package/utils/testing.ts +0 -65
- package/web-dev-server.config.js +0 -24
- package/web-test-runner.config.js +0 -180
package/demo/AddPlugins.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-alert */
|
|
2
|
-
export default class AddPlugins extends HTMLElement {
|
|
3
|
-
/* eslint-disable-next-line class-methods-use-this */
|
|
4
|
-
run() {
|
|
5
|
-
const editor = (this.getRootNode()).host;
|
|
6
|
-
const kind = window.confirm(
|
|
7
|
-
`Add a menu type plugin?
|
|
8
|
-
If you choose 'Cancel', an editor type plugin will be added instead.`)
|
|
9
|
-
? 'menu'
|
|
10
|
-
: 'editor';
|
|
11
|
-
const requireDoc = window.confirm(
|
|
12
|
-
'Does the plugin require a loaded document? (OK=yes, Cancel=no)')
|
|
13
|
-
;
|
|
14
|
-
const name =
|
|
15
|
-
window.prompt('Plugin name', 'My plugin') ||
|
|
16
|
-
'Default plugin name';
|
|
17
|
-
const icon =
|
|
18
|
-
window.prompt('Plugin icon (material icon name)', 'extension') ||
|
|
19
|
-
'extension';
|
|
20
|
-
const active = true;
|
|
21
|
-
const src =
|
|
22
|
-
window.prompt(
|
|
23
|
-
'Plugin source URI',
|
|
24
|
-
`/demo/DemoPluginSrc.js?${Date.now()}`
|
|
25
|
-
) || 'data:text/javascript,';
|
|
26
|
-
const plugin = { name, src, icon, active, requireDoc };
|
|
27
|
-
if (
|
|
28
|
-
!window.confirm(
|
|
29
|
-
`Add ${kind} plugin ${JSON.stringify(plugin, null, ' ')}?`)
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
return;
|
|
33
|
-
editor.plugins = {
|
|
34
|
-
...editor.plugins,
|
|
35
|
-
[kind]: [
|
|
36
|
-
...(editor.plugins[kind] || []),
|
|
37
|
-
plugin,
|
|
38
|
-
],
|
|
39
|
-
}
|
|
40
|
-
editor.requestUpdate('plugins');
|
|
41
|
-
}
|
|
42
|
-
}
|
package/demo/DemoPluginSrc.js
DELETED
package/demo/embedded.html
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<title>OpenSCD Core Embedding Demo</title>
|
|
3
|
-
<iframe src="./index.html?locale=de&dark"></iframe>
|
|
4
|
-
<style>
|
|
5
|
-
iframe {
|
|
6
|
-
width:50vw;
|
|
7
|
-
height: 50vh;
|
|
8
|
-
position: relative;
|
|
9
|
-
top: 25vh;
|
|
10
|
-
left: 25vw;
|
|
11
|
-
border: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
background-color: darkseagreen;
|
|
16
|
-
}
|
|
17
|
-
</style>
|
package/demo/index.html
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<title>OpenSCD Shell Demo</title>
|
|
3
|
-
<link
|
|
4
|
-
rel="stylesheet"
|
|
5
|
-
href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap"
|
|
6
|
-
/>
|
|
7
|
-
<link
|
|
8
|
-
rel="stylesheet"
|
|
9
|
-
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
|
|
10
|
-
/>
|
|
11
|
-
<link
|
|
12
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined"
|
|
13
|
-
rel="stylesheet"
|
|
14
|
-
/>
|
|
15
|
-
|
|
16
|
-
<oscd-shell></oscd-shell>
|
|
17
|
-
|
|
18
|
-
<script type="module">
|
|
19
|
-
import '../dist/oscd-shell.js';
|
|
20
|
-
|
|
21
|
-
const plugins = {
|
|
22
|
-
menu: [
|
|
23
|
-
{
|
|
24
|
-
name: 'Add plugins...',
|
|
25
|
-
translations: { de: 'Erweitern...' },
|
|
26
|
-
icon: 'extension',
|
|
27
|
-
active: true,
|
|
28
|
-
src: '/demo/AddPlugins.js',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'Open File',
|
|
32
|
-
translations: { de: 'Datei öffnen' },
|
|
33
|
-
icon: 'folder_open',
|
|
34
|
-
active: true,
|
|
35
|
-
src: 'https://openenergytools.github.io/oscd-open/oscd-open.js',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'Save File',
|
|
39
|
-
translations: { de: 'Datei öffnen' },
|
|
40
|
-
icon: 'save',
|
|
41
|
-
active: true,
|
|
42
|
-
src: 'https://openenergytools.github.io/oscd-save/oscd-save.js',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
editor: [
|
|
46
|
-
{
|
|
47
|
-
name: 'Start',
|
|
48
|
-
translations: {
|
|
49
|
-
de: 'Start',
|
|
50
|
-
},
|
|
51
|
-
icon: 'start',
|
|
52
|
-
active: true,
|
|
53
|
-
src: 'https://openenergytools.github.io/scl-editor-landing/scl-editor-landing.js',
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
name: 'Substation',
|
|
58
|
-
icon: 'margin',
|
|
59
|
-
active: true,
|
|
60
|
-
requireDoc: true,
|
|
61
|
-
src: 'https://openenergytools.github.io/scl-substation-editor/scl-substation-editor.js',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'Design SLD',
|
|
65
|
-
translations: {
|
|
66
|
-
de: 'Designer',
|
|
67
|
-
},
|
|
68
|
-
icon: 'add_box',
|
|
69
|
-
active: true,
|
|
70
|
-
requireDoc: true,
|
|
71
|
-
src: 'https://openenergytools.github.io/oscd-designer/oscd-designer.js',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const editor = document.querySelector('oscd-shell');
|
|
77
|
-
const params = new URL(document.location).searchParams;
|
|
78
|
-
for (const [name, value] of params) {
|
|
79
|
-
editor.setAttribute(name, value);
|
|
80
|
-
}
|
|
81
|
-
editor.plugins = plugins;
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<style>
|
|
85
|
-
html,
|
|
86
|
-
body {
|
|
87
|
-
width: 100%;
|
|
88
|
-
height: 100%;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
* {
|
|
92
|
-
margin: 0px;
|
|
93
|
-
padding: 0px;
|
|
94
|
-
}
|
|
95
|
-
</style>
|
package/foundation/cyrb64.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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: string): string {
|
|
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 (
|
|
23
|
-
(h2 >>> 0).toString(16).padStart(8, '0') +
|
|
24
|
-
(h1 >>> 0).toString(16).padStart(8, '0')
|
|
25
|
-
);
|
|
26
|
-
/* eslint-enable no-bitwise */
|
|
27
|
-
}
|
package/foundation/edit-event.ts
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/** Intent to `parent.insertBefore(node, reference)` */
|
|
2
|
-
export type Insert = {
|
|
3
|
-
parent: Node;
|
|
4
|
-
node: Node;
|
|
5
|
-
reference: Node | null;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type NamespacedAttributeValue = {
|
|
9
|
-
value: string | null;
|
|
10
|
-
namespaceURI: string | null;
|
|
11
|
-
};
|
|
12
|
-
export type Value = string | null;
|
|
13
|
-
export type AttributeValue = Value | NamespacedAttributeValue;
|
|
14
|
-
/**
|
|
15
|
-
* Intent to set or remove (if null) attributes on element
|
|
16
|
-
* @deprecated - use `UpdateNS` for updating namespaced attributes instead.
|
|
17
|
-
*/
|
|
18
|
-
export type Update = {
|
|
19
|
-
element: Element;
|
|
20
|
-
attributes: Partial<Record<string, AttributeValue>>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/** Intent to set or remove (if null) attributes on element */
|
|
24
|
-
export type UpdateNS = {
|
|
25
|
-
element: Element;
|
|
26
|
-
attributes: Partial<Record<string, Value>>;
|
|
27
|
-
attributesNS: Partial<Record<string, Partial<Record<string, Value>>>>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/** Intent to remove a node from its ownerDocument */
|
|
31
|
-
export type Remove = {
|
|
32
|
-
node: Node;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/** Represents the user's intent to change an XMLDocument */
|
|
36
|
-
export type Edit = Insert | Update | UpdateNS | Remove | Edit[];
|
|
37
|
-
|
|
38
|
-
export function isComplex(edit: Edit): edit is Edit[] {
|
|
39
|
-
return edit instanceof Array;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isInsert(edit: Edit): edit is Insert {
|
|
43
|
-
return (edit as Insert).parent !== undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function isNamespaced(
|
|
47
|
-
value: AttributeValue,
|
|
48
|
-
): value is NamespacedAttributeValue {
|
|
49
|
-
return value !== null && typeof value !== 'string';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isUpdate(edit: Edit): edit is Update {
|
|
53
|
-
return 'element' in edit && !('attributesNS' in edit);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function isUpdateNS(edit: Edit): edit is UpdateNS {
|
|
57
|
-
return 'element' in edit && 'attributesNS' in edit;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function isRemove(edit: Edit): edit is Remove {
|
|
61
|
-
return (
|
|
62
|
-
(edit as Insert).parent === undefined && (edit as Remove).node !== undefined
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type EditEvent<E extends Edit = Edit> = CustomEvent<E>;
|
|
67
|
-
|
|
68
|
-
export function newEditEvent<E extends Edit>(edit: E): EditEvent<E> {
|
|
69
|
-
return new CustomEvent<E>('oscd-edit', {
|
|
70
|
-
composed: true,
|
|
71
|
-
bubbles: true,
|
|
72
|
-
detail: edit,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
declare global {
|
|
77
|
-
interface ElementEventMap {
|
|
78
|
-
['oscd-edit']: EditEvent;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** EDIT HANDLING */
|
|
83
|
-
|
|
84
|
-
function uniqueNSPrefix(element: Element, ns: string): string {
|
|
85
|
-
let i = 1;
|
|
86
|
-
const attributes = Array.from(element.attributes);
|
|
87
|
-
const hasSamePrefix = (attribute: Attr) =>
|
|
88
|
-
attribute.prefix === `ens${i}` && attribute.namespaceURI !== ns;
|
|
89
|
-
const nsOrNull = new Set([null, ns]);
|
|
90
|
-
const differentNamespace = (prefix: string) =>
|
|
91
|
-
!nsOrNull.has(element.lookupNamespaceURI(prefix));
|
|
92
|
-
while (differentNamespace(`ens${i}`) || attributes.find(hasSamePrefix)) {
|
|
93
|
-
i += 1;
|
|
94
|
-
}
|
|
95
|
-
return `ens${i}`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function localAttributeName(attribute: string): string {
|
|
99
|
-
return attribute.includes(':') ? attribute.split(':', 2)[1] : attribute;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function handleInsert({
|
|
103
|
-
parent,
|
|
104
|
-
node,
|
|
105
|
-
reference,
|
|
106
|
-
}: Insert): Insert | Remove | [] {
|
|
107
|
-
try {
|
|
108
|
-
const { parentNode, nextSibling } = node;
|
|
109
|
-
parent.insertBefore(node, reference);
|
|
110
|
-
if (parentNode) {
|
|
111
|
-
return {
|
|
112
|
-
node,
|
|
113
|
-
parent: parentNode,
|
|
114
|
-
reference: nextSibling,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
return { node };
|
|
118
|
-
} catch (e) {
|
|
119
|
-
// do nothing if insert doesn't work on these nodes
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function handleUpdate({ element, attributes }: Update): Update {
|
|
125
|
-
const oldAttributes = { ...attributes };
|
|
126
|
-
Object.entries(attributes)
|
|
127
|
-
.reverse()
|
|
128
|
-
.forEach(([name, value]) => {
|
|
129
|
-
let oldAttribute: AttributeValue;
|
|
130
|
-
if (isNamespaced(value!)) {
|
|
131
|
-
oldAttribute = {
|
|
132
|
-
value: element.getAttributeNS(
|
|
133
|
-
value.namespaceURI,
|
|
134
|
-
localAttributeName(name),
|
|
135
|
-
),
|
|
136
|
-
namespaceURI: value.namespaceURI,
|
|
137
|
-
};
|
|
138
|
-
} else {
|
|
139
|
-
oldAttribute = element.getAttributeNode(name)?.namespaceURI
|
|
140
|
-
? {
|
|
141
|
-
value: element.getAttribute(name),
|
|
142
|
-
namespaceURI: element.getAttributeNode(name)!.namespaceURI!,
|
|
143
|
-
}
|
|
144
|
-
: element.getAttribute(name);
|
|
145
|
-
}
|
|
146
|
-
oldAttributes[name] = oldAttribute;
|
|
147
|
-
});
|
|
148
|
-
for (const entry of Object.entries(attributes)) {
|
|
149
|
-
try {
|
|
150
|
-
const [attribute, value] = entry as [string, AttributeValue];
|
|
151
|
-
if (isNamespaced(value)) {
|
|
152
|
-
if (value.value === null) {
|
|
153
|
-
element.removeAttributeNS(
|
|
154
|
-
value.namespaceURI,
|
|
155
|
-
localAttributeName(attribute),
|
|
156
|
-
);
|
|
157
|
-
} else {
|
|
158
|
-
element.setAttributeNS(value.namespaceURI, attribute, value.value);
|
|
159
|
-
}
|
|
160
|
-
} else if (value === null) {
|
|
161
|
-
element.removeAttribute(attribute);
|
|
162
|
-
} else {
|
|
163
|
-
element.setAttribute(attribute, value);
|
|
164
|
-
}
|
|
165
|
-
} catch (e) {
|
|
166
|
-
// do nothing if update doesn't work on this attribute
|
|
167
|
-
delete oldAttributes[entry[0]];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
element,
|
|
172
|
-
attributes: oldAttributes,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function handleUpdateNS({
|
|
177
|
-
element,
|
|
178
|
-
attributes,
|
|
179
|
-
attributesNS,
|
|
180
|
-
}: UpdateNS): UpdateNS {
|
|
181
|
-
const oldAttributes = { ...attributes };
|
|
182
|
-
const oldAttributesNS = { ...attributesNS };
|
|
183
|
-
Object.keys(attributes)
|
|
184
|
-
.reverse()
|
|
185
|
-
.forEach(name => {
|
|
186
|
-
oldAttributes[name] = element.getAttribute(name);
|
|
187
|
-
});
|
|
188
|
-
for (const entry of Object.entries(attributes)) {
|
|
189
|
-
try {
|
|
190
|
-
const [name, value] = entry as [string, Value];
|
|
191
|
-
if (value === null) {
|
|
192
|
-
element.removeAttribute(name);
|
|
193
|
-
} else {
|
|
194
|
-
element.setAttribute(name, value);
|
|
195
|
-
}
|
|
196
|
-
} catch (e) {
|
|
197
|
-
// do nothing if update doesn't work on this attribute
|
|
198
|
-
delete oldAttributes[entry[0]];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
Object.entries(attributesNS).forEach(([ns, attrs]) => {
|
|
202
|
-
Object.keys(attrs!)
|
|
203
|
-
.reverse()
|
|
204
|
-
.forEach(name => {
|
|
205
|
-
oldAttributesNS[ns] = {
|
|
206
|
-
...oldAttributesNS[ns],
|
|
207
|
-
[name]: element.getAttributeNS(ns, name),
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
for (const nsEntry of Object.entries(attributesNS)) {
|
|
212
|
-
const [ns, attrs] = nsEntry as [string, Partial<Record<string, Value>>];
|
|
213
|
-
for (const entry of Object.entries(attrs)) {
|
|
214
|
-
try {
|
|
215
|
-
const [name, value] = entry as [string, Value];
|
|
216
|
-
if (value === null) {
|
|
217
|
-
element.removeAttributeNS(ns, name);
|
|
218
|
-
} else {
|
|
219
|
-
let qualifiedName = name;
|
|
220
|
-
if (!qualifiedName.includes(':')) {
|
|
221
|
-
let prefix = element.lookupPrefix(ns);
|
|
222
|
-
if (!prefix) {
|
|
223
|
-
prefix = uniqueNSPrefix(element, ns);
|
|
224
|
-
}
|
|
225
|
-
qualifiedName = `${prefix}:${name}`;
|
|
226
|
-
}
|
|
227
|
-
element.setAttributeNS(ns, qualifiedName, value);
|
|
228
|
-
}
|
|
229
|
-
} catch (e) {
|
|
230
|
-
delete oldAttributesNS[entry[0]];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/*
|
|
235
|
-
*/
|
|
236
|
-
return {
|
|
237
|
-
element,
|
|
238
|
-
attributes: oldAttributes,
|
|
239
|
-
attributesNS: oldAttributesNS,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function handleRemove({ node }: Remove): Insert | [] {
|
|
244
|
-
const { parentNode: parent, nextSibling: reference } = node;
|
|
245
|
-
node.parentNode?.removeChild(node);
|
|
246
|
-
if (parent) {
|
|
247
|
-
return {
|
|
248
|
-
node,
|
|
249
|
-
parent,
|
|
250
|
-
reference,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return [];
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export function handleEdit(edit: Edit): Edit {
|
|
257
|
-
if (isInsert(edit)) {
|
|
258
|
-
return handleInsert(edit);
|
|
259
|
-
}
|
|
260
|
-
if (isUpdate(edit)) {
|
|
261
|
-
return handleUpdate(edit);
|
|
262
|
-
}
|
|
263
|
-
if (isUpdateNS(edit)) {
|
|
264
|
-
return handleUpdateNS(edit);
|
|
265
|
-
}
|
|
266
|
-
if (isRemove(edit)) {
|
|
267
|
-
return handleRemove(edit);
|
|
268
|
-
}
|
|
269
|
-
if (isComplex(edit)) {
|
|
270
|
-
return edit.map(handleEdit).reverse();
|
|
271
|
-
}
|
|
272
|
-
return [];
|
|
273
|
-
}
|
package/foundation/open-event.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type OpenDetail = {
|
|
2
|
-
doc: XMLDocument;
|
|
3
|
-
docName: string;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
/** Represents the intent to open `doc` with filename `docName`. */
|
|
7
|
-
export type OpenEvent = CustomEvent<OpenDetail>;
|
|
8
|
-
|
|
9
|
-
export function newOpenEvent(doc: XMLDocument, docName: string): OpenEvent {
|
|
10
|
-
return new CustomEvent<OpenDetail>('oscd-open', {
|
|
11
|
-
bubbles: true,
|
|
12
|
-
composed: true,
|
|
13
|
-
detail: { doc, docName },
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare global {
|
|
18
|
-
interface ElementEventMap {
|
|
19
|
-
['oscd-open']: OpenEvent;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/foundation.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
|
|
3
|
-
/** Constructor type for defining `LitElement` mixins. */
|
|
4
|
-
export type LitElementConstructor = new (...args: any[]) => LitElement;
|
|
5
|
-
|
|
6
|
-
export { newOpenEvent } from './foundation/open-event.js';
|
|
7
|
-
export type { OpenEvent, OpenDetail } from './foundation/open-event.js';
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
handleEdit,
|
|
11
|
-
isComplex,
|
|
12
|
-
isInsert,
|
|
13
|
-
isNamespaced,
|
|
14
|
-
isRemove,
|
|
15
|
-
isUpdate,
|
|
16
|
-
newEditEvent,
|
|
17
|
-
} from './foundation/edit-event.js';
|
|
18
|
-
export type {
|
|
19
|
-
AttributeValue,
|
|
20
|
-
Edit,
|
|
21
|
-
EditEvent,
|
|
22
|
-
Insert,
|
|
23
|
-
NamespacedAttributeValue,
|
|
24
|
-
Remove,
|
|
25
|
-
Update,
|
|
26
|
-
} from './foundation/edit-event.js';
|
|
27
|
-
|
|
28
|
-
export { cyrb64 } from './foundation/cyrb64.js';
|
package/lit-localize.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/lit/lit/main/packages/localize-tools/config.schema.json",
|
|
3
|
-
"sourceLocale": "en",
|
|
4
|
-
"targetLocales": ["de"],
|
|
5
|
-
"tsConfig": "./tsconfig.json",
|
|
6
|
-
"output": {
|
|
7
|
-
"mode": "runtime",
|
|
8
|
-
"outputDir": "./locales",
|
|
9
|
-
"localeCodesModule": "./locales.ts"
|
|
10
|
-
},
|
|
11
|
-
"interchange": {
|
|
12
|
-
"format": "xliff",
|
|
13
|
-
"xliffDir": "./localization/"
|
|
14
|
-
}
|
|
15
|
-
}
|
package/localization/de.xlf
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
|
3
|
-
<file target-language="de" source-language="en" original="lit-localize-inputs" datatype="plaintext">
|
|
4
|
-
<body>
|
|
5
|
-
<trans-unit id="sbcdf43ebad9c5a3a">
|
|
6
|
-
<source>Something unexpected happened!</source>
|
|
7
|
-
<target>Etwas unerwartetes ist passiert!</target>
|
|
8
|
-
</trans-unit>
|
|
9
|
-
<trans-unit id="s62b4f83c9503e1af">
|
|
10
|
-
<source>≥ <x id="0" equiv-text="${redo.length}"/> nodes changed</source>
|
|
11
|
-
<target>≥ <x id="0" equiv-text="${redo.length}"/> Knoten verändert</target>
|
|
12
|
-
</trans-unit>
|
|
13
|
-
<trans-unit id="s0731afca1ab76175">
|
|
14
|
-
<source><x id="0" equiv-text="${redo.node.nodeName}"/> moved to <x id="1" equiv-text="${redo.parent.nodeName}"/></source>
|
|
15
|
-
<target><x id="0" equiv-text="${redo.node.nodeName}"/> nach <x id="1" equiv-text="${redo.parent.nodeName}"/> verschoben</target>
|
|
16
|
-
</trans-unit>
|
|
17
|
-
<trans-unit id="s83eaab546be4bfb9">
|
|
18
|
-
<source><x id="0" equiv-text="${redo.node.nodeName}"/> inserted into <x id="1" equiv-text="${redo.parent.nodeName}"/></source>
|
|
19
|
-
<target><x id="0" equiv-text="${redo.node.nodeName}"/> in <x id="1" equiv-text="${redo.parent.nodeName}"/> eingefügt</target>
|
|
20
|
-
</trans-unit>
|
|
21
|
-
<trans-unit id="s0f8217f07c54b541">
|
|
22
|
-
<source><x id="0" equiv-text="${redo.node.nodeName}"/> removed</source>
|
|
23
|
-
<target><x id="0" equiv-text="${redo.node.nodeName}"/> entfernt</target>
|
|
24
|
-
</trans-unit>
|
|
25
|
-
<trans-unit id="s85a55e7007003cc2">
|
|
26
|
-
<source><x id="0" equiv-text="${redo.element.tagName}"/> updated</source>
|
|
27
|
-
<target><x id="0" equiv-text="${redo.element.tagName}"/> verändert</target>
|
|
28
|
-
</trans-unit>
|
|
29
|
-
<trans-unit id="s8f4be9f086eb530f">
|
|
30
|
-
<source>Undo</source>
|
|
31
|
-
<target>Rückgängig</target>
|
|
32
|
-
</trans-unit>
|
|
33
|
-
<trans-unit id="s7417792bbe720149">
|
|
34
|
-
<source>Redo</source>
|
|
35
|
-
<target>Wiederholen</target>
|
|
36
|
-
</trans-unit>
|
|
37
|
-
<trans-unit id="s90c6a2fed2796c07">
|
|
38
|
-
<source>Editing history</source>
|
|
39
|
-
<target>Bearbeitungshistorie</target>
|
|
40
|
-
</trans-unit>
|
|
41
|
-
<trans-unit id="s6d8c02aee480af7a">
|
|
42
|
-
<source>Menu</source>
|
|
43
|
-
<target>Menü</target>
|
|
44
|
-
</trans-unit>
|
|
45
|
-
<trans-unit id="sfb0e98cb12fe463c">
|
|
46
|
-
<source>Your editing history will be displayed here.</source>
|
|
47
|
-
<target>Hier wird Ihre Bearbeitungshistorie angezeigt.</target>
|
|
48
|
-
</trans-unit>
|
|
49
|
-
<trans-unit id="s690714fde574c188">
|
|
50
|
-
<source>Filename</source>
|
|
51
|
-
<target>Dateiname</target>
|
|
52
|
-
</trans-unit>
|
|
53
|
-
<trans-unit id="s1b528387ae29637a">
|
|
54
|
-
<source>Extension</source>
|
|
55
|
-
<target>Dateiendung</target>
|
|
56
|
-
</trans-unit>
|
|
57
|
-
<trans-unit id="s737e3dbdf9c08cdf">
|
|
58
|
-
<source>Close file</source>
|
|
59
|
-
<target>Datei schließen</target>
|
|
60
|
-
</trans-unit>
|
|
61
|
-
<trans-unit id="s2ceb11be2290bb1b">
|
|
62
|
-
<source>Cancel</source>
|
|
63
|
-
<target>Abbrechen</target>
|
|
64
|
-
</trans-unit>
|
|
65
|
-
<trans-unit id="s60320a18282b2b33">
|
|
66
|
-
<source>Rename</source>
|
|
67
|
-
<target>Umbenennen</target>
|
|
68
|
-
</trans-unit>
|
|
69
|
-
<trans-unit id="s5e8250fb85d64c23">
|
|
70
|
-
<source>Close</source>
|
|
71
|
-
<target>Schließen</target>
|
|
72
|
-
</trans-unit>
|
|
73
|
-
</body>
|
|
74
|
-
</file>
|
|
75
|
-
</xliff>
|