@mak-98/xml-dirvi-app 0.11.0-beta.3.1 → 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.
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { State, TreeNodeModel } from 'dirvi-lib';
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 XmlIdSchema: z.ZodNumber;
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 XmlNodeValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
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,EAK0B,KAAK,EAAc,aAAa,EAChE,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,OAAO,EAEP,QAAQ,EACT,MAAM,WAAW,CAAC;AAYnB;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,eAAO,MAAM,WAAW,aAGsB,CAAC;AAY/C,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,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;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FoldsApi, createNavNodeApi, createStateApi, createTreeNodeApi, } from 'dirvi-lib';
3
- export const XmlIdSchema = 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 XmlNodeValueSchema = z.discriminatedUnion('kind', [
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 const XmlTreeNode = {
51
- document(id, children) {
52
- return xmlTreeNodeApi.createLoadedBranch(id, { kind: 'document' }, children);
53
- },
54
- declaration(id, version, encoding, standalone) {
55
- return xmlTreeNodeApi.createLeaf(id, {
56
- kind: 'declaration',
57
- version,
58
- encoding,
59
- standalone,
60
- });
61
- },
62
- doctype(id, name, publicId, systemId, internalSubset) {
63
- return xmlTreeNodeApi.createLeaf(id, {
64
- kind: 'doctype',
65
- name,
66
- publicId,
67
- systemId,
68
- internalSubset,
69
- });
70
- },
71
- element(id, name, attributes, children) {
72
- return xmlTreeNodeApi.createLoadedBranch(id, {
73
- kind: 'element',
74
- name,
75
- attributes,
76
- }, children);
77
- },
78
- text(id, text) {
79
- return xmlTreeNodeApi.createLeaf(id, {
80
- kind: 'text',
81
- text,
82
- });
83
- },
84
- comment(id, text) {
85
- return xmlTreeNodeApi.createLeaf(id, {
86
- kind: 'comment',
87
- text,
88
- });
89
- },
90
- cdata(id, text) {
91
- return xmlTreeNodeApi.createLeaf(id, {
92
- kind: 'cdata',
93
- text,
94
- });
95
- },
96
- processingInstruction(id, target, data) {
97
- return xmlTreeNodeApi.createLeaf(id, {
98
- kind: 'processing-instruction',
99
- target,
100
- data,
101
- });
102
- },
103
- };
104
- const xmlFoldTreeNodeApi = createTreeNodeApi();
105
- export const xmlFoldsApi = createFoldsApi(xmlFoldTreeNodeApi);
106
- // -----------------------------------------------------------------------------
107
- // XmlCursor
108
- // -----------------------------------------------------------------------------
109
- export const xmlCursorSchema = createCursorSchema(XmlIdSchema);
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
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { xmlAppPlugin2 as default } from './xml-dirvi-app.js';
2
- export { xmlAppPlugin2 } from './xml-dirvi-app.js';
1
+ export { xmlAppPlugin as default } from './xml-dirvi-app.js';
2
+ export { xmlAppPlugin } from './xml-dirvi-app.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { xmlAppPlugin2 as default } from './xml-dirvi-app.js';
2
- export { xmlAppPlugin2 } from './xml-dirvi-app.js';
1
+ export { xmlAppPlugin as default } from './xml-dirvi-app.js';
2
+ export { xmlAppPlugin } from './xml-dirvi-app.js';
@@ -0,0 +1,2 @@
1
+ export declare function createXmlFileResyncSubscription(xmlAbsolutePath: string): (listener: () => void) => () => void;
2
+ //# sourceMappingURL=create-xml-file-resync.d.ts.map
@@ -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 { XmlTreeNode } from '../domain/xml-tree.js';
3
- import { type Position } from '../domain/xml-tree.js';
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,uBAAuB,CAAC;AACzD,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,uBAAuB,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,cAAc,EAAE,cAAc,GAC7B,WAAW,EAAE,CAmEf"}
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 { XmlTreeNode as XmlTreeNodeDomain, } from '../domain/xml-tree.js';
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 = XmlTreeNodeDomain.element(id, xmlNode.name, Object.entries(xmlNode.attributes).map(([name, value]) => ({
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 XmlTreeNodeDomain.text(id, xmlNode.text);
26
+ return constructors.text(id, xmlNode.text);
26
27
  }
27
28
  if (xmlNode instanceof XmlCdata) {
28
- return XmlTreeNodeDomain.cdata(id, xmlNode.text);
29
+ return constructors.cdata(id, xmlNode.text);
29
30
  }
30
31
  if (xmlNode instanceof XmlComment) {
31
- return XmlTreeNodeDomain.comment(id, xmlNode.content);
32
+ return constructors.comment(id, xmlNode.content);
32
33
  }
33
34
  if (xmlNode instanceof XmlProcessingInstruction) {
34
- return XmlTreeNodeDomain.processingInstruction(id, xmlNode.name, xmlNode.content);
35
+ return constructors.processingInstruction(id, xmlNode.name, xmlNode.content);
35
36
  }
36
37
  if (xmlNode instanceof XmlDeclaration) {
37
- return XmlTreeNodeDomain.declaration(id, xmlNode.version, xmlNode.encoding, xmlNode.standalone);
38
+ return constructors.declaration(id, xmlNode.version, xmlNode.encoding, xmlNode.standalone);
38
39
  }
39
40
  if (xmlNode instanceof XmlDocumentType) {
40
- return XmlTreeNodeDomain.doctype(id, xmlNode.name, xmlNode.publicId, xmlNode.systemId, xmlNode.internalSubset);
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
  });
@@ -1,9 +1,10 @@
1
- import type { XmlTreeNode } from '../domain/xml-tree.js';
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;AAIzD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAwB5D"}
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 { XmlTreeNode as XmlTreeNodeDomain } from '../domain/xml-tree.js';
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 = XmlTreeNodeDomain.document(0, getXmlEntries(document.children, () => {
13
+ const root = createConstructors(treeNodeApi).document(0, getXmlEntries(treeNodeApi, document.children, () => {
14
14
  const position = nextPosition;
15
15
  nextPosition += 1;
16
16
  return position;
@@ -1,12 +1,12 @@
1
- import type { AppPlugin, AppPlugin2 } from 'dirvi-apis/plugin';
1
+ import type { AppPlugin } from 'dirvi-apis/plugin';
2
2
  /**
3
- * A dirvi app that exposes a POSIX filesystem as a navigable tree.
4
- */
5
- export declare const xmlAppPlugin: AppPlugin;
6
- /**
7
- * Creates applicator of AppDefinition.
3
+ * Creates applicator of `AppDefinition<Position, XmlValue>`.
8
4
  *
9
- * @param input - the absolute path to the XML file to open.
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.
10
10
  */
11
- export declare const xmlAppPlugin2: AppPlugin2;
11
+ export declare const xmlAppPlugin: AppPlugin;
12
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":"AAAA,OAAO,KAAK,EACV,SAAS,EAAE,UAAU,EACtB,MAAM,mBAAmB,CAAC;AAS3B;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SAY1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,UA8B3B,CAAC"}
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"}
@@ -1,28 +1,18 @@
1
- import { createXmlFileResyncSubscription, loadNodeXmlAppApi } from './infrastructure/load-node-xml-app-api.js';
2
- import { XmlIdSchema, XmlNodeValueSchema } from './domain/xml-tree.js';
3
1
  import { readFile } from 'node:fs/promises';
4
- import { parseXmlDocument } from './infrastructure/parse-xml-document.js';
5
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';
6
6
  /**
7
- * A dirvi app that exposes a POSIX filesystem as a navigable tree.
8
- */
9
- export const xmlAppPlugin = {
10
- createAppApiApplicator: (input) => {
11
- if (input === undefined) {
12
- throw new Error('xml-app: No file path to XML file given.');
13
- }
14
- const appApi = loadNodeXmlAppApi(input);
15
- return (appApiConsumer) => {
16
- return appApiConsumer(appApi);
17
- };
18
- },
19
- };
20
- /**
21
- * Creates applicator of AppDefinition.
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.
22
12
  *
23
- * @param input - the absolute path to the XML file to open.
13
+ * @param input - the path of the XML file to open.
24
14
  */
25
- export const xmlAppPlugin2 = {
15
+ export const xmlAppPlugin = {
26
16
  createAppDefinitionApplicator: (input) => {
27
17
  if (input === undefined) {
28
18
  throw new Error('xml-dirvi-app: No file path to XML file given.');
@@ -31,13 +21,13 @@ export const xmlAppPlugin2 = {
31
21
  const appDefinition = {
32
22
  displayName: `XML: ${input}`,
33
23
  rootId: 0,
34
- idSchema: XmlIdSchema,
35
- valueSchema: XmlNodeValueSchema,
36
- createRoot: async () => {
24
+ idSchema: xmlIdSchema,
25
+ valueSchema: xmlValueSchema,
26
+ createRoot: async (treeNodeApi) => {
37
27
  const source = await readFile(input, 'utf8');
38
- return parseXmlDocument(source);
28
+ return parseXmlDocument(treeNodeApi, source);
39
29
  },
40
- loadChildren: async (path) => {
30
+ loadChildren: async (treeNodeApi, path) => {
41
31
  // TODO Later: load from the file
42
32
  throw new Error('Cannot load XML branches: parsed XML documents have no unloaded branches.');
43
33
  },
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.1",
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.3",
24
- "dirvi-lib": "0.11.0-beta.3",
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
  },