@mak-98/xml-dirvi-app 0.11.0-beta.16 → 0.11.0-beta.16.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.
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# XML dirvi app plugin
|
|
2
|
+
|
|
3
|
+
The XML dirvi app plugin lets dirvi load, browse and edit XML data as interactive tree srtuctures.
|
|
4
|
+
|
|
5
|
+
## Default view
|
|
6
|
+
|
|
7
|
+
By default, shows the document structure without applying specialized leaf rules.
|
|
8
|
+
|
|
9
|
+
Elements can be expanded to reveal their child nodes, including text, CDATA,
|
|
10
|
+
comments, and processing instructions. Whitespace-only text nodes are visible,
|
|
11
|
+
including what would be considered newlines for formatting:
|
|
12
|
+
|
|
13
|
+
```xml
|
|
14
|
+
<library>
|
|
15
|
+
<book>My book</book>
|
|
16
|
+
</library>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
would give by default:
|
|
20
|
+
|
|
21
|
+
```txt
|
|
22
|
+
library
|
|
23
|
+
text
|
|
24
|
+
book
|
|
25
|
+
text
|
|
26
|
+
text
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This is usually not desirable, and a way to filter the nodes to only show such
|
|
30
|
+
whitespace formatting in subtrees with `xml:space="preserve"` is provided.
|
|
31
|
+
|
|
32
|
+
Attributes are not child nodes of elements, but are inspectable and changeable.
|
|
33
|
+
|
|
34
|
+
## View options
|
|
35
|
+
|
|
36
|
+
### Filter whitespace-only text
|
|
37
|
+
|
|
38
|
+
- Default: off.
|
|
39
|
+
- Hide text nodes containing only XML whitespace.
|
|
40
|
+
- Do not hide whitespace where `xml:space="preserve"` applies.
|
|
41
|
+
|
|
42
|
+
### Treat text-only elements as leaves
|
|
43
|
+
|
|
44
|
+
- Default: off.
|
|
45
|
+
- Treat an element as a leaf when all of its children are text or CDATA.
|
|
46
|
+
- An empty element also qualifies.
|
|
47
|
+
- Edit its contents as plain text.
|
|
48
|
+
|
|
49
|
+
Saving plain text replaces the element's contents with text. Markup typed into
|
|
50
|
+
the editor is text, not a request to create XML elements. CDATA boundaries
|
|
51
|
+
need not be retained.
|
|
52
|
+
|
|
53
|
+
### Treat extension-marked elements as leaves
|
|
54
|
+
|
|
55
|
+
- Default: off.
|
|
56
|
+
- Configure the attribute name used to specify a file extension.
|
|
57
|
+
- An element with that attribute is a leaf, edited as plain text.
|
|
58
|
+
- Open the editor with a temporary filename using the specified extension, so
|
|
59
|
+
the editor can choose syntax highlighting.
|
|
60
|
+
- The extension rule takes precedence over the other leaf rules.
|
|
61
|
+
|
|
62
|
+
For example, assuming the configured attribute is `extension`:
|
|
63
|
+
|
|
64
|
+
```xml
|
|
65
|
+
<snippet extension="tsx">const App = () => <div>Hello</div>;</snippet>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The editor receives:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
const App = () => <div>Hello</div>;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
After saving, the contents are still text, and the element remains a leaf.
|
|
75
|
+
If an extension-marked element contains child elements or other non-text
|
|
76
|
+
content, report an error rather than silently flattening or discarding it.
|
|
77
|
+
|
|
78
|
+
Treat the extension as data, not as a path or shell command. Reject unsafe
|
|
79
|
+
values before constructing a temporary filename.
|
|
80
|
+
|
|
81
|
+
### Treat `xml:space="preserve"` elements as leaves
|
|
82
|
+
|
|
83
|
+
- Default: off.
|
|
84
|
+
- An element with `xml:space="preserve"` directly on it is a leaf.
|
|
85
|
+
- Edit its contents as **inner XML**, including any nested markup.
|
|
86
|
+
- Parse the edited contents as XML on save.
|
|
87
|
+
|
|
88
|
+
For example, the editor for this element:
|
|
89
|
+
|
|
90
|
+
```xml
|
|
91
|
+
<note xml:space="preserve">Hello <em>world</em>.</note>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
receives:
|
|
95
|
+
|
|
96
|
+
```xml
|
|
97
|
+
Hello <em>world</em>.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The extension rule takes precedence if both rules apply.
|
|
101
|
+
|
|
102
|
+
`xml:space` can be inherited in XML. For this view option, however, only the
|
|
103
|
+
element that directly declares `xml:space="preserve"` becomes a leaf.
|
|
104
|
+
|
|
105
|
+
## Editing and saving
|
|
106
|
+
|
|
107
|
+
- Open editable content in an external editor through a temporary file.
|
|
108
|
+
- Distinguish plain-text editing from inner-XML editing. Never parse plain-text
|
|
109
|
+
edits as XML markup.
|
|
110
|
+
- For inner-XML edits, support multiple child nodes and namespace declarations
|
|
111
|
+
inherited from ancestors.
|
|
112
|
+
- Reject invalid edits without overwriting the original file.
|
|
113
|
+
- Detect if the original file changed while the editor was open; do not
|
|
114
|
+
silently overwrite those changes.
|
|
115
|
+
- Clean up temporary files after editing.
|
|
116
|
+
- Preserve document content not intentionally edited, even if its serialized
|
|
117
|
+
formatting changes. In particular, do not add or remove meaningful
|
|
118
|
+
whitespace while formatting.
|
|
119
|
+
- Report unsupported XML features instead of silently losing content.
|
|
120
|
+
|
|
121
|
+
Creating or restructuring branches should be a separate, intentional user
|
|
122
|
+
operation, not a side effect of saving plain text.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-xml-dom.d.ts","sourceRoot":"","sources":["../../src/infrastructure/create-xml-dom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-xml-dom.d.ts","sourceRoot":"","sources":["../../src/infrastructure/create-xml-dom.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA+JrD;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MA6C7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-xml-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-xml-entries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get-xml-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-xml-entries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA8DhD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,KAAK,EAAE,GACrB,SAAS,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,CA0B1C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAK9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-dom.d.ts","sourceRoot":"","sources":["../../src/services/xml-dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"xml-dom.d.ts","sourceRoot":"","sources":["../../src/services/xml-dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,MAAM,GAAG;IACnB;;;OAGG;IACH,WAAW,EAAE,MAAM,WAAW,CAAC;IAE/B;;;;;;OAMG;IACH,WAAW,EAAE,CACX,IAAI,EAAE,WAAW,KACd,SAAS,CAAC,gBAAgB,GAAG,eAAe,CAAC,EAAE,CAAC;CACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,YAAY,CAAC;AAY3D,eAAO,MAAM,YAAY,EAAE,SAyD1B,CAAC"}
|
package/dist/xml-dirvi-app.js
CHANGED
|
@@ -3,13 +3,15 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { xmlIdSchema, xmlValueSchema } from './domain/xml-tree.js';
|
|
4
4
|
import { createXmlFileResyncSubscription } from './infrastructure/create-xml-file-resync.js';
|
|
5
5
|
import { createXmlDom } from './infrastructure/create-xml-dom.js';
|
|
6
|
-
import { createXmlRoot, getXmlEntries } from './infrastructure/get-xml-entries.js';
|
|
6
|
+
import { createXmlRoot, getXmlEntries, } from './infrastructure/get-xml-entries.js';
|
|
7
7
|
export const xmlAppPlugin = {
|
|
8
8
|
createAppDefinitionApplicator: (input) => {
|
|
9
9
|
if (input === undefined) {
|
|
10
10
|
throw new Error('xml-dirvi-app: No file path to XML file given.');
|
|
11
11
|
}
|
|
12
12
|
const xmlAbsolutePath = resolve(input);
|
|
13
|
+
// TODO: Make the `xmldom` nodes the IDs, but need to first get rid of the
|
|
14
|
+
// `SerializableKey` requirement.
|
|
13
15
|
// Create dom async on first need, cache afterward
|
|
14
16
|
let dom;
|
|
15
17
|
let domPromise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mak-98/xml-dirvi-app",
|
|
3
|
-
"version": "0.11.0-beta.16",
|
|
3
|
+
"version": "0.11.0-beta.16.1",
|
|
4
4
|
"description": "XML file app for dirvi.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@rgrove/parse-xml": "^5.0.0",
|
|
23
23
|
"@xmldom/xmldom": "^0.9.12",
|
|
24
|
-
"dirvi-apis": "0.11.0-beta.16",
|
|
24
|
+
"dirvi-apis": "0.11.0-beta.16.1",
|
|
25
25
|
"env-paths": "^4.0.0",
|
|
26
26
|
"zod": "^4.4.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.0.0",
|
|
30
|
-
"dirvi-lib": "0.11.0-beta.16",
|
|
30
|
+
"dirvi-lib": "0.11.0-beta.16.1",
|
|
31
31
|
"typescript": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|