@promptctl/rich-js 0.1.0 → 0.2.0

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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shared internal helpers for the rich-js template binding layer.
3
+ *
4
+ * [LAW:one-source-of-truth] `applyStyleToFragment` is the single implementation
5
+ * of "apply a Style to an existing RichText fragment." Both the style-function
6
+ * registrations and the palette-function registrations use this same operation;
7
+ * keeping one copy prevents the two from drifting.
8
+ */
9
+ import { Style } from "../core/style.js";
10
+ import { RichText } from "../core/text.js";
11
+ /**
12
+ * Apply a style on top of an already-styled RichText fragment.
13
+ *
14
+ * [LAW:single-enforcer] Type validation lives here; callers trust the result.
15
+ * The `"liftable"` arg type lifts string literals to `RichText` via the
16
+ * engine's `fromString` before the body runs, so `child` is always a
17
+ * `RichText` by the time this runs. The instanceof check exists because
18
+ * `"liftable"` admits any non-primitive — the engine cannot prove the object
19
+ * is the binding's own `T`. Misuse (`{{ red someMap }}`) fails loudly here
20
+ * rather than producing a malformed fragment.
21
+ *
22
+ * Conflict resolution: `Style.add` — the outer (newly applied) style wins.
23
+ */
24
+ export declare function applyStyleToFragment(child: unknown, style: Style): RichText;
25
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/template-bindings/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAS3E"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared internal helpers for the rich-js template binding layer.
3
+ *
4
+ * [LAW:one-source-of-truth] `applyStyleToFragment` is the single implementation
5
+ * of "apply a Style to an existing RichText fragment." Both the style-function
6
+ * registrations and the palette-function registrations use this same operation;
7
+ * keeping one copy prevents the two from drifting.
8
+ */
9
+ import { RichText } from "../core/text.js";
10
+ /**
11
+ * Apply a style on top of an already-styled RichText fragment.
12
+ *
13
+ * [LAW:single-enforcer] Type validation lives here; callers trust the result.
14
+ * The `"liftable"` arg type lifts string literals to `RichText` via the
15
+ * engine's `fromString` before the body runs, so `child` is always a
16
+ * `RichText` by the time this runs. The instanceof check exists because
17
+ * `"liftable"` admits any non-primitive — the engine cannot prove the object
18
+ * is the binding's own `T`. Misuse (`{{ red someMap }}`) fails loudly here
19
+ * rather than producing a malformed fragment.
20
+ *
21
+ * Conflict resolution: `Style.add` — the outer (newly applied) style wins.
22
+ */
23
+ export function applyStyleToFragment(child, style) {
24
+ if (!(child instanceof RichText)) {
25
+ throw new TypeError(`template function expected a RichText fragment, got ${typeof child === "object" ? Object.prototype.toString.call(child) : typeof child}`);
26
+ }
27
+ const result = child.copy();
28
+ result.style = child.style.add(style);
29
+ return result;
30
+ }
31
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/template-bindings/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,KAAY;IAC/D,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CACjB,uDAAuD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAC1I,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,16 +1,21 @@
1
1
  /**
2
2
  * rich-js template bindings — public entry point.
3
3
  *
4
- * [LAW:one-source-of-truth] This module is the single place where rich-js's
5
- * styling vocabulary is exposed as `@promptctl/go-template-js` template
6
- * functions. The current registration set covers foreground colour
7
- * (named, palette index, hex, RGB), background (`on`), and text
8
- * attributes (canonical names, short aliases, `not_*` negations) — all
9
- * registered via `richTextStyleFuncs`. `link`, palette / theme /
10
- * auto-contrast helpers, and per-position hue rotation ship in follow-up
11
- * epics on the same `template-bindings` topic and merge into this same
12
- * map. Consumers compose templates against the Engine returned here;
13
- * nesting is plain function composition (`{{ red (bold "x") }}`), not a
4
+ * [LAW:one-source-of-truth] This module is the public entry point for
5
+ * rich-js's styling vocabulary as `@promptctl/go-template-js` template
6
+ * functions. Two complementary registrations are exported:
7
+ *
8
+ * - `richTextFuncs()` — foreground colours, background, text attributes, and
9
+ * `link`. Does not require configuration; safe to register unconditionally.
10
+ * - `paletteFuncs(resolver)` — semantic palette, auto-contrast, and extended
11
+ * spec forms. Requires a `PaletteResolver` argument bound to the active
12
+ * theme; consumers merge it alongside `richTextFuncs()`.
13
+ *
14
+ * `createRichTextEngine()` is convenience sugar that wires up `richTextFuncs()`
15
+ * only — it does not include `paletteFuncs`, because palette functions require
16
+ * a resolver the factory cannot supply. Consumers that need palette access
17
+ * call `paletteFuncs(resolver)` and merge it into their own engine config.
18
+ * Nesting is plain function composition (`{{ red (bold "x") }}`), not a
14
19
  * second markup grammar.
15
20
  *
16
21
  * Fragment type: `RichText`. Chosen because it is the library's primary
@@ -23,15 +28,14 @@
23
28
  */
