@mak-98/xml-dirvi-app 0.11.0-beta.16.1 → 0.11.0-beta.17

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.
@@ -1,18 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import type { TreeNode } from 'dirvi-lib';
3
+ declare const xmlIdBrand: unique symbol;
3
4
  /**
4
- * A node key containing its UUID and display name.
5
- *
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.
5
+ * An opaque, reference-identity ID for a node in the current XML document.
10
6
  */
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;
7
+ export type XmlId = object & {
8
+ readonly [xmlIdBrand]: true;
9
+ };
16
10
  import type { XmlElementChild, XmlNode } from './xml-doc.js';
17
11
  export type XmlNodeValue = XmlNode;
18
12
  export type XmlTreeNode = TreeNode<XmlId, XmlNodeValue>;
@@ -107,4 +101,5 @@ export declare const xmlValueSchema: z.ZodUnion<readonly [z.ZodObject<{
107
101
  target: z.ZodString;
108
102
  data: z.ZodString;
109
103
  }, z.core.$strip>]>;
104
+ export {};
110
105
  //# 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,MAAM,WAAW,CAAC;AAc3D;;;;;;;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;AAKD,OAAO,KAAK,EAAc,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC;AACnC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAqFxD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA7BT,CAAC,CAAC,gBAAgB,CAChC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CACtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAFe,CAAC,CAAC,gBAAgB,CAChC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CACtD;;;;;;;;;;;;;;mBAoCiC,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,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,CAAC,MAAM,UAAU,EAAE,OAAO,MAAM,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAM7D,OAAO,KAAK,EAAc,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC;AACnC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAqFxD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA7BT,CAAC,CAAC,gBAAgB,CAChC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CACtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAFe,CAAC,CAAC,gBAAgB,CAChC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CACtD;;;;;;;;;;;;;;mBAoCiC,CAAC"}
@@ -1,33 +1,4 @@
1
1
  import { z } from 'zod';
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
- }
31
2
  const xmlNameSchema = z.object({
32
3
  qualifiedName: z.string(),
33
4
  localName: z.string(),
@@ -1 +1 @@
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
+ {"version":3,"file":"create-xml-dom.d.ts","sourceRoot":"","sources":["../../src/infrastructure/create-xml-dom.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiKrD;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MA4C7C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { DOMParser, Node, } from '@xmldom/xmldom';
2
+ const createXmlId = (node) => node;
2
3
  /**
3
4
  * Extract name for the domain type from xmldom.
4
5
  * @param node
@@ -136,28 +137,30 @@ export const createXmlDom = (source) => {
136
137
  },
137
138
  }).parseFromString(source, 'application/xml');
138
139
  return {
139
- getDocument: () => ({ kind: 'document' }),
140
- getChildren: (path) => {
141
- let node = document;
142
- for (const index of path) {
143
- if (node.nodeType !== Node.DOCUMENT_NODE &&
144
- node.nodeType !== Node.ELEMENT_NODE) {
145
- throw new Error(`XML path addresses a leaf: ${path.join(' / ')}`);
146
- }
147
- const child = getChildrenXmldomNode(node)[index];
148
- if (!child) {
149
- throw new Error(`XML path not found: ${path.join(' / ')}`);
150
- }
151
- node = child;
140
+ getDocument: () => ({
141
+ id: createXmlId(document),
142
+ value: { kind: 'document' },
143
+ }),
144
+ getChildren: (id) => {
145
+ const node = id === undefined ? document : id;
146
+ // Reject detached nodes and nodes from another document.
147
+ let current = node;
148
+ while (current && current !== document) {
149
+ current = current.parentNode;
152
150
  }
153
- const children = getChildrenXmldomNode(node);
154
- if (node.nodeType === Node.DOCUMENT_NODE) {
155
- return children.map(toXmlDocumentChild);
151
+ if (current !== document) {
152
+ throw new Error('XML node does not belong to the current document');
156
153
  }
157
- if (node.nodeType === Node.ELEMENT_NODE) {
158
- return children.map(toXmlElementChild);
154
+ if (node.nodeType !== Node.DOCUMENT_NODE &&
155
+ node.nodeType !== Node.ELEMENT_NODE) {
156
+ throw new Error('XML node is a leaf');
159
157
  }
160
- throw new Error(`XML path addresses a leaf: ${path.join(' / ')}`);
158
+ return getChildrenXmldomNode(node).map((child) => ({
159
+ id: createXmlId(child),
160
+ value: node.nodeType === Node.DOCUMENT_NODE
161
+ ? toXmlDocumentChild(child)
162
+ : toXmlElementChild(child),
163
+ }));
161
164
  },
162
165
  };
163
166
  };
@@ -1,10 +1,2 @@
1
- import type { AppChild, AppRoot } from 'dirvi-apis';
2
- import type { XmlDocument } from '../domain/xml-doc.js';
3
- import type { XmlId, XmlNodeValue } from '../domain/xml-tree.js';
4
- import { XmlDom } from '../services/xml-dom.js';
5
- /**
6
- * Returns the direct children addressed by a dirvi path, in document order.
7
- */
8
- export declare function getXmlEntries(filePath: string, dom: XmlDom, path: readonly XmlId[]): readonly AppChild<XmlId, XmlNodeValue>[];
9
- export declare function createXmlRoot(filePath: string, document: XmlDocument): AppRoot<XmlId, XmlNodeValue>;
1
+ export {};
10
2
  //# 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":"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
+ {"version":3,"file":"get-xml-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-xml-entries.ts"],"names":[],"mappings":""}
@@ -1,74 +1,118 @@
1
- import { createHash } from 'node:crypto';
2
- import { createXmlId } from '../domain/xml-tree.js';
3
- // RFC 4122 URL namespace, used to derive deterministic version-5 UUIDs.
4
- const uuidNamespace = Buffer.from('6ba7b8119dad11d180b400c04fd430c8', 'hex');
5
- function nodeId(filePath, position, name) {
6
- const hash = createHash('sha1')
7
- .update(uuidNamespace)
8
- .update(JSON.stringify([filePath, position, name]), 'utf8')
9
- .digest();
10
- const bytes = Buffer.from(hash.subarray(0, 16));
11
- bytes[6] = (bytes[6] & 0x0f) | 0x50; // UUID version 5
12
- bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC variant
13
- const hex = bytes.toString('hex');
14
- const uuid = [
15
- hex.slice(0, 8),
16
- hex.slice(8, 12),
17
- hex.slice(12, 16),
18
- hex.slice(16, 20),
19
- hex.slice(20, 32),
20
- ].join('-');
21
- return createXmlId(name, uuid);
22
- }
23
- function nodeName(node) {
24
- switch (node.kind) {
25
- case 'element':
26
- return node.name.qualifiedName;
27
- case 'doctype':
28
- return node.name;
29
- case 'processing-instruction':
30
- return node.target;
31
- case 'declaration':
32
- return '#declaration';
33
- case 'text':
34
- return '#text';
35
- case 'cdata':
36
- return '#cdata';
37
- case 'comment':
38
- return '#comment';
39
- }
40
- }
41
- function describeChild(filePath, position, node) {
42
- return {
43
- id: nodeId(filePath, position, nodeName(node)),
44
- kind: node.kind === 'element' ? 'unloaded-branch' : 'leaf',
45
- value: node,
46
- };
47
- }
48
- /**
49
- * Returns the direct children addressed by a dirvi path, in document order.
50
- */
51
- export function getXmlEntries(filePath, dom, path) {
52
- let position = [];
53
- for (const segment of path) {
54
- const children = dom.getChildren(position);
55
- const index = children.findIndex((node, i) => nodeId(filePath, [...position, i], nodeName(node)) === segment);
56
- if (index === -1) {
57
- throw new Error(`XML path not found: ${path.join(' / ')}`);
58
- }
59
- const node = children[index];
60
- if (!node || node.kind !== 'element') {
61
- throw new Error(`XML path addresses a leaf: ${path.join(' / ')}`);
62
- }
63
- position = [...position, index];
64
- }
65
- return dom
66
- .getChildren(position)
67
- .map((node, index) => describeChild(filePath, [...position, index], node));
68
- }
69
- export function createXmlRoot(filePath, document) {
70
- return {
71
- id: nodeId(filePath, [], '#document'),
72
- value: { kind: document.kind },
73
- };
74
- }
1
+ export {};
2
+ // import { createHash } from 'node:crypto';
3
+ //
4
+ // import type { AppChild, AppRoot } from 'dirvi-apis';
5
+ //
6
+ // import type {
7
+ // XmlChildNode,
8
+ // XmlDocument,
9
+ // XmlNodePath,
10
+ // } from '../domain/xml-doc.js';
11
+ // import type { XmlId, XmlNodeValue } from '../domain/xml-tree.js';
12
+ // import { createXmlId } from '../domain/xml-tree.js';
13
+ // import { XmlDom } from '../services/xml-dom.js';
14
+ //
15
+ // // RFC 4122 URL namespace, used to derive deterministic version-5 UUIDs.
16
+ // const uuidNamespace = Buffer.from('6ba7b8119dad11d180b400c04fd430c8', 'hex');
17
+ //
18
+ // function nodeId(
19
+ // filePath: string,
20
+ // position: readonly number[],
21
+ // name: string,
22
+ // ): XmlId {
23
+ // const hash = createHash('sha1')
24
+ // .update(uuidNamespace)
25
+ // .update(JSON.stringify([filePath, position, name]), 'utf8')
26
+ // .digest();
27
+ //
28
+ // const bytes = Buffer.from(hash.subarray(0, 16));
29
+ // bytes[6] = (bytes[6]! & 0x0f) | 0x50; // UUID version 5
30
+ // bytes[8] = (bytes[8]! & 0x3f) | 0x80; // RFC variant
31
+ //
32
+ // const hex = bytes.toString('hex');
33
+ // const uuid = [
34
+ // hex.slice(0, 8),
35
+ // hex.slice(8, 12),
36
+ // hex.slice(12, 16),
37
+ // hex.slice(16, 20),
38
+ // hex.slice(20, 32),
39
+ // ].join('-');
40
+ //
41
+ // return createXmlId(name, uuid);
42
+ // }
43
+ //
44
+ // function nodeName(node: XmlChildNode): string {
45
+ // switch (node.kind) {
46
+ // case 'element':
47
+ // return node.name.qualifiedName;
48
+ // case 'doctype':
49
+ // return node.name;
50
+ // case 'processing-instruction':
51
+ // return node.target;
52
+ // case 'declaration':
53
+ // return '#declaration';
54
+ // case 'text':
55
+ // return '#text';
56
+ // case 'cdata':
57
+ // return '#cdata';
58
+ // case 'comment':
59
+ // return '#comment';
60
+ // }
61
+ // }
62
+ //
63
+ // function describeChild(
64
+ // filePath: string,
65
+ // position: XmlNodePath,
66
+ // node: XmlChildNode,
67
+ // ): AppChild<XmlId, XmlNodeValue> {
68
+ // return {
69
+ // id: nodeId(filePath, position, nodeName(node)),
70
+ // kind: node.kind === 'element' ? 'unloaded-branch' : 'leaf',
71
+ // value: node,
72
+ // };
73
+ // }
74
+ //
75
+ // /**
76
+ // * Returns the direct children addressed by a dirvi path, in document order.
77
+ // */
78
+ // export function getXmlEntries(
79
+ // filePath: string,
80
+ // dom: XmlDom,
81
+ // path: readonly XmlId[],
82
+ // ): readonly AppChild<XmlId, XmlNodeValue>[] {
83
+ // let position: XmlNodePath = [];
84
+ //
85
+ // for (const segment of path) {
86
+ // const children = dom.getChildren(position);
87
+ // const index = children.findIndex(
88
+ // (node, i) =>
89
+ // nodeId(filePath, [...position, i], nodeName(node)) === segment,
90
+ // );
91
+ //
92
+ // if (index === -1) {
93
+ // throw new Error(`XML path not found: ${path.join(' / ')}`);
94
+ // }
95
+ //
96
+ // const node = children[index];
97
+ //
98
+ // if (!node || node.kind !== 'element') {
99
+ // throw new Error(`XML path addresses a leaf: ${path.join(' / ')}`);
100
+ // }
101
+ //
102
+ // position = [...position, index];
103
+ // }
104
+ //
105
+ // return dom
106
+ // .getChildren(position)
107
+ // .map((node, index) => describeChild(filePath, [...position, index], node));
108
+ // }
109
+ //
110
+ // export function createXmlRoot(
111
+ // filePath: string,
112
+ // document: XmlDocument,
113
+ // ): AppRoot<XmlId, XmlNodeValue> {
114
+ // return {
115
+ // id: nodeId(filePath, [], '#document'),
116
+ // value: { kind: document.kind },
117
+ // };
118
+ // }
@@ -1,17 +1,16 @@
1
- import type { XmlDocument, XmlDocumentChild, XmlElementChild, XmlNodePath } from '../domain/xml-doc.js';
1
+ import type { XmlDocument, XmlDocumentChild, XmlElementChild } from '../domain/xml-doc.js';
2
+ import { XmlId } from '../domain/xml-tree.js';
3
+ export type XmlDomEntry<Value> = {
4
+ id: XmlId;
5
+ value: Value;
6
+ };
2
7
  export type XmlDom = {
8
+ /** Returns the document and its ID. */
9
+ getDocument: () => XmlDomEntry<XmlDocument>;
3
10
  /**
4
- * Loads the document and its direct children. Element descendants are not
5
- * loaded: each direct child element has `children` undefined.
6
- */
7
- getDocument: () => XmlDocument;
8
- /**
9
- * Loads the direct children of the document or an element.
10
- * Child elements do not have their own children loaded.
11
- *
12
- * An empty path addresses the document. Each index selects a child in
13
- * document order.
11
+ * Loads direct children in document order.
12
+ * Omitting the ID addresses the document.
14
13
  */
15
- getChildren: (path: XmlNodePath) => readonly (XmlDocumentChild | XmlElementChild)[];
14
+ getChildren: (id?: XmlId) => readonly XmlDomEntry<XmlDocumentChild | XmlElementChild>[];
16
15
  };
17
16
  //# sourceMappingURL=xml-dom.d.ts.map
@@ -1 +1 @@
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
+ {"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,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM,MAAM,WAAW,CAAC,KAAK,IAAI;IAC/B,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,uCAAuC;IACvC,WAAW,EAAE,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IAE5C;;;OAGG;IACH,WAAW,EAAE,CACX,EAAE,CAAC,EAAE,KAAK,KACP,SAAS,WAAW,CAAC,gBAAgB,GAAG,eAAe,CAAC,EAAE,CAAC;CACjE,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;AAY3D,eAAO,MAAM,YAAY,EAAE,SAyD1B,CAAC"}
1
+ {"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,YAAY,CAAC;AAQrE,eAAO,MAAM,YAAY,EAAE,SA8D1B,CAAC"}
@@ -1,17 +1,15 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
- import { xmlIdSchema, xmlValueSchema } from './domain/xml-tree.js';
3
+ import { 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';
7
6
  export const xmlAppPlugin = {
8
7
  createAppDefinitionApplicator: (input) => {
9
8
  if (input === undefined) {
10
9
  throw new Error('xml-dirvi-app: No file path to XML file given.');
11
10
  }
12
11
  const xmlAbsolutePath = resolve(input);
13
- // TODO: Make the `xmldom` nodes the IDs, but need to first get rid of the
14
- // `SerializableKey` requirement.
12
+ // TODO: Make the `xmldom` nodes the IDs.
15
13
  // Create dom async on first need, cache afterward
16
14
  let dom;
17
15
  let domPromise;
@@ -33,15 +31,18 @@ export const xmlAppPlugin = {
33
31
  };
34
32
  const appDefinition = {
35
33
  semanticOrder: true,
36
- idSchema: xmlIdSchema,
37
34
  valueSchema: xmlValueSchema,
38
35
  loadChildren: async (path) => {
39
36
  const dom = await getDom();
40
- return getXmlEntries(xmlAbsolutePath, dom, path);
37
+ return dom.getChildren(path.at(-1)).map(({ id, value }) => ({
38
+ id,
39
+ kind: value.kind === 'element' ? 'unloaded-branch' : 'leaf',
40
+ value,
41
+ }));
41
42
  },
42
43
  loadRoot: async () => {
43
44
  const dom = await getDom();
44
- return createXmlRoot(xmlAbsolutePath, dom.getDocument());
45
+ return dom.getDocument();
45
46
  },
46
47
  presentNode: (_id, value, isBranch) => ({
47
48
  content: value.kind,
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.1",
3
+ "version": "0.11.0-beta.17",
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.1",
24
+ "dirvi-apis": "0.11.0-beta.17",
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.1",
30
+ "dirvi-lib": "0.11.0-beta.17",
31
31
  "typescript": "^5.0.0"
32
32
  },
33
33
  "scripts": {