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

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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { xmlAppPlugin as default } from './xml-dirvi-app.js';
2
- export { xmlAppPlugin } from './xml-dirvi-app.js';
1
+ export { xmlApp as default } from './xml-dirvi-app.js';
2
+ export { xmlApp } 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,YAAY,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { xmlAppPlugin as default } from './xml-dirvi-app.js';
2
- export { xmlAppPlugin } from './xml-dirvi-app.js';
1
+ export { xmlApp as default } from './xml-dirvi-app.js';
2
+ export { xmlApp } from './xml-dirvi-app.js';
@@ -1,3 +1,3 @@
1
- import type { AppPlugin } from 'dirvi-apis';
2
- export declare const xmlAppPlugin: AppPlugin;
1
+ import type { CreateAppDefinitionApplicator } from 'dirvi-apis';
2
+ export declare const xmlApp: CreateAppDefinitionApplicator;
3
3
  //# 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":"AAGA,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,YAAY,CAAC;AAQrE,eAAO,MAAM,YAAY,EAAE,SA8D1B,CAAC"}
1
+ {"version":3,"file":"xml-dirvi-app.d.ts","sourceRoot":"","sources":["../src/xml-dirvi-app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,6BAA6B,EAC9B,MAAM,YAAY,CAAC;AAQpB,eAAO,MAAM,MAAM,EAAE,6BA8DpB,CAAC"}
@@ -3,53 +3,53 @@ import { resolve } from 'node:path';
3
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
- export const xmlAppPlugin = {
7
- createAppDefinitionApplicator: (input) => {
8
- if (input === undefined) {
9
- throw new Error('xml-dirvi-app: No file path to XML file given.');
6
+ export const xmlApp = (input) => {
7
+ if (input === undefined) {
8
+ throw new Error('xml-dirvi-app: No file path to XML file given.');
9
+ }
10
+ const xmlAbsolutePath = resolve(input);
11
+ // TODO: Make the `xmldom` nodes the IDs.
12
+ // Create dom async on first need, cache afterward
13
+ let dom;
14
+ let domPromise;
15
+ const getDom = async () => {
16
+ if (dom !== undefined) {
17
+ return dom;
10
18
  }
11
- const xmlAbsolutePath = resolve(input);
12
- // TODO: Make the `xmldom` nodes the IDs.
13
- // Create dom async on first need, cache afterward
14
- let dom;
15
- let domPromise;
16
- const getDom = async () => {
17
- if (dom !== undefined) {
19
+ if (domPromise === undefined) {
20
+ domPromise = readFile(xmlAbsolutePath, 'utf8')
21
+ .then((source) => {
22
+ dom = createXmlDom(source);
18
23
  return dom;
19
- }
20
- if (domPromise === undefined) {
21
- domPromise = readFile(xmlAbsolutePath, 'utf8')
22
- .then((source) => {
23
- dom = createXmlDom(source);
24
- return dom;
25
- })
26
- .finally(() => {
27
- domPromise = undefined;
28
- });
29
- }
30
- return domPromise;
31
- };
32
- const appDefinition = {
33
- semanticOrder: true,
34
- valueSchema: xmlValueSchema,
35
- loadChildren: async (path) => {
36
- const dom = await getDom();
37
- return dom.getChildren(path.at(-1)).map(({ id, value }) => ({
38
- id,
39
- kind: value.kind === 'element' ? 'unloaded-branch' : 'leaf',
40
- value,
41
- }));
42
- },
43
- loadRoot: async () => {
44
- const dom = await getDom();
45
- return dom.getDocument();
46
- },
47
- presentNode: (_id, value, isBranch) => ({
24
+ })
25
+ .finally(() => {
26
+ domPromise = undefined;
27
+ });
28
+ }
29
+ return domPromise;
30
+ };
31
+ const appDefinition = {
32
+ semanticOrder: true,
33
+ valueSchema: xmlValueSchema,
34
+ loadChildren: async (path) => {
35
+ const dom = await getDom();
36
+ return dom.getChildren(path.at(-1)).map(({ id, value }) => ({
37
+ id,
38
+ kind: value.kind === 'element' ? 'unloaded-branch' : 'leaf',
39
+ value,
40
+ }));
41
+ },
42
+ loadRoot: async () => {
43
+ const dom = await getDom();
44
+ return dom.getDocument();
45
+ },
46
+ presentNode: (_id, value, isBranch) => [
47
+ {
48
48
  content: value.kind,
49
49
  highlight: isBranch ? 'branch' : 'leaf',
50
- }),
51
- subscribeToResync: createXmlFileResyncSubscription(xmlAbsolutePath),
52
- };
53
- return (appDefinitionConsumer) => appDefinitionConsumer(appDefinition);
54
- },
50
+ },
51
+ ],
52
+ subscribeToResync: createXmlFileResyncSubscription(xmlAbsolutePath),
53
+ };
54
+ return (appDefinitionConsumer) => appDefinitionConsumer(appDefinition);
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mak-98/xml-dirvi-app",
3
- "version": "0.11.0-beta.17",
3
+ "version": "0.11.0-beta.19",
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.17",
24
+ "dirvi-apis": "0.11.0-beta.18",
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.17",
30
+ "dirvi-lib": "0.11.0-beta.18",
31
31
  "typescript": "^5.0.0"
32
32
  },
33
33
  "scripts": {