@mak-98/dirvi-app 0.11.0-beta.2 → 0.11.0-beta.3
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.d.ts +11 -0
- package/dist/application/create-app-api.d.ts.map +1 -0
- package/dist/application/create-app-api.js +33 -0
- package/dist/application/package-loader.d.ts +2 -2
- package/dist/application/package-loader.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/ui/Shell.d.ts +15 -3
- package/dist/ui/Shell.d.ts.map +1 -1
- package/dist/ui/Shell.js +8 -6
- package/package.json +3 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SerializableKey, type AppApi } from 'dirvi-lib';
|
|
2
|
+
import type { AppApiApplicator, AppDefinition, AppDefinitionApplicator } from 'dirvi-apis';
|
|
3
|
+
/**
|
|
4
|
+
* Turns a plugin-owned app definition into a host-owned runtime AppApi.
|
|
5
|
+
*
|
|
6
|
+
* The plugin's concrete generic types remain hidden by the applicator
|
|
7
|
+
* boundary, while the host creates the matching AppApi specialization.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAppApiApplicator(appDefinitionApplicator: AppDefinitionApplicator): AppApiApplicator;
|
|
10
|
+
export declare function createAppApi<Id extends SerializableKey, Value>(appDefinition: AppDefinition<Id, Value>): AppApi<Id, Value>;
|
|
11
|
+
//# sourceMappingURL=create-app-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-app-api.d.ts","sourceRoot":"","sources":["../../src/application/create-app-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,MAAM,EAMZ,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,gBAAgB,EAAkB,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,uBAAuB,EAAE,uBAAuB,GAC/C,gBAAgB,CAQlB;AAED,wBAAgB,YAAY,CAC1B,EAAE,SAAS,eAAe,EAC1B,KAAK,EACL,aAAa,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAyB5D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createCursorApi, createFoldsApi, createNavNodeApi, createStateApi, createTreeNodeApi, } from 'dirvi-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Turns a plugin-owned app definition into a host-owned runtime AppApi.
|
|
4
|
+
*
|
|
5
|
+
* The plugin's concrete generic types remain hidden by the applicator
|
|
6
|
+
* boundary, while the host creates the matching AppApi specialization.
|
|
7
|
+
*/
|
|
8
|
+
export function createAppApiApplicator(appDefinitionApplicator) {
|
|
9
|
+
return appDefinitionApplicator((appDefinition) => {
|
|
10
|
+
const appApi = createAppApi(appDefinition);
|
|
11
|
+
return (appApiConsumer) => appApiConsumer(appApi);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function createAppApi(appDefinition) {
|
|
15
|
+
const treeNodeApi = createTreeNodeApi();
|
|
16
|
+
const foldTreeNodeApi = createTreeNodeApi();
|
|
17
|
+
const foldsApi = createFoldsApi(foldTreeNodeApi);
|
|
18
|
+
const cursorApi = createCursorApi();
|
|
19
|
+
const stateApi = createStateApi(treeNodeApi, cursorApi);
|
|
20
|
+
const navNodeApi = createNavNodeApi(treeNodeApi, foldsApi, cursorApi, appDefinition.createNavNodeApiOptions);
|
|
21
|
+
return {
|
|
22
|
+
name: appDefinition.displayName,
|
|
23
|
+
rootId: appDefinition.rootId,
|
|
24
|
+
createRoot: appDefinition.createRoot,
|
|
25
|
+
loadBranches: appDefinition.loadChildren,
|
|
26
|
+
subscribeToResync: appDefinition.subscribeToResync,
|
|
27
|
+
treeNodeApi,
|
|
28
|
+
foldsApi,
|
|
29
|
+
cursorApi,
|
|
30
|
+
stateApi,
|
|
31
|
+
navNodeApi,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AppPackageReference } from '../domain/app-pack-ref.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppPlugin2 } 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<AppPlugin2>;
|
|
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,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACxE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type { ShellApi } from './domain/shell-api.js';
|
|
|
7
7
|
export { AppPackageReference } from './domain/app-pack-ref.js';
|
|
8
8
|
export type { PackageLoader } from './application/package-loader.js';
|
|
9
9
|
export { createInitRuntime } from './application/init-runtime.js';
|
|
10
|
+
export { createAppApi } from './application/create-app-api.js';
|
|
10
11
|
export type { ViewRow } from './ui/view.js';
|
|
11
12
|
export { View } from './ui/view.js';
|
|
12
13
|
export { viewNameSchema } from './domain/view-name-schema.js';
|
|
@@ -14,4 +15,5 @@ export type { LoadingScreenRenderer } from './ui/loading-screen-renderer.js';
|
|
|
14
15
|
export { colorConfigToInkColor } from './ui/color-resolver.js';
|
|
15
16
|
export type { AppScreenProps, AppScreenRenderer, } from './ui/app-screen-renderer.js';
|
|
16
17
|
export { Shell } from './ui/Shell.js';
|
|
18
|
+
export type { InitialAppOptions } from './ui/Shell.js';
|
|
17
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,YAAY,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,YAAY,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,YAAY,EACV,cAAc,EACd,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AppPackageReference } from './domain/app-pack-ref.js';
|
|
2
2
|
export { createInitRuntime } from './application/init-runtime.js';
|
|
3
|
+
export { createAppApi } from './application/create-app-api.js';
|
|
3
4
|
export { View } from './ui/view.js';
|
|
4
5
|
export { viewNameSchema } from './domain/view-name-schema.js';
|
|
5
6
|
export { colorConfigToInkColor } from './ui/color-resolver.js';
|
package/dist/ui/Shell.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import type { AppInput } from '../domain/app.js';
|
|
2
1
|
import type { AppScreenRenderer } from './app-screen-renderer.js';
|
|
3
2
|
import type { LoadingScreenRenderer } from './loading-screen-renderer.js';
|
|
4
3
|
import type { Initialization } from '../domain/initialization.js';
|
|
5
4
|
import type { PackageLoader } from '../application/package-loader.js';
|
|
5
|
+
export type InitialAppOptions = Readonly<{
|
|
6
|
+
/**
|
|
7
|
+
* Requested app ID at startup.
|
|
8
|
+
*
|
|
9
|
+
* The Shell will later use this to override or select the app chosen by
|
|
10
|
+
* initialization.
|
|
11
|
+
*/
|
|
12
|
+
readonly app?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Host-provided startup input interpreted by the selected app.
|
|
15
|
+
*/
|
|
16
|
+
readonly input?: string;
|
|
17
|
+
}>;
|
|
6
18
|
/**
|
|
7
19
|
* Dependencies and output callbacks required by {@link Shell}.
|
|
8
20
|
*
|
|
@@ -15,7 +27,7 @@ export type ShellAppProps = {
|
|
|
15
27
|
*/
|
|
16
28
|
readonly loadingScreenRenderer: LoadingScreenRenderer;
|
|
17
29
|
readonly appScreenRenderer: AppScreenRenderer;
|
|
18
|
-
readonly
|
|
30
|
+
readonly initialAppOptions: InitialAppOptions;
|
|
19
31
|
readonly initialization: Initialization;
|
|
20
32
|
readonly packageLoader: PackageLoader;
|
|
21
33
|
/** Writes non-interactive application output. */
|
|
@@ -33,5 +45,5 @@ export type ShellAppProps = {
|
|
|
33
45
|
*
|
|
34
46
|
* AppSetup receives the concrete AppApi and mounts the app-specific tree UI.
|
|
35
47
|
*/
|
|
36
|
-
export declare function Shell({ loadingScreenRenderer, appScreenRenderer,
|
|
48
|
+
export declare function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppOptions, initialization, packageLoader, stdout, clipboard, }: ShellAppProps): import("react").JSX.Element;
|
|
37
49
|
//# sourceMappingURL=Shell.d.ts.map
|
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,
|
|
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,+BAsEf"}
|
package/dist/ui/Shell.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { AppSetup } from './AppSetup.js';
|
|
4
|
+
import { createAppApiApplicator } from '../application/create-app-api.js';
|
|
4
5
|
/**
|
|
5
6
|
* Hosts the currently active application inside the persistent terminal shell.
|
|
6
7
|
*
|
|
@@ -11,9 +12,9 @@ import { AppSetup } from './AppSetup.js';
|
|
|
11
12
|
*
|
|
12
13
|
* AppSetup receives the concrete AppApi and mounts the app-specific tree UI.
|
|
13
14
|
*/
|
|
14
|
-
export function Shell({ loadingScreenRenderer, appScreenRenderer,
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
15
|
+
export function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppOptions, initialization, packageLoader, stdout, clipboard, }) {
|
|
16
|
+
const initialAppReference = initialization.registeredApps.get(initialization.initialAppId);
|
|
17
|
+
if (initialAppReference === undefined) {
|
|
17
18
|
throw new Error(`Startup app "${initialization.initialAppId}" has not been registered.`);
|
|
18
19
|
}
|
|
19
20
|
const [appApiApplicator, setAppApiApplicator] = useState(undefined);
|
|
@@ -28,18 +29,19 @@ export function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppInpu
|
|
|
28
29
|
setAppApiApplicator(undefined);
|
|
29
30
|
setAppError(undefined);
|
|
30
31
|
const appPlugin = await packageLoader.loadAppPlugin(appReference);
|
|
31
|
-
const
|
|
32
|
+
const appDefinitionApplicator = appPlugin.createAppDefinitionApplicator(input);
|
|
33
|
+
const loadedAppApiApplicator = createAppApiApplicator(appDefinitionApplicator);
|
|
32
34
|
setAppApiApplicator(() => loadedAppApiApplicator);
|
|
33
35
|
},
|
|
34
36
|
};
|
|
35
37
|
}, [initialization.registeredApps, packageLoader]);
|
|
36
38
|
useEffect(() => {
|
|
37
39
|
void shellApi
|
|
38
|
-
.openApp(initialization.initialAppId,
|
|
40
|
+
.openApp(initialization.initialAppId, initialAppOptions.input)
|
|
39
41
|
.catch((error) => {
|
|
40
42
|
setAppError(error instanceof Error ? error : new Error(String(error)));
|
|
41
43
|
});
|
|
42
|
-
}, [
|
|
44
|
+
}, [initialAppOptions.input, initialization.initialAppId, shellApi]);
|
|
43
45
|
if (appError !== undefined) {
|
|
44
46
|
throw appError;
|
|
45
47
|
}
|
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.3",
|
|
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.3",
|
|
20
|
+
"dirvi-lib": "0.11.0-beta.3",
|
|
21
21
|
"zod": "^4.4.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|