@mak-98/dirvi-app 0.0.0-stage → 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/LICENSE +674 -0
- 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/create-dirvi-api.d.ts +10 -0
- package/dist/application/create-dirvi-api.d.ts.map +1 -0
- package/dist/application/create-dirvi-api.js +23 -0
- package/dist/application/init-runtime.d.ts +20 -0
- package/dist/application/init-runtime.d.ts.map +1 -0
- package/dist/application/init-runtime.js +117 -0
- package/dist/application/package-loader.d.ts +9 -0
- package/dist/application/package-loader.d.ts.map +1 -0
- package/dist/application/package-loader.js +1 -0
- package/dist/application/shell-api.d.ts +5 -0
- package/dist/application/shell-api.d.ts.map +1 -0
- package/dist/application/shell-api.js +1 -0
- package/dist/domain/app-pack-ref.d.ts +17 -0
- package/dist/domain/app-pack-ref.d.ts.map +1 -0
- package/dist/domain/app-pack-ref.js +37 -0
- package/dist/domain/app.d.ts +39 -0
- package/dist/domain/app.d.ts.map +1 -0
- package/dist/domain/app.js +25 -0
- package/dist/domain/config.d.ts +402 -0
- package/dist/domain/config.d.ts.map +1 -0
- package/dist/domain/config.js +44 -0
- package/dist/domain/dirvi-api.d.ts +24 -0
- package/dist/domain/dirvi-api.d.ts.map +1 -0
- package/dist/domain/dirvi-api.js +1 -0
- package/dist/domain/ex-command.d.ts +12 -0
- package/dist/domain/ex-command.d.ts.map +1 -0
- package/dist/domain/ex-command.js +1 -0
- package/dist/domain/init-runtime.d.ts +41 -0
- package/dist/domain/init-runtime.d.ts.map +1 -0
- package/dist/domain/init-runtime.js +1 -0
- package/dist/domain/initialization.d.ts +20 -0
- package/dist/domain/initialization.d.ts.map +1 -0
- package/dist/domain/initialization.js +1 -0
- package/dist/domain/public-init-api.d.ts +42 -0
- package/dist/domain/public-init-api.d.ts.map +1 -0
- package/dist/domain/public-init-api.js +1 -0
- package/dist/domain/shell-api.d.ts +5 -0
- package/dist/domain/shell-api.d.ts.map +1 -0
- package/dist/domain/shell-api.js +1 -0
- package/dist/domain/theme.d.ts +536 -0
- package/dist/domain/theme.d.ts.map +1 -0
- package/dist/domain/theme.js +170 -0
- package/dist/domain/view-name-schema.d.ts +18 -0
- package/dist/domain/view-name-schema.d.ts.map +1 -0
- package/dist/domain/view-name-schema.js +68 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/theme.d.ts +536 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +170 -0
- package/dist/ui/App.d.ts +18 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +225 -0
- package/dist/ui/AppSetup.d.ts +17 -0
- package/dist/ui/AppSetup.d.ts.map +1 -0
- package/dist/ui/AppSetup.js +88 -0
- package/dist/ui/Shell.d.ts +49 -0
- package/dist/ui/Shell.d.ts.map +1 -0
- package/dist/ui/Shell.js +54 -0
- package/dist/ui/app-screen-renderer.d.ts +28 -0
- package/dist/ui/app-screen-renderer.d.ts.map +1 -0
- package/dist/ui/app-screen-renderer.js +1 -0
- package/dist/ui/color-resolver.d.ts +3 -0
- package/dist/ui/color-resolver.d.ts.map +1 -0
- package/dist/ui/color-resolver.js +61 -0
- package/dist/ui/hooks/useView.d.ts +4 -0
- package/dist/ui/hooks/useView.d.ts.map +1 -0
- package/dist/ui/hooks/useView.js +32 -0
- package/dist/ui/loading-screen-renderer.d.ts +3 -0
- package/dist/ui/loading-screen-renderer.d.ts.map +1 -0
- package/dist/ui/loading-screen-renderer.js +1 -0
- package/dist/ui/view.d.ts +23 -0
- package/dist/ui/view.d.ts.map +1 -0
- package/dist/ui/view.js +74 -0
- package/package.json +34 -3
- package/README.md +0 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Terminal colors
|
|
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
|
+
*/
|
|
16
|
+
export const basicColorNames = [
|
|
17
|
+
'black',
|
|
18
|
+
'red',
|
|
19
|
+
'green',
|
|
20
|
+
'yellow',
|
|
21
|
+
'blue',
|
|
22
|
+
'cyan',
|
|
23
|
+
'magenta',
|
|
24
|
+
'white',
|
|
25
|
+
// Common aliases for blackBright.
|
|
26
|
+
'gray',
|
|
27
|
+
'grey',
|
|
28
|
+
'blackBright',
|
|
29
|
+
'redBright',
|
|
30
|
+
'greenBright',
|
|
31
|
+
'yellowBright',
|
|
32
|
+
'blueBright',
|
|
33
|
+
'cyanBright',
|
|
34
|
+
'magentaBright',
|
|
35
|
+
'whiteBright',
|
|
36
|
+
];
|
|
37
|
+
const BasicColorSchema = z.enum(basicColorNames);
|
|
38
|
+
export const ColorConfigSchema = z
|
|
39
|
+
.object({
|
|
40
|
+
hex: HexColorSchema.optional(),
|
|
41
|
+
ansi256: Ansi256ColorSchema.optional(),
|
|
42
|
+
basic: BasicColorSchema.optional(),
|
|
43
|
+
})
|
|
44
|
+
.refine((value) => value.hex !== undefined ||
|
|
45
|
+
value.ansi256 !== undefined ||
|
|
46
|
+
value.basic !== undefined, {
|
|
47
|
+
message: 'Expected at least one terminal color profile',
|
|
48
|
+
});
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// Highlights
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// Note: these schemas are meant to be non-strict
|
|
53
|
+
export const ForegroundHighlightConfigSchema = z.object({
|
|
54
|
+
fg: ColorConfigSchema,
|
|
55
|
+
});
|
|
56
|
+
export const OptionalForegroundHighlightConfigSchema = z.object({
|
|
57
|
+
fg: ColorConfigSchema.optional(),
|
|
58
|
+
});
|
|
59
|
+
export const BackgroundHighlightConfigSchema = z.object({
|
|
60
|
+
bg: ColorConfigSchema,
|
|
61
|
+
});
|
|
62
|
+
export const ForegroundBackgroundHighlightConfigSchema = z.object({
|
|
63
|
+
fg: ColorConfigSchema,
|
|
64
|
+
bg: ColorConfigSchema,
|
|
65
|
+
});
|
|
66
|
+
// =============================================================================
|
|
67
|
+
// Theme defaults
|
|
68
|
+
// =============================================================================
|
|
69
|
+
const black = {
|
|
70
|
+
hex: '#28282a',
|
|
71
|
+
ansi256: 235,
|
|
72
|
+
basic: 'black',
|
|
73
|
+
};
|
|
74
|
+
const lightGray = {
|
|
75
|
+
hex: '#eaeaec',
|
|
76
|
+
ansi256: 254,
|
|
77
|
+
basic: 'gray',
|
|
78
|
+
};
|
|
79
|
+
const leaf = {
|
|
80
|
+
hex: '#e5e5e5',
|
|
81
|
+
ansi256: 254,
|
|
82
|
+
basic: 'white',
|
|
83
|
+
};
|
|
84
|
+
const branch = {
|
|
85
|
+
hex: '#2472c8',
|
|
86
|
+
ansi256: 26,
|
|
87
|
+
basic: 'blue',
|
|
88
|
+
};
|
|
89
|
+
const folded = {
|
|
90
|
+
hex: '#808080',
|
|
91
|
+
ansi256: 245,
|
|
92
|
+
basic: 'gray',
|
|
93
|
+
};
|
|
94
|
+
const indentGuide = {
|
|
95
|
+
hex: '#808080',
|
|
96
|
+
ansi256: 245,
|
|
97
|
+
basic: 'gray',
|
|
98
|
+
};
|
|
99
|
+
const cursorLine = {
|
|
100
|
+
hex: '#3a3a3c',
|
|
101
|
+
ansi256: 237,
|
|
102
|
+
basic: 'gray',
|
|
103
|
+
};
|
|
104
|
+
const success = {
|
|
105
|
+
hex: '#238c4b',
|
|
106
|
+
ansi256: 28,
|
|
107
|
+
basic: 'green',
|
|
108
|
+
};
|
|
109
|
+
const error = {
|
|
110
|
+
hex: '#be2d2d',
|
|
111
|
+
ansi256: 160,
|
|
112
|
+
basic: 'red',
|
|
113
|
+
};
|
|
114
|
+
const themeDefaults = {
|
|
115
|
+
statusBar: {
|
|
116
|
+
command: { fg: black },
|
|
117
|
+
normal: { fg: black },
|
|
118
|
+
background: { bg: lightGray },
|
|
119
|
+
},
|
|
120
|
+
tree: {
|
|
121
|
+
leaf: { fg: leaf },
|
|
122
|
+
branch: { fg: branch },
|
|
123
|
+
folded: { fg: folded },
|
|
124
|
+
cursorLine: { bg: cursorLine },
|
|
125
|
+
indentGuide: { fg: indentGuide },
|
|
126
|
+
},
|
|
127
|
+
feedbackBar: {
|
|
128
|
+
message: {
|
|
129
|
+
fg: black,
|
|
130
|
+
bg: lightGray,
|
|
131
|
+
},
|
|
132
|
+
success: {
|
|
133
|
+
fg: success,
|
|
134
|
+
bg: lightGray,
|
|
135
|
+
},
|
|
136
|
+
error: {
|
|
137
|
+
fg: error,
|
|
138
|
+
bg: lightGray,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// Theme schema
|
|
144
|
+
// =============================================================================
|
|
145
|
+
export const ThemeSchema = z.object({
|
|
146
|
+
statusBar: z
|
|
147
|
+
.object({
|
|
148
|
+
command: ForegroundHighlightConfigSchema.default(themeDefaults.statusBar.command),
|
|
149
|
+
normal: ForegroundHighlightConfigSchema.default(themeDefaults.statusBar.normal),
|
|
150
|
+
background: BackgroundHighlightConfigSchema.default(themeDefaults.statusBar.background),
|
|
151
|
+
})
|
|
152
|
+
.default(themeDefaults.statusBar),
|
|
153
|
+
tree: z
|
|
154
|
+
.object({
|
|
155
|
+
leaf: ForegroundHighlightConfigSchema.default(themeDefaults.tree.leaf),
|
|
156
|
+
branch: ForegroundHighlightConfigSchema.default(themeDefaults.tree.branch),
|
|
157
|
+
folded: ForegroundHighlightConfigSchema.default(themeDefaults.tree.folded),
|
|
158
|
+
cursorLine: BackgroundHighlightConfigSchema.default(themeDefaults.tree.cursorLine),
|
|
159
|
+
indentGuide: OptionalForegroundHighlightConfigSchema.default(themeDefaults.tree.indentGuide),
|
|
160
|
+
})
|
|
161
|
+
.default(themeDefaults.tree),
|
|
162
|
+
feedbackBar: z
|
|
163
|
+
.object({
|
|
164
|
+
message: ForegroundBackgroundHighlightConfigSchema.default(themeDefaults.feedbackBar.message),
|
|
165
|
+
success: ForegroundBackgroundHighlightConfigSchema.default(themeDefaults.feedbackBar.success),
|
|
166
|
+
error: ForegroundBackgroundHighlightConfigSchema.default(themeDefaults.feedbackBar.error),
|
|
167
|
+
})
|
|
168
|
+
.default(themeDefaults.feedbackBar),
|
|
169
|
+
});
|
|
170
|
+
export const defaultTheme = ThemeSchema.parse({});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* View names are also used as filenames.
|
|
4
|
+
*
|
|
5
|
+
* We intentionally keep the accepted format human-readable instead of
|
|
6
|
+
* encoding names into opaque filenames. The restrictions are mostly for
|
|
7
|
+
* portability between POSIX and Windows filesystems:
|
|
8
|
+
*
|
|
9
|
+
* - no path separators or control characters;
|
|
10
|
+
* - no Windows-invalid filename characters;
|
|
11
|
+
* - no leading/trailing whitespace;
|
|
12
|
+
* - no trailing periods or spaces;
|
|
13
|
+
* - no "." or "..";
|
|
14
|
+
* - no Windows device names such as "CON" or "NUL";
|
|
15
|
+
* - limited length.
|
|
16
|
+
*/
|
|
17
|
+
export declare const viewNameSchema: z.ZodString;
|
|
18
|
+
//# sourceMappingURL=view-name-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-name-schema.d.ts","sourceRoot":"","sources":["../../src/domain/view-name-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2BxB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,aA8BxB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const windowsReservedNames = new Set([
|
|
3
|
+
'CON',
|
|
4
|
+
'PRN',
|
|
5
|
+
'AUX',
|
|
6
|
+
'NUL',
|
|
7
|
+
'COM1',
|
|
8
|
+
'COM2',
|
|
9
|
+
'COM3',
|
|
10
|
+
'COM4',
|
|
11
|
+
'COM5',
|
|
12
|
+
'COM6',
|
|
13
|
+
'COM7',
|
|
14
|
+
'COM8',
|
|
15
|
+
'COM9',
|
|
16
|
+
'LPT1',
|
|
17
|
+
'LPT2',
|
|
18
|
+
'LPT3',
|
|
19
|
+
'LPT4',
|
|
20
|
+
'LPT5',
|
|
21
|
+
'LPT6',
|
|
22
|
+
'LPT7',
|
|
23
|
+
'LPT8',
|
|
24
|
+
'LPT9',
|
|
25
|
+
]);
|
|
26
|
+
/**
|
|
27
|
+
* View names are also used as filenames.
|
|
28
|
+
*
|
|
29
|
+
* We intentionally keep the accepted format human-readable instead of
|
|
30
|
+
* encoding names into opaque filenames. The restrictions are mostly for
|
|
31
|
+
* portability between POSIX and Windows filesystems:
|
|
32
|
+
*
|
|
33
|
+
* - no path separators or control characters;
|
|
34
|
+
* - no Windows-invalid filename characters;
|
|
35
|
+
* - no leading/trailing whitespace;
|
|
36
|
+
* - no trailing periods or spaces;
|
|
37
|
+
* - no "." or "..";
|
|
38
|
+
* - no Windows device names such as "CON" or "NUL";
|
|
39
|
+
* - limited length.
|
|
40
|
+
*/
|
|
41
|
+
export const viewNameSchema = z
|
|
42
|
+
.string()
|
|
43
|
+
.min(1, 'View name cannot be empty.')
|
|
44
|
+
.max(100, 'View name cannot be longer than 100 characters.')
|
|
45
|
+
.refine((name) => name === name.trim(), {
|
|
46
|
+
message: 'View name cannot start or end with whitespace.',
|
|
47
|
+
})
|
|
48
|
+
.refine((name) => name !== '.' && name !== '..', {
|
|
49
|
+
message: 'View name cannot be "." or "..".',
|
|
50
|
+
})
|
|
51
|
+
.refine((name) => !/[\/\\]/u.test(name), {
|
|
52
|
+
message: 'View name cannot contain path separators.',
|
|
53
|
+
})
|
|
54
|
+
.refine((name) => !/[\u0000-\u001f\u007f]/u.test(name), {
|
|
55
|
+
message: 'View name cannot contain control characters.',
|
|
56
|
+
})
|
|
57
|
+
.refine((name) => !/[<>:"|?*]/u.test(name), {
|
|
58
|
+
message: 'View name contains a character that is not portable.',
|
|
59
|
+
})
|
|
60
|
+
.refine((name) => !/[. ]$/u.test(name), {
|
|
61
|
+
message: 'View name cannot end with a period or space.',
|
|
62
|
+
})
|
|
63
|
+
.refine((name) => {
|
|
64
|
+
const basename = name.split('.')[0].toUpperCase();
|
|
65
|
+
return !windowsReservedNames.has(basename);
|
|
66
|
+
}, {
|
|
67
|
+
message: 'View name is reserved by Windows.',
|
|
68
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { Theme } from './domain/theme.js';
|
|
2
|
+
export type { Config } from './domain/config.js';
|
|
3
|
+
export type { Initialization } from './domain/initialization.js';
|
|
4
|
+
export type { PublicInitApi } from './domain/public-init-api.js';
|
|
5
|
+
export type { ExCommand } from './domain/ex-command.js';
|
|
6
|
+
export type { ShellApi } from './domain/shell-api.js';
|
|
7
|
+
export { AppPackageReference } from './domain/app-pack-ref.js';
|
|
8
|
+
export type { PackageLoader } from './application/package-loader.js';
|
|
9
|
+
export { createInitRuntime } from './application/init-runtime.js';
|
|
10
|
+
export { createAppApi } from './application/create-app-api.js';
|
|
11
|
+
export type { ViewRow } from './ui/view.js';
|
|
12
|
+
export { View } from './ui/view.js';
|
|
13
|
+
export { viewNameSchema } from './domain/view-name-schema.js';
|
|
14
|
+
export type { LoadingScreenRenderer } from './ui/loading-screen-renderer.js';
|
|
15
|
+
export { colorConfigToInkColor } from './ui/color-resolver.js';
|
|
16
|
+
export type { AppScreenProps, AppScreenRenderer, } from './ui/app-screen-renderer.js';
|
|
17
|
+
export { Shell } from './ui/Shell.js';
|
|
18
|
+
export type { InitialAppOptions } from './ui/Shell.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,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
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AppPackageReference } from './domain/app-pack-ref.js';
|
|
2
|
+
export { createInitRuntime } from './application/init-runtime.js';
|
|
3
|
+
export { createAppApi } from './application/create-app-api.js';
|
|
4
|
+
export { View } from './ui/view.js';
|
|
5
|
+
export { viewNameSchema } from './domain/view-name-schema.js';
|
|
6
|
+
export { colorConfigToInkColor } from './ui/color-resolver.js';
|
|
7
|
+
export { Shell } from './ui/Shell.js';
|