@caelo-cms/shared 0.10.22 → 0.10.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-tools.d.ts +290 -214
- package/dist/ai-tools.d.ts.map +1 -1
- package/dist/ai-tools.js +341 -264
- package/dist/ai-tools.js.map +1 -1
- package/dist/auth-forms.d.ts.map +1 -1
- package/dist/auth-forms.js +4 -1
- package/dist/auth-forms.js.map +1 -1
- package/dist/base-css.d.ts +24 -0
- package/dist/base-css.d.ts.map +1 -0
- package/dist/base-css.js +28 -0
- package/dist/base-css.js.map +1 -0
- package/dist/build-page.d.ts +330 -0
- package/dist/build-page.d.ts.map +1 -0
- package/dist/build-page.js +282 -0
- package/dist/build-page.js.map +1 -0
- package/dist/content.d.ts +322 -9
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +354 -11
- package/dist/content.js.map +1 -1
- package/dist/css-gradient-scan.d.ts +14 -0
- package/dist/css-gradient-scan.d.ts.map +1 -0
- package/dist/css-gradient-scan.js +81 -0
- package/dist/css-gradient-scan.js.map +1 -0
- package/dist/css-var-scan.d.ts +56 -0
- package/dist/css-var-scan.d.ts.map +1 -0
- package/dist/css-var-scan.js +97 -0
- package/dist/css-var-scan.js.map +1 -0
- package/dist/design-manifest.d.ts +36 -0
- package/dist/design-manifest.d.ts.map +1 -0
- package/dist/design-manifest.js +90 -0
- package/dist/design-manifest.js.map +1 -0
- package/dist/fonts.d.ts +89 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +241 -0
- package/dist/fonts.js.map +1 -0
- package/dist/genesis-inventory.d.ts +32 -0
- package/dist/genesis-inventory.d.ts.map +1 -0
- package/dist/genesis-inventory.js +186 -0
- package/dist/genesis-inventory.js.map +1 -0
- package/dist/genesis.d.ts +62 -0
- package/dist/genesis.d.ts.map +1 -0
- package/dist/genesis.js +78 -0
- package/dist/genesis.js.map +1 -0
- package/dist/i18n.d.ts +44 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +72 -6
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/interactions.d.ts +23 -0
- package/dist/interactions.d.ts.map +1 -0
- package/dist/interactions.js +44 -0
- package/dist/interactions.js.map +1 -0
- package/dist/media.d.ts +101 -16
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +126 -15
- package/dist/media.js.map +1 -1
- package/dist/page-log.d.ts +94 -0
- package/dist/page-log.d.ts.map +1 -0
- package/dist/page-log.js +111 -0
- package/dist/page-log.js.map +1 -0
- package/dist/preview-compose.d.ts +79 -0
- package/dist/preview-compose.d.ts.map +1 -1
- package/dist/preview-compose.js +155 -25
- package/dist/preview-compose.js.map +1 -1
- package/dist/proposal-status.d.ts +40 -0
- package/dist/proposal-status.d.ts.map +1 -0
- package/dist/proposal-status.js +34 -0
- package/dist/proposal-status.js.map +1 -0
- package/dist/responsive-images.d.ts +64 -0
- package/dist/responsive-images.d.ts.map +1 -0
- package/dist/responsive-images.js +98 -0
- package/dist/responsive-images.js.map +1 -0
- package/dist/safe-keys.d.ts +9 -0
- package/dist/safe-keys.d.ts.map +1 -0
- package/dist/safe-keys.js +20 -0
- package/dist/safe-keys.js.map +1 -0
- package/dist/seo.d.ts +8 -0
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +3 -1
- package/dist/seo.js.map +1 -1
- package/dist/skills.d.ts +14 -68
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +19 -113
- package/dist/skills.js.map +1 -1
- package/dist/strip-cdata.d.ts +7 -0
- package/dist/strip-cdata.d.ts.map +1 -0
- package/dist/strip-cdata.js +48 -0
- package/dist/strip-cdata.js.map +1 -0
- package/dist/structured-sets.d.ts +6 -16
- package/dist/structured-sets.d.ts.map +1 -1
- package/dist/structured-sets.js +5 -16
- package/dist/structured-sets.js.map +1 -1
- package/dist/subagents.d.ts +105 -3
- package/dist/subagents.d.ts.map +1 -1
- package/dist/subagents.js +224 -41
- package/dist/subagents.js.map +1 -1
- package/dist/template-engine.d.ts +85 -0
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/template-engine.js +403 -0
- package/dist/template-engine.js.map +1 -0
- package/dist/theme-importers/auto-detect.d.ts +26 -0
- package/dist/theme-importers/auto-detect.d.ts.map +1 -0
- package/dist/theme-importers/auto-detect.js +42 -0
- package/dist/theme-importers/auto-detect.js.map +1 -0
- package/dist/theme-importers/css-comments.d.ts +12 -0
- package/dist/theme-importers/css-comments.d.ts.map +1 -0
- package/dist/theme-importers/css-comments.js +15 -0
- package/dist/theme-importers/css-comments.js.map +1 -0
- package/dist/theme-importers/dtcg.d.ts +46 -0
- package/dist/theme-importers/dtcg.d.ts.map +1 -0
- package/dist/theme-importers/dtcg.js +111 -0
- package/dist/theme-importers/dtcg.js.map +1 -0
- package/dist/theme-importers/loose.d.ts +3 -0
- package/dist/theme-importers/loose.d.ts.map +1 -0
- package/dist/theme-importers/loose.js +76 -0
- package/dist/theme-importers/loose.js.map +1 -0
- package/dist/theme-importers/shadcn.d.ts +24 -0
- package/dist/theme-importers/shadcn.d.ts.map +1 -0
- package/dist/theme-importers/shadcn.js +135 -0
- package/dist/theme-importers/shadcn.js.map +1 -0
- package/dist/theme-importers/style-dictionary.d.ts +17 -0
- package/dist/theme-importers/style-dictionary.d.ts.map +1 -0
- package/dist/theme-importers/style-dictionary.js +125 -0
- package/dist/theme-importers/style-dictionary.js.map +1 -0
- package/dist/theme-importers/tailwind.d.ts +3 -0
- package/dist/theme-importers/tailwind.d.ts.map +1 -0
- package/dist/theme-importers/tailwind.js +218 -0
- package/dist/theme-importers/tailwind.js.map +1 -0
- package/dist/theme-literal-binding.d.ts +37 -0
- package/dist/theme-literal-binding.d.ts.map +1 -0
- package/dist/theme-literal-binding.js +138 -0
- package/dist/theme-literal-binding.js.map +1 -0
- package/dist/theme-normalize.d.ts +31 -0
- package/dist/theme-normalize.d.ts.map +1 -0
- package/dist/theme-normalize.js +587 -0
- package/dist/theme-normalize.js.map +1 -0
- package/dist/theme-ramp.d.ts +55 -0
- package/dist/theme-ramp.d.ts.map +1 -0
- package/dist/theme-ramp.js +149 -0
- package/dist/theme-ramp.js.map +1 -0
- package/dist/theme-render.d.ts +105 -0
- package/dist/theme-render.d.ts.map +1 -0
- package/dist/theme-render.js +441 -0
- package/dist/theme-render.js.map +1 -0
- package/dist/themes-errors.d.ts +109 -0
- package/dist/themes-errors.d.ts.map +1 -0
- package/dist/themes-errors.js +170 -0
- package/dist/themes-errors.js.map +1 -0
- package/dist/themes.d.ts +343 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +697 -0
- package/dist/themes.js.map +1 -0
- package/dist/version.d.ts +7 -4
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +6 -3
- package/dist/version.js.map +1 -1
- package/package.json +10 -2
- package/src/__tests__/redos-hardening.test.ts +160 -0
- package/src/ai-tools-add-module-modes.test.ts +106 -0
- package/src/ai-tools-position.test.ts +134 -0
- package/src/ai-tools.test.ts +81 -0
- package/src/ai-tools.ts +1179 -0
- package/src/auth-forms.ts +36 -0
- package/src/base-css.ts +30 -0
- package/src/build-page.test.ts +228 -0
- package/src/build-page.ts +319 -0
- package/src/cap-failures.ts +67 -0
- package/src/content.test.ts +170 -0
- package/src/content.ts +620 -0
- package/src/context.ts +43 -0
- package/src/css-gradient-scan.ts +88 -0
- package/src/css-var-scan.test.ts +96 -0
- package/src/css-var-scan.ts +144 -0
- package/src/derive-module-type.test.ts +80 -0
- package/src/design-manifest.ts +93 -0
- package/src/fonts.test.ts +157 -0
- package/src/fonts.ts +296 -0
- package/src/genesis-inventory.test.ts +86 -0
- package/src/genesis-inventory.ts +215 -0
- package/src/genesis-sanitize.test.ts +35 -0
- package/src/genesis.ts +87 -0
- package/src/i18n.test.ts +274 -0
- package/src/i18n.ts +269 -0
- package/src/index.test.ts +10 -0
- package/src/index.ts +59 -0
- package/src/interactions.ts +48 -0
- package/src/logger.ts +147 -0
- package/src/media.test.ts +160 -0
- package/src/media.ts +355 -0
- package/src/page-log.test.ts +163 -0
- package/src/page-log.ts +124 -0
- package/src/preview-compose.test.ts +602 -0
- package/src/preview-compose.ts +709 -0
- package/src/preview-scanner.test.ts +96 -0
- package/src/preview-scanner.ts +214 -0
- package/src/proposal-status.test.ts +69 -0
- package/src/proposal-status.ts +40 -0
- package/src/responsive-images.test.ts +104 -0
- package/src/responsive-images.ts +151 -0
- package/src/result.ts +29 -0
- package/src/safe-keys.ts +21 -0
- package/src/seo.test.ts +234 -0
- package/src/seo.ts +261 -0
- package/src/skills.ts +48 -0
- package/src/snapshots.test.ts +80 -0
- package/src/snapshots.ts +81 -0
- package/src/strip-cdata.test.ts +41 -0
- package/src/strip-cdata.ts +50 -0
- package/src/structured-sets.ts +180 -0
- package/src/subagents.test.ts +262 -0
- package/src/subagents.ts +432 -0
- package/src/template-engine.test.ts +379 -0
- package/src/template-engine.ts +520 -0
- package/src/theme-gradient.test.ts +92 -0
- package/src/theme-importers/__tests__/proto-pollution.test.ts +54 -0
- package/src/theme-importers/auto-detect.ts +84 -0
- package/src/theme-importers/css-comments.ts +15 -0
- package/src/theme-importers/dtcg.ts +106 -0
- package/src/theme-importers/loose.ts +76 -0
- package/src/theme-importers/shadcn.ts +133 -0
- package/src/theme-importers/style-dictionary.ts +125 -0
- package/src/theme-importers/tailwind.ts +217 -0
- package/src/theme-literal-binding.test.ts +71 -0
- package/src/theme-literal-binding.ts +159 -0
- package/src/theme-motion.test.ts +115 -0
- package/src/theme-normalize-envelope.test.ts +43 -0
- package/src/theme-normalize-gradient.test.ts +135 -0
- package/src/theme-normalize.ts +661 -0
- package/src/theme-ramp.ts +187 -0
- package/src/theme-render-sanitize.test.ts +45 -0
- package/src/theme-render.test.ts +119 -0
- package/src/theme-render.ts +487 -0
- package/src/theme-shadow.test.ts +56 -0
- package/src/themes-errors.ts +199 -0
- package/src/themes.ts +842 -0
- package/src/translation.test.ts +160 -0
- package/src/translation.ts +295 -0
- package/src/version.ts +66 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* issue #153 regression — gradient tokens must be settable end to end.
|
|
4
|
+
*
|
|
5
|
+
* Two live-run failures this covers (the #1 red-error class in migration
|
|
6
|
+
* chat):
|
|
7
|
+
*
|
|
8
|
+
* 1. `UnknownTokenName: cannot infer canonical path for 'gradient'` —
|
|
9
|
+
* the normalizer had no gradient category, so every loose gradient
|
|
10
|
+
* name (`gradient`, `heroGradient`, `gradient.hero`) threw.
|
|
11
|
+
* 2. `theme document invalid after edit: … gradient token invalid:
|
|
12
|
+
* expected "gradient"` — a gradient written to `gradient.hero` got
|
|
13
|
+
* `$type: "dimension"` because `inferTypeFromPath` had no gradient
|
|
14
|
+
* case and fell through to sniffing the (unrecognised) gradient
|
|
15
|
+
* string.
|
|
16
|
+
*
|
|
17
|
+
* The assertions therefore exercise BOTH the normalizer's canonical-path
|
|
18
|
+
* + $type inference AND the exact document validator that produced
|
|
19
|
+
* error #2 (`validateThemeTokens`).
|
|
20
|
+
*/
|
|
21
|
+
import { describe, expect, it } from "bun:test";
|
|
22
|
+
import { normalizeTokens } from "./theme-normalize.js";
|
|
23
|
+
import { applyDtcgWrites, validateThemeTokens } from "./themes.js";
|
|
24
|
+
|
|
25
|
+
const HERO_CSS = "linear-gradient(135deg, #4f46e5, #7c3aed)";
|
|
26
|
+
|
|
27
|
+
/** Normalize → apply → validate, returning the written leaf. */
|
|
28
|
+
function roundTrip(set: Record<string, unknown>): { leaf: unknown; path: string } {
|
|
29
|
+
const normalized = normalizeTokens(set);
|
|
30
|
+
const path = normalized.canonicalPaths[0]!;
|
|
31
|
+
const doc = applyDtcgWrites({}, normalized.set, normalized.types);
|
|
32
|
+
// The exact validator that threw `gradient token invalid` in prod.
|
|
33
|
+
const validated = validateThemeTokens(doc);
|
|
34
|
+
const leaf = (validated.gradient as Record<string, unknown>)?.[path.split(".")[1]!];
|
|
35
|
+
return { leaf, path };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe("normalizeTokens — gradient canonicalisation (#153)", () => {
|
|
39
|
+
it.each([
|
|
40
|
+
["gradient", "gradient.hero"],
|
|
41
|
+
["heroGradient", "gradient.hero"],
|
|
42
|
+
["gradientHero", "gradient.hero"],
|
|
43
|
+
["gradient.hero", "gradient.hero"],
|
|
44
|
+
["gradient.subtle", "gradient.subtle"],
|
|
45
|
+
["--gradient-hero", "gradient.hero"],
|
|
46
|
+
])("canonicalises loose name %p → %p with $type gradient", (name, expectedPath) => {
|
|
47
|
+
const r = normalizeTokens({ [name]: HERO_CSS });
|
|
48
|
+
expect(r.canonicalPaths).toEqual([expectedPath]);
|
|
49
|
+
expect(r.types[expectedPath]).toBe("gradient");
|
|
50
|
+
expect(r.set[expectedPath]).toBe(HERO_CSS);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("no longer throws UnknownTokenName for a bare `gradient` name", () => {
|
|
54
|
+
expect(() => normalizeTokens({ gradient: HERO_CSS })).not.toThrow();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("gradient tokens pass the DTCG document validator (#153)", () => {
|
|
59
|
+
it("bare CSS string on a loose name validates as $type gradient", () => {
|
|
60
|
+
const { leaf } = roundTrip({ heroGradient: HERO_CSS });
|
|
61
|
+
expect(leaf).toEqual({ $value: HERO_CSS, $type: "gradient" });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("direct DTCG path `gradient.hero` no longer stamps $type dimension (error #2)", () => {
|
|
65
|
+
const { leaf } = roundTrip({ "gradient.hero": HERO_CSS });
|
|
66
|
+
expect(leaf).toEqual({ $value: HERO_CSS, $type: "gradient" });
|
|
67
|
+
// The precise regression: $type must be the literal "gradient".
|
|
68
|
+
expect((leaf as Record<string, unknown>).$type).toBe("gradient");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("accepts the full DTCG envelope the tool guidance documents", () => {
|
|
72
|
+
const { leaf } = roundTrip({
|
|
73
|
+
"gradient.hero": { $type: "gradient", $value: HERO_CSS },
|
|
74
|
+
});
|
|
75
|
+
expect(leaf).toEqual({ $value: HERO_CSS, $type: "gradient" });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("accepts a JSON-encoded envelope string", () => {
|
|
79
|
+
const { leaf } = roundTrip({
|
|
80
|
+
"gradient.hero": JSON.stringify({ $type: "gradient", $value: HERO_CSS }),
|
|
81
|
+
});
|
|
82
|
+
expect(leaf).toEqual({ $value: HERO_CSS, $type: "gradient" });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("folds a structured {type, angle, stops} object into a CSS string", () => {
|
|
86
|
+
const { leaf } = roundTrip({
|
|
87
|
+
"gradient.hero": {
|
|
88
|
+
type: "linear",
|
|
89
|
+
angle: 135,
|
|
90
|
+
stops: [{ color: "#4f46e5" }, { color: "#7c3aed", position: 100 }],
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
expect(leaf).toEqual({
|
|
94
|
+
$value: "linear-gradient(135deg, #4f46e5, #7c3aed 100%)",
|
|
95
|
+
$type: "gradient",
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("defaults a bare {stops} structured object to a diagonal linear sweep", () => {
|
|
100
|
+
const { leaf } = roundTrip({
|
|
101
|
+
"gradient.subtle": { stops: ["#ffffff", "#f1f5f9"] },
|
|
102
|
+
});
|
|
103
|
+
expect(leaf).toEqual({
|
|
104
|
+
$value: "linear-gradient(135deg, #ffffff, #f1f5f9)",
|
|
105
|
+
$type: "gradient",
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("renders a radial gradient without inventing an angle", () => {
|
|
110
|
+
const { leaf } = roundTrip({
|
|
111
|
+
"gradient.hero": { type: "radial", stops: ["#4f46e5", "#7c3aed"] },
|
|
112
|
+
});
|
|
113
|
+
expect(leaf).toEqual({
|
|
114
|
+
$value: "radial-gradient(#4f46e5, #7c3aed)",
|
|
115
|
+
$type: "gradient",
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("gradient value-shape guards stay loud (#153, CLAUDE.md §2)", () => {
|
|
121
|
+
it("rejects a flat color sent to a gradient path with a category mismatch", () => {
|
|
122
|
+
expect(() => normalizeTokens({ "gradient.hero": "#4f46e5" })).toThrow(
|
|
123
|
+
/dimension|color|gradient/i,
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("a structured object with no usable stops falls through to the doc validator", () => {
|
|
128
|
+
const normalized = normalizeTokens({ "gradient.hero": { stops: [] } });
|
|
129
|
+
// Not fabricated into a gradient — the object passes through…
|
|
130
|
+
expect(typeof normalized.set["gradient.hero"]).toBe("object");
|
|
131
|
+
// …and the document validator rejects it loudly.
|
|
132
|
+
const doc = applyDtcgWrites({}, normalized.set, normalized.types);
|
|
133
|
+
expect(() => validateThemeTokens(doc)).toThrow(/gradient/i);
|
|
134
|
+
});
|
|
135
|
+
});
|