@mak-98/dirvi-app 0.11.0-beta.5 → 0.11.0-beta.7

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.
Files changed (44) hide show
  1. package/dist/application/create-app-api.d.ts +1 -1
  2. package/dist/application/create-app-api.d.ts.map +1 -1
  3. package/dist/application/create-app-api.js +41 -14
  4. package/dist/application/init-runtime.d.ts +26 -6
  5. package/dist/application/init-runtime.d.ts.map +1 -1
  6. package/dist/application/init-runtime.error.d.ts +53 -0
  7. package/dist/application/init-runtime.error.d.ts.map +1 -0
  8. package/dist/application/init-runtime.error.js +77 -0
  9. package/dist/application/init-runtime.js +123 -89
  10. package/dist/domain/app-input.d.ts +2 -0
  11. package/dist/domain/app-input.d.ts.map +1 -0
  12. package/dist/domain/app-input.js +1 -0
  13. package/dist/domain/ex-command.d.ts +5 -2
  14. package/dist/domain/ex-command.d.ts.map +1 -1
  15. package/dist/domain/initialization.d.ts +14 -11
  16. package/dist/domain/initialization.d.ts.map +1 -1
  17. package/dist/domain/node-presentation.d.ts +12 -0
  18. package/dist/domain/node-presentation.d.ts.map +1 -0
  19. package/dist/domain/node-presentation.js +1 -0
  20. package/dist/domain/public-init-api.d.ts +12 -7
  21. package/dist/domain/public-init-api.d.ts.map +1 -1
  22. package/dist/domain/shell-api.d.ts +1 -1
  23. package/dist/domain/shell-api.d.ts.map +1 -1
  24. package/dist/domain/theme.d.ts +2 -14
  25. package/dist/domain/theme.d.ts.map +1 -1
  26. package/dist/domain/theme.js +9 -15
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/ui/App.d.ts +3 -5
  30. package/dist/ui/App.d.ts.map +1 -1
  31. package/dist/ui/App.js +36 -19
  32. package/dist/ui/AppSetup.d.ts +1 -1
  33. package/dist/ui/AppSetup.d.ts.map +1 -1
  34. package/dist/ui/AppSetup.js +30 -24
  35. package/dist/ui/Shell.js +6 -6
  36. package/dist/ui/color-resolver.d.ts +1 -1
  37. package/dist/ui/color-resolver.d.ts.map +1 -1
  38. package/dist/ui/hooks/useView.d.ts +2 -2
  39. package/dist/ui/hooks/useView.d.ts.map +1 -1
  40. package/dist/ui/hooks/useView.js +3 -3
  41. package/dist/ui/view.d.ts +7 -3
  42. package/dist/ui/view.d.ts.map +1 -1
  43. package/dist/ui/view.js +76 -19
  44. package/package.json +3 -3
@@ -1,23 +1,28 @@
1
1
  import { AppPackageReference } from './app-pack-ref.js';
2
2
  import { ConfigPatch } from './config.js';
3
- import { ShellApi } from './shell-api.js';
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
- * This is intentionally a narrow facade. It is the public scripting boundary,
8
- * rather than an escape hatch into UI state or infrastructure implementations.
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 apps: {
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
- initialAppId: (appId: string) => void;
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: (shell: ShellApi) => void | Promise<void>) => void;
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,gBAAgB,CAAC;AAE1C;;;;;GAKG;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,IAAI,EAAE;QACb;;;;WAIG;QACH,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACtC;;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,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAC/C,IAAI,CAAC;KACX,CAAC;CACH,CAAC"}
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,4 +1,4 @@
1
- import type { AppInput } from './initialization.js';
1
+ import type { AppInput } from './app-input.js';
2
2
  export type ShellApi = {
3
3
  readonly openApp: (appId: string, input: AppInput) => Promise<void>;
4
4
  };
@@ -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,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"}
1
+ {"version":3,"file":"shell-api.d.ts","sourceRoot":"","sources":["../../src/domain/shell-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,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"}
@@ -1,13 +1,7 @@
1
1
  import { z } from 'zod';
2
- /**
3
- * Named ANSI foreground colors supported by Dirvi themes.
4
- *
5
- * Renderers translate these symbolic names into their own color APIs. The CLI
6
- * renderer currently maps them to terminal colors; another renderer does not
7
- * need to depend on Chalk to interpret the same theme.
8
- */
2
+ import type { Theme } from 'dirvi-apis';
3
+ /** Named ANSI colors accepted by the theme schema. */
9
4
  export declare const basicColorNames: readonly ["black", "red", "green", "yellow", "blue", "cyan", "magenta", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "cyanBright", "magentaBright", "whiteBright"];
10
- export type BasicColorName = (typeof basicColorNames)[number];
11
5
  export declare const ColorConfigSchema: z.ZodObject<{
12
6
  hex: z.ZodOptional<z.ZodString>;
13
7
  ansi256: z.ZodOptional<z.ZodNumber>;
@@ -32,7 +26,6 @@ export declare const ColorConfigSchema: z.ZodObject<{
32
26
  whiteBright: "whiteBright";
33
27
  }>>;
34
28
  }, z.core.$strip>;
35
- export type ColorConfig = z.infer<typeof ColorConfigSchema>;
36
29
  export declare const ForegroundHighlightConfigSchema: z.ZodObject<{
37
30
  fg: z.ZodObject<{
38
31
  hex: z.ZodOptional<z.ZodString>;
@@ -161,10 +154,6 @@ export declare const ForegroundBackgroundHighlightConfigSchema: z.ZodObject<{
161
154
  }>>;
162
155
  }, z.core.$strip>;
163
156
  }, z.core.$strip>;
164
- export type ForegroundHighlightConfig = z.infer<typeof ForegroundHighlightConfigSchema>;
165
- export type OptionalForegroundHighlightConfig = z.infer<typeof OptionalForegroundHighlightConfigSchema>;
166
- export type BackgroundHighlightConfig = z.infer<typeof BackgroundHighlightConfigSchema>;
167
- export type ForegroundBackgroundHighlightConfig = z.infer<typeof ForegroundBackgroundHighlightConfigSchema>;
168
157
  export declare const ThemeSchema: z.ZodObject<{
169
158
  statusBar: z.ZodDefault<z.ZodObject<{
170
159
  command: z.ZodDefault<z.ZodObject<{
@@ -531,6 +520,5 @@ export declare const ThemeSchema: z.ZodObject<{
531
520
  }, z.core.$strip>>;
532
521
  }, z.core.$strip>>;
533
522
  }, z.core.$strip>;
534
- export type Theme = z.infer<typeof ThemeSchema>;
535
523
  export declare const defaultTheme: Theme;
536
524
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/domain/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,yNAsBlB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAI9D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;iBAc3B,CAAC;AAEJ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAM5D,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;iBAE1C,CAAC;AAEH,eAAO,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;iBAElD,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;iBAE1C,CAAC;AAEH,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGpD,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CACrD,OAAO,uCAAuC,CAC/C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,yCAAyC,CACjD,CAAC;AA6FF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CK,CAAC;AAE9B,eAAO,MAAM,YAAY,EAAE,KAA6B,CAAC"}
@@ -1,18 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  // =============================================================================
3
- // Terminal colors
3
+ // Colors: Schemas
4
4
  // =============================================================================
5
- const HexColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, {
6
- message: 'Expected a #rrggbb color',
7
- });
8
- const Ansi256ColorSchema = z.number().int().min(0).max(255);
9
- /**
10
- * Named ANSI foreground colors supported by Dirvi themes.
11
- *
12
- * Renderers translate these symbolic names into their own color APIs. The CLI
13
- * renderer currently maps them to terminal colors; another renderer does not
14
- * need to depend on Chalk to interpret the same theme.
15
- */
5
+ /** Named ANSI colors accepted by the theme schema. */
16
6
  export const basicColorNames = [
17
7
  'black',
18
8
  'red',
@@ -34,6 +24,10 @@ export const basicColorNames = [
34
24
  'magentaBright',
35
25
  'whiteBright',
36
26
  ];
27
+ const HexColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, {
28
+ message: 'Expected a #rrggbb color',
29
+ });
30
+ const Ansi256ColorSchema = z.number().int().min(0).max(255);
37
31
  const BasicColorSchema = z.enum(basicColorNames);
38
32
  export const ColorConfigSchema = z
39
33
  .object({
@@ -47,9 +41,9 @@ export const ColorConfigSchema = z
47
41
  message: 'Expected at least one terminal color profile',
48
42
  });
49
43
  // =============================================================================
50
- // Highlights
44
+ // Highlights: Schemas
51
45
  // =============================================================================
52
- // Note: these schemas are meant to be non-strict
46
+ // These schemas are intentionally non-strict.
53
47
  export const ForegroundHighlightConfigSchema = z.object({
54
48
  fg: ColorConfigSchema,
55
49
  });
@@ -140,7 +134,7 @@ const themeDefaults = {
140
134
  },
141
135
  };
142
136
  // =============================================================================
143
- // Theme schema
137
+ // Theme: Schema
144
138
  // =============================================================================
145
139
  export const ThemeSchema = z.object({
146
140
  statusBar: z
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export type { Theme } from './domain/theme.js';
2
1
  export type { Config } from './domain/config.js';
3
2
  export type { Initialization } from './domain/initialization.js';
4
3
  export type { PublicInitApi } from './domain/public-init-api.js';
@@ -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;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,iCAA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ppApi, 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';
4
- import { AppPackageReference } from '../domain/app-pack-ref.js';
5
3
  import { ShellApi } from '../domain/shell-api.js';
4
+ import { Initialization } from '../domain/initialization.js';
6
5
  type AppProps<Id extends SerializableKey, Value, ViewKey = string> = {
7
6
  screenRenderer: AppScreenRenderer;
8
7
  shellApi: ShellApi;
9
8
  appApi: AppApi<Id, Value, ViewKey>;
10
- config: Config;
11
- registeredApps: ReadonlyMap<string, AppPackageReference>;
9
+ initialization: Initialization;
12
10
  initialState: State<Id, Value>;
13
11
  reducer: Reducer<Id, Value>;
14
12
  intentToEffect: IntentToEffect<Id, Value>;
@@ -17,6 +15,6 @@ type AppProps<Id extends SerializableKey, Value, ViewKey = string> = {
17
15
  clipboard?: (value: string) => void;
18
16
  onError?: (error: Error) => void;
19
17
  };
20
- export declare function App<Id extends SerializableKey, Value, ViewKey = string>({ screenRenderer, shellApi, appApi, config, registeredApps, initialState, reducer, intentToEffect, effectToAction, stdout, clipboard, onError, }: AppProps<Id, Value, ViewKey>): import("react").JSX.Element;
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;
21
19
  export {};
22
20
  //# sourceMappingURL=App.d.ts.map
@@ -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;AAEnB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0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,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,+BAoW9B"}
package/dist/ui/App.js CHANGED
@@ -2,22 +2,21 @@ 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 toError(error) {
6
- return error instanceof Error ? error : new Error(String(error));
7
- }
8
- export function App({ screenRenderer, shellApi, appApi, config, registeredApps, 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
12
9
  // see current state
13
10
  stateRef.current = state;
14
11
  const navEntry = useMemo(() => {
15
- const navigation = appApi.navNodeApi.from(state.root, state.folds);
12
+ const root = appApi.stateApi.getRoot(state);
13
+ const folds = appApi.stateApi.getFolds(state);
14
+ const navigation = appApi.navMethods.from(root, folds);
16
15
  if (navigation === undefined) {
17
16
  throw new Error('Tree-surfer state root must be a loaded branch.');
18
17
  }
19
18
  return navigation;
20
- }, [appApi.navNodeApi, state.root, state.folds]);
19
+ }, [appApi.navMethods, appApi.stateApi, state]);
21
20
  const [inputState, setInputState] = useState({
22
21
  inputMode: 'normal',
23
22
  normalBuffer: '',
@@ -34,7 +33,7 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
34
33
  const feedbackApi = useMemo(() => createFeedbackApi((nextFeedback) => {
35
34
  setFeedback(nextFeedback);
36
35
  }), []);
37
- const view = useView(navEntry, state, appApi.navNodeApi, appApi.cursorApi, rowCount);
36
+ const view = useView(navEntry, state, appApi.stateApi, appApi.navMethods, appApi.stateApi.cursorApi, rowCount, appApi.presentNode);
38
37
  // ===========================================================================
39
38
  // Resync Subscriptions
40
39
  // ===========================================================================
@@ -43,7 +42,7 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
43
42
  const unsubscribe = appApi.subscribeToResync(() => {
44
43
  const oldState = stateRef.current;
45
44
  void appApi.stateApi
46
- .resync(oldState, appApi.loadBranches)
45
+ .resync(oldState, appApi.loadChildren)
47
46
  .then((newState) => {
48
47
  if (!active) {
49
48
  return;
@@ -72,11 +71,29 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
72
71
  return;
73
72
  }
74
73
  switch (effect.effectType) {
74
+ case 'userExCommand': {
75
+ setInputState({
76
+ inputMode: 'normal',
77
+ normalBuffer: '',
78
+ });
79
+ const command = initialization.exCommands.get(effect.name);
80
+ if (command === undefined) {
81
+ feedbackApi.addMessage(`Command is no longer registered: ${effect.name}`, 'error');
82
+ return;
83
+ }
84
+ void Promise.resolve()
85
+ .then(() => command.execute({ shell: shellApi })) // TODO: Add args
86
+ .catch((error) => {
87
+ const appError = error instanceof Error ? error : new Error(String(error));
88
+ feedbackApi.addMessage(`Command "${effect.name}" failed: ${appError.message}`, 'error');
89
+ });
90
+ return;
91
+ }
75
92
  case 'quit':
76
93
  setExitStatus(effect.exitMessage);
77
94
  return;
78
95
  case 'listApps': {
79
- const appIds = [...registeredApps.keys()];
96
+ const appIds = [...initialization.app.registered.keys()];
80
97
  const lines = appIds.map((id) => `${id}`);
81
98
  setInputState({
82
99
  inputMode: 'normal',
@@ -113,7 +130,7 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
113
130
  return;
114
131
  case 'loadBranchEntries': {
115
132
  void appApi
116
- .loadBranches(effect.path)
133
+ .loadChildren(effect.path)
117
134
  .then((entries) => {
118
135
  dispatch({
119
136
  kind: 'updateBranch',
@@ -132,7 +149,7 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
132
149
  if (navigation === null) {
133
150
  return;
134
151
  }
135
- const visibleLeavesPaths = appApi.navNodeApi.visibleLeavesPaths(navigation);
152
+ const visibleLeavesPaths = appApi.navMethods.visibleLeavesPaths(navigation);
136
153
  stdout?.(JSON.stringify({
137
154
  type: 'displayed-leaves-paths',
138
155
  paths: visibleLeavesPaths,
@@ -192,11 +209,11 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
192
209
  }
193
210
  // TODO: Add descriptions with `...` truncation.
194
211
  case 'listFolds': {
195
- const folds = state.folds;
196
- const foldTrees = [...appApi.foldsApi.indexes(folds)].map((index) => ({
212
+ const folds = appApi.stateApi.getFolds(state);
213
+ const foldTrees = [...appApi.stateApi.foldsApi.indexes(folds)].map((index) => ({
197
214
  index,
198
- info: appApi.foldsApi.getInfoAtIndex(folds, index),
199
- active: appApi.foldsApi.isActiveAtIndex(folds, index),
215
+ info: appApi.stateApi.foldsApi.getInfoAtIndex(folds, index),
216
+ active: appApi.stateApi.foldsApi.isActiveAtIndex(folds, index),
200
217
  }));
201
218
  const indexWidth = Math.max(...foldTrees.map(({ index }) => String(index).length));
202
219
  const lines = foldTrees.map(({ index, info, active }) => {
@@ -211,11 +228,11 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
211
228
  feedbackApi.addMessage(['Fold trees:', ...lines].join('\n'));
212
229
  return;
213
230
  }
214
- case 'unrecognizedCommand':
215
- feedbackApi.addMessage(`Unrecognized command: ${effect.commandLine}`, 'error');
231
+ case 'emitError':
232
+ feedbackApi.addMessage(effect.message, 'error');
216
233
  return;
217
234
  }
218
- }, [appApi, effectToAction, feedbackApi, navEntry, state, stdout, registeredApps]);
235
+ }, [appApi, effectToAction, feedbackApi, navEntry, state, stdout, initialization.app.registered, shellApi, initialization.exCommands]);
219
236
  // ===========================================================================
220
237
  // Input hook
221
238
  // ===========================================================================
@@ -234,5 +251,5 @@ export function App({ screenRenderer, shellApi, appApi, config, registeredApps,
234
251
  // ===========================================================================
235
252
  // Render
236
253
  // ===========================================================================
237
- return (_jsx(ScreenRenderer, { view: view, feedback: feedback, feedbackApi: feedbackApi, config: config, inputState: inputState, handleInput: handleInput, onRowsChange: handleRowsChange, exitStatus: exitStatus }));
254
+ return (_jsx(ScreenRenderer, { view: view, feedback: feedback, feedbackApi: feedbackApi, config: initialization.config, inputState: inputState, handleInput: handleInput, onRowsChange: handleRowsChange, exitStatus: exitStatus }));
238
255
  }
@@ -1,4 +1,4 @@
1
- import type { AppApi, SerializableKey } from 'dirvi-lib';
1
+ import { AppApi, SerializableKey } from 'dirvi-lib';
2
2
  import type { LoadingScreenRenderer } from './loading-screen-renderer.js';
3
3
  import type { AppScreenRenderer } from './app-screen-renderer.js';
4
4
  import { ShellApi } from '../domain/shell-api.js';
@@ -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;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,CA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AE,KAAK,EAAE,OAAO,CAAC,+BA4FrC"}
@@ -1,47 +1,53 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from 'react';
3
+ import { createTreeMethods } from 'dirvi-lib';
3
4
  import { createEffectToAction, createIntentToEffect, createReducer, } from 'dirvi-lib';
4
5
  import { App } from './App.js';
5
6
  export function AppSetup({ appScreenRenderer, loadingScreenRenderer, initialization, shellApi, appApi, stdout, clipboard, }) {
7
+ const [loadState, setLoadState] = useState();
6
8
  const [initialState, setInitialState] = useState();
7
- const [config, setConfig] = useState(initialization.config);
8
9
  // Loading and setting initial state.
9
10
  useEffect(() => {
10
11
  let mounted = true;
11
- appApi
12
- .createRoot()
13
- .then((root) => {
14
- if (!mounted) {
15
- return;
16
- }
17
- setInitialState({
18
- root,
19
- folds: appApi.foldsApi.create(appApi.rootId, {
12
+ setLoadState({ status: 'loading', appApi });
13
+ async function initialize() {
14
+ try {
15
+ const root = await appApi.loadRoot();
16
+ if (!mounted) {
17
+ return;
18
+ }
19
+ const rootId = createTreeMethods().id(root);
20
+ const folds = appApi.stateApi.foldsApi.create(rootId, {
20
21
  name: 'default',
21
22
  description: null,
22
- }),
23
- cursor: [],
24
- });
25
- })
26
- .catch((cause) => {
27
- const nextError = cause instanceof Error ? cause : new Error(String(cause));
28
- if (!mounted) {
29
- return;
23
+ });
24
+ const initialState = appApi.stateApi.create(root, folds, { path: [] });
25
+ if (initialState === undefined) {
26
+ throw new Error('Cannot create initial app state');
27
+ }
28
+ setLoadState({ status: 'ready', appApi, initialState });
29
+ }
30
+ catch (cause) {
31
+ if (!mounted) {
32
+ return;
33
+ }
34
+ const error = cause instanceof Error ? cause : new Error(String(cause));
35
+ setLoadState({ status: 'error', appApi, error });
30
36
  }
31
- throw nextError;
32
- });
37
+ }
38
+ void initialize();
33
39
  return () => {
34
40
  mounted = false;
35
41
  };
36
42
  }, [appApi]);
37
43
  // --- Pure function deps ---
38
- const reducer = useMemo(() => createReducer(appApi.treeNodeApi, appApi.foldsApi), [appApi.treeNodeApi, appApi.foldsApi]);
39
- const intentToEffect = useMemo(() => createIntentToEffect(appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi), [appApi.stateApi, appApi.cursorApi, appApi.treeNodeApi]);
40
- const effectToAction = useMemo(() => createEffectToAction(appApi.foldsApi, appApi.cursorApi, appApi.navNodeApi), [appApi.navNodeApi, appApi.cursorApi, appApi.foldsApi]);
44
+ const reducer = useMemo(() => createReducer(appApi.stateApi, appApi.navMethods), [appApi.stateApi, appApi.navMethods]);
45
+ const intentToEffect = useMemo(() => createIntentToEffect(new Set(initialization.exCommands.keys()), appApi.stateApi), [appApi.stateApi, initialization.exCommands]);
46
+ const effectToAction = useMemo(() => createEffectToAction(appApi.stateApi, appApi.navMethods), [appApi.navMethods, appApi.stateApi]);
41
47
  // --- JSX ---
42
48
  const LoadingScreenRenderer = loadingScreenRenderer;
43
49
  if (initialState === undefined) {
44
50
  return _jsx(LoadingScreenRenderer, {});
45
51
  }
46
- return (_jsx(App, { screenRenderer: appScreenRenderer, shellApi: shellApi, appApi: appApi, config: config, registeredApps: initialization.registeredApps, initialState: initialState, reducer: reducer, intentToEffect: intentToEffect, effectToAction: effectToAction, ...(stdout === undefined ? {} : { stdout }), ...(clipboard === undefined ? {} : { clipboard }) }));
52
+ 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 }) }));
47
53
  }
package/dist/ui/Shell.js CHANGED
@@ -18,7 +18,7 @@ export function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppOpti
18
18
  const shellApi = useMemo(() => {
19
19
  return {
20
20
  openApp: async (appId, input) => {
21
- const appReference = initialization.registeredApps.get(appId);
21
+ const appReference = initialization.app.registered.get(appId);
22
22
  if (appReference === undefined) {
23
23
  throw new Error(`App "${appId}" has not been registered.`);
24
24
  }
@@ -29,20 +29,20 @@ export function Shell({ loadingScreenRenderer, appScreenRenderer, initialAppOpti
29
29
  setAppApiApplicator(() => loadedAppApiApplicator);
30
30
  },
31
31
  };
32
- }, [initialization.registeredApps, packageLoader]);
32
+ }, [packageLoader, initialization.app.registered]);
33
33
  useEffect(() => {
34
34
  void shellApi
35
- .openApp(initialAppOptions.app ?? initialization.initialAppId, initialAppOptions.input)
35
+ .openApp(initialAppOptions.app ?? initialization.app.initial, initialAppOptions.input)
36
36
  .catch((error) => {
37
37
  setAppError(error instanceof Error ? error : new Error(String(error)));
38
38
  });
39
- }, [initialAppOptions.input, initialization.initialAppId, shellApi]);
39
+ }, [initialAppOptions.input, initialization.app.initial, shellApi]);
40
40
  if (appError !== undefined) {
41
41
  throw appError;
42
42
  }
43
- const initialAppReference = initialization.registeredApps.get(initialization.initialAppId);
43
+ const initialAppReference = initialization.app.registered.get(initialization.app.initial);
44
44
  if (initialAppReference === undefined) {
45
- throw new Error(`Startup app "${initialization.initialAppId}" has not been registered.`);
45
+ throw new Error(`Startup app "${initialization.app.initial}" has not been registered.`);
46
46
  }
47
47
  if (appApiApplicator === undefined) {
48
48
  const LoadingScreenRenderer = loadingScreenRenderer;
@@ -1,3 +1,3 @@
1
- import type { ColorConfig } from '../domain/theme.js';
1
+ import type { ColorConfig } from 'dirvi-apis';
2
2
  export declare function colorConfigToInkColor(colorConfig: ColorConfig, colorDepth?: number): string;
3
3
  //# sourceMappingURL=color-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-resolver.d.ts","sourceRoot":"","sources":["../../src/ui/color-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAuBtD,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,UAAU,GAAE,MAAuC,GAClD,MAAM,CA2BR"}
1
+ {"version":3,"file":"color-resolver.d.ts","sourceRoot":"","sources":["../../src/ui/color-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuB9C,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,UAAU,GAAE,MAAuC,GAClD,MAAM,CA2BR"}
@@ -1,4 +1,4 @@
1
- import type { CursorApi, NavBranch, NavNodeApi, SerializableKey, State } from 'dirvi-lib';
1
+ import type { CursorMethods, NavBranch, NavMethods, PresentNode, SerializableKey, State, StateApi } from 'dirvi-lib';
2
2
  import { View } from '../view.js';
3
- export declare function useView<Id extends SerializableKey, Value>(navNode: NavBranch<Id>, state: State<Id, Value>, navNodeApi: NavNodeApi<Id, Value>, cursorApi: CursorApi<Id>, rowCount: number): View;
3
+ export declare function useView<Id extends SerializableKey, Value>(navNode: NavBranch<Id>, state: State<Id, Value>, stateApi: StateApi<Id, Value>, navNodeApi: NavMethods<Id, Value>, cursorMethods: CursorMethods<Id>, rowCount: number, presentNode: PresentNode<Id>): View;
4
4
  //# sourceMappingURL=useView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useView.d.ts","sourceRoot":"","sources":["../../../src/ui/hooks/useView.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAC;AAMhD,wBAAgB,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EACvD,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,EACtB,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,EACvB,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,EACjC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,EACxB,QAAQ,EAAE,MAAM,GACf,IAAI,CAwBN"}
1
+ {"version":3,"file":"useView.d.ts","sourceRoot":"","sources":["../../../src/ui/hooks/useView.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,UAAU,EAAE,WAAW,EACvB,eAAe,EACf,KAAK,EAAE,QAAQ,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAC;AAMhD,wBAAgB,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,KAAK,EACvD,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,EACtB,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,EACvB,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,EAC7B,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,EACjC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,GAC3B,IAAI,CAyBN"}
@@ -3,15 +3,15 @@ import { View } from '../view.js';
3
3
  const STATUS_BAR_HEIGHT = 1;
4
4
  // Hooks that keeps Ref of the viewport's start, and returns View sliced to
5
5
  // only the rows that should be visible.
6
- export function useView(navNode, state, navNodeApi, cursorApi, rowCount) {
6
+ export function useView(navNode, state, stateApi, navNodeApi, cursorMethods, rowCount, presentNode) {
7
7
  const viewportStartRef = useRef(0);
8
8
  const viewportHeight = Math.max(0, rowCount - STATUS_BAR_HEIGHT);
9
9
  if (viewportHeight === 0) {
10
10
  return { rows: [] };
11
11
  }
12
- const rows = View.createRows(navNode, navNodeApi, state.cursor, cursorApi);
12
+ const rows = View.createRows(navNode, navNodeApi, stateApi.getCursor(state), cursorMethods, presentNode);
13
13
  viewportStartRef.current = viewportStart(rows, viewportHeight, viewportStartRef.current);
14
- return View.create(navNode, navNodeApi, state.cursor, cursorApi, viewportHeight, viewportStartRef.current);
14
+ return View.create(navNode, navNodeApi, stateApi.getCursor(state), cursorMethods, viewportHeight, viewportStartRef.current, presentNode);
15
15
  }
16
16
  function viewportStart(rows, viewportHeight, currentViewportStart) {
17
17
  const scrollMargin = 3;
package/dist/ui/view.d.ts CHANGED
@@ -1,23 +1,27 @@
1
- import type { Cursor, CursorApi, NavBranch, NavNodeApi, SerializableKey } from 'dirvi-lib';
1
+ import type { Cursor, HighlightToken, NavBranch, NavMethods, PresentNode, SerializableKey, CursorMethods } from 'dirvi-lib';
2
2
  type ViewRowBase = {
3
3
  id: string;
4
4
  indent: number;
5
5
  content: string;
6
6
  cursor: boolean;
7
7
  selected: boolean;
8
+ highlight: HighlightToken;
8
9
  };
9
10
  export type ViewRow = (ViewRowBase & {
10
11
  type: 'leaf';
11
12
  }) | (ViewRowBase & {
12
13
  type: 'branch';
13
14
  foldedCount: number;
15
+ }) | (ViewRowBase & {
16
+ type: 'fold';
17
+ foldedCount: number;
14
18
  });
15
19
  export type View = {
16
20
  rows: ViewRow[];
17
21
  };
18
22
  export declare const View: {
19
- createRows<Id extends SerializableKey, Value>(rootNode: NavBranch<Id>, navNodeApi: NavNodeApi<Id, Value>, cursor: Cursor<Id>, cursorApi: CursorApi<Id>): ViewRow[];
20
- create<Id extends SerializableKey, Value>(rootNode: NavBranch<Id>, navNodeApi: NavNodeApi<Id, Value>, cursor: Cursor<Id>, cursorApi: CursorApi<Id>, viewportHeight: number, viewportStart: number): View;
23
+ createRows<Id extends SerializableKey, Value>(rootNode: NavBranch<Id>, navNodeApi: NavMethods<Id, Value>, cursor: Cursor<Id>, cursorMethods: CursorMethods<Id>, presentNode: PresentNode<Id>): ViewRow[];
24
+ create<Id extends SerializableKey, Value>(rootNode: NavBranch<Id>, navNodeApi: NavMethods<Id, Value>, cursor: Cursor<Id>, cursorMethods: CursorMethods<Id>, viewportHeight: number, viewportStart: number, presentNode: PresentNode<Id>): View;
21
25
  };
22
26
  export {};
23
27
  //# sourceMappingURL=view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/ui/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,SAAS,EAGT,UAAU,EACV,eAAe,EAChB,MAAM,WAAW,CAAC;AAEnB,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,OAAO,GACf,CAAC,WAAW,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,GACF,CAAC,WAAW,GAAG;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEP,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,IAAI;eACJ,EAAE,SAAS,eAAe,EAAE,KAAK,YAChC,SAAS,CAAC,EAAE,CAAC,cACX,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,UACzB,MAAM,CAAC,EAAE,CAAC,aACP,SAAS,CAAC,EAAE,CAAC,GACvB,OAAO,EAAE;WAoBL,EAAE,SAAS,eAAe,EAAE,KAAK,YAC5B,SAAS,CAAC,EAAE,CAAC,cACX,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,UACzB,MAAM,CAAC,EAAE,CAAC,aACP,SAAS,CAAC,EAAE,CAAC,kBACR,MAAM,iBACP,MAAM,GACpB,IAAI;CAOR,CAAC"}
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/ui/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACd,SAAS,EAET,UAAU,EACV,WAAW,EACX,eAAe,EAAE,aAAa,EAC/B,MAAM,WAAW,CAAC;AAGnB,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,M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