@mak-98/xml-dirvi-app 0.11.0-beta.3 → 0.11.0-beta.4
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 +5 -151
- package/dist/domain/xml-tree.d.ts.map +1 -1
- package/dist/domain/xml-tree.js +58 -67
- package/dist/infrastructure/create-xml-file-resync.d.ts +2 -0
- package/dist/infrastructure/create-xml-file-resync.d.ts.map +1 -0
- package/dist/infrastructure/create-xml-file-resync.js +68 -0
- package/dist/infrastructure/get-xml-entries.d.ts +4 -3
- package/dist/infrastructure/get-xml-entries.d.ts.map +1 -1
- package/dist/infrastructure/get-xml-entries.js +11 -10
- package/dist/infrastructure/load-node-xml-app-api.d.ts +1 -0
- package/dist/infrastructure/load-node-xml-app-api.d.ts.map +1 -1
- package/dist/infrastructure/load-node-xml-app-api.js +7 -3
- package/dist/infrastructure/parse-xml-document.d.ts +3 -2
- package/dist/infrastructure/parse-xml-document.d.ts.map +1 -1
- package/dist/infrastructure/parse-xml-document.js +3 -3
- package/dist/xml-dirvi-app.d.ts +7 -1
- package/dist/xml-dirvi-app.d.ts.map +1 -1
- package/dist/xml-dirvi-app.js +33 -7
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import type { Cursor, Folds, NavNode, TreeNode } from 'dirvi-lib';
|
|
2
|
+
import type { TreeNode, TreeNodeApi } from 'dirvi-lib';
|
|
4
3
|
/**
|
|
5
4
|
* A parser-assigned node identity within one XML document.
|
|
6
5
|
*
|
|
@@ -8,7 +7,7 @@ import type { Cursor, Folds, NavNode, TreeNode } from 'dirvi-lib';
|
|
|
8
7
|
* by the source TreeNode child sequence.
|
|
9
8
|
*/
|
|
10
9
|
export type Position = number;
|
|
11
|
-
export declare const
|
|
10
|
+
export declare const xmlIdSchema: z.ZodNumber;
|
|
12
11
|
export type XmlAttribute = Readonly<{
|
|
13
12
|
readonly name: string;
|
|
14
13
|
readonly value: string;
|
|
@@ -57,6 +56,7 @@ export type XmlProcessingInstructionValue = Readonly<{
|
|
|
57
56
|
* Child ordering is deliberately not represented here.
|
|
58
57
|
*/
|
|
59
58
|
export type XmlNodeValue = XmlDocumentValue | XmlDeclarationValue | XmlDoctypeValue | XmlElementValue | XmlTextValue | XmlCommentValue | XmlCdataValue | XmlProcessingInstructionValue;
|
|
59
|
+
export type XmlTreeNode = TreeNode<Position, XmlNodeValue>;
|
|
60
60
|
export declare const XmlAttributeSchema: z.ZodObject<{
|
|
61
61
|
name: z.ZodString;
|
|
62
62
|
value: z.ZodString;
|
|
@@ -89,7 +89,7 @@ export declare const XmlProcessingInstructionValueSchema: z.ZodObject<{
|
|
|
89
89
|
target: z.ZodString;
|
|
90
90
|
data: z.ZodString;
|
|
91
91
|
}, z.core.$strip>;
|
|
92
|
-
export declare const
|
|
92
|
+
export declare const xmlValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
93
93
|
kind: z.ZodLiteral<"document">;
|
|
94
94
|
}, z.core.$strip>, z.ZodObject<{
|
|
95
95
|
kind: z.ZodLiteral<"element">;
|
|
@@ -112,46 +112,7 @@ export declare const XmlNodeValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
112
112
|
target: z.ZodString;
|
|
113
113
|
data: z.ZodString;
|
|
114
114
|
}, z.core.$strip>], "kind">;
|
|
115
|
-
|
|
116
|
-
* An opaque tree whose IDs are parser-assigned positions and whose values
|
|
117
|
-
* describe XML node semantics.
|
|
118
|
-
*/
|
|
119
|
-
export type XmlTreeNode = TreeNode<Position, XmlNodeValue>;
|
|
120
|
-
export declare const xmlTreeNodeApi: Readonly<{
|
|
121
|
-
createLeaf(id: number, value: XmlNodeValue): TreeNode<number, XmlNodeValue>;
|
|
122
|
-
createUnloadedBranch(id: number, value: XmlNodeValue): TreeNode<number, XmlNodeValue>;
|
|
123
|
-
createLoadedBranch(id: number, value: XmlNodeValue, children: Iterable<TreeNode<number, XmlNodeValue>>): TreeNode<number, XmlNodeValue> | undefined;
|
|
124
|
-
id(node: TreeNode<number, XmlNodeValue>): number;
|
|
125
|
-
value(node: TreeNode<number, XmlNodeValue>): XmlNodeValue;
|
|
126
|
-
kind(node: TreeNode<number, XmlNodeValue>): import("dirvi-lib").TreeNodeKind;
|
|
127
|
-
matchByKind<Result>(node: TreeNode<number, XmlNodeValue>, handlers: Readonly<{
|
|
128
|
-
leaf: (node: Readonly<{
|
|
129
|
-
id: number;
|
|
130
|
-
value: XmlNodeValue;
|
|
131
|
-
}>) => Result;
|
|
132
|
-
unloadedBranch: (node: Readonly<{
|
|
133
|
-
id: number;
|
|
134
|
-
value: XmlNodeValue;
|
|
135
|
-
}>) => Result;
|
|
136
|
-
loadedBranch: (node: Readonly<{
|
|
137
|
-
id: number;
|
|
138
|
-
value: XmlNodeValue;
|
|
139
|
-
children: Iterable<TreeNode<number, XmlNodeValue>>;
|
|
140
|
-
}>) => Result;
|
|
141
|
-
}>): Result;
|
|
142
|
-
getLoadedChildren(node: TreeNode<number, XmlNodeValue>): Iterable<TreeNode<number, XmlNodeValue>> | undefined;
|
|
143
|
-
findChildById(node: TreeNode<number, XmlNodeValue>, id: number): TreeNode<number, XmlNodeValue> | undefined;
|
|
144
|
-
withValue(node: TreeNode<number, XmlNodeValue>, value: XmlNodeValue): TreeNode<number, XmlNodeValue>;
|
|
145
|
-
toLeaf(node: TreeNode<number, XmlNodeValue>): TreeNode<number, XmlNodeValue>;
|
|
146
|
-
toUnloadedBranch(node: TreeNode<number, XmlNodeValue>): TreeNode<number, XmlNodeValue>;
|
|
147
|
-
withLoadedChildren(node: TreeNode<number, XmlNodeValue>, children: Iterable<TreeNode<number, XmlNodeValue>>): TreeNode<number, XmlNodeValue> | undefined;
|
|
148
|
-
findAtPath(root: TreeNode<number, XmlNodeValue>, path: readonly number[]): TreeNode<number, XmlNodeValue> | undefined;
|
|
149
|
-
selectAtPath<Result>(root: TreeNode<number, XmlNodeValue>, path: readonly number[], selector: (node: TreeNode<number, XmlNodeValue>) => Result): Result | undefined;
|
|
150
|
-
updateAtPath(root: TreeNode<number, XmlNodeValue>, path: readonly number[], update: (node: TreeNode<number, XmlNodeValue>) => TreeNode<number, XmlNodeValue> | undefined): TreeNode<number, XmlNodeValue> | undefined;
|
|
151
|
-
toModel(node: TreeNode<number, XmlNodeValue>): TreeNodeModel<number, XmlNodeValue>;
|
|
152
|
-
fromModel(model: TreeNodeModel<number, XmlNodeValue>): TreeNode<number, XmlNodeValue> | undefined;
|
|
153
|
-
}>;
|
|
154
|
-
export declare const XmlTreeNode: {
|
|
115
|
+
export declare function createConstructors(xmlTreeNodeApi: TreeNodeApi<Position, XmlNodeValue>): {
|
|
155
116
|
readonly document: (id: Position, children: Iterable<XmlTreeNode>) => XmlTreeNode | undefined;
|
|
156
117
|
readonly declaration: (id: Position, version: string, encoding: string | null, standalone: "yes" | "no" | null) => XmlTreeNode;
|
|
157
118
|
readonly doctype: (id: Position, name: string, publicId: string | null, systemId: string | null, internalSubset: string | null) => XmlTreeNode;
|
|
@@ -161,111 +122,4 @@ export declare const XmlTreeNode: {
|
|
|
161
122
|
readonly cdata: (id: Position, text: string) => XmlTreeNode;
|
|
162
123
|
readonly processingInstruction: (id: Position, target: string, data: string) => XmlTreeNode;
|
|
163
124
|
};
|
|
164
|
-
export type XmlFolds = Folds<Position>;
|
|
165
|
-
export declare const xmlFoldsApi: Readonly<{
|
|
166
|
-
create(rootId: number, initialPrimaryInfo: Readonly<{
|
|
167
|
-
name: string;
|
|
168
|
-
description: string | null;
|
|
169
|
-
}>): Folds<number>;
|
|
170
|
-
getIndexByName(folds: Folds<number>, name: string): import("dirvi-lib").FoldIndex | undefined;
|
|
171
|
-
getInfoAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): Readonly<{
|
|
172
|
-
name: string;
|
|
173
|
-
description: string | null;
|
|
174
|
-
}> | undefined;
|
|
175
|
-
isActiveAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): boolean | undefined;
|
|
176
|
-
hasAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): boolean;
|
|
177
|
-
indexes(folds: Folds<number>): Iterable<import("dirvi-lib").FoldIndex>;
|
|
178
|
-
setAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, foldData: Readonly<{
|
|
179
|
-
name: string;
|
|
180
|
-
description: string | null;
|
|
181
|
-
active: boolean;
|
|
182
|
-
tree: Readonly<{
|
|
183
|
-
id: number;
|
|
184
|
-
hiddenEntryIds: readonly number[];
|
|
185
|
-
children: readonly Readonly</*elided*/ any>[];
|
|
186
|
-
}>;
|
|
187
|
-
}>): Folds<number> | undefined;
|
|
188
|
-
setAdditionalFoldAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, rootId: number, info: Readonly<{
|
|
189
|
-
name: string;
|
|
190
|
-
description: string | null;
|
|
191
|
-
}>): Folds<number> | undefined;
|
|
192
|
-
removeAdditionalFoldAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): Folds<number> | undefined;
|
|
193
|
-
updateInfoAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, update: Readonly<{
|
|
194
|
-
name?: string;
|
|
195
|
-
description?: string | null;
|
|
196
|
-
}>): Folds<number> | undefined;
|
|
197
|
-
activateAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): Folds<number> | undefined;
|
|
198
|
-
deactivateAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): Folds<number> | undefined;
|
|
199
|
-
toggleActiveAtIndex(folds: Folds<number>, index: import("dirvi-lib").FoldIndex): Folds<number> | undefined;
|
|
200
|
-
isEntryHiddenInFoldAtPath(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, path: readonly number[], entryId: number): boolean;
|
|
201
|
-
isEntryHiddenAtPath(folds: Folds<number>, path: readonly number[], entryId: number): boolean;
|
|
202
|
-
hiddenEntryIdsAtPath(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, path: readonly number[]): Iterable<number> | undefined;
|
|
203
|
-
hideEntryAtPath(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, path: readonly number[], entryId: number): Folds<number> | undefined;
|
|
204
|
-
showEntryAtPath(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, path: readonly number[], entryId: number): Folds<number> | undefined;
|
|
205
|
-
showAllHiddenEntriesAtPath(folds: Folds<number>, index: import("dirvi-lib").FoldIndex, path: readonly number[]): Folds<number> | undefined;
|
|
206
|
-
toModel(folds: Folds<number>): Readonly<{
|
|
207
|
-
slots: readonly [Readonly<{
|
|
208
|
-
name: string;
|
|
209
|
-
description: string | null;
|
|
210
|
-
active: boolean;
|
|
211
|
-
tree: Readonly<{
|
|
212
|
-
id: number;
|
|
213
|
-
hiddenEntryIds: readonly number[];
|
|
214
|
-
children: readonly Readonly</*elided*/ any>[];
|
|
215
|
-
}>;
|
|
216
|
-
}>, ...(Readonly<{
|
|
217
|
-
name: string;
|
|
218
|
-
description: string | null;
|
|
219
|
-
active: boolean;
|
|
220
|
-
tree: Readonly<{
|
|
221
|
-
id: number;
|
|
222
|
-
hiddenEntryIds: readonly number[];
|
|
223
|
-
children: readonly Readonly</*elided*/ any>[];
|
|
224
|
-
}>;
|
|
225
|
-
}> | null)[]];
|
|
226
|
-
}>;
|
|
227
|
-
fromModel(model: Readonly<{
|
|
228
|
-
slots: readonly [Readonly<{
|
|
229
|
-
name: string;
|
|
230
|
-
description: string | null;
|
|
231
|
-
active: boolean;
|
|
232
|
-
tree: Readonly<{
|
|
233
|
-
id: number;
|
|
234
|
-
hiddenEntryIds: readonly number[];
|
|
235
|
-
children: readonly Readonly</*elided*/ any>[];
|
|
236
|
-
}>;
|
|
237
|
-
}>, ...(Readonly<{
|
|
238
|
-
name: string;
|
|
239
|
-
description: string | null;
|
|
240
|
-
active: boolean;
|
|
241
|
-
tree: Readonly<{
|
|
242
|
-
id: number;
|
|
243
|
-
hiddenEntryIds: readonly number[];
|
|
244
|
-
children: readonly Readonly</*elided*/ any>[];
|
|
245
|
-
}>;
|
|
246
|
-
}> | null)[]];
|
|
247
|
-
}>): Folds<number> | undefined;
|
|
248
|
-
}>;
|
|
249
|
-
export declare const xmlCursorSchema: z.ZodType<XmlCursor>;
|
|
250
|
-
export type XmlCursor = Cursor<Position>;
|
|
251
|
-
export declare const xmlCursorApi: import("dirvi-lib").CursorApi<number>;
|
|
252
|
-
export type XmlNavNode = NavNode<Position>;
|
|
253
|
-
export declare const xmlNavApi: import("dirvi-lib").NavNodeApi<number, XmlNodeValue>;
|
|
254
|
-
export type XmlState = State<Position, XmlNodeValue>;
|
|
255
|
-
export declare const xmlStateApi: Readonly<{
|
|
256
|
-
getNodeAtCursor(state: Readonly<{
|
|
257
|
-
root: TreeNode<number, XmlNodeValue>;
|
|
258
|
-
folds: Folds<number>;
|
|
259
|
-
cursor: Cursor<number>;
|
|
260
|
-
}>): TreeNode<number, XmlNodeValue> | undefined;
|
|
261
|
-
resync(oldState: Readonly<{
|
|
262
|
-
root: TreeNode<number, XmlNodeValue>;
|
|
263
|
-
folds: Folds<number>;
|
|
264
|
-
cursor: Cursor<number>;
|
|
265
|
-
}>, loadBranches: (path: readonly number[]) => Promise<readonly TreeNode<number, XmlNodeValue>[]>): Promise<Readonly<{
|
|
266
|
-
root: TreeNode<number, XmlNodeValue>;
|
|
267
|
-
folds: Folds<number>;
|
|
268
|
-
cursor: Cursor<number>;
|
|
269
|
-
}>>;
|
|
270
|
-
}>;
|
|
271
125
|
//# 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,
|
|
1
|
+
{"version":3,"file":"xml-tree.d.ts","sourceRoot":"","sources":["../../src/domain/xml-tree.ts"],"names":[],"mappings":"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"}
|
package/dist/domain/xml-tree.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export const XmlNodeIdSchema = z
|
|
2
|
+
export const xmlIdSchema = z
|
|
4
3
|
.number()
|
|
5
4
|
.int()
|
|
6
5
|
.nonnegative();
|
|
@@ -35,7 +34,7 @@ export const XmlProcessingInstructionValueSchema = z.object({
|
|
|
35
34
|
target: z.string().min(1),
|
|
36
35
|
data: z.string(),
|
|
37
36
|
});
|
|
38
|
-
export const
|
|
37
|
+
export const xmlValueSchema = z.discriminatedUnion('kind', [
|
|
39
38
|
XmlDocumentValueSchema,
|
|
40
39
|
XmlElementValueSchema,
|
|
41
40
|
XmlTextValueSchema,
|
|
@@ -43,70 +42,62 @@ export const XmlNodeValueSchema = z.discriminatedUnion('kind', [
|
|
|
43
42
|
XmlCdataValueSchema,
|
|
44
43
|
XmlProcessingInstructionValueSchema,
|
|
45
44
|
]);
|
|
46
|
-
export const xmlTreeNodeApi = createTreeNodeApi();
|
|
47
45
|
// -----------------------------------------------------------------------------
|
|
48
46
|
// XML domain constructors
|
|
49
47
|
// -----------------------------------------------------------------------------
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// -----------------------------------------------------------------------------
|
|
107
|
-
// XmlCursor
|
|
108
|
-
// -----------------------------------------------------------------------------
|
|
109
|
-
export const xmlCursorSchema = createCursorSchema(XmlNodeIdSchema);
|
|
110
|
-
export const xmlCursorApi = createCursorApi();
|
|
111
|
-
export const xmlNavApi = createNavNodeApi(xmlTreeNodeApi, xmlFoldsApi, xmlCursorApi, {});
|
|
112
|
-
export const xmlStateApi = createStateApi(xmlTreeNodeApi, xmlCursorApi);
|
|
48
|
+
export function createConstructors(xmlTreeNodeApi) {
|
|
49
|
+
return {
|
|
50
|
+
document(id, children) {
|
|
51
|
+
return xmlTreeNodeApi.createLoadedBranch(id, { kind: 'document' }, children);
|
|
52
|
+
},
|
|
53
|
+
declaration(id, version, encoding, standalone) {
|
|
54
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
55
|
+
kind: 'declaration',
|
|
56
|
+
version,
|
|
57
|
+
encoding,
|
|
58
|
+
standalone,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
doctype(id, name, publicId, systemId, internalSubset) {
|
|
62
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
63
|
+
kind: 'doctype',
|
|
64
|
+
name,
|
|
65
|
+
publicId,
|
|
66
|
+
systemId,
|
|
67
|
+
internalSubset,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
element(id, name, attributes, children) {
|
|
71
|
+
return xmlTreeNodeApi.createLoadedBranch(id, {
|
|
72
|
+
kind: 'element',
|
|
73
|
+
name,
|
|
74
|
+
attributes,
|
|
75
|
+
}, children);
|
|
76
|
+
},
|
|
77
|
+
text(id, text) {
|
|
78
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
79
|
+
kind: 'text',
|
|
80
|
+
text,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
comment(id, text) {
|
|
84
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
85
|
+
kind: 'comment',
|
|
86
|
+
text,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
cdata(id, text) {
|
|
90
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
91
|
+
kind: 'cdata',
|
|
92
|
+
text,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
processingInstruction(id, target, data) {
|
|
96
|
+
return xmlTreeNodeApi.createLeaf(id, {
|
|
97
|
+
kind: 'processing-instruction',
|
|
98
|
+
target,
|
|
99
|
+
data,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-xml-file-resync.d.ts","sourceRoot":"","sources":["../../src/infrastructure/create-xml-file-resync.ts"],"names":[],"mappings":"AAGA,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,MAAM,GACtB,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAiFtC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { watch } from 'node:fs';
|
|
2
|
+
import { basename, dirname } from 'node:path';
|
|
3
|
+
export function createXmlFileResyncSubscription(xmlAbsolutePath) {
|
|
4
|
+
const listeners = new Set();
|
|
5
|
+
const parentDirectory = dirname(xmlAbsolutePath);
|
|
6
|
+
const fileName = basename(xmlAbsolutePath);
|
|
7
|
+
let watcher;
|
|
8
|
+
let notificationTimer;
|
|
9
|
+
function notifyListeners() {
|
|
10
|
+
for (const listener of listeners) {
|
|
11
|
+
listener();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function scheduleNotification() {
|
|
15
|
+
if (notificationTimer !== undefined) {
|
|
16
|
+
clearTimeout(notificationTimer);
|
|
17
|
+
}
|
|
18
|
+
notificationTimer = setTimeout(() => {
|
|
19
|
+
notificationTimer = undefined;
|
|
20
|
+
if (listeners.size > 0) {
|
|
21
|
+
notifyListeners();
|
|
22
|
+
}
|
|
23
|
+
}, 100);
|
|
24
|
+
}
|
|
25
|
+
function startWatcher() {
|
|
26
|
+
if (watcher !== undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
watcher = watch(parentDirectory, (_eventType, changedName) => {
|
|
30
|
+
/*
|
|
31
|
+
* A null filename means the platform could not identify the changed
|
|
32
|
+
* entry. Conservatively resync in that case.
|
|
33
|
+
*/
|
|
34
|
+
if (changedName === null || changedName.toString() === fileName) {
|
|
35
|
+
scheduleNotification();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
watcher.on('error', () => {
|
|
39
|
+
/*
|
|
40
|
+
* The next createRoot() call will report the filesystem or XML parsing
|
|
41
|
+
* failure through normal application error handling.
|
|
42
|
+
*/
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function stopWatcher() {
|
|
46
|
+
if (notificationTimer !== undefined) {
|
|
47
|
+
clearTimeout(notificationTimer);
|
|
48
|
+
notificationTimer = undefined;
|
|
49
|
+
}
|
|
50
|
+
watcher?.close();
|
|
51
|
+
watcher = undefined;
|
|
52
|
+
}
|
|
53
|
+
return (listener) => {
|
|
54
|
+
listeners.add(listener);
|
|
55
|
+
startWatcher();
|
|
56
|
+
let subscribed = true;
|
|
57
|
+
return () => {
|
|
58
|
+
if (!subscribed) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
subscribed = false;
|
|
62
|
+
listeners.delete(listener);
|
|
63
|
+
if (listeners.size === 0) {
|
|
64
|
+
stopWatcher();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { XmlNode } from '@rgrove/parse-xml';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { TreeNodeApi } from 'dirvi-lib';
|
|
3
|
+
import type { XmlNodeValue, XmlTreeNode } from '../domain/xml-tree.js';
|
|
4
|
+
import type { Position } from '../domain/xml-tree.js';
|
|
4
5
|
/**
|
|
5
6
|
* Allocates unique XML tree IDs while one parsed document is converted.
|
|
6
7
|
*
|
|
@@ -15,5 +16,5 @@ export type CreatePosition = () => Position;
|
|
|
15
16
|
* mixed content such as text, elements, comments, and CDATA remains in its
|
|
16
17
|
* source-document order.
|
|
17
18
|
*/
|
|
18
|
-
export declare function getXmlEntries(xmlNodes: readonly XmlNode[], createPosition: CreatePosition): XmlTreeNode[];
|
|
19
|
+
export declare function getXmlEntries(treeNodeApi: TreeNodeApi<Position, XmlNodeValue>, xmlNodes: readonly XmlNode[], createPosition: CreatePosition): XmlTreeNode[];
|
|
19
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,
|
|
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,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,EAChD,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,cAAc,EAAE,cAAc,GAC7B,WAAW,EAAE,CAwEf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XmlCdata, XmlComment, XmlDeclaration, XmlDocumentType, XmlElement, XmlProcessingInstruction, XmlText, } from '@rgrove/parse-xml';
|
|
2
|
-
import {
|
|
2
|
+
import { createConstructors } from '../domain/xml-tree.js';
|
|
3
3
|
/**
|
|
4
4
|
* Converts XML parser nodes into ordered Dirvi XML tree nodes.
|
|
5
5
|
*
|
|
@@ -7,12 +7,13 @@ import { XmlTreeNode as XmlTreeNodeDomain, } 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(xmlNodes, createPosition) {
|
|
10
|
+
export function getXmlEntries(treeNodeApi, xmlNodes, createPosition) {
|
|
11
11
|
return xmlNodes.map((xmlNode) => {
|
|
12
12
|
const id = createPosition();
|
|
13
|
+
const constructors = createConstructors(treeNodeApi);
|
|
13
14
|
if (xmlNode instanceof XmlElement) {
|
|
14
|
-
const children = getXmlEntries(xmlNode.children, createPosition);
|
|
15
|
-
const node =
|
|
15
|
+
const children = getXmlEntries(treeNodeApi, xmlNode.children, createPosition);
|
|
16
|
+
const node = constructors.element(id, xmlNode.name, Object.entries(xmlNode.attributes).map(([name, value]) => ({
|
|
16
17
|
name,
|
|
17
18
|
value,
|
|
18
19
|
})), children);
|
|
@@ -22,22 +23,22 @@ export function getXmlEntries(xmlNodes, createPosition) {
|
|
|
22
23
|
return node;
|
|
23
24
|
}
|
|
24
25
|
if (xmlNode instanceof XmlText) {
|
|
25
|
-
return
|
|
26
|
+
return constructors.text(id, xmlNode.text);
|
|
26
27
|
}
|
|
27
28
|
if (xmlNode instanceof XmlCdata) {
|
|
28
|
-
return
|
|
29
|
+
return constructors.cdata(id, xmlNode.text);
|
|
29
30
|
}
|
|
30
31
|
if (xmlNode instanceof XmlComment) {
|
|
31
|
-
return
|
|
32
|
+
return constructors.comment(id, xmlNode.content);
|
|
32
33
|
}
|
|
33
34
|
if (xmlNode instanceof XmlProcessingInstruction) {
|
|
34
|
-
return
|
|
35
|
+
return constructors.processingInstruction(id, xmlNode.name, xmlNode.content);
|
|
35
36
|
}
|
|
36
37
|
if (xmlNode instanceof XmlDeclaration) {
|
|
37
|
-
return
|
|
38
|
+
return constructors.declaration(id, xmlNode.version, xmlNode.encoding, xmlNode.standalone);
|
|
38
39
|
}
|
|
39
40
|
if (xmlNode instanceof XmlDocumentType) {
|
|
40
|
-
return
|
|
41
|
+
return constructors.doctype(id, xmlNode.name, xmlNode.publicId, xmlNode.systemId, xmlNode.internalSubset);
|
|
41
42
|
}
|
|
42
43
|
throw new Error(`Unsupported XML node type "${xmlNode.type}".`);
|
|
43
44
|
});
|
|
@@ -7,4 +7,5 @@ import { type Position, type XmlNodeValue } from '../domain/xml-tree.js';
|
|
|
7
7
|
* XML domain tree and displayed through xmlNavApi's source-order navigation.
|
|
8
8
|
*/
|
|
9
9
|
export declare function loadNodeXmlAppApi(filePath: string): AppApi<Position, XmlNodeValue, string>;
|
|
10
|
+
export declare function createXmlFileResyncSubscription(xmlAbsolutePath: string): (listener: () => void) => () => void;
|
|
10
11
|
//# sourceMappingURL=load-node-xml-app-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-node-xml-app-api.d.ts","sourceRoot":"","sources":["../../src/infrastructure/load-node-xml-app-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"load-node-xml-app-api.d.ts","sourceRoot":"","sources":["../../src/infrastructure/load-node-xml-app-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;AAI/B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CA6CxC;AAED,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,MAAM,GACtB,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAiFtC"}
|
|
@@ -2,7 +2,8 @@ import { watch } from 'node:fs';
|
|
|
2
2
|
import { basename, dirname, resolve } from 'node:path';
|
|
3
3
|
import { createAppStateApis } from 'dirvi-lib';
|
|
4
4
|
import { xmlFoldsApi, xmlNavApi, } from '../domain/xml-tree.js';
|
|
5
|
-
import {
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { parseXmlDocument } from './parse-xml-document.js';
|
|
6
7
|
/**
|
|
7
8
|
* Creates the AppApi for one XML document.
|
|
8
9
|
*
|
|
@@ -18,7 +19,10 @@ export function loadNodeXmlAppApi(filePath) {
|
|
|
18
19
|
* parseXmlDocument() reserves position 0 for the synthetic document root.
|
|
19
20
|
*/
|
|
20
21
|
rootId: 0,
|
|
21
|
-
createRoot: () =>
|
|
22
|
+
createRoot: async () => {
|
|
23
|
+
const source = await readFile(xmlAbsolutePath, 'utf8');
|
|
24
|
+
return parseXmlDocument(source);
|
|
25
|
+
},
|
|
22
26
|
/*
|
|
23
27
|
* XML documents are parsed completely when their root is created. No XML
|
|
24
28
|
* branch is represented as an unloaded branch.
|
|
@@ -42,7 +46,7 @@ export function loadNodeXmlAppApi(filePath) {
|
|
|
42
46
|
...apis,
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
|
-
function createXmlFileResyncSubscription(xmlAbsolutePath) {
|
|
49
|
+
export function createXmlFileResyncSubscription(xmlAbsolutePath) {
|
|
46
50
|
const listeners = new Set();
|
|
47
51
|
const parentDirectory = dirname(xmlAbsolutePath);
|
|
48
52
|
const fileName = basename(xmlAbsolutePath);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TreeNodeApi } from 'dirvi-lib';
|
|
2
|
+
import type { Position, XmlNodeValue, XmlTreeNode } from '../domain/xml-tree.js';
|
|
2
3
|
/**
|
|
3
4
|
* Parses XML source into one Dirvi XML document tree.
|
|
4
5
|
*
|
|
5
6
|
* The synthetic document root always receives ID 0. Descendants receive
|
|
6
7
|
* monotonically allocated IDs in parser encounter order.
|
|
7
8
|
*/
|
|
8
|
-
export declare function parseXmlDocument(source: string): XmlTreeNode;
|
|
9
|
+
export declare function parseXmlDocument(treeNodeApi: TreeNodeApi<Position, XmlNodeValue>, source: string): XmlTreeNode;
|
|
9
10
|
//# 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":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-xml-document.d.ts","sourceRoot":"","sources":["../../src/infrastructure/parse-xml-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAI/B;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,EAChD,MAAM,EAAE,MAAM,GACb,WAAW,CAwBb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseXml } from '@rgrove/parse-xml';
|
|
2
|
-
import {
|
|
2
|
+
import { createConstructors } from '../domain/xml-tree.js';
|
|
3
3
|
import { getXmlEntries } from './get-xml-entries.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parses XML source into one Dirvi XML document tree.
|
|
@@ -7,10 +7,10 @@ import { getXmlEntries } from './get-xml-entries.js';
|
|
|
7
7
|
* The synthetic document root always receives ID 0. Descendants receive
|
|
8
8
|
* monotonically allocated IDs in parser encounter order.
|
|
9
9
|
*/
|
|
10
|
-
export function parseXmlDocument(source) {
|
|
10
|
+
export function parseXmlDocument(treeNodeApi, source) {
|
|
11
11
|
const document = parseXml(source);
|
|
12
12
|
let nextPosition = 1;
|
|
13
|
-
const root =
|
|
13
|
+
const root = createConstructors(treeNodeApi).document(0, getXmlEntries(treeNodeApi, document.children, () => {
|
|
14
14
|
const position = nextPosition;
|
|
15
15
|
nextPosition += 1;
|
|
16
16
|
return position;
|
package/dist/xml-dirvi-app.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { AppPlugin } from 'dirvi-apis/plugin';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates applicator of `AppDefinition<Position, XmlValue>`.
|
|
4
|
+
*
|
|
5
|
+
* This style is used, instead of just creating the `AppDefinition`, for the
|
|
6
|
+
* user of the package to be able to apply the AppDefinition without specifying
|
|
7
|
+
* the generics.
|
|
8
|
+
*
|
|
9
|
+
* @param input - the path of the XML file to open.
|
|
4
10
|
*/
|
|
5
11
|
export declare const xmlAppPlugin: AppPlugin;
|
|
6
12
|
//# sourceMappingURL=xml-dirvi-app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"
|
|
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,SAmC1B,CAAC"}
|
package/dist/xml-dirvi-app.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { xmlIdSchema, xmlValueSchema } from './domain/xml-tree.js';
|
|
4
|
+
import { createXmlFileResyncSubscription } from './infrastructure/create-xml-file-resync.js';
|
|
5
|
+
import { parseXmlDocument } from './infrastructure/parse-xml-document.js';
|
|
2
6
|
/**
|
|
3
|
-
*
|
|
7
|
+
* Creates applicator of `AppDefinition<Position, XmlValue>`.
|
|
8
|
+
*
|
|
9
|
+
* This style is used, instead of just creating the `AppDefinition`, for the
|
|
10
|
+
* user of the package to be able to apply the AppDefinition without specifying
|
|
11
|
+
* the generics.
|
|
12
|
+
*
|
|
13
|
+
* @param input - the path of the XML file to open.
|
|
4
14
|
*/
|
|
5
15
|
export const xmlAppPlugin = {
|
|
6
|
-
|
|
16
|
+
createAppDefinitionApplicator: (input) => {
|
|
7
17
|
if (input === undefined) {
|
|
8
|
-
throw new Error('xml-app: No file path to XML file given.');
|
|
18
|
+
throw new Error('xml-dirvi-app: No file path to XML file given.');
|
|
9
19
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
const xmlAbsolutePath = resolve(input);
|
|
21
|
+
const appDefinition = {
|
|
22
|
+
displayName: `XML: ${input}`,
|
|
23
|
+
rootId: 0,
|
|
24
|
+
idSchema: xmlIdSchema,
|
|
25
|
+
valueSchema: xmlValueSchema,
|
|
26
|
+
createRoot: async (treeNodeApi) => {
|
|
27
|
+
const source = await readFile(input, 'utf8');
|
|
28
|
+
return parseXmlDocument(treeNodeApi, source);
|
|
29
|
+
},
|
|
30
|
+
loadChildren: async (treeNodeApi, path) => {
|
|
31
|
+
// TODO Later: load from the file
|
|
32
|
+
throw new Error('Cannot load XML branches: parsed XML documents have no unloaded branches.');
|
|
33
|
+
},
|
|
34
|
+
subscribeToResync: createXmlFileResyncSubscription(xmlAbsolutePath),
|
|
35
|
+
createNavNodeApiOptions: {},
|
|
36
|
+
};
|
|
37
|
+
return (appDefinitionConsumer) => {
|
|
38
|
+
return appDefinitionConsumer(appDefinition);
|
|
13
39
|
};
|
|
14
40
|
},
|
|
15
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mak-98/xml-dirvi-app",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.4",
|
|
4
4
|
"description": "XML file app for dirvi.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@rgrove/parse-xml": "^5.0.0",
|
|
23
|
-
"dirvi-apis": "0.11.0-beta.
|
|
24
|
-
"dirvi-lib": "0.11.0-beta.2",
|
|
23
|
+
"dirvi-apis": "0.11.0-beta.4",
|
|
25
24
|
"env-paths": "^4.0.0",
|
|
26
25
|
"zod": "^4.4.3"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
28
|
+
"dirvi-lib": "0.11.0-beta.4",
|
|
29
29
|
"@types/node": "^22.0.0",
|
|
30
30
|
"typescript": "^5.0.0"
|
|
31
31
|
},
|