@hypercli/ui 0.1.1
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 +21 -0
- package/README.md +11 -0
- package/dist/capabilities/index.d.ts +62 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +182 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/colors.d.ts +32 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/components/columns.d.ts +28 -0
- package/dist/components/columns.d.ts.map +1 -0
- package/dist/components/columns.js +70 -0
- package/dist/components/columns.js.map +1 -0
- package/dist/components/confirmPrompt.d.ts +38 -0
- package/dist/components/confirmPrompt.d.ts.map +1 -0
- package/dist/components/confirmPrompt.js +109 -0
- package/dist/components/confirmPrompt.js.map +1 -0
- package/dist/components/diff.d.ts +37 -0
- package/dist/components/diff.d.ts.map +1 -0
- package/dist/components/diff.js +36 -0
- package/dist/components/diff.js.map +1 -0
- package/dist/components/helpLayout.d.ts +59 -0
- package/dist/components/helpLayout.d.ts.map +1 -0
- package/dist/components/helpLayout.js +103 -0
- package/dist/components/helpLayout.js.map +1 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +23 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/keyValue.d.ts +31 -0
- package/dist/components/keyValue.d.ts.map +1 -0
- package/dist/components/keyValue.js +36 -0
- package/dist/components/keyValue.js.map +1 -0
- package/dist/components/list.d.ts +30 -0
- package/dist/components/list.d.ts.map +1 -0
- package/dist/components/list.js +80 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/message.d.ts +33 -0
- package/dist/components/message.d.ts.map +1 -0
- package/dist/components/message.js +86 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/panel.d.ts +28 -0
- package/dist/components/panel.d.ts.map +1 -0
- package/dist/components/panel.js +30 -0
- package/dist/components/panel.js.map +1 -0
- package/dist/components/progressBar.d.ts +44 -0
- package/dist/components/progressBar.d.ts.map +1 -0
- package/dist/components/progressBar.js +154 -0
- package/dist/components/progressBar.js.map +1 -0
- package/dist/components/section.d.ts +22 -0
- package/dist/components/section.d.ts.map +1 -0
- package/dist/components/section.js +48 -0
- package/dist/components/section.js.map +1 -0
- package/dist/components/selectPrompt.d.ts +58 -0
- package/dist/components/selectPrompt.d.ts.map +1 -0
- package/dist/components/selectPrompt.js +206 -0
- package/dist/components/selectPrompt.js.map +1 -0
- package/dist/components/spinner.d.ts +38 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +125 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/statusList.d.ts +22 -0
- package/dist/components/statusList.d.ts.map +1 -0
- package/dist/components/statusList.js +43 -0
- package/dist/components/statusList.js.map +1 -0
- package/dist/components/table.d.ts +39 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +132 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/textPrompt.d.ts +43 -0
- package/dist/components/textPrompt.d.ts.map +1 -0
- package/dist/components/textPrompt.js +123 -0
- package/dist/components/textPrompt.js.map +1 -0
- package/dist/components/tree.d.ts +30 -0
- package/dist/components/tree.d.ts.map +1 -0
- package/dist/components/tree.js +49 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/ds-index.d.ts +113 -0
- package/dist/ds-index.d.ts.map +1 -0
- package/dist/ds-index.js +112 -0
- package/dist/ds-index.js.map +1 -0
- package/dist/help.d.ts +32 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +34 -0
- package/dist/help.js.map +1 -0
- package/dist/hyper-theme.d.ts +8 -0
- package/dist/hyper-theme.d.ts.map +1 -0
- package/dist/hyper-theme.js +30 -0
- package/dist/hyper-theme.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/md.d.ts +12 -0
- package/dist/md.d.ts.map +1 -0
- package/dist/md.js +19 -0
- package/dist/md.js.map +1 -0
- package/dist/messages.d.ts +20 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +65 -0
- package/dist/messages.js.map +1 -0
- package/dist/palette.d.ts +20 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +22 -0
- package/dist/palette.js.map +1 -0
- package/dist/primitives/align.d.ts +23 -0
- package/dist/primitives/align.d.ts.map +1 -0
- package/dist/primitives/align.js +40 -0
- package/dist/primitives/align.js.map +1 -0
- package/dist/primitives/badge.d.ts +24 -0
- package/dist/primitives/badge.d.ts.map +1 -0
- package/dist/primitives/badge.js +40 -0
- package/dist/primitives/badge.js.map +1 -0
- package/dist/primitives/border.d.ts +29 -0
- package/dist/primitives/border.d.ts.map +1 -0
- package/dist/primitives/border.js +100 -0
- package/dist/primitives/border.js.map +1 -0
- package/dist/primitives/context.d.ts +48 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +64 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/primitives/divider.d.ts +25 -0
- package/dist/primitives/divider.d.ts.map +1 -0
- package/dist/primitives/divider.js +56 -0
- package/dist/primitives/divider.js.map +1 -0
- package/dist/primitives/indent.d.ts +16 -0
- package/dist/primitives/indent.d.ts.map +1 -0
- package/dist/primitives/indent.js +25 -0
- package/dist/primitives/indent.js.map +1 -0
- package/dist/primitives/index.d.ts +32 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +22 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/line.d.ts +21 -0
- package/dist/primitives/line.d.ts.map +1 -0
- package/dist/primitives/line.js +29 -0
- package/dist/primitives/line.js.map +1 -0
- package/dist/primitives/markdown.d.ts +91 -0
- package/dist/primitives/markdown.d.ts.map +1 -0
- package/dist/primitives/markdown.js +62 -0
- package/dist/primitives/markdown.js.map +1 -0
- package/dist/primitives/pad.d.ts +24 -0
- package/dist/primitives/pad.d.ts.map +1 -0
- package/dist/primitives/pad.js +20 -0
- package/dist/primitives/pad.js.map +1 -0
- package/dist/primitives/stack.d.ts +22 -0
- package/dist/primitives/stack.d.ts.map +1 -0
- package/dist/primitives/stack.js +21 -0
- package/dist/primitives/stack.js.map +1 -0
- package/dist/primitives/styledText.d.ts +36 -0
- package/dist/primitives/styledText.d.ts.map +1 -0
- package/dist/primitives/styledText.js +42 -0
- package/dist/primitives/styledText.js.map +1 -0
- package/dist/primitives/symbol.d.ts +15 -0
- package/dist/primitives/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol.js +18 -0
- package/dist/primitives/symbol.js.map +1 -0
- package/dist/primitives/truncate.d.ts +23 -0
- package/dist/primitives/truncate.d.ts.map +1 -0
- package/dist/primitives/truncate.js +99 -0
- package/dist/primitives/truncate.js.map +1 -0
- package/dist/primitives/wrap.d.ts +23 -0
- package/dist/primitives/wrap.d.ts.map +1 -0
- package/dist/primitives/wrap.js +30 -0
- package/dist/primitives/wrap.js.map +1 -0
- package/dist/render/ansi-utils.d.ts +49 -0
- package/dist/render/ansi-utils.d.ts.map +1 -0
- package/dist/render/ansi-utils.js +405 -0
- package/dist/render/ansi-utils.js.map +1 -0
- package/dist/render/index.d.ts +11 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/sgr.d.ts +60 -0
- package/dist/render/sgr.d.ts.map +1 -0
- package/dist/render/sgr.js +191 -0
- package/dist/render/sgr.js.map +1 -0
- package/dist/render/strip.d.ts +24 -0
- package/dist/render/strip.d.ts.map +1 -0
- package/dist/render/strip.js +81 -0
- package/dist/render/strip.js.map +1 -0
- package/dist/render/width.d.ts +30 -0
- package/dist/render/width.d.ts.map +1 -0
- package/dist/render/width.js +149 -0
- package/dist/render/width.js.map +1 -0
- package/dist/shortcuts.d.ts +76 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +117 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/styles.d.ts +43 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +44 -0
- package/dist/styles.js.map +1 -0
- package/dist/symbols.d.ts +19 -0
- package/dist/symbols.d.ts.map +1 -0
- package/dist/symbols.js +21 -0
- package/dist/symbols.js.map +1 -0
- package/dist/test/compare.d.ts +28 -0
- package/dist/test/compare.d.ts.map +1 -0
- package/dist/test/compare.js +37 -0
- package/dist/test/compare.js.map +1 -0
- package/dist/test/index.d.ts +16 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +14 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mock.d.ts +50 -0
- package/dist/test/mock.d.ts.map +1 -0
- package/dist/test/mock.js +135 -0
- package/dist/test/mock.js.map +1 -0
- package/dist/test/render.d.ts +29 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +87 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/snapshot.d.ts +16 -0
- package/dist/test/snapshot.d.ts.map +1 -0
- package/dist/test/snapshot.js +216 -0
- package/dist/test/snapshot.js.map +1 -0
- package/dist/theme/builtins.d.ts +10 -0
- package/dist/theme/builtins.d.ts.map +1 -0
- package/dist/theme/builtins.js +102 -0
- package/dist/theme/builtins.js.map +1 -0
- package/dist/theme/engine.d.ts +51 -0
- package/dist/theme/engine.d.ts.map +1 -0
- package/dist/theme/engine.js +123 -0
- package/dist/theme/engine.js.map +1 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +12 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/merge.d.ts +24 -0
- package/dist/theme/merge.d.ts.map +1 -0
- package/dist/theme/merge.js +66 -0
- package/dist/theme/merge.js.map +1 -0
- package/dist/theme/types.d.ts +44 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +8 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme.d.ts +9 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +53 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens/defaults.d.ts +13 -0
- package/dist/tokens/defaults.d.ts.map +1 -0
- package/dist/tokens/defaults.js +248 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/tokens/index.d.ts +10 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +10 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/resolver.d.ts +100 -0
- package/dist/tokens/resolver.d.ts.map +1 -0
- package/dist/tokens/resolver.js +138 -0
- package/dist/tokens/resolver.js.map +1 -0
- package/dist/tokens/types.d.ts +265 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/dist/tokens/types.js +10 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/tokens.d.ts +26 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +30 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Context
|
|
3
|
+
*
|
|
4
|
+
* Provides a shared context object that holds the ThemeEngine and resolved
|
|
5
|
+
* tokens. Primitives read from this context instead of accepting tokens
|
|
6
|
+
* as parameters on every call.
|
|
7
|
+
*/
|
|
8
|
+
import type { TerminalCapabilities } from "../capabilities/index.ts";
|
|
9
|
+
import { ThemeEngine } from "../theme/index.ts";
|
|
10
|
+
import type { ThemeInput } from "../theme/index.ts";
|
|
11
|
+
import type { ResolvedTokens } from "../tokens/index.ts";
|
|
12
|
+
/** Shared state holding the active theme engine, terminal capabilities, and resolved tokens. */
|
|
13
|
+
export type SystemContext = {
|
|
14
|
+
/** The active theme engine instance. */
|
|
15
|
+
theme: ThemeEngine;
|
|
16
|
+
/** Detected or overridden terminal capabilities. */
|
|
17
|
+
capabilities: TerminalCapabilities;
|
|
18
|
+
/** Design tokens resolved by the theme engine. */
|
|
19
|
+
tokens: ResolvedTokens;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the current system context, auto-initializing with defaults on first use.
|
|
23
|
+
*
|
|
24
|
+
* @returns The active {@link SystemContext}.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const ctx = getContext()
|
|
29
|
+
* console.log(ctx.tokens.color.primary)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function getContext(): SystemContext;
|
|
33
|
+
/**
|
|
34
|
+
* Replaces the current system context with the provided one.
|
|
35
|
+
*
|
|
36
|
+
* @param ctx - The new system context to set as active.
|
|
37
|
+
*/
|
|
38
|
+
export declare function setContext(ctx: SystemContext): void;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new system context with specific capabilities and optional theme input.
|
|
41
|
+
* Useful for testing or rendering in non-default environments.
|
|
42
|
+
*
|
|
43
|
+
* @param capabilities - Partial terminal capabilities to merge with defaults.
|
|
44
|
+
* @param themeInput - Optional theme overrides to apply.
|
|
45
|
+
* @returns A new {@link SystemContext} configured with the given options.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createContext(capabilities?: Partial<TerminalCapabilities>, themeInput?: ThemeInput): SystemContext;
|
|
48
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/primitives/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,gGAAgG;AAChG,MAAM,MAAM,aAAa,GAAG;IAC3B,wCAAwC;IACxC,KAAK,EAAE,WAAW,CAAC;IACnB,oDAAoD;IACpD,YAAY,EAAE,oBAAoB,CAAC;IACnC,kDAAkD;IAClD,MAAM,EAAE,cAAc,CAAC;CACvB,CAAC;AAIF;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,aAAa,CAc1C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,YAAY,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAC5C,UAAU,CAAC,EAAE,UAAU,GACrB,aAAa,CAUf"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Context
|
|
3
|
+
*
|
|
4
|
+
* Provides a shared context object that holds the ThemeEngine and resolved
|
|
5
|
+
* tokens. Primitives read from this context instead of accepting tokens
|
|
6
|
+
* as parameters on every call.
|
|
7
|
+
*/
|
|
8
|
+
import { createCapabilities, detectCapabilities } from "../capabilities/index.js";
|
|
9
|
+
import { ThemeEngine } from "../theme/index.js";
|
|
10
|
+
let currentContext = null;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current system context, auto-initializing with defaults on first use.
|
|
13
|
+
*
|
|
14
|
+
* @returns The active {@link SystemContext}.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const ctx = getContext()
|
|
19
|
+
* console.log(ctx.tokens.color.primary)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function getContext() {
|
|
23
|
+
if (!currentContext) {
|
|
24
|
+
// Auto-initialize with defaults on first use
|
|
25
|
+
const capabilities = detectCapabilities();
|
|
26
|
+
const theme = new ThemeEngine(capabilities);
|
|
27
|
+
currentContext = {
|
|
28
|
+
theme,
|
|
29
|
+
capabilities,
|
|
30
|
+
get tokens() {
|
|
31
|
+
return theme.resolvedTokens;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return currentContext;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Replaces the current system context with the provided one.
|
|
39
|
+
*
|
|
40
|
+
* @param ctx - The new system context to set as active.
|
|
41
|
+
*/
|
|
42
|
+
export function setContext(ctx) {
|
|
43
|
+
currentContext = ctx;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new system context with specific capabilities and optional theme input.
|
|
47
|
+
* Useful for testing or rendering in non-default environments.
|
|
48
|
+
*
|
|
49
|
+
* @param capabilities - Partial terminal capabilities to merge with defaults.
|
|
50
|
+
* @param themeInput - Optional theme overrides to apply.
|
|
51
|
+
* @returns A new {@link SystemContext} configured with the given options.
|
|
52
|
+
*/
|
|
53
|
+
export function createContext(capabilities, themeInput) {
|
|
54
|
+
const caps = createCapabilities(capabilities);
|
|
55
|
+
const theme = new ThemeEngine(caps, themeInput);
|
|
56
|
+
return {
|
|
57
|
+
theme,
|
|
58
|
+
capabilities: caps,
|
|
59
|
+
get tokens() {
|
|
60
|
+
return theme.resolvedTokens;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/primitives/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAchD,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU;IACzB,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,6CAA6C;QAC7C,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC;QAC5C,cAAc,GAAG;YAChB,KAAK;YACL,YAAY;YACZ,IAAI,MAAM;gBACT,OAAO,KAAK,CAAC,cAAc,CAAC;YAC7B,CAAC;SACD,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAkB;IAC5C,cAAc,GAAG,GAAG,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC5B,YAA4C,EAC5C,UAAuB;IAEvB,MAAM,IAAI,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChD,OAAO;QACN,KAAK;QACL,YAAY,EAAE,IAAI;QAClB,IAAI,MAAM;YACT,OAAO,KAAK,CAAC,cAAc,CAAC;QAC7B,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* divider Primitive
|
|
3
|
+
*
|
|
4
|
+
* Renders a horizontal divider line with optional title. Supports
|
|
5
|
+
* multiple styles and gracefully degrades to ASCII.
|
|
6
|
+
*/
|
|
7
|
+
/** Options for rendering a horizontal divider. */
|
|
8
|
+
export type DividerOptions = {
|
|
9
|
+
/** Total width of the divider in columns. Defaults to terminal width or `layout.defaultWidth`. */
|
|
10
|
+
width?: number;
|
|
11
|
+
/** Visual style of the divider line. Defaults to `'line'`. */
|
|
12
|
+
style?: "line" | "dashed" | "heavy" | "blank";
|
|
13
|
+
/** Title text displayed inline within the divider. */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Alignment of the title within the divider. Defaults to `'left'`. */
|
|
16
|
+
titleAlign?: "left" | "center" | "right";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Renders a horizontal divider line, optionally with an inline title.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Divider configuration.
|
|
22
|
+
* @returns The divider string, or an empty string for the `'blank'` style.
|
|
23
|
+
*/
|
|
24
|
+
export declare function divider(options?: DividerOptions): string;
|
|
25
|
+
//# sourceMappingURL=divider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.d.ts","sourceRoot":"","sources":["../../src/primitives/divider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG;IAC5B,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAC9C,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACzC,CAAC;AAgBF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAmCxD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* divider Primitive
|
|
3
|
+
*
|
|
4
|
+
* Renders a horizontal divider line with optional title. Supports
|
|
5
|
+
* multiple styles and gracefully degrades to ASCII.
|
|
6
|
+
*/
|
|
7
|
+
import { stringWidth } from "../render/index.js";
|
|
8
|
+
import { getContext } from "./context.js";
|
|
9
|
+
/** Unicode divider characters keyed by style name. */
|
|
10
|
+
const UNICODE_CHARS = {
|
|
11
|
+
line: "\u2500", // ─
|
|
12
|
+
dashed: "\u254C", // ╌
|
|
13
|
+
heavy: "\u2501", // ━
|
|
14
|
+
};
|
|
15
|
+
/** ASCII fallback divider characters keyed by style name. */
|
|
16
|
+
const ASCII_CHARS = {
|
|
17
|
+
line: "-",
|
|
18
|
+
dashed: "-",
|
|
19
|
+
heavy: "=",
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Renders a horizontal divider line, optionally with an inline title.
|
|
23
|
+
*
|
|
24
|
+
* @param options - Divider configuration.
|
|
25
|
+
* @returns The divider string, or an empty string for the `'blank'` style.
|
|
26
|
+
*/
|
|
27
|
+
export function divider(options) {
|
|
28
|
+
const ctx = getContext();
|
|
29
|
+
const style = options?.style ?? "line";
|
|
30
|
+
const width = options?.width ?? ctx.capabilities.columns ?? ctx.tokens.layout.defaultWidth;
|
|
31
|
+
const titleAlign = options?.titleAlign ?? "left";
|
|
32
|
+
if (style === "blank")
|
|
33
|
+
return "";
|
|
34
|
+
const chars = ctx.capabilities.unicode ? UNICODE_CHARS : ASCII_CHARS;
|
|
35
|
+
const ch = chars[style];
|
|
36
|
+
if (!options?.title) {
|
|
37
|
+
return ch.repeat(width);
|
|
38
|
+
}
|
|
39
|
+
const title = ` ${options.title} `;
|
|
40
|
+
const titleWidth = stringWidth(title);
|
|
41
|
+
const available = width - titleWidth;
|
|
42
|
+
if (available <= 0) {
|
|
43
|
+
return ch.repeat(width);
|
|
44
|
+
}
|
|
45
|
+
if (titleAlign === "left") {
|
|
46
|
+
return ch.repeat(2) + title + ch.repeat(available - 2);
|
|
47
|
+
}
|
|
48
|
+
if (titleAlign === "right") {
|
|
49
|
+
return ch.repeat(available - 2) + title + ch.repeat(2);
|
|
50
|
+
}
|
|
51
|
+
// center
|
|
52
|
+
const left = Math.floor(available / 2);
|
|
53
|
+
const right = available - left;
|
|
54
|
+
return ch.repeat(left) + title + ch.repeat(right);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.js","sourceRoot":"","sources":["../../src/primitives/divider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C,sDAAsD;AACtD,MAAM,aAAa,GAA2B;IAC7C,IAAI,EAAE,QAAQ,EAAE,IAAI;IACpB,MAAM,EAAE,QAAQ,EAAE,IAAI;IACtB,KAAK,EAAE,QAAQ,EAAE,IAAI;CACrB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,WAAW,GAA2B;IAC3C,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAwB;IAC/C,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IAC3F,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,MAAM,CAAC;IAEjD,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,EAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC;IACrE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAE,CAAC;IAEzB,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC;IACnC,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC;IAErC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,SAAS;IACT,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* indent Primitive
|
|
3
|
+
*
|
|
4
|
+
* Prepends indentation spaces to each line of content based on
|
|
5
|
+
* the resolved space.indent token.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Indents each line of content by a number of indent levels.
|
|
9
|
+
* The indent size per level is determined by the `space.indent` token.
|
|
10
|
+
*
|
|
11
|
+
* @param content - The text content to indent (may contain newlines).
|
|
12
|
+
* @param level - Number of indent levels to apply. Defaults to `1`.
|
|
13
|
+
* @returns The indented text string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function indent(content: string, level?: number): string;
|
|
16
|
+
//# sourceMappingURL=indent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../src/primitives/indent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CASzD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* indent Primitive
|
|
3
|
+
*
|
|
4
|
+
* Prepends indentation spaces to each line of content based on
|
|
5
|
+
* the resolved space.indent token.
|
|
6
|
+
*/
|
|
7
|
+
import { getContext } from "./context.js";
|
|
8
|
+
/**
|
|
9
|
+
* Indents each line of content by a number of indent levels.
|
|
10
|
+
* The indent size per level is determined by the `space.indent` token.
|
|
11
|
+
*
|
|
12
|
+
* @param content - The text content to indent (may contain newlines).
|
|
13
|
+
* @param level - Number of indent levels to apply. Defaults to `1`.
|
|
14
|
+
* @returns The indented text string.
|
|
15
|
+
*/
|
|
16
|
+
export function indent(content, level = 1) {
|
|
17
|
+
const ctx = getContext();
|
|
18
|
+
const indentSize = ctx.tokens.space.indent;
|
|
19
|
+
const prefix = " ".repeat(level * indentSize);
|
|
20
|
+
return content
|
|
21
|
+
.split("\n")
|
|
22
|
+
.map((line) => prefix + line)
|
|
23
|
+
.join("\n");
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=indent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indent.js","sourceRoot":"","sources":["../../src/primitives/indent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,OAAe,EAAE,KAAK,GAAG,CAAC;IAChD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC;IAE9C,OAAO,OAAO;SACZ,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitives — Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* The 13 atomic building blocks plus context management.
|
|
5
|
+
*/
|
|
6
|
+
export { getContext, setContext, createContext } from "./context.ts";
|
|
7
|
+
export type { SystemContext } from "./context.ts";
|
|
8
|
+
export { styledText } from "./styledText.ts";
|
|
9
|
+
export type { StyledTextOptions } from "./styledText.ts";
|
|
10
|
+
export { symbol } from "./symbol.ts";
|
|
11
|
+
export { pad } from "./pad.ts";
|
|
12
|
+
export type { PadOptions } from "./pad.ts";
|
|
13
|
+
export { truncate } from "./truncate.ts";
|
|
14
|
+
export type { TruncateOptions } from "./truncate.ts";
|
|
15
|
+
export { align } from "./align.ts";
|
|
16
|
+
export type { AlignOptions } from "./align.ts";
|
|
17
|
+
export { line } from "./line.ts";
|
|
18
|
+
export type { LinePart } from "./line.ts";
|
|
19
|
+
export { stack } from "./stack.ts";
|
|
20
|
+
export type { StackOptions } from "./stack.ts";
|
|
21
|
+
export { indent } from "./indent.ts";
|
|
22
|
+
export { wrap } from "./wrap.ts";
|
|
23
|
+
export type { WrapOptions } from "./wrap.ts";
|
|
24
|
+
export { border } from "./border.ts";
|
|
25
|
+
export type { BorderOptions } from "./border.ts";
|
|
26
|
+
export { divider } from "./divider.ts";
|
|
27
|
+
export type { DividerOptions } from "./divider.ts";
|
|
28
|
+
export { badge } from "./badge.ts";
|
|
29
|
+
export type { BadgeOptions } from "./badge.ts";
|
|
30
|
+
export { markdown, defaultMarkdownTheme } from "./markdown.ts";
|
|
31
|
+
export type { MarkdownTheme, MarkdownOptions, HeadingStyle } from "./markdown.ts";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitives — Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* The 13 atomic building blocks plus context management.
|
|
5
|
+
*/
|
|
6
|
+
// Context
|
|
7
|
+
export { getContext, setContext, createContext } from "./context.js";
|
|
8
|
+
// Primitives
|
|
9
|
+
export { styledText } from "./styledText.js";
|
|
10
|
+
export { symbol } from "./symbol.js";
|
|
11
|
+
export { pad } from "./pad.js";
|
|
12
|
+
export { truncate } from "./truncate.js";
|
|
13
|
+
export { align } from "./align.js";
|
|
14
|
+
export { line } from "./line.js";
|
|
15
|
+
export { stack } from "./stack.js";
|
|
16
|
+
export { indent } from "./indent.js";
|
|
17
|
+
export { wrap } from "./wrap.js";
|
|
18
|
+
export { border } from "./border.js";
|
|
19
|
+
export { divider } from "./divider.js";
|
|
20
|
+
export { badge } from "./badge.js";
|
|
21
|
+
export { markdown, defaultMarkdownTheme } from "./markdown.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU;AACV,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGrE,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* line Primitive
|
|
3
|
+
*
|
|
4
|
+
* Composes a single horizontal line from parts. String parts are
|
|
5
|
+
* concatenated directly. Tuple [string, number] parts pad the string
|
|
6
|
+
* to the given column width.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A segment of a line: either a plain string or a `[text, columnWidth]` tuple
|
|
10
|
+
* that pads the text to a fixed column width.
|
|
11
|
+
*/
|
|
12
|
+
export type LinePart = string | [string, number];
|
|
13
|
+
/**
|
|
14
|
+
* Composes a horizontal line by concatenating parts.
|
|
15
|
+
* Tuple parts are padded to their specified column width.
|
|
16
|
+
*
|
|
17
|
+
* @param parts - Line segments to compose.
|
|
18
|
+
* @returns The composed line string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function line(...parts: LinePart[]): string;
|
|
21
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../src/primitives/line.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAWjD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* line Primitive
|
|
3
|
+
*
|
|
4
|
+
* Composes a single horizontal line from parts. String parts are
|
|
5
|
+
* concatenated directly. Tuple [string, number] parts pad the string
|
|
6
|
+
* to the given column width.
|
|
7
|
+
*/
|
|
8
|
+
import { ansiPad } from "../render/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* Composes a horizontal line by concatenating parts.
|
|
11
|
+
* Tuple parts are padded to their specified column width.
|
|
12
|
+
*
|
|
13
|
+
* @param parts - Line segments to compose.
|
|
14
|
+
* @returns The composed line string.
|
|
15
|
+
*/
|
|
16
|
+
export function line(...parts) {
|
|
17
|
+
let result = "";
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
if (typeof part === "string") {
|
|
20
|
+
result += part;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const [text, colWidth] = part;
|
|
24
|
+
result += ansiPad(text, colWidth);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/primitives/line.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAQ7C;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG,KAAiB;IACxC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;YAC9B,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* markdown Primitive
|
|
3
|
+
*
|
|
4
|
+
* Renders markdown text to styled terminal output. This is the design system's
|
|
5
|
+
* rich text rendering primitive — scope item #16 (Markdown/Rich Text Rendering).
|
|
6
|
+
*
|
|
7
|
+
* The underlying rendering engine is an opaque implementation detail.
|
|
8
|
+
* Consumers interact only with the MarkdownTheme type defined here.
|
|
9
|
+
*
|
|
10
|
+
* Degradation chain:
|
|
11
|
+
* - Truecolor terminals: full color + styling
|
|
12
|
+
* - 256-color terminals: mapped palette
|
|
13
|
+
* - 16-color terminals: named ANSI colors
|
|
14
|
+
* - No color / dumb: plain text passthrough
|
|
15
|
+
*/
|
|
16
|
+
/** Style specification for a heading level. */
|
|
17
|
+
export interface HeadingStyle {
|
|
18
|
+
/** Color specification string (e.g. 'blue bold', 'yellow'). */
|
|
19
|
+
color?: string;
|
|
20
|
+
/** Optional indicator marker shown before the heading. */
|
|
21
|
+
indicator?: {
|
|
22
|
+
/** The marker character (e.g. '▶︎', '▸'). */
|
|
23
|
+
marker?: string;
|
|
24
|
+
/** Color specification for the marker. */
|
|
25
|
+
color?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Theme for markdown rendering — controls how each element is styled. */
|
|
29
|
+
export interface MarkdownTheme {
|
|
30
|
+
/** Heading styles (h1-h6). Can be a color string or full HeadingStyle object. */
|
|
31
|
+
h1?: string | HeadingStyle;
|
|
32
|
+
h2?: string | HeadingStyle;
|
|
33
|
+
h3?: string | HeadingStyle;
|
|
34
|
+
h4?: string | HeadingStyle;
|
|
35
|
+
h5?: string | HeadingStyle;
|
|
36
|
+
h6?: string | HeadingStyle;
|
|
37
|
+
/** Inline code and code block styling. */
|
|
38
|
+
code?: {
|
|
39
|
+
/** Color for inline code spans. */
|
|
40
|
+
color?: string;
|
|
41
|
+
/** Code block styling. */
|
|
42
|
+
block?: {
|
|
43
|
+
/** Color for code block text. */
|
|
44
|
+
color?: string;
|
|
45
|
+
/** Line number configuration. */
|
|
46
|
+
numbers?: {
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** Table styling. */
|
|
52
|
+
table?: {
|
|
53
|
+
/** Header row styling. */
|
|
54
|
+
header?: {
|
|
55
|
+
color?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/** Link styling. */
|
|
59
|
+
a?: {
|
|
60
|
+
color?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Options for the markdown rendering function. */
|
|
64
|
+
export interface MarkdownOptions {
|
|
65
|
+
/** Custom theme overriding the default. */
|
|
66
|
+
theme?: MarkdownTheme;
|
|
67
|
+
}
|
|
68
|
+
/** The default markdown theme matching HyperDev's brand. */
|
|
69
|
+
export declare const defaultMarkdownTheme: MarkdownTheme;
|
|
70
|
+
/**
|
|
71
|
+
* Renders a markdown string to styled terminal output.
|
|
72
|
+
*
|
|
73
|
+
* This is the design system's rich text primitive. It converts standard
|
|
74
|
+
* markdown (headings, code blocks, tables, links, etc.) into ANSI-styled
|
|
75
|
+
* terminal text using the provided or default theme.
|
|
76
|
+
*
|
|
77
|
+
* @param input - The markdown string to render.
|
|
78
|
+
* @param options - Optional rendering configuration.
|
|
79
|
+
* @returns The styled terminal string.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* // With defaults
|
|
84
|
+
* console.log(markdown('# Hello\n\nSome **bold** text'))
|
|
85
|
+
*
|
|
86
|
+
* // With custom theme
|
|
87
|
+
* console.log(markdown('# Hello', { theme: { h1: 'green bold' } }))
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function markdown(input: string, options?: MarkdownOptions): string;
|
|
91
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/primitives/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC5B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,SAAS,CAAC,EAAE;QACX,6CAA6C;QAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,0CAA0C;QAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACF;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC7B,iFAAiF;IACjF,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC3B,0CAA0C;IAC1C,IAAI,CAAC,EAAE;QACN,mCAAmC;QACnC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,0BAA0B;QAC1B,KAAK,CAAC,EAAE;YACP,iCAAiC;YACjC,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,iCAAiC;YACjC,OAAO,CAAC,EAAE;gBAAE,OAAO,CAAC,EAAE,OAAO,CAAA;aAAE,CAAC;SAChC,CAAC;KACF,CAAC;IACF,qBAAqB;IACrB,KAAK,CAAC,EAAE;QACP,0BAA0B;QAC1B,MAAM,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC5B,CAAC;IACF,oBAAoB;IACpB,CAAC,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvB;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC/B,2CAA2C;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;CACtB;AAMD,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,EAAE,aAUlC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CAKzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* markdown Primitive
|
|
3
|
+
*
|
|
4
|
+
* Renders markdown text to styled terminal output. This is the design system's
|
|
5
|
+
* rich text rendering primitive — scope item #16 (Markdown/Rich Text Rendering).
|
|
6
|
+
*
|
|
7
|
+
* The underlying rendering engine is an opaque implementation detail.
|
|
8
|
+
* Consumers interact only with the MarkdownTheme type defined here.
|
|
9
|
+
*
|
|
10
|
+
* Degradation chain:
|
|
11
|
+
* - Truecolor terminals: full color + styling
|
|
12
|
+
* - 256-color terminals: mapped palette
|
|
13
|
+
* - 16-color terminals: named ANSI colors
|
|
14
|
+
* - No color / dumb: plain text passthrough
|
|
15
|
+
*/
|
|
16
|
+
// Internal implementation — the rendering engine is an opaque dependency
|
|
17
|
+
import { renderMarkdown as renderEngine } from "cli-html";
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Default theme — Hyper's brand-consistent markdown rendering
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/** The default markdown theme matching HyperDev's brand. */
|
|
22
|
+
export const defaultMarkdownTheme = {
|
|
23
|
+
h1: { color: "blue bold", indicator: { marker: "\u25b6\ufe0e", color: "blue bold" } },
|
|
24
|
+
h2: { color: "yellow bold", indicator: { marker: "\u25b8", color: "yellow bold" } },
|
|
25
|
+
h3: { color: "white bold", indicator: { marker: "\u25b9", color: "white bold" } },
|
|
26
|
+
code: {
|
|
27
|
+
color: "hex-4EC9B0",
|
|
28
|
+
block: { color: "gray", numbers: { enabled: false } },
|
|
29
|
+
},
|
|
30
|
+
table: { header: { color: "white bold" } },
|
|
31
|
+
a: { color: "cyan underline" },
|
|
32
|
+
};
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Render function
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Renders a markdown string to styled terminal output.
|
|
38
|
+
*
|
|
39
|
+
* This is the design system's rich text primitive. It converts standard
|
|
40
|
+
* markdown (headings, code blocks, tables, links, etc.) into ANSI-styled
|
|
41
|
+
* terminal text using the provided or default theme.
|
|
42
|
+
*
|
|
43
|
+
* @param input - The markdown string to render.
|
|
44
|
+
* @param options - Optional rendering configuration.
|
|
45
|
+
* @returns The styled terminal string.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* // With defaults
|
|
50
|
+
* console.log(markdown('# Hello\n\nSome **bold** text'))
|
|
51
|
+
*
|
|
52
|
+
* // With custom theme
|
|
53
|
+
* console.log(markdown('# Hello', { theme: { h1: 'green bold' } }))
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function markdown(input, options) {
|
|
57
|
+
const theme = options?.theme ?? defaultMarkdownTheme;
|
|
58
|
+
// The engine accepts the theme object directly — our MarkdownTheme is a
|
|
59
|
+
// strict subset of its internal type, so this cast is safe.
|
|
60
|
+
return renderEngine(input, theme);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/primitives/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,yEAAyE;AACzE,OAAO,EAAE,cAAc,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AAuD1D,8EAA8E;AAC9E,8DAA8D;AAC9D,8EAA8E;AAE9E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IAClD,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;IACrF,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE;IACnF,EAAE,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;IACjF,IAAI,EAAE;QACL,KAAK,EAAE,YAAY;QACnB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;KACrD;IACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;IAC1C,CAAC,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;CAC9B,CAAC;AAEF,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,OAAyB;IAChE,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,oBAAoB,CAAC;IACrD,wEAAwE;IACxE,4DAA4D;IAC5D,OAAO,YAAY,CAAC,KAAK,EAAE,KAAY,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pad Primitive
|
|
3
|
+
*
|
|
4
|
+
* Adds left and/or right padding to a string using a configurable
|
|
5
|
+
* fill character.
|
|
6
|
+
*/
|
|
7
|
+
/** Options for adding padding to text. */
|
|
8
|
+
export type PadOptions = {
|
|
9
|
+
/** Number of padding characters to prepend. Defaults to `0`. */
|
|
10
|
+
left?: number;
|
|
11
|
+
/** Number of padding characters to append. Defaults to `0`. */
|
|
12
|
+
right?: number;
|
|
13
|
+
/** Character used for padding. Defaults to `' '`. */
|
|
14
|
+
char?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Pads a string with a fill character on the left and/or right.
|
|
18
|
+
*
|
|
19
|
+
* @param text - The text to pad.
|
|
20
|
+
* @param options - Padding configuration.
|
|
21
|
+
* @returns The padded text string.
|
|
22
|
+
*/
|
|
23
|
+
export declare function pad(text: string, options?: PadOptions): string;
|
|
24
|
+
//# sourceMappingURL=pad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../../src/primitives/pad.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,UAAU,GAAG;IACxB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAM9D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pad Primitive
|
|
3
|
+
*
|
|
4
|
+
* Adds left and/or right padding to a string using a configurable
|
|
5
|
+
* fill character.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Pads a string with a fill character on the left and/or right.
|
|
9
|
+
*
|
|
10
|
+
* @param text - The text to pad.
|
|
11
|
+
* @param options - Padding configuration.
|
|
12
|
+
* @returns The padded text string.
|
|
13
|
+
*/
|
|
14
|
+
export function pad(text, options) {
|
|
15
|
+
const left = options?.left ?? 0;
|
|
16
|
+
const right = options?.right ?? 0;
|
|
17
|
+
const ch = options?.char ?? " ";
|
|
18
|
+
return ch.repeat(left) + text + ch.repeat(right);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=pad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../../src/primitives/pad.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,OAAoB;IACrD,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,OAAO,EAAE,IAAI,IAAI,GAAG,CAAC;IAEhC,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stack Primitive
|
|
3
|
+
*
|
|
4
|
+
* Joins lines vertically with configurable spacing and an optional
|
|
5
|
+
* prefix prepended to each line.
|
|
6
|
+
*/
|
|
7
|
+
/** Options for vertical stacking of lines. */
|
|
8
|
+
export type StackOptions = {
|
|
9
|
+
/** Number of blank lines to insert between each content line. Defaults to `0`. */
|
|
10
|
+
spacing?: number;
|
|
11
|
+
/** String to prepend to every line. */
|
|
12
|
+
prefix?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Joins lines vertically with optional spacing and a per-line prefix.
|
|
16
|
+
*
|
|
17
|
+
* @param lines - The lines to stack vertically.
|
|
18
|
+
* @param options - Stacking configuration.
|
|
19
|
+
* @returns The joined multi-line string.
|
|
20
|
+
*/
|
|
21
|
+
export declare function stack(lines: string[], options?: StackOptions): string;
|
|
22
|
+
//# sourceMappingURL=stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/primitives/stack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG;IAC1B,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAQrE"}
|