@mak-98/dirvi-app 0.11.0-beta.4 → 0.11.0-beta.6
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/application/create-app-api.js +2 -2
- package/dist/application/init-runtime.d.ts +11 -3
- package/dist/application/init-runtime.d.ts.map +1 -1
- package/dist/application/init-runtime.js +53 -53
- package/dist/application/package-loader.d.ts +2 -2
- package/dist/application/package-loader.d.ts.map +1 -1
- package/dist/domain/ex-command.d.ts +5 -2
- package/dist/domain/ex-command.d.ts.map +1 -1
- package/dist/domain/initialization.d.ts +6 -3
- package/dist/domain/initialization.d.ts.map +1 -1
- package/dist/domain/public-init-api.d.ts +12 -7
- package/dist/domain/public-init-api.d.ts.map +1 -1
- package/dist/domain/shell-api.d.ts +1 -1
- package/dist/domain/shell-api.d.ts.map +1 -1
- package/dist/ui/App.d.ts +5 -3
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +39 -11
- package/dist/ui/AppSetup.d.ts +1 -1
- package/dist/ui/AppSetup.d.ts.map +1 -1
- package/dist/ui/AppSetup.js +3 -45
- package/dist/ui/Shell.d.ts.map +1 -1
- package/dist/ui/Shell.js +9 -10
- package/package.json +3 -3
|
@@ -21,8 +21,8 @@ export function createAppApi(appDefinition) {
|
|
|
21
21
|
return {
|
|
22
22
|
name: appDefinition.displayName,
|
|
23
23
|
rootId: appDefinition.rootId,
|
|
24
|
-
createRoot: appDefinition.createRoot,
|
|
25
|
-
loadBranches: appDefinition.loadChildren,
|
|
24
|
+
createRoot: () => appDefinition.createRoot(treeNodeApi),
|
|
25
|
+
loadBranches: (path) => appDefinition.loadChildren(treeNodeApi, path),
|
|
26
26
|
subscribeToResync: appDefinition.subscribeToResync,
|
|
27
27
|
treeNodeApi,
|
|
28
28
|
foldsApi,
|
|
@@ -11,10 +11,18 @@ export type InitRuntime = {
|
|
|
11
11
|
readonly finish: () => Initialization;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* Creates
|
|
14
|
+
* Creates an isolated startup configuration session.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* The returned API is exposed to `init.mjs` while the script is evaluated.
|
|
17
|
+
* Registration calls validate their runtime inputs, and option updates validate
|
|
18
|
+
* the merged configuration. The session keeps its mutable state private.
|
|
19
|
+
*
|
|
20
|
+
* Call `finish()` after evaluating `init.mjs` to seal the session and obtain
|
|
21
|
+
* the validated initialization. A successful call can happen only once; later
|
|
22
|
+
* API calls and calls to `finish()` throw an error.
|
|
23
|
+
*
|
|
24
|
+
* @returns A fresh initialization runtime with a public registration API and
|
|
25
|
+
* a function for sealing the session.
|
|
18
26
|
*/
|
|
19
27
|
export declare function createInitRuntime(): InitRuntime;
|
|
20
28
|
//# sourceMappingURL=init-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-runtime.d.ts","sourceRoot":"","sources":["../../src/application/init-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,cAAc,CAAC;CACvC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"init-runtime.d.ts","sourceRoot":"","sources":["../../src/application/init-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,cAAc,CAAC;CACvC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CA+G/C"}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
1
|
import { ConfigSchema, defaultConfig, merge } from '../domain/config.js';
|
|
2
|
+
import { AppPackageReference } from '../domain/app-pack-ref.js';
|
|
2
3
|
/**
|
|
3
|
-
* Creates
|
|
4
|
+
* Creates an isolated startup configuration session.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* The returned API is exposed to `init.mjs` while the script is evaluated.
|
|
7
|
+
* Registration calls validate their runtime inputs, and option updates validate
|
|
8
|
+
* the merged configuration. The session keeps its mutable state private.
|
|
9
|
+
*
|
|
10
|
+
* Call `finish()` after evaluating `init.mjs` to seal the session and obtain
|
|
11
|
+
* the validated initialization. A successful call can happen only once; later
|
|
12
|
+
* API calls and calls to `finish()` throw an error.
|
|
13
|
+
*
|
|
14
|
+
* @returns A fresh initialization runtime with a public registration API and
|
|
15
|
+
* a function for sealing the session.
|
|
7
16
|
*/
|
|
8
17
|
export function createInitRuntime() {
|
|
9
18
|
let config = defaultConfig;
|
|
10
19
|
let initialAppId;
|
|
11
|
-
const
|
|
20
|
+
const registeredApps = new Map();
|
|
12
21
|
const exCommands = new Map();
|
|
13
22
|
let finished = false;
|
|
23
|
+
const checkFinished = () => {
|
|
24
|
+
if (finished) {
|
|
25
|
+
throw new Error('Initialization has finished. Make all initializations while init.mjs is evaluated.');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const checkNonEmptyString = (value, label) => {
|
|
29
|
+
if (typeof value !== 'string') {
|
|
30
|
+
throw new Error(`${label} must be a string.`);
|
|
31
|
+
}
|
|
32
|
+
if (value.trim().length === 0) {
|
|
33
|
+
throw new Error(`${label} must not be empty.`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
14
36
|
return {
|
|
15
37
|
api: {
|
|
16
38
|
options: {
|
|
17
39
|
set: (patch) => {
|
|
18
|
-
|
|
19
|
-
// after the host has finished evaluating and consuming it.
|
|
20
|
-
if (finished) {
|
|
21
|
-
throw new Error('Initialization has finished. Configure dirvi while init.mjs is being evaluated.');
|
|
22
|
-
}
|
|
40
|
+
checkFinished();
|
|
23
41
|
// Validate the complete result, not merely the patch. This preserves
|
|
24
42
|
// domain invariants even when a patch changes nested configuration.
|
|
25
43
|
config = ConfigSchema.parse(merge(config, patch));
|
|
26
44
|
},
|
|
27
45
|
},
|
|
28
|
-
|
|
46
|
+
app: {
|
|
29
47
|
register: (id, appReference) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (id.trim().length === 0) {
|
|
35
|
-
throw new Error('App ID must not be empty.');
|
|
36
|
-
}
|
|
37
|
-
if (apps.has(id)) {
|
|
48
|
+
checkFinished();
|
|
49
|
+
checkNonEmptyString(id, 'App ID');
|
|
50
|
+
if (registeredApps.has(id)) {
|
|
38
51
|
throw new Error(`An app with ID "${id}" was registered multiple times.`);
|
|
39
52
|
}
|
|
40
|
-
|
|
53
|
+
registeredApps.set(id, AppPackageReference.parse(appReference));
|
|
41
54
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'init.mjs is being evaluated.');
|
|
46
|
-
}
|
|
47
|
-
if (appId.trim().length === 0) {
|
|
48
|
-
throw new Error('App ID must not be empty.');
|
|
49
|
-
}
|
|
55
|
+
initial: (appId) => {
|
|
56
|
+
checkFinished();
|
|
57
|
+
checkNonEmptyString(appId, 'App ID');
|
|
50
58
|
initialAppId = appId;
|
|
51
59
|
},
|
|
52
60
|
},
|
|
53
61
|
ex: {
|
|
54
62
|
register: (name, execute) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (name.trim().length === 0) {
|
|
60
|
-
throw new Error('Ex command name must not be empty.');
|
|
63
|
+
checkFinished();
|
|
64
|
+
checkNonEmptyString(name, 'Ex command name');
|
|
65
|
+
if (typeof execute !== 'function') {
|
|
66
|
+
throw new Error('Ex command handler must be a function.');
|
|
61
67
|
}
|
|
62
68
|
if (exCommands.has(name)) {
|
|
63
69
|
throw new Error(`An Ex command named "${name}" was registered multiple times.`);
|
|
64
70
|
}
|
|
65
|
-
exCommands.set(name, {
|
|
66
|
-
name,
|
|
67
|
-
execute,
|
|
68
|
-
});
|
|
71
|
+
exCommands.set(name, { name, execute });
|
|
69
72
|
},
|
|
70
73
|
},
|
|
71
74
|
},
|
|
72
75
|
finish: () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
if (apps.size === 0) {
|
|
76
|
+
checkFinished();
|
|
77
|
+
if (registeredApps.size === 0) {
|
|
77
78
|
throw new Error('Initialization did not register any apps. Call ' +
|
|
78
79
|
'dirvi.apps.register(id, appReference) at least once in init.mjs.');
|
|
79
80
|
}
|
|
81
|
+
let initial;
|
|
80
82
|
if (initialAppId !== undefined) {
|
|
81
|
-
if (!
|
|
83
|
+
if (!registeredApps.has(initialAppId)) {
|
|
82
84
|
throw new Error(`Startup app "${initialAppId}" has not been registered.`);
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
registeredApps: new Map(apps),
|
|
89
|
-
exCommands: [...exCommands.values()],
|
|
90
|
-
};
|
|
86
|
+
initial = initialAppId;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
initial = getLastRegisteredAppId(registeredApps);
|
|
91
90
|
}
|
|
92
|
-
const lastRegisteredAppRef = getLastRegisteredAppId(apps);
|
|
93
91
|
finished = true;
|
|
94
92
|
return {
|
|
95
93
|
config,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
app: {
|
|
95
|
+
initial,
|
|
96
|
+
registered: new Map(registeredApps),
|
|
97
|
+
},
|
|
98
|
+
exCommands: new Map(exCommands),
|
|
99
99
|
};
|
|
100
100
|
},
|
|
101
101
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AppPackageReference } from '../domain/app-pack-ref.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppPlugin } from 'dirvi-apis';
|
|
3
3
|
/**
|
|
4
4
|
* In the future will be expanded to load other plugins too.
|
|
5
5
|
*/
|
|
6
6
|
export type PackageLoader = {
|
|
7
|
-
loadAppPlugin: (reference: AppPackageReference) => Promise<
|
|
7
|
+
loadAppPlugin: (reference: AppPackageReference) => Promise<AppPlugin>;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=package-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-loader.d.ts","sourceRoot":"","sources":["../../src/application/package-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"package-loader.d.ts","sourceRoot":"","sources":["../../src/application/package-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CACvE,CAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ShellApi } from './shell-api.js';
|
|
2
|
+
export type DirviApi = {
|
|
3
|
+
shell: ShellApi;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
6
|
* A command registered by init.mjs and invoked through Ex mode.
|
|
4
7
|
*
|
|
5
|
-
* The command receives the live
|
|
8
|
+
* The command receives the live Api only when it is executed. This keeps
|
|
6
9
|
* initialization separate from the running application lifecycle.
|
|
7
10
|
*/
|
|
8
11
|
export type ExCommand = {
|
|
9
12
|
readonly name: string;
|
|
10
|
-
readonly execute: (
|
|
13
|
+
readonly execute: (api: DirviApi) => void | Promise<void>;
|
|
11
14
|
};
|
|
12
15
|
//# sourceMappingURL=ex-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ex-command.d.ts","sourceRoot":"","sources":["../../src/domain/ex-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ex-command.d.ts","sourceRoot":"","sources":["../../src/domain/ex-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAA;AAGD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Config } from './config.js';
|
|
2
2
|
import { ExCommand } from './ex-command.js';
|
|
3
3
|
import { AppPackageReference } from './app-pack-ref.js';
|
|
4
|
+
export type AppInput = string | undefined;
|
|
4
5
|
/**
|
|
5
6
|
* Object set through initialization, i.e. evaluating init.mjs.
|
|
6
7
|
*
|
|
@@ -13,8 +14,10 @@ import { AppPackageReference } from './app-pack-ref.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export type Initialization = {
|
|
15
16
|
readonly config: Readonly<Config>;
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
readonly app: {
|
|
18
|
+
initial: string;
|
|
19
|
+
registered: ReadonlyMap<string, AppPackageReference>;
|
|
20
|
+
};
|
|
21
|
+
readonly exCommands: ReadonlyMap<string, ExCommand>;
|
|
19
22
|
};
|
|
20
23
|
//# sourceMappingURL=initialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../src/domain/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../src/domain/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;KACtD,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACrD,CAAC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { AppPackageReference } from './app-pack-ref.js';
|
|
2
2
|
import { ConfigPatch } from './config.js';
|
|
3
|
-
import {
|
|
3
|
+
import { DirviApi } from './ex-command.js';
|
|
4
4
|
/**
|
|
5
|
-
* The startup configuration API exposed to init.mjs as the global `dirvi`.
|
|
5
|
+
* The startup configuration API exposed to `init.mjs` as the global `dirvi`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* These types describe the intended API for TypeScript consumers and provide
|
|
8
|
+
* editor guidance and compile-time checking. They do not validate values at
|
|
9
|
+
* runtime: `init.mjs` may be plain JavaScript and can pass values that do not
|
|
10
|
+
* match these types. The runtime must validate inputs at the scripting
|
|
11
|
+
* boundary before relying on them.
|
|
12
|
+
*
|
|
13
|
+
* This is intentionally a narrow facade; it is the public scripting boundary.
|
|
9
14
|
*/
|
|
10
15
|
export type PublicInitApi = {
|
|
11
16
|
readonly options: {
|
|
12
17
|
set: (patch: ConfigPatch) => void;
|
|
13
18
|
};
|
|
14
|
-
readonly
|
|
19
|
+
readonly app: {
|
|
15
20
|
/**
|
|
16
21
|
* Optionally selects the app initially opened by the shell.
|
|
17
22
|
*
|
|
18
23
|
* If omitted, the runtime falls back to the most recently registered app.
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
initial: (appId: string) => void;
|
|
21
26
|
/**
|
|
22
27
|
* Registers an application made available by init.mjs.
|
|
23
28
|
*/
|
|
@@ -36,7 +41,7 @@ export type PublicInitApi = {
|
|
|
36
41
|
* });
|
|
37
42
|
* ```
|
|
38
43
|
*/
|
|
39
|
-
register: (name: string, execute: (
|
|
44
|
+
register: (name: string, execute: (api: DirviApi) => void | Promise<void>) => void;
|
|
40
45
|
};
|
|
41
46
|
};
|
|
42
47
|
//# sourceMappingURL=public-init-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-init-api.d.ts","sourceRoot":"","sources":["../../src/domain/public-init-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"public-init-api.d.ts","sourceRoot":"","sources":["../../src/domain/public-init-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE;QAChB,GAAG,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;KACnC,CAAC;IAEF,QAAQ,CAAC,GAAG,EAAE;QACZ;;;;WAIG;QACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC;;WAEG;QACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;KACnE,CAAC;IAEF,QAAQ,CAAC,EAAE,EAAE;QACX;;;;;;;;;;;WAWG;QACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAC7C,IAAI,CAAC;KACX,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-api.d.ts","sourceRoot":"","sources":["../../src/domain/shell-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"shell-api.d.ts","sourceRoot":"","sources":["../../src/domain/shell-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE,CAAC"}
|
package/dist/ui/App.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AppApi, EffectToAction, IntentToEffect, Reducer, SerializableKey, State } from 'dirvi-lib';
|
|
2
|
-
import type { Config } from '../domain/config.js';
|
|
3
2
|
import type { AppScreenRenderer } from './app-screen-renderer.js';
|
|
3
|
+
import { ShellApi } from '../domain/shell-api.js';
|
|
4
|
+
import { Initialization } from '../domain/initialization.js';
|
|
4
5
|
type AppProps<Id extends SerializableKey, Value, ViewKey = string> = {
|
|
5
6
|
screenRenderer: AppScreenRenderer;
|
|
7
|
+
shellApi: ShellApi;
|
|
6
8
|
appApi: AppApi<Id, Value, ViewKey>;
|
|
7
|
-
|
|
9
|
+
initialization: Initialization;
|
|
8
10
|
initialState: State<Id, Value>;
|
|
9
11
|
reducer: Reducer<Id, Value>;
|
|
10
12
|
intentToEffect: IntentToEffect<Id, Value>;
|
|
@@ -13,6 +15,6 @@ type AppProps<Id extends SerializableKey, Value, ViewKey = string> = {
|
|
|
13
15
|
clipboard?: (value: string) => void;
|
|
14
16
|
onError?: (error: Error) => void;
|
|
15
17
|
};
|
|
16
|
-
export declare function App<Id extends SerializableKey, Value, ViewKey = string>({ screenRenderer, appApi,
|
|
18
|
+
export declare function App<Id extends SerializableKey, Value, ViewKey = string>({ screenRenderer, shellApi, appApi, initialization, initialState, reducer, intentToEffect, effectToAction, stdout, clipboard, onError, }: AppProps<Id, Value, ViewKey>): import("react").JSX.Element;
|
|
17
19
|
export {};
|
|
18
20
|
//# sourceMappingURL=App.d.ts.map
|
package/dist/ui/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/ui/App.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,MAAM,EAEN,cAAc,EAEd,cAAc,EAEd,OAAO,EACP,eAAe,EACf,KAAK,EAGN,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/ui/App.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,MAAM,EAEN,cAAc,EAEd,cAAc,EAEd,OAAO,EACP,eAAe,EACf,KAAK,EAGN,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,KAAK,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI;IACnE,cAAc,EAAE,iBAAiB,CAAC;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,cAAc,EAAE,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,EACvE,cAAc,EACd,QAAQ,EACR,MAAM,EACN,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,cAAc,EACd,MAAM,EACN,SAAS,EACT,OAAO,GACR,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,+BAgW9B"}
|
package/dist/ui/App.js
CHANGED
|
@@ -2,10 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useEffect, useMemo, useReducer, useRef, useState, } from 'react';
|
|
3
3
|
import { createFeedbackApi, userInputToIntent } from 'dirvi-lib';
|
|
4
4
|
import { useView } from './hooks/useView.js';
|
|
5
|
-
function
|
|
6
|
-
return error instanceof Error ? error : new Error(String(error));
|
|
7
|
-
}
|
|
8
|
-
export function App({ screenRenderer, appApi, config, initialState, reducer, intentToEffect, effectToAction, stdout, clipboard, onError, }) {
|
|
5
|
+
export function App({ screenRenderer, shellApi, appApi, initialization, initialState, reducer, intentToEffect, effectToAction, stdout, clipboard, onError, }) {
|
|
9
6
|
const ScreenRenderer = screenRenderer;
|
|
10
7
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
11
8
|
const stateRef = useRef(state); // Gives `subscribeToResync` callback a way to
|
|
@@ -72,6 +69,40 @@ export function App({ screenRenderer, appApi, config, initialState, reducer, int
|
|
|
72
69
|
return;
|
|
73
70
|
}
|
|
74
71
|
switch (effect.effectType) {
|
|
72
|
+
case 'userExCommand': {
|
|
73
|
+
setInputState({
|
|
74
|
+
inputMode: 'normal',
|
|
75
|
+
normalBuffer: '',
|
|
76
|
+
});
|
|
77
|
+
const command = initialization.exCommands.get(effect.name);
|
|
78
|
+
if (command === undefined) {
|
|
79
|
+
feedbackApi.addMessage(`Command is no longer registered: ${effect.name}`, 'error');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
void Promise.resolve()
|
|
83
|
+
.then(() => command.execute({ shell: shellApi })) // TODO: Add args
|
|
84
|
+
.catch((error) => {
|
|
85
|
+
const appError = error instanceof Error ? error : new Error(String(error));
|
|
86
|
+
feedbackApi.addMessage(`Command "${effect.name}" failed: ${appError.message}`, 'error');
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
case 'quit':
|
|
91
|
+
setExitStatus(effect.exitMessage);
|
|
92
|
+
return;
|
|
93
|
+
case 'listApps': {
|
|
94
|
+
const appIds = [...initialization.app.registered.keys()];
|
|
95
|
+
const lines = appIds.map((id) => `${id}`);
|
|
96
|
+
setInputState({
|
|
97
|
+
inputMode: 'normal',
|
|
98
|
+
normalBuffer: '',
|
|
99
|
+
});
|
|
100
|
+
feedbackApi.addMessage(['Apps:', ...lines].join('\n'));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
case 'switchApp':
|
|
104
|
+
void shellApi.openApp(effect.appId, effect.input);
|
|
105
|
+
return;
|
|
75
106
|
case 'dispatchEffectAction':
|
|
76
107
|
const effectActionResult = effectToAction(effect.action, navEntry, state);
|
|
77
108
|
// A completed normal-mode command or submitted Ex command always
|
|
@@ -195,14 +226,11 @@ export function App({ screenRenderer, appApi, config, initialState, reducer, int
|
|
|
195
226
|
feedbackApi.addMessage(['Fold trees:', ...lines].join('\n'));
|
|
196
227
|
return;
|
|
197
228
|
}
|
|
198
|
-
case '
|
|
199
|
-
feedbackApi.addMessage(
|
|
200
|
-
return;
|
|
201
|
-
case 'quit':
|
|
202
|
-
setExitStatus(effect.exitMessage);
|
|
229
|
+
case 'emitError':
|
|
230
|
+
feedbackApi.addMessage(effect.message, 'error');
|
|
203
231
|
return;
|
|
204
232
|
}
|
|
205
|
-
}, [appApi, effectToAction, feedbackApi, navEntry,
|
|
233
|
+
}, [appApi, effectToAction, feedbackApi, navEntry, state, stdout, initialization.app.registered, shellApi]);
|
|
206
234
|
// ===========================================================================
|
|
207
235
|
// Input hook
|
|
208
236
|
// ===========================================================================
|
|
@@ -221,5 +249,5 @@ export function App({ screenRenderer, appApi, config, initialState, reducer, int
|
|
|
221
249
|
// ===========================================================================
|
|
222
250
|
// Render
|
|
223
251
|
// ===========================================================================
|
|
224
|
-
return (_jsx(ScreenRenderer, { view: view, feedback: feedback, feedbackApi: feedbackApi, config: config, inputState: inputState, handleInput: handleInput, onRowsChange: handleRowsChange, exitStatus: exitStatus }));
|
|
252
|
+
return (_jsx(ScreenRenderer, { view: view, feedback: feedback, feedbackApi: feedbackApi, config: initialization.config, inputState: inputState, handleInput: handleInput, onRowsChange: handleRowsChange, exitStatus: exitStatus }));
|
|
225
253
|
}
|
package/dist/ui/AppSetup.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ type LoadingAppProps<Id extends SerializableKey, Value, ViewKey = string> = {
|
|
|
12
12
|
stdout?: (message: string) => void;
|
|
13
13
|
clipboard?: (value: string) => void;
|
|
14
14
|
};
|
|
15
|
-
export declare function AppSetup<Id extends SerializableKey, Value, ViewKey = string>({ appScreenRenderer, loadingScreenRenderer,
|
|
15
|
+
export declare function AppSetup<Id extends SerializableKey, Value, ViewKey = string>({ appScreenRenderer, loadingScreenRenderer, initialization, shellApi, appApi, stdout, clipboard, }: LoadingAppProps<Id, Value, ViewKey>): import("react").JSX.Element;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=AppSetup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSetup.d.ts","sourceRoot":"","sources":["../../src/ui/AppSetup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAS,MAAM,WAAW,CAAC;AAOhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"AppSetup.d.ts","sourceRoot":"","sources":["../../src/ui/AppSetup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAS,MAAM,WAAW,CAAC;AAOhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,KAAK,eAAe,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI;IAC1E,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,EAC5E,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,GACV,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,+BAuFrC"}
|
package/dist/ui/AppSetup.js
CHANGED
|
@@ -2,50 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { createEffectToAction, createIntentToEffect, createReducer, } from 'dirvi-lib';
|
|
4
4
|
import { App } from './App.js';
|
|
5
|
-
export function AppSetup({ appScreenRenderer, loadingScreenRenderer,
|
|
5
|
+
export function AppSetup({ appScreenRenderer, loadingScreenRenderer, initialization, shellApi, appApi, stdout, clipboard, }) {
|
|
6
6
|
const [initialState, setInitialState] = useState();
|
|
7
|
-
const [config, setConfig] = useState(initialization.config);
|
|
8
|
-
// Load the initial configuration and keep it synchronized with changes made
|
|
9
|
-
// by another process or another running dirvi instance.
|
|
10
|
-
// useEffect(() => {
|
|
11
|
-
// let mounted = true;
|
|
12
|
-
// let latestLoad = 0;
|
|
13
|
-
//
|
|
14
|
-
// const loadConfig = (): void => {
|
|
15
|
-
// const loadNumber = ++latestLoad;
|
|
16
|
-
//
|
|
17
|
-
// void configApi
|
|
18
|
-
// .load()
|
|
19
|
-
// .then((nextConfig) => {
|
|
20
|
-
// // Ignore a stale read if a newer config read has begun meanwhile.
|
|
21
|
-
// if (!mounted || loadNumber !== latestLoad) {
|
|
22
|
-
// return;
|
|
23
|
-
// }
|
|
24
|
-
//
|
|
25
|
-
// setConfig(nextConfig);
|
|
26
|
-
// })
|
|
27
|
-
// .catch((cause: unknown) => {
|
|
28
|
-
// if (!mounted || loadNumber !== latestLoad) {
|
|
29
|
-
// return;
|
|
30
|
-
// }
|
|
31
|
-
//
|
|
32
|
-
// const nextError =
|
|
33
|
-
// cause instanceof Error ? cause : new Error(String(cause));
|
|
34
|
-
//
|
|
35
|
-
// setError(nextError);
|
|
36
|
-
// onError?.(nextError);
|
|
37
|
-
// });
|
|
38
|
-
// };
|
|
39
|
-
//
|
|
40
|
-
// // Subscribe before the first load so a change during startup is not missed.
|
|
41
|
-
// const unsubscribe = configApi.subscribeToResync(loadConfig);
|
|
42
|
-
// loadConfig();
|
|
43
|
-
//
|
|
44
|
-
// return () => {
|
|
45
|
-
// mounted = false;
|
|
46
|
-
// unsubscribe();
|
|
47
|
-
// };
|
|
48
|
-
// }, [configApi, onError]);
|
|
49
7
|
// Loading and setting initial state.
|
|
50
8
|
useEffect(() => {
|
|
51
9
|
let mounted = true;
|
|
@@ -77,12 +35,12 @@ export function AppSetup({ appScreenRenderer, loadingScreenRenderer, appApi, ini
|
|
|
77
35
|
}, [appApi]);
|
|
78
36
|
// --- Pure function deps ---
|
|
79
37
|
const reducer = useMemo(() => createReducer(appApi.treeNodeApi, appApi.foldsApi), [appApi.treeNodeApi, appApi.foldsApi]);
|
|
80
|
-
const intentToEffect = useMemo(() => createIntentToEffect(appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi), [appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi]);
|
|
38
|
+
const intentToEffect = useMemo(() => createIntentToEffect(new Set(initialization.exCommands.keys()), appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi), [appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi, initialization.exCommands]);
|
|
81
39
|
const effectToAction = useMemo(() => createEffectToAction(appApi.foldsApi, appApi.cursorApi, appApi.navNodeApi), [appApi.navNodeApi, appApi.cursorApi, appApi.foldsApi]);
|
|
82
40
|
// --- JSX ---
|
|
83
41
|
const LoadingScreenRenderer = loadingScreenRenderer;
|
|
84
42
|
if (initialState === undefined) {
|
|
85
43
|
return _jsx(LoadingScreenRenderer, {});
|
|
86
44
|
}
|
|
87
|
-
return (_jsx(App, { screenRenderer: appScreenRenderer, appApi: appApi,
|
|
45
|
+
return (_jsx(App, { screenRenderer: appScreenRenderer, shellApi: shellApi, appApi: appApi, initialization: initialization, initialState: initialState, reducer: reducer, intentToEffect: intentToEffect, effectToAction: effectToAction, ...(stdout === undefined ? {} : { stdout }), ...(clipboard === undefined ? {} : { clipboard }) }));
|
|
88
46
|
}
|
package/dist/ui/Shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shell.d.ts","sourceRoot":"","sources":["../../src/ui/Shell.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAItE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE9C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEtC,iDAAiD;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,MAAM,EACN,SAAS,GACV,EAAE,aAAa,+
|
|
1
|
+
{"version":3,"file":"Shell.d.ts","sourceRoot":"","sources":["../../src/ui/Shell.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAItE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE9C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEtC,iDAAiD;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,MAAM,EACN,SAAS,GACV,EAAE,aAAa,+BAoEf"}
|
package/dist/ui/Shell.js
CHANGED
|
@@ -13,38 +13,37 @@ import { createAppApiApplicator } from '../application/create-app-api.js';
|
|
|
13
13
|
* AppSetup receives the concrete AppApi and mounts the app-specific tree UI.
|
|
14
14
|
*/
|
|
15
15
|
export function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppOptions, initialization, packageLoader, stdout, clipboard, }) {
|
|
16
|
-
const initialAppReference = initialization.registeredApps.get(initialization.initialAppId);
|
|
17
|
-
if (initialAppReference === undefined) {
|
|
18
|
-
throw new Error(`Startup app "${initialization.initialAppId}" has not been registered.`);
|
|
19
|
-
}
|
|
20
16
|
const [appApiApplicator, setAppApiApplicator] = useState(undefined);
|
|
21
17
|
const [appError, setAppError] = useState(undefined);
|
|
22
18
|
const shellApi = useMemo(() => {
|
|
23
19
|
return {
|
|
24
20
|
openApp: async (appId, input) => {
|
|
25
|
-
const appReference = initialization.
|
|
21
|
+
const appReference = initialization.app.registered.get(appId);
|
|
26
22
|
if (appReference === undefined) {
|
|
27
23
|
throw new Error(`App "${appId}" has not been registered.`);
|
|
28
24
|
}
|
|
29
25
|
setAppApiApplicator(undefined);
|
|
30
26
|
setAppError(undefined);
|
|
31
27
|
const appPlugin = await packageLoader.loadAppPlugin(appReference);
|
|
32
|
-
const
|
|
33
|
-
const loadedAppApiApplicator = createAppApiApplicator(appDefinitionApplicator);
|
|
28
|
+
const loadedAppApiApplicator = createAppApiApplicator(appPlugin.createAppDefinitionApplicator(input));
|
|
34
29
|
setAppApiApplicator(() => loadedAppApiApplicator);
|
|
35
30
|
},
|
|
36
31
|
};
|
|
37
|
-
}, [initialization.
|
|
32
|
+
}, [packageLoader, initialization.app.registered]);
|
|
38
33
|
useEffect(() => {
|
|
39
34
|
void shellApi
|
|
40
|
-
.openApp(initialization.
|
|
35
|
+
.openApp(initialAppOptions.app ?? initialization.app.initial, initialAppOptions.input)
|
|
41
36
|
.catch((error) => {
|
|
42
37
|
setAppError(error instanceof Error ? error : new Error(String(error)));
|
|
43
38
|
});
|
|
44
|
-
}, [initialAppOptions.input, initialization.
|
|
39
|
+
}, [initialAppOptions.input, initialization.app.initial, shellApi]);
|
|
45
40
|
if (appError !== undefined) {
|
|
46
41
|
throw appError;
|
|
47
42
|
}
|
|
43
|
+
const initialAppReference = initialization.app.registered.get(initialization.app.initial);
|
|
44
|
+
if (initialAppReference === undefined) {
|
|
45
|
+
throw new Error(`Startup app "${initialization.app.initial}" has not been registered.`);
|
|
46
|
+
}
|
|
48
47
|
if (appApiApplicator === undefined) {
|
|
49
48
|
const LoadingScreenRenderer = loadingScreenRenderer;
|
|
50
49
|
return _jsx(LoadingScreenRenderer, {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mak-98/dirvi-app",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.6",
|
|
4
4
|
"description": "Shared React application logic for dirvi hosts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"dirvi-apis": "0.11.0-beta.
|
|
20
|
-
"dirvi-lib": "0.11.0-beta.
|
|
19
|
+
"dirvi-apis": "0.11.0-beta.6",
|
|
20
|
+
"dirvi-lib": "0.11.0-beta.6",
|
|
21
21
|
"zod": "^4.4.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|