24
29
  import { type Engine, type FuncMap } from "@promptctl/go-template-js";
25
30
  import { RichText } from "../core/text.js";
31
+ export { paletteFuncs } from "./palette-funcs.js";
26
32
  /**
27
- * Funcs registered by the rich-js binding. Style functions
28
- * (foreground / attribute / background) are populated by
29
- * `richTextStyleFuncs`; subsequent epics on the `template-bindings`
30
- * topic merge `link`, palette/theme/auto-contrast, and per-position
31
- * hue rotation into the same map. Exposed as a factory (not a const)
32
- * so future registrations that need configuration (e.g. a palette
33
- * resolver bound at construction time) have a place to receive
34
- * arguments without breaking the public shape.
33
+ * Funcs registered by the rich-js binding — style functions (foreground,
34
+ * background, attributes) and the `link` cell-splitter. Exposed as a factory
35
+ * so future registrations that need configuration have a place to receive
36
+ * arguments. Palette/theme/auto-contrast functions ship separately via
37
+ * `paletteFuncs(resolver)` and are merged at consumer side — they require a
38
+ * `PaletteResolver` argument and so cannot be included in this generic call.
35
39
  *
36
40
  * `FuncMap` is not parameterised over `T` in `@promptctl/go-template-js` — the engine's
37
41
  * `T` lives on the `Engine`/`EngineConfig`, and per-function input/output
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/template-bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAMvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/template-bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAMvD"}
@@ -1,16 +1,21 @@
1
1
  /**
2
2
  * rich-js template bindings — public entry point.
3
3
  *
4
- * [LAW:one-source-of-truth] This module is the single place where rich-js's
5
- * styling vocabulary is exposed as `@promptctl/go-template-js` template
6
- * functions. The current registration set covers foreground colour
7
- * (named, palette index, hex, RGB), background (`on`), and text
8
- * attributes (canonical names, short aliases, `not_*` negations) — all
9
- * registered via `richTextStyleFuncs`. `link`, palette / theme /
10
- * auto-contrast helpers, and per-position hue rotation ship in follow-up
11
- * epics on the same `template-bindings` topic and merge into this same
12
- * map. Consumers compose templates against the Engine returned here;
13
- * nesting is plain function composition (`{{ red (bold "x") }}`), not a
4
+ * [LAW:one-source-of-truth] This module is the public entry point for
5
+ * rich-js's styling vocabulary as `@promptctl/go-template-js` template
6
+ * functions. Two complementary registrations are exported:
7
+ *
8
+ * - `richTextFuncs()` — foreground colours, background, text attributes, and
9
+ * `link`. Does not require configuration; safe to register unconditionally.
10
+ * - `paletteFuncs(resolver)` — semantic palette, auto-contrast, and extended
11
+ * spec forms. Requires a `PaletteResolver` argument bound to the active
12
+ * theme; consumers merge it alongside `richTextFuncs()`.
13
+ *
14
+ * `createRichTextEngine()` is convenience sugar that wires up `richTextFuncs()`
15
+ * only — it does not include `paletteFuncs`, because palette functions require
16
+ * a resolver the factory cannot supply. Consumers that need palette access
17
+ * call `paletteFuncs(resolver)` and merge it into their own engine config.
18
+ * Nesting is plain function composition (`{{ red (bold "x") }}`), not a
14
19
  * second markup grammar.
15
20
  *
16
21
  * Fragment type: `RichText`. Chosen because it is the library's primary
@@ -24,15 +29,14 @@
24
29
  import { createEngine } from "@promptctl/go-template-js";
25
30
  import { RichText } from "../core/text.js";
26
31
  import { richTextStyleFuncs } from "./style-funcs.js";
32
+ export { paletteFuncs } from "./palette-funcs.js";
27
33
  /**
28
- * Funcs registered by the rich-js binding. Style functions
29
- * (foreground / attribute / background) are populated by
30
- * `richTextStyleFuncs`; subsequent epics on the `template-bindings`
31
- * topic merge `link`, palette/theme/auto-contrast, and per-position
32
- * hue rotation into the same map. Exposed as a factory (not a const)
33
- * so future registrations that need configuration (e.g. a palette
34
- * resolver bound at construction time) have a place to receive
35
- * arguments without breaking the public shape.
34
+ * Funcs registered by the rich-js binding — style functions (foreground,
35
+ * background, attributes) and the `link` cell-splitter. Exposed as a factory
36
+ * so future registrations that need configuration have a place to receive
37
+ * arguments. Palette/theme/auto-contrast functions ship separately via
38
+ * `paletteFuncs(resolver)` and are merged at consumer side — they require a
39
+ * `PaletteResolver` argument and so cannot be included in this generic call.
36
40
  *
37
41
  * `FuncMap` is not parameterised over `T` in `@promptctl/go-template-js` — the engine's
38
42
  * `T` lives on the `Engine`/`EngineConfig`, and per-function input/output
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/template-bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,YAAY,EAA6B,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,YAAY,CAAW;QAC5B,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK;QAC1B,KAAK,EAAE,aAAa,EAAE;KACvB,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/template-bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,YAAY,EAA6B,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,YAAY,CAAW;QAC5B,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK;QAC1B,KAAK,EAAE,aAAa,EAAE;KACvB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Palette / theme / auto-contrast function registrations for the rich-js
3
+ * template binding.
4
+ *
5
+ * [LAW:one-source-of-truth] All palette resolution flows through the existing
6
+ * `PaletteResolver.resolve(spec, ctx)` API — this module adds no resolution
7
+ * logic of its own. The template functions here are thin adaptors that translate
8
+ * function call arguments into a `(spec, ctx)` call and wrap the resulting
9
+ * `ColorRgba` as a `Style` applied to the child fragment.
10
+ *
11
+ * [LAW:dataflow-not-control-flow] Every function follows the same shape:
12
+ * resolve spec → apply as foreground color → return styled fragment. The
13
+ * variability is in the spec string and the optional against context; the
14
+ * operation is fixed.
15
+ *
16
+ * ### Surface design rationale
17
+ *
18
+ * Four layers of ergonomics:
19
+ *
20
+ * 1. **Semantic-name functions** — one function per palette variable whose
21
+ * name is a valid Go template identifier (no hyphens). `{{ primary child }}`,
22
+ * `{{ accent child }}`, etc. The happy path: common semantic names read
23
+ * cleanly in templates. Hyphenated names (`primary-muted`, `text-primary`)
24
+ * cannot be Go template identifiers and are accessed via `palette`.
25
+ *
26
+ * 2. **`palette "spec" child`** — the general-purpose function for any spec
27
+ * that does not need a background context (bare names and darken/lighten
28
+ * modifiers). Covers hyphenated names and modifier chains.
29
+ *
30
+ * 3. **`paletteOver "spec" "#bgHex" child`** — for specs that require a
31
+ * background context: alpha compositing (`"primary 50%"`) and auto-contrast
32
+ * (`"auto"`, `"auto 33%"`). The bg color is threaded as an explicit hex
33
+ * argument rather than via a scope side-channel — no mutable state, no
34
+ * closure magic; the data flows through the function call.
35
+ *
36
+ * 4. **`auto "#bgHex" child`** — syntactic sugar for
37
+ * `{{ paletteOver "auto" "#bgHex" child }}`, the common auto-contrast case.
38
+ *
39
+ * ### Theme switching
40
+ *
41
+ * `paletteFuncs(resolver)` captures `resolver` at construction time. Consumers
42
+ * that need runtime theme switching create a new `paletteFuncs()` from the new
43
+ * theme's resolver and rebuild their engine (or merge into a fresh `FuncMap`).
44
+ * The same template *source* produces different colors because the functions in
45
+ * the engine changed — the template text is the same, the resolver differs.
46
+ */
47
+ import type { FuncMap } from "@promptctl/go-template-js";
48
+ import { PaletteResolver } from "../themes/paletteResolver.js";
49
+ /**
50
+ * Build a `FuncMap` exposing the semantic palette of `resolver` as template
51
+ * functions. Merge into `richTextFuncs()` (or pass to `createEngine`) to make
52
+ * palette colors available in templates.
53
+ *
54
+ * Registered functions:
55
+ * - One function per palette variable whose name is a valid Go template
56
+ * identifier: `{{ primary child }}`, `{{ accent child }}`, etc.
57
+ * - `palette "spec" child` — any spec without background context.
58
+ * - `paletteOver "spec" "#bgHex" child` — any spec needing a background (alpha,
59
+ * auto-contrast).
60
+ * - `auto "#bgHex" child` — sugar for `paletteOver "auto" bgHex child`.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import { createEngine } from "@promptctl/go-template-js";
65
+ * import { GRUVBOX, PaletteResolver, RichText } from "rich-js";
66
+ * import { richTextFuncs, paletteFuncs } from "rich-js/template-bindings";
67
+ *
68
+ * const engine = createEngine({
69
+ * fromString: (s) => new RichText(s),
70
+ * toString: (rt) => rt.plain,
71
+ * funcs: { ...richTextFuncs(), ...paletteFuncs(new PaletteResolver(GRUVBOX.palette)) },
72
+ * });
73
+ * ```
74
+ */
75
+ export declare function paletteFuncs(resolver: PaletteResolver): FuncMap;
76
+ //# sourceMappingURL=palette-funcs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette-funcs.d.ts","sourceRoot":"","sources":["../../src/template-bindings/palette-funcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAIvE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAiG/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAO/D"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Palette / theme / auto-contrast function registrations for the rich-js
3
+ * template binding.
4
+ *
5
+ * [LAW:one-source-of-truth] All palette resolution flows through the existing
6
+ * `PaletteResolver.resolve(spec, ctx)` API — this module adds no resolution
7
+ * logic of its own. The template functions here are thin adaptors that translate
8
+ * function call arguments into a `(spec, ctx)` call and wrap the resulting
9
+ * `ColorRgba` as a `Style` applied to the child fragment.
10
+ *
11
+ * [LAW:dataflow-not-control-flow] Every function follows the same shape:
12
+ * resolve spec → apply as foreground color → return styled fragment. The
13
+ * variability is in the spec string and the optional against context; the
14
+ * operation is fixed.
15
+ *
16
+ * ### Surface design rationale
17
+ *
18
+ * Four layers of ergonomics:
19
+ *
20
+ * 1. **Semantic-name functions** — one function per palette variable whose
21
+ * name is a valid Go template identifier (no hyphens). `{{ primary child }}`,
22
+ * `{{ accent child }}`, etc. The happy path: common semantic names read
23
+ * cleanly in templates. Hyphenated names (`primary-muted`, `text-primary`)
24
+ * cannot be Go template identifiers and are accessed via `palette`.
25
+ *
26
+ * 2. **`palette "spec" child`** — the general-purpose function for any spec
27
+ * that does not need a background context (bare names and darken/lighten
28
+ * modifiers). Covers hyphenated names and modifier chains.
29
+ *
30
+ * 3. **`paletteOver "spec" "#bgHex" child`** — for specs that require a
31
+ * background context: alpha compositing (`"primary 50%"`) and auto-contrast
32
+ * (`"auto"`, `"auto 33%"`). The bg color is threaded as an explicit hex
33
+ * argument rather than via a scope side-channel — no mutable state, no
34
+ * closure magic; the data flows through the function call.
35
+ *
36
+ * 4. **`auto "#bgHex" child`** — syntactic sugar for
37
+ * `{{ paletteOver "auto" "#bgHex" child }}`, the common auto-contrast case.
38
+ *
39
+ * ### Theme switching
40
+ *
41
+ * `paletteFuncs(resolver)` captures `resolver` at construction time. Consumers
42
+ * that need runtime theme switching create a new `paletteFuncs()` from the new
43
+ * theme's resolver and rebuild their engine (or merge into a fresh `FuncMap`).
44
+ * The same template *source* produces different colors because the functions in
45
+ * the engine changed — the template text is the same, the resolver differs.
46
+ */
47
+ import { ColorSpec } from "../core/color.js";
48
+ import { Style } from "../core/style.js";
49
+ import { applyStyleToFragment } from "./helpers.js";
50
+ // Regex for validating hex bg strings accepted by `paletteOver` and `auto`.
51
+ // Accepts #RRGGBB and #RRGGBBAA — same gate as the `hex` style function.
52
+ const HEX_BG_RE = /^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/;
53
+ /**
54
+ * Convert a hex string to `ColorRgba`. Only #RRGGBB / #RRGGBBAA accepted.
55
+ * Throws `RangeError` on invalid input — surfaces as an `EvalError` in the
56
+ * template engine, giving the author a precise failure message.
57
+ */
58
+ function hexToColorRgba(hex) {
59
+ if (!HEX_BG_RE.test(hex)) {
60
+ throw new RangeError(`palette background expected #RRGGBB or #RRGGBBAA, got ${JSON.stringify(hex)}`);
61
+ }
62
+ // ColorSpec.parse("#RRGGBB") → TRUECOLOR spec; getTruecolor() returns value directly.
63
+ return ColorSpec.parse(hex).getTruecolor();
64
+ }
65
+ /**
66
+ * Resolve `spec` against the resolver (with optional background context) and
67
+ * apply the resulting color as a foreground `Style` on `child`.
68
+ *
69
+ * Throws on resolution failure with a contextual message — including a hint to
70
+ * use `paletteOver` when the spec needs a background but none was provided.
71
+ */
72
+ function resolveAndApply(resolver, spec, against, child) {
73
+ const color = resolver.resolve(spec, against !== undefined ? { against } : undefined);
74
+ if (color === null) {
75
+ const hint = against === undefined
76
+ ? "; for specs with alpha or auto-contrast, use paletteOver"
77
+ : "";
78
+ throw new Error(`palette spec ${JSON.stringify(spec)} did not resolve — check the spec string is valid and the variable exists${hint}`);
79
+ }
80
+ return applyStyleToFragment(child, new Style({ color: ColorSpec.fromRgba(color) }));
81
+ }
82
+ // [LAW:types-are-the-program] Only palette var names that are valid Go template
83
+ // identifiers (letter/underscore start, alphanumeric/underscore body) get
84
+ // individual functions. Hyphenated names like "primary-muted" parse as subtraction
85
+ // in Go template syntax and cannot be function names.
86
+ const IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
87
+ function semanticNameFuncs(resolver) {
88
+ const out = {};
89
+ for (const name of resolver.palette.vars.keys()) {
90
+ if (!IDENTIFIER_RE.test(name))
91
+ continue;
92
+ // [LAW:dataflow-not-control-flow] Capture name; same fn shape for every entry.
93
+ const captured = name;
94
+ out[captured] = {
95
+ fn: ((child) => resolveAndApply(resolver, captured, undefined, child)),
96
+ argTypes: ["liftable"],
97
+ returnType: "T",
98
+ };
99
+ }
100
+ return out;
101
+ }
102
+ function makePaletteFunc(resolver) {
103
+ return {
104
+ fn: ((spec, child) => resolveAndApply(resolver, spec, undefined, child)),
105
+ argTypes: ["string", "liftable"],
106
+ returnType: "T",
107
+ };
108
+ }
109
+ function makePaletteOverFunc(resolver) {
110
+ return {
111
+ fn: ((spec, bgHex, child) => resolveAndApply(resolver, spec, hexToColorRgba(bgHex), child)),
112
+ argTypes: ["string", "string", "liftable"],
113
+ returnType: "T",
114
+ };
115
+ }
116
+ function makeAutoFunc(resolver) {
117
+ return {
118
+ fn: ((bgHex, child) => resolveAndApply(resolver, "auto", hexToColorRgba(bgHex), child)),
119
+ argTypes: ["string", "liftable"],
120
+ returnType: "T",
121
+ };
122
+ }
123
+ /**
124
+ * Build a `FuncMap` exposing the semantic palette of `resolver` as template
125
+ * functions. Merge into `richTextFuncs()` (or pass to `createEngine`) to make
126
+ * palette colors available in templates.
127
+ *
128
+ * Registered functions:
129
+ * - One function per palette variable whose name is a valid Go template
130
+ * identifier: `{{ primary child }}`, `{{ accent child }}`, etc.
131
+ * - `palette "spec" child` — any spec without background context.
132
+ * - `paletteOver "spec" "#bgHex" child` — any spec needing a background (alpha,
133
+ * auto-contrast).
134
+ * - `auto "#bgHex" child` — sugar for `paletteOver "auto" bgHex child`.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * import { createEngine } from "@promptctl/go-template-js";
139
+ * import { GRUVBOX, PaletteResolver, RichText } from "rich-js";
140
+ * import { richTextFuncs, paletteFuncs } from "rich-js/template-bindings";
141
+ *
142
+ * const engine = createEngine({
143
+ * fromString: (s) => new RichText(s),
144
+ * toString: (rt) => rt.plain,
145
+ * funcs: { ...richTextFuncs(), ...paletteFuncs(new PaletteResolver(GRUVBOX.palette)) },
146
+ * });
147
+ * ```
148
+ */
149
+ export function paletteFuncs(resolver) {
150
+ return {
151
+ ...semanticNameFuncs(resolver),
152
+ palette: makePaletteFunc(resolver),
153
+ paletteOver: makePaletteOverFunc(resolver),
154
+ auto: makeAutoFunc(resolver),
155
+ };
156
+ }
157
+ //# sourceMappingURL=palette-funcs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette-funcs.js","sourceRoot":"","sources":["../../src/template-bindings/palette-funcs.ts"],"names":[],"mappings":"AAAA;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,GAAG;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,QAAyB;IAC7C,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,KAAa,EAAE,KAAc,EAAE,EAAE,CACrC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAuB;QACxF,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;QAChC,UAAU,EAAE,GAAG;KAChB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,YAAY,CAAC,QAAyB;IACpD,OAAO;QACL,GAAG,iBAAiB,CAAC,QAAQ,CAAC;QAC9B,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC;QAClC,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC;QAC1C,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;KAC7B,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"style-funcs.d.ts","sourceRoot":"","sources":["../../src/template-bindings/style-funcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAkKvE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAU5C"}
1
+ {"version":3,"file":"style-funcs.d.ts","sourceRoot":"","sources":["../../src/template-bindings/style-funcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAoIvE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAU5C"}
@@ -18,33 +18,7 @@
18
18
  */
19
19
  import { Style, ATTRIBUTE_NAMES, ATTRIBUTE_SHORT_ALIASES, } from "../core/style.js";
20
20
  import { ColorSpec, ANSI_COLOR_NAMES } from "../core/color.js";
21
- import { RichText } from "../core/text.js";
22
- // --- Helpers ---
23
- /**
24
- * Apply a style on top of an already-styled RichText fragment.
25
- *
26
- * The engine's `"liftable"` arg type lifts string literals to
27
- * `RichText` via the binding's `fromString` *before* the body runs,
28
- * so by the time we get here, `child` is always a `RichText`. The
29
- * defensive instanceof check exists because `"liftable"` admits any
30
- * non-primitive value — the engine cannot prove the object is the
31
- * binding's own `T`. A misuse (`{{ red someMap }}`) lands here and
32
- * fails loudly rather than producing a malformed fragment.
33
- *
34
- * Conflict resolution follows `Style.add`: the outer (newly applied)
35
- * style wins. `red (bold "x")` → bold + red; `red (red "x")` → red.
36
- * Spans inside the inner fragment are preserved as-is — their styles
37
- * compose with the new wrapper at render time via the segment
38
- * pipeline's existing additive semantics.
39
- */
40
- function applyStyleToFragment(child, style) {
41
- if (!(child instanceof RichText)) {
42
- throw new TypeError(`style function expected a RichText fragment, got ${typeof child === "object" ? Object.prototype.toString.call(child) : typeof child}`);
43
- }
44
- const result = child.copy();
45
- result.style = child.style.add(style);
46
- return result;
47
- }
21
+ import { applyStyleToFragment } from "./helpers.js";
48
22
  function fgFunc(style) {
49
23
  return {
50
24
  fn: ((child) => applyStyleToFragment(child, style)),
@@ -1 +1 @@
1
- {"version":3,"file":"style-funcs.js","sourceRoot":"","sources":["../../src/template-bindings/style-funcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,KAAK,EACL,eAAe,EACf,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,kBAAkB;AAElB;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,oBAAoB,CAAC,KAAc,EAAE,KAAY;IACxD,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,EAAE,CAAC;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AE1B;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,GAAG,eAAe,EAAE;QACpB,KAAK,EAAE,gBAAgB;QACvB,GAAG,EAAE,YAAY;QACjB,GAAG,EAAE,YAAY;QACjB,EAAE,EAAE,MAAM;QACV,GAAG,cAAc,EAAE;QACnB,IAAI,EAAE,QAAQ;KACf,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptctl/rich-js",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Rich text and beautiful formatting in the terminal — a TypeScript port of Python's Rich",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",