@mak-98/xml-dirvi-app 0.11.0-beta.6 → 0.11.0-beta.6.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/dist/domain/xml-tree.d.ts +20 -15
- package/dist/domain/xml-tree.d.ts.map +1 -1
- package/dist/domain/xml-tree.js +29 -4
- package/dist/infrastructure/get-xml-entries.d.ts +4 -4
- package/dist/infrastructure/get-xml-entries.d.ts.map +1 -1
- package/dist/infrastructure/get-xml-entries.js +28 -3
- package/dist/infrastructure/parse-xml-document.d.ts +5 -4
- package/dist/infrastructure/parse-xml-document.d.ts.map +1 -1
- package/dist/infrastructure/parse-xml-document.js +8 -11
- package/dist/xml-dirvi-app.d.ts.map +1 -1
- package/dist/xml-dirvi-app.js +7 -8
- package/package.json +1 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { TreeNode, TreeNodeApi } from 'dirvi-lib';
|
|
3
3
|
/**
|
|
4
|
-
* A
|
|
4
|
+
* A node key containing its UUID and display name.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* This is not XML document order. XML sibling order is held by the source
|
|
7
|
+
* TreeNode child sequence.
|
|
8
|
+
*
|
|
9
|
+
* Changing the name changes the complete tree key.
|
|
8
10
|
*/
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
+
export declare const xmlIdSchema: z.ZodString;
|
|
12
|
+
export type XmlId = z.infer<typeof xmlIdSchema>;
|
|
13
|
+
export declare function createXmlId(name: string, uuid: string): XmlId;
|
|
14
|
+
export declare function xmlIdName(id: XmlId): string;
|
|
15
|
+
export declare function xmlIdUuid(id: XmlId): string;
|
|
11
16
|
export type XmlAttribute = Readonly<{
|
|
12
17
|
readonly name: string;
|
|
13
18
|
readonly value: string;
|
|
@@ -56,7 +61,7 @@ export type XmlProcessingInstructionValue = Readonly<{
|
|
|
56
61
|
* Child ordering is deliberately not represented here.
|
|
57
62
|
*/
|
|
58
63
|
export type XmlNodeValue = XmlDocumentValue | XmlDeclarationValue | XmlDoctypeValue | XmlElementValue | XmlTextValue | XmlCommentValue | XmlCdataValue | XmlProcessingInstructionValue;
|
|
59
|
-
export type XmlTreeNode = TreeNode<
|
|
64
|
+
export type XmlTreeNode = TreeNode<XmlId, XmlNodeValue>;
|
|
60
65
|
export declare const XmlAttributeSchema: z.ZodObject<{
|
|
61
66
|
name: z.ZodString;
|
|
62
67
|
value: z.ZodString;
|
|
@@ -112,14 +117,14 @@ export declare const xmlValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
112
117
|
target: z.ZodString;
|
|
113
118
|
data: z.ZodString;
|
|
114
119
|
}, z.core.$strip>], "kind">;
|
|
115
|
-
export declare function createConstructors(xmlTreeNodeApi: TreeNodeApi<
|
|
116
|
-
readonly document: (id:
|
|
117
|
-
readonly declaration: (id:
|
|
118
|
-
readonly doctype: (id:
|
|
119
|
-
readonly element: (id:
|
|
120
|
-
readonly text: (id:
|
|
121
|
-
readonly comment: (id:
|
|
122
|
-
readonly cdata: (id:
|
|
123
|
-
readonly processingInstruction: (id:
|
|
120
|
+
export declare function createConstructors(xmlTreeNodeApi: TreeNodeApi<XmlId, XmlNodeValue>): {
|
|
121
|
+
readonly document: (id: XmlId, children: Iterable<XmlTreeNode>) => XmlTreeNode | undefined;
|
|
122
|
+
readonly declaration: (id: XmlId, version: string, encoding: string | null, standalone: "yes" | "no" | null) => XmlTreeNode;
|
|
123
|
+
readonly doctype: (id: XmlId, name: string, publicId: string | null, systemId: string | null, internalSubset: string | null) => XmlTreeNode;
|
|
124
|
+
readonly element: (id: XmlId, name: string, attributes: readonly XmlAttribute[], children: Iterable<XmlTreeNode>) => XmlTreeNode | undefined;
|
|
125
|
+
readonly text: (id: XmlId, text: string) => XmlTreeNode;
|
|
126
|
+
readonly comment: (id: XmlId, text: string) => XmlTreeNode;
|
|
127
|
+
readonly cdata: (id: XmlId, text: string) => XmlTreeNode;
|
|
128
|
+
readonly processingInstruction: (id: XmlId, target: string, data: string) => XmlTreeNode;
|
|
124
129
|
};
|
|
125
130
|
//# sourceMappingURL=xml-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-tree.d.ts","sourceRoot":"","sources":["../../src/domain/xml-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAmB,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"xml-tree.d.ts","sourceRoot":"","sources":["../../src/domain/xml-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAmB,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAcxE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,aAavB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAMhD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAE7D;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CAE3C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CAE3C;AAQD,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,aA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KAAG,WAAW;yBAOnC,KAAK,QAAQ,MAAM,KAAG,WAAW;yCAQrC,KAAK,UACD,MAAM,QACR,MAAM,KACX,WAAW;EAQjB"}
|
package/dist/domain/xml-tree.js
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// -----------------------------------------------------------------------------
|
|
3
|
+
// Position: Id extends SerializableKey
|
|
4
|
+
// -----------------------------------------------------------------------------
|
|
5
|
+
const uuidSchema = z.uuid();
|
|
6
|
+
/**
|
|
7
|
+
* A node key containing its UUID and display name.
|
|
8
|
+
*
|
|
9
|
+
* This is not XML document order. XML sibling order is held by the source
|
|
10
|
+
* TreeNode child sequence.
|
|
11
|
+
*
|
|
12
|
+
* Changing the name changes the complete tree key.
|
|
13
|
+
*/
|
|
14
|
+
export const xmlIdSchema = z.string().refine((value) => {
|
|
15
|
+
const separator = value.indexOf(':');
|
|
16
|
+
return (separator > 0 &&
|
|
17
|
+
uuidSchema.safeParse(value.slice(0, separator)).success &&
|
|
18
|
+
value.slice(separator + 1).trim().length > 0);
|
|
19
|
+
}, {
|
|
20
|
+
message: 'Expected an XML node ID in the form <uuid>:<node-name>.',
|
|
21
|
+
});
|
|
22
|
+
export function createXmlId(name, uuid) {
|
|
23
|
+
return xmlIdSchema.parse(`${uuid}:${name}`);
|
|
24
|
+
}
|
|
25
|
+
export function xmlIdName(id) {
|
|
26
|
+
return id.slice(id.indexOf(':') + 1);
|
|
27
|
+
}
|
|
28
|
+
export function xmlIdUuid(id) {
|
|
29
|
+
return id.slice(0, id.indexOf(':'));
|
|
30
|
+
}
|
|
6
31
|
// Schema ----------------------------------------------------------------------
|
|
7
32
|
export const XmlAttributeSchema = z.object({
|
|
8
33
|
name: z.string().min(1),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { XmlNode } from '@rgrove/parse-xml';
|
|
2
2
|
import type { TreeNodeApi } from 'dirvi-lib';
|
|
3
3
|
import type { XmlNodeValue, XmlTreeNode } from '../domain/xml-tree.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { XmlId } from '../domain/xml-tree.js';
|
|
5
5
|
/**
|
|
6
|
-
* Allocates
|
|
6
|
+
* Allocates an XML tree ID containing the node's name and a unique UUID.
|
|
7
7
|
*
|
|
8
8
|
* IDs identify nodes and cursor paths. They do not represent sibling order:
|
|
9
9
|
* source child order is preserved by the TreeNode child sequence.
|
|
10
10
|
*/
|
|
11
|
-
export type
|
|
11
|
+
export type CreateXmlId = (name: string) => XmlId;
|
|
12
12
|
/**
|
|
13
13
|
* Converts XML parser nodes into ordered Dirvi XML tree nodes.
|
|
14
14
|
*
|
|
@@ -16,5 +16,5 @@ export type CreatePosition = () => Position;
|
|
|
16
16
|
* mixed content such as text, elements, comments, and CDATA remains in its
|
|
17
17
|
* source-document order.
|
|
18
18
|
*/
|
|
19
|
-
export declare function getXmlEntries(treeNodeApi: TreeNodeApi<
|
|
19
|
+
export declare function getXmlEntries(treeNodeApi: TreeNodeApi<XmlId, XmlNodeValue>, xmlNodes: readonly XmlNode[], createXmlId: CreateXmlId): XmlTreeNode[];
|
|
20
20
|
//# sourceMappingURL=get-xml-entries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-xml-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-xml-entries.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"get-xml-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-xml-entries.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,EAC7C,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,WAAW,EAAE,WAAW,GACvB,WAAW,EAAE,CAwEf"}
|
|
@@ -7,12 +7,12 @@ import { createConstructors } from '../domain/xml-tree.js';
|
|
|
7
7
|
* mixed content such as text, elements, comments, and CDATA remains in its
|
|
8
8
|
* source-document order.
|
|
9
9
|
*/
|
|
10
|
-
export function getXmlEntries(treeNodeApi, xmlNodes,
|
|
10
|
+
export function getXmlEntries(treeNodeApi, xmlNodes, createXmlId) {
|
|
11
11
|
return xmlNodes.map((xmlNode) => {
|
|
12
|
-
const id =
|
|
12
|
+
const id = createXmlId(getXmlNodeName(xmlNode));
|
|
13
13
|
const constructors = createConstructors(treeNodeApi);
|
|
14
14
|
if (xmlNode instanceof XmlElement) {
|
|
15
|
-
const children = getXmlEntries(treeNodeApi, xmlNode.children,
|
|
15
|
+
const children = getXmlEntries(treeNodeApi, xmlNode.children, createXmlId);
|
|
16
16
|
const node = constructors.element(id, xmlNode.name, Object.entries(xmlNode.attributes).map(([name, value]) => ({
|
|
17
17
|
name,
|
|
18
18
|
value,
|
|
@@ -43,3 +43,28 @@ export function getXmlEntries(treeNodeApi, xmlNodes, createPosition) {
|
|
|
43
43
|
throw new Error(`Unsupported XML node type "${xmlNode.type}".`);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the XML name where one exists, otherwise a synthetic node label.
|
|
48
|
+
*
|
|
49
|
+
* Namespace prefixes are preserved, for example "svg:path".
|
|
50
|
+
*/
|
|
51
|
+
function getXmlNodeName(xmlNode) {
|
|
52
|
+
if (xmlNode instanceof XmlElement ||
|
|
53
|
+
xmlNode instanceof XmlProcessingInstruction ||
|
|
54
|
+
xmlNode instanceof XmlDocumentType) {
|
|
55
|
+
return xmlNode.name;
|
|
56
|
+
}
|
|
57
|
+
if (xmlNode instanceof XmlText) {
|
|
58
|
+
return '#text';
|
|
59
|
+
}
|
|
60
|
+
if (xmlNode instanceof XmlCdata) {
|
|
61
|
+
return '#cdata';
|
|
62
|
+
}
|
|
63
|
+
if (xmlNode instanceof XmlComment) {
|
|
64
|
+
return '#comment';
|
|
65
|
+
}
|
|
66
|
+
if (xmlNode instanceof XmlDeclaration) {
|
|
67
|
+
return '#declaration';
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Unsupported XML node type "${xmlNode.type}".`);
|
|
70
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { TreeNodeApi } from 'dirvi-lib';
|
|
2
|
-
import type {
|
|
2
|
+
import type { XmlId, XmlNodeValue, XmlTreeNode } from '../domain/xml-tree.js';
|
|
3
|
+
export declare const createXmlId: (name: string) => XmlId;
|
|
3
4
|
/**
|
|
4
5
|
* Parses XML source into one Dirvi XML document tree.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Each node receives an ID containing a fresh UUID and its node name.
|
|
8
|
+
* Source child order is preserved by the TreeNode child sequence.
|
|
8
9
|
*/
|
|
9
|
-
export declare function parseXmlDocument(treeNodeApi: TreeNodeApi<
|
|
10
|
+
export declare function parseXmlDocument(treeNodeApi: TreeNodeApi<XmlId, XmlNodeValue>, source: string): XmlTreeNode;
|
|
10
11
|
//# sourceMappingURL=parse-xml-document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-xml-document.d.ts","sourceRoot":"","sources":["../../src/infrastructure/parse-xml-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-xml-document.d.ts","sourceRoot":"","sources":["../../src/infrastructure/parse-xml-document.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI9E,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,KACG,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,EAC7C,MAAM,EAAE,MAAM,GACb,WAAW,CAiBb"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { parseXml } from '@rgrove/parse-xml';
|
|
2
|
-
import { createConstructors } from '../domain/xml-tree.js';
|
|
3
|
+
import { createConstructors, xmlIdSchema } from '../domain/xml-tree.js';
|
|
3
4
|
import { getXmlEntries } from './get-xml-entries.js';
|
|
5
|
+
export const createXmlId = (name) => xmlIdSchema.parse(`${randomUUID()}:${name}`);
|
|
4
6
|
/**
|
|
5
7
|
* Parses XML source into one Dirvi XML document tree.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* Each node receives an ID containing a fresh UUID and its node name.
|
|
10
|
+
* Source child order is preserved by the TreeNode child sequence.
|
|
9
11
|
*/
|
|
10
12
|
export function parseXmlDocument(treeNodeApi, source) {
|
|
11
13
|
const document = parseXml(source);
|
|
12
|
-
|
|
13
|
-
const root = createConstructors(treeNodeApi).document(0, getXmlEntries(treeNodeApi, document.children, () => {
|
|
14
|
-
const position = nextPosition;
|
|
15
|
-
nextPosition += 1;
|
|
16
|
-
return position;
|
|
17
|
-
}));
|
|
14
|
+
const root = createConstructors(treeNodeApi).document(createXmlId('#document'), getXmlEntries(treeNodeApi, document.children, createXmlId));
|
|
18
15
|
if (root === undefined) {
|
|
19
16
|
/*
|
|
20
|
-
*
|
|
21
|
-
* XML-to-domain conversion
|
|
17
|
+
* Each node receives a fresh UUID, so duplicate child IDs would indicate
|
|
18
|
+
* an ID collision or a defect in XML-to-domain conversion.
|
|
22
19
|
*/
|
|
23
20
|
throw new Error('Cannot create XML document: duplicate child IDs.');
|
|
24
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQnD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQnD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,SAuC1B,CAAC"}
|
package/dist/xml-dirvi-app.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
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
|
-
import { parseXmlDocument } from './infrastructure/parse-xml-document.js';
|
|
5
|
+
import { createXmlId, parseXmlDocument } from './infrastructure/parse-xml-document.js';
|
|
6
6
|
/**
|
|
7
7
|
* Creates applicator of `AppDefinition<Position, XmlValue>`.
|
|
8
8
|
*
|
|
@@ -20,7 +20,7 @@ export const xmlAppPlugin = {
|
|
|
20
20
|
const xmlAbsolutePath = resolve(input);
|
|
21
21
|
const appDefinition = {
|
|
22
22
|
displayName: `XML: ${input}`,
|
|
23
|
-
rootId:
|
|
23
|
+
rootId: createXmlId('document'),
|
|
24
24
|
idSchema: xmlIdSchema,
|
|
25
25
|
valueSchema: xmlValueSchema,
|
|
26
26
|
createRoot: async (treeNodeApi) => {
|
|
@@ -31,12 +31,11 @@ export const xmlAppPlugin = {
|
|
|
31
31
|
// TODO Later: load from the file
|
|
32
32
|
throw new Error('Cannot load XML branches: parsed XML documents have no unloaded branches.');
|
|
33
33
|
},
|
|
34
|
-
presentNode: (id, isBranch) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
34
|
+
presentNode: (id, isBranch) => ({
|
|
35
|
+
// Split at the first colon only, preserving names such as "svg:path".
|
|
36
|
+
content: id.slice(id.indexOf(':') + 1),
|
|
37
|
+
highlight: isBranch ? 'branch' : 'leaf',
|
|
38
|
+
}),
|
|
40
39
|
subscribeToResync: createXmlFileResyncSubscription(xmlAbsolutePath),
|
|
41
40
|
createNavNodeApiOptions: {},
|
|
42
41
|
};
|