@fluid-app/rep-core 0.1.14 → 0.1.15
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/chunk-CKQMccvm.cjs +28 -0
- package/dist/data-sources/DataAwareWidget.cjs +47 -56
- package/dist/data-sources/DataAwareWidget.cjs.map +1 -1
- package/dist/data-sources/DataAwareWidget.d.cts +27 -19
- package/dist/data-sources/DataAwareWidget.d.cts.map +1 -0
- package/dist/data-sources/DataAwareWidget.d.mts +38 -0
- package/dist/data-sources/DataAwareWidget.d.mts.map +1 -0
- package/dist/data-sources/DataAwareWidget.mjs +48 -0
- package/dist/data-sources/DataAwareWidget.mjs.map +1 -0
- package/dist/data-sources/ErrorState.cjs +18 -10
- package/dist/data-sources/ErrorState.cjs.map +1 -1
- package/dist/data-sources/ErrorState.d.cts +5 -3
- package/dist/data-sources/ErrorState.d.cts.map +1 -0
- package/dist/data-sources/ErrorState.d.mts +7 -0
- package/dist/data-sources/ErrorState.d.mts.map +1 -0
- package/dist/data-sources/ErrorState.mjs +18 -0
- package/dist/data-sources/ErrorState.mjs.map +1 -0
- package/dist/data-sources/context.cjs +22 -14
- package/dist/data-sources/context.cjs.map +1 -1
- package/dist/data-sources/context.d.cts +16 -10
- package/dist/data-sources/context.d.cts.map +1 -0
- package/dist/data-sources/context.d.mts +22 -0
- package/dist/data-sources/context.d.mts.map +1 -0
- package/dist/data-sources/context.mjs +21 -0
- package/dist/data-sources/context.mjs.map +1 -0
- package/dist/data-sources/fetchers/api.cjs +63 -10
- package/dist/data-sources/fetchers/api.cjs.map +1 -1
- package/dist/data-sources/fetchers/api.d.cts +4 -2
- package/dist/data-sources/fetchers/api.d.cts.map +1 -0
- package/dist/data-sources/fetchers/api.d.mts +10 -0
- package/dist/data-sources/fetchers/api.d.mts.map +1 -0
- package/dist/data-sources/fetchers/api.mjs +64 -0
- package/dist/data-sources/fetchers/api.mjs.map +1 -0
- package/dist/data-sources/fetchers/custom.cjs +106 -10
- package/dist/data-sources/fetchers/custom.cjs.map +1 -1
- package/dist/data-sources/fetchers/custom.d.cts +4 -2
- package/dist/data-sources/fetchers/custom.d.cts.map +1 -0
- package/dist/data-sources/fetchers/{custom.d.ts → custom.d.mts} +4 -2
- package/dist/data-sources/fetchers/custom.d.mts.map +1 -0
- package/dist/data-sources/fetchers/custom.mjs +107 -0
- package/dist/data-sources/fetchers/custom.mjs.map +1 -0
- package/dist/data-sources/fetchers/static.cjs +159 -14
- package/dist/data-sources/fetchers/static.cjs.map +1 -1
- package/dist/data-sources/fetchers/static.d.cts +12 -10
- package/dist/data-sources/fetchers/static.d.cts.map +1 -0
- package/dist/data-sources/fetchers/{static.d.ts → static.d.mts} +12 -10
- package/dist/data-sources/fetchers/static.d.mts.map +1 -0
- package/dist/data-sources/fetchers/static.mjs +158 -0
- package/dist/data-sources/fetchers/static.mjs.map +1 -0
- package/dist/data-sources/preview-context.cjs +15 -15
- package/dist/data-sources/preview-context.cjs.map +1 -1
- package/dist/data-sources/preview-context.d.cts +10 -6
- package/dist/data-sources/preview-context.d.cts.map +1 -0
- package/dist/data-sources/preview-context.d.mts +15 -0
- package/dist/data-sources/preview-context.d.mts.map +1 -0
- package/dist/data-sources/preview-context.mjs +18 -0
- package/dist/data-sources/preview-context.mjs.map +1 -0
- package/dist/data-sources/registry-context.cjs +51 -24
- package/dist/data-sources/registry-context.cjs.map +1 -1
- package/dist/data-sources/registry-context.d.cts +30 -22
- package/dist/data-sources/registry-context.d.cts.map +1 -0
- package/dist/data-sources/registry-context.d.mts +49 -0
- package/dist/data-sources/registry-context.d.mts.map +1 -0
- package/dist/data-sources/registry-context.mjs +49 -0
- package/dist/data-sources/registry-context.mjs.map +1 -0
- package/dist/data-sources/registry.cjs +29 -18
- package/dist/data-sources/registry.cjs.map +1 -1
- package/dist/data-sources/registry.d.cts +9 -7
- package/dist/data-sources/registry.d.cts.map +1 -0
- package/dist/data-sources/registry.d.mts +19 -0
- package/dist/data-sources/registry.d.mts.map +1 -0
- package/dist/data-sources/registry.mjs +29 -0
- package/dist/data-sources/registry.mjs.map +1 -0
- package/dist/data-sources/transformers.cjs +152 -10
- package/dist/data-sources/transformers.cjs.map +1 -1
- package/dist/data-sources/transformers.d.cts +4 -17
- package/dist/data-sources/transformers.d.cts.map +1 -0
- package/dist/data-sources/transformers.d.mts +10 -0
- package/dist/data-sources/transformers.d.mts.map +1 -0
- package/dist/data-sources/transformers.mjs +153 -0
- package/dist/data-sources/transformers.mjs.map +1 -0
- package/dist/data-sources/types.cjs +0 -4
- package/dist/data-sources/types.d.cts +2 -157
- package/dist/data-sources/types.d.mts +2 -0
- package/dist/data-sources/types.mjs +1 -0
- package/dist/data-sources/use-widget-data.cjs +109 -17
- package/dist/data-sources/use-widget-data.cjs.map +1 -1
- package/dist/data-sources/use-widget-data.d.cts +9 -8
- package/dist/data-sources/use-widget-data.d.cts.map +1 -0
- package/dist/data-sources/use-widget-data.d.mts +17 -0
- package/dist/data-sources/use-widget-data.d.mts.map +1 -0
- package/dist/data-sources/use-widget-data.mjs +109 -0
- package/dist/data-sources/use-widget-data.mjs.map +1 -0
- package/dist/index-Bxe_LIi8.d.cts +287 -0
- package/dist/index-Bxe_LIi8.d.cts.map +1 -0
- package/dist/index-CCAu2n19.d.mts +287 -0
- package/dist/index-CCAu2n19.d.mts.map +1 -0
- package/dist/registries/index.cjs +212 -127
- package/dist/registries/index.cjs.map +1 -1
- package/dist/registries/index.d.cts +146 -149
- package/dist/registries/index.d.cts.map +1 -0
- package/dist/registries/{index.d.ts → index.d.mts} +146 -149
- package/dist/registries/index.d.mts.map +1 -0
- package/dist/registries/index.mjs +229 -0
- package/dist/registries/index.mjs.map +1 -0
- package/dist/shell/AppShellLayout.cjs +47 -12
- package/dist/shell/AppShellLayout.cjs.map +1 -1
- package/dist/shell/AppShellLayout.d.cts +29 -19
- package/dist/shell/AppShellLayout.d.cts.map +1 -0
- package/dist/shell/AppShellLayout.d.mts +40 -0
- package/dist/shell/AppShellLayout.d.mts.map +1 -0
- package/dist/shell/AppShellLayout.mjs +46 -0
- package/dist/{chunk-45BCVWQK.cjs.map → shell/AppShellLayout.mjs.map} +1 -1
- package/dist/shell/ScreenHeader.cjs +44 -0
- package/dist/shell/ScreenHeader.cjs.map +1 -0
- package/dist/shell/ScreenHeader.d.cts +12 -0
- package/dist/shell/ScreenHeader.d.cts.map +1 -0
- package/dist/shell/ScreenHeader.d.mts +12 -0
- package/dist/shell/ScreenHeader.d.mts.map +1 -0
- package/dist/shell/ScreenHeader.mjs +42 -0
- package/dist/shell/ScreenHeader.mjs.map +1 -0
- package/dist/shell/ScreenHeaderContext.cjs +91 -0
- package/dist/shell/ScreenHeaderContext.cjs.map +1 -0
- package/dist/shell/ScreenHeaderContext.d.cts +36 -0
- package/dist/shell/ScreenHeaderContext.d.cts.map +1 -0
- package/dist/shell/ScreenHeaderContext.d.mts +36 -0
- package/dist/shell/ScreenHeaderContext.d.mts.map +1 -0
- package/dist/shell/ScreenHeaderContext.mjs +86 -0
- package/dist/shell/ScreenHeaderContext.mjs.map +1 -0
- package/dist/shell/ThemeModeContext.cjs +68 -18
- package/dist/shell/ThemeModeContext.cjs.map +1 -1
- package/dist/shell/ThemeModeContext.d.cts +23 -16
- package/dist/shell/ThemeModeContext.d.cts.map +1 -0
- package/dist/shell/ThemeModeContext.d.mts +34 -0
- package/dist/shell/ThemeModeContext.d.mts.map +1 -0
- package/dist/shell/ThemeModeContext.mjs +66 -0
- package/dist/shell/ThemeModeContext.mjs.map +1 -0
- package/dist/shell/index.cjs +43 -205
- package/dist/shell/index.d.cts +7 -43
- package/dist/shell/index.d.mts +7 -0
- package/dist/shell/index.mjs +7 -0
- package/dist/shell/sidebar.cjs +372 -87
- package/dist/shell/sidebar.cjs.map +1 -1
- package/dist/shell/sidebar.d.cts +38 -36
- package/dist/shell/sidebar.d.cts.map +1 -0
- package/dist/shell/{sidebar.d.ts → sidebar.d.mts} +38 -36
- package/dist/shell/sidebar.d.mts.map +1 -0
- package/dist/shell/sidebar.mjs +364 -0
- package/dist/{chunk-PFDBULOI.cjs.map → shell/sidebar.mjs.map} +1 -1
- package/dist/shell/use-mobile.cjs +49 -18
- package/dist/shell/use-mobile.cjs.map +1 -1
- package/dist/shell/use-mobile.d.cts +3 -1
- package/dist/shell/use-mobile.d.cts.map +1 -0
- package/dist/shell/{use-mobile.d.ts → use-mobile.d.mts} +3 -1
- package/dist/shell/use-mobile.d.mts.map +1 -0
- package/dist/shell/use-mobile.mjs +47 -0
- package/dist/shell/use-mobile.mjs.map +1 -0
- package/dist/theme/index.cjs +662 -549
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.d.cts +32 -32
- package/dist/theme/index.d.cts.map +1 -0
- package/dist/theme/{index.d.ts → index.d.mts} +32 -32
- package/dist/theme/index.d.mts.map +1 -0
- package/dist/theme/index.mjs +727 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/types/index.cjs +18 -72
- package/dist/types/index.d.cts +4 -268
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types-BIXtQlHB.d.cts +155 -0
- package/dist/types-BIXtQlHB.d.cts.map +1 -0
- package/dist/types-BXFX9bXp.cjs +303 -0
- package/dist/types-BXFX9bXp.cjs.map +1 -0
- package/dist/types-Bjmd7Fdx.mjs +208 -0
- package/dist/types-Bjmd7Fdx.mjs.map +1 -0
- package/dist/types-ByG6Xy3C.d.mts +85 -0
- package/dist/types-ByG6Xy3C.d.mts.map +1 -0
- package/dist/types-C5OFJy-O.d.mts +155 -0
- package/dist/types-C5OFJy-O.d.mts.map +1 -0
- package/dist/types-Ctu-Zio6.d.cts +85 -0
- package/dist/types-Ctu-Zio6.d.cts.map +1 -0
- package/dist/{widget-schema-D-ca3--K.d.ts → widget-schema--PY1uMWx.d.cts} +38 -41
- package/dist/widget-schema--PY1uMWx.d.cts.map +1 -0
- package/dist/{widget-schema-DvJdg1-B.d.cts → widget-schema-YkD5p3v4.d.mts} +38 -41
- package/dist/widget-schema-YkD5p3v4.d.mts.map +1 -0
- package/dist/widget-utils/index.cjs +96 -89
- package/dist/widget-utils/index.cjs.map +1 -1
- package/dist/widget-utils/index.d.cts +8 -6
- package/dist/widget-utils/index.d.cts.map +1 -0
- package/dist/widget-utils/{index.d.ts → index.d.mts} +8 -6
- package/dist/widget-utils/index.d.mts.map +1 -0
- package/dist/widget-utils/index.mjs +119 -0
- package/dist/widget-utils/index.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-2SPTFZRC.js +0 -72
- package/dist/chunk-2SPTFZRC.js.map +0 -1
- package/dist/chunk-3I5Y3PEO.js +0 -23
- package/dist/chunk-3I5Y3PEO.js.map +0 -1
- package/dist/chunk-3ZRE7GX6.js +0 -620
- package/dist/chunk-3ZRE7GX6.js.map +0 -1
- package/dist/chunk-45BCVWQK.cjs +0 -38
- package/dist/chunk-46PUWB7C.cjs +0 -69
- package/dist/chunk-46PUWB7C.cjs.map +0 -1
- package/dist/chunk-5NYM4UTW.cjs +0 -58
- package/dist/chunk-5NYM4UTW.cjs.map +0 -1
- package/dist/chunk-B2NTWEDF.cjs +0 -130
- package/dist/chunk-B2NTWEDF.cjs.map +0 -1
- package/dist/chunk-GDY76JA6.cjs +0 -153
- package/dist/chunk-GDY76JA6.cjs.map +0 -1
- package/dist/chunk-HGVSPZEL.cjs +0 -119
- package/dist/chunk-HGVSPZEL.cjs.map +0 -1
- package/dist/chunk-HIDJYVKJ.js +0 -54
- package/dist/chunk-HIDJYVKJ.js.map +0 -1
- package/dist/chunk-KTXGU7OP.cjs +0 -136
- package/dist/chunk-KTXGU7OP.cjs.map +0 -1
- package/dist/chunk-KW5E2H5T.js +0 -128
- package/dist/chunk-KW5E2H5T.js.map +0 -1
- package/dist/chunk-LBLHDGMT.js +0 -25
- package/dist/chunk-LBLHDGMT.js.map +0 -1
- package/dist/chunk-MNVDL4FX.js +0 -134
- package/dist/chunk-MNVDL4FX.js.map +0 -1
- package/dist/chunk-MOTOSPAO.cjs +0 -15
- package/dist/chunk-MOTOSPAO.cjs.map +0 -1
- package/dist/chunk-N2K6W7FX.cjs +0 -169
- package/dist/chunk-N2K6W7FX.cjs.map +0 -1
- package/dist/chunk-PFDBULOI.cjs +0 -665
- package/dist/chunk-PVTQWD4I.js +0 -166
- package/dist/chunk-PVTQWD4I.js.map +0 -1
- package/dist/chunk-SJQPHJL4.cjs +0 -26
- package/dist/chunk-SJQPHJL4.cjs.map +0 -1
- package/dist/chunk-TML66UEU.js +0 -13
- package/dist/chunk-TML66UEU.js.map +0 -1
- package/dist/chunk-U3CQLX2Z.cjs +0 -28
- package/dist/chunk-U3CQLX2Z.cjs.map +0 -1
- package/dist/chunk-UUNEVOA5.js +0 -36
- package/dist/chunk-UUNEVOA5.js.map +0 -1
- package/dist/chunk-VRF7QEID.js +0 -67
- package/dist/chunk-VRF7QEID.js.map +0 -1
- package/dist/chunk-VSZWXSQA.js +0 -38
- package/dist/chunk-VSZWXSQA.js.map +0 -1
- package/dist/chunk-WYOHFNNW.js +0 -117
- package/dist/chunk-WYOHFNNW.js.map +0 -1
- package/dist/chunk-YKF5ZFF5.js +0 -136
- package/dist/chunk-YKF5ZFF5.js.map +0 -1
- package/dist/chunk-YXJMBVXO.cjs +0 -76
- package/dist/chunk-YXJMBVXO.cjs.map +0 -1
- package/dist/chunk-ZA4AE7KF.cjs +0 -42
- package/dist/chunk-ZA4AE7KF.cjs.map +0 -1
- package/dist/data-sources/DataAwareWidget.d.ts +0 -30
- package/dist/data-sources/DataAwareWidget.js +0 -57
- package/dist/data-sources/DataAwareWidget.js.map +0 -1
- package/dist/data-sources/ErrorState.d.ts +0 -5
- package/dist/data-sources/ErrorState.js +0 -3
- package/dist/data-sources/ErrorState.js.map +0 -1
- package/dist/data-sources/context.d.ts +0 -16
- package/dist/data-sources/context.js +0 -3
- package/dist/data-sources/context.js.map +0 -1
- package/dist/data-sources/fetchers/api.d.ts +0 -8
- package/dist/data-sources/fetchers/api.js +0 -3
- package/dist/data-sources/fetchers/api.js.map +0 -1
- package/dist/data-sources/fetchers/custom.js +0 -3
- package/dist/data-sources/fetchers/custom.js.map +0 -1
- package/dist/data-sources/fetchers/static.js +0 -3
- package/dist/data-sources/fetchers/static.js.map +0 -1
- package/dist/data-sources/preview-context.d.ts +0 -11
- package/dist/data-sources/preview-context.js +0 -18
- package/dist/data-sources/preview-context.js.map +0 -1
- package/dist/data-sources/registry-context.d.ts +0 -41
- package/dist/data-sources/registry-context.js +0 -9
- package/dist/data-sources/registry-context.js.map +0 -1
- package/dist/data-sources/registry.d.ts +0 -17
- package/dist/data-sources/registry.js +0 -7
- package/dist/data-sources/registry.js.map +0 -1
- package/dist/data-sources/transformers.d.ts +0 -23
- package/dist/data-sources/transformers.js +0 -3
- package/dist/data-sources/transformers.js.map +0 -1
- package/dist/data-sources/types.cjs.map +0 -1
- package/dist/data-sources/types.d.ts +0 -157
- package/dist/data-sources/types.js +0 -3
- package/dist/data-sources/types.js.map +0 -1
- package/dist/data-sources/use-widget-data.d.ts +0 -16
- package/dist/data-sources/use-widget-data.js +0 -10
- package/dist/data-sources/use-widget-data.js.map +0 -1
- package/dist/registries/index.js +0 -144
- package/dist/registries/index.js.map +0 -1
- package/dist/shareable-item-DkgWpwoU.d.cts +0 -21
- package/dist/shareable-item-DkgWpwoU.d.ts +0 -21
- package/dist/shell/AppShellLayout.d.ts +0 -30
- package/dist/shell/AppShellLayout.js +0 -5
- package/dist/shell/AppShellLayout.js.map +0 -1
- package/dist/shell/ThemeModeContext.d.ts +0 -27
- package/dist/shell/ThemeModeContext.js +0 -3
- package/dist/shell/ThemeModeContext.js.map +0 -1
- package/dist/shell/index.cjs.map +0 -1
- package/dist/shell/index.d.ts +0 -43
- package/dist/shell/index.js +0 -76
- package/dist/shell/index.js.map +0 -1
- package/dist/shell/sidebar.js +0 -4
- package/dist/shell/sidebar.js.map +0 -1
- package/dist/shell/use-mobile.js +0 -3
- package/dist/shell/use-mobile.js.map +0 -1
- package/dist/theme/index.js +0 -611
- package/dist/theme/index.js.map +0 -1
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.ts +0 -268
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types-CNIhy4JD.d.cts +0 -83
- package/dist/types-CNIhy4JD.d.ts +0 -83
- package/dist/widget-utils/index.js +0 -111
- package/dist/widget-utils/index.js.map +0 -1
package/dist/theme/index.js
DELETED
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
import Color2 from 'colorjs.io';
|
|
2
|
-
|
|
3
|
-
// src/theme/color-engine.ts
|
|
4
|
-
|
|
5
|
-
// src/theme/types.ts
|
|
6
|
-
var SEMANTIC_COLOR_NAMES = [
|
|
7
|
-
"background",
|
|
8
|
-
"foreground",
|
|
9
|
-
"primary",
|
|
10
|
-
"secondary",
|
|
11
|
-
"accent",
|
|
12
|
-
"muted",
|
|
13
|
-
"destructive"
|
|
14
|
-
];
|
|
15
|
-
var SHADE_STEPS = [
|
|
16
|
-
100,
|
|
17
|
-
200,
|
|
18
|
-
300,
|
|
19
|
-
400,
|
|
20
|
-
500,
|
|
21
|
-
600,
|
|
22
|
-
700,
|
|
23
|
-
800,
|
|
24
|
-
900
|
|
25
|
-
];
|
|
26
|
-
var FONT_SIZE_KEYS = [
|
|
27
|
-
"extraSmall",
|
|
28
|
-
"small",
|
|
29
|
-
"regular",
|
|
30
|
-
"large",
|
|
31
|
-
"extraLarge",
|
|
32
|
-
"giant"
|
|
33
|
-
];
|
|
34
|
-
var FONT_FAMILY_KEYS = ["header", "body"];
|
|
35
|
-
var RADIUS_KEYS = ["small", "medium", "large", "extraLarge"];
|
|
36
|
-
|
|
37
|
-
// src/theme/color-engine.ts
|
|
38
|
-
function parseColor(value) {
|
|
39
|
-
if (value.length === 6) {
|
|
40
|
-
value = `#${value}`;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
return new Color2(value);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.warn("[theme] Failed to parse color:", value, error);
|
|
46
|
-
return new Color2("oklch", [0.5, 0, 0]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function getForegroundColor(foreground, color) {
|
|
50
|
-
if (foreground.oklch.l == null || color.oklch.l == null) {
|
|
51
|
-
return foreground;
|
|
52
|
-
}
|
|
53
|
-
const contrast = color.contrastAPCA(foreground);
|
|
54
|
-
if (contrast < 50) {
|
|
55
|
-
return new Color2("oklch", [
|
|
56
|
-
color.oklch.l < 0.7 ? 0.95 : 0.15,
|
|
57
|
-
foreground.oklch.c || 0,
|
|
58
|
-
foreground.oklch.h || 0
|
|
59
|
-
]);
|
|
60
|
-
}
|
|
61
|
-
return foreground;
|
|
62
|
-
}
|
|
63
|
-
function generateShades(base) {
|
|
64
|
-
const l = base.oklch.l ?? 0;
|
|
65
|
-
const c = base.oklch.c ?? 0;
|
|
66
|
-
const h = base.oklch.h ?? 0;
|
|
67
|
-
const safeMax = l >= 0.885 ? 0.995 : 0.97;
|
|
68
|
-
const safeMin = l <= 0.33 ? 0 : 0.21;
|
|
69
|
-
const lightStep = (safeMax - l) / 5;
|
|
70
|
-
const darkStep = -(l - safeMin) / 8;
|
|
71
|
-
const shade = (lDelta, cDelta) => {
|
|
72
|
-
return new Color2("oklch", [
|
|
73
|
-
Math.max(0, Math.min(1, l + lDelta)),
|
|
74
|
-
c <= 1e-3 ? c : Math.max(0, c + cDelta),
|
|
75
|
-
h
|
|
76
|
-
]);
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
100: shade(5 * lightStep, -375e-5),
|
|
80
|
-
200: shade(4 * lightStep, -375e-5),
|
|
81
|
-
300: shade(3 * lightStep, -375e-5),
|
|
82
|
-
400: shade(2 * lightStep, -375e-5),
|
|
83
|
-
500: new Color2("oklch", [l, c, h]),
|
|
84
|
-
600: shade(1.6 * darkStep, 0.025),
|
|
85
|
-
700: shade(1.875 * 2 * darkStep, 0.05),
|
|
86
|
-
800: shade(3 * 2 * darkStep, 0.075),
|
|
87
|
-
900: shade(4 * 2 * darkStep, 0.1)
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
var DARK_DERIVATION_CONFIG = {
|
|
91
|
-
background: { baseLightness: 0.15, fgLightness: 0.93 },
|
|
92
|
-
foreground: { baseLightness: 0.93, fgLightness: 0.15 },
|
|
93
|
-
muted: { baseLightness: 0.22, fgLightness: 0.75 },
|
|
94
|
-
primary: { baseLightness: "invert", fgLightness: 0.95, chromaScale: 0.9 },
|
|
95
|
-
secondary: { baseLightness: "invert", fgLightness: 0.93, chromaScale: 0.85 },
|
|
96
|
-
accent: { baseLightness: "invert", fgLightness: 0.95, chromaScale: 0.9 },
|
|
97
|
-
destructive: {
|
|
98
|
-
baseLightness: "invert",
|
|
99
|
-
fgLightness: 0.95,
|
|
100
|
-
chromaScale: 0.95
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
function invertLightness(l) {
|
|
104
|
-
const inverted = 1 - l;
|
|
105
|
-
return Math.max(0.35, Math.min(0.75, inverted));
|
|
106
|
-
}
|
|
107
|
-
function deriveDarkVariant(name, light) {
|
|
108
|
-
const config = DARK_DERIVATION_CONFIG[name];
|
|
109
|
-
const chromaScale = config.chromaScale ?? 1;
|
|
110
|
-
const baseLightness = config.baseLightness === "invert" ? invertLightness(light.base.oklch.l ?? 0) : config.baseLightness;
|
|
111
|
-
const fgLightness = config.fgLightness === "invert" ? invertLightness(light.foreground.oklch.l ?? 0) : config.fgLightness;
|
|
112
|
-
return {
|
|
113
|
-
base: new Color2("oklch", [
|
|
114
|
-
baseLightness,
|
|
115
|
-
(light.base.oklch.c || 0) * chromaScale,
|
|
116
|
-
light.base.oklch.h || 0
|
|
117
|
-
]),
|
|
118
|
-
foreground: new Color2("oklch", [
|
|
119
|
-
fgLightness,
|
|
120
|
-
(light.foreground.oklch.c || 0) * chromaScale,
|
|
121
|
-
light.foreground.oklch.h || 0
|
|
122
|
-
])
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function mergeDarkOverrides(def) {
|
|
126
|
-
const darkColors = {};
|
|
127
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
128
|
-
const lightInput = def.light[name];
|
|
129
|
-
const darkOverride = def.dark[name];
|
|
130
|
-
if (darkOverride?.base && darkOverride?.foreground) {
|
|
131
|
-
darkColors[name] = darkOverride;
|
|
132
|
-
} else if (darkOverride) {
|
|
133
|
-
const base = darkOverride.base ?? deriveDarkVariant(name, lightInput).base;
|
|
134
|
-
darkColors[name] = {
|
|
135
|
-
base,
|
|
136
|
-
foreground: darkOverride.foreground ?? getForegroundColor(def.light.foreground.base, base)
|
|
137
|
-
};
|
|
138
|
-
} else {
|
|
139
|
-
darkColors[name] = deriveDarkVariant(name, lightInput);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return darkColors;
|
|
143
|
-
}
|
|
144
|
-
function resolveColorSet(colors) {
|
|
145
|
-
const resolved = {};
|
|
146
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
147
|
-
const input = colors[name];
|
|
148
|
-
const shades = generateShades(input.base);
|
|
149
|
-
const resolvedShades = {};
|
|
150
|
-
for (const step of SHADE_STEPS) {
|
|
151
|
-
resolvedShades[step] = shades[step];
|
|
152
|
-
}
|
|
153
|
-
resolved[name] = {
|
|
154
|
-
base: input.base.clone(),
|
|
155
|
-
foreground: input.foreground.clone(),
|
|
156
|
-
shades: resolvedShades
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return resolved;
|
|
160
|
-
}
|
|
161
|
-
function resolveTheme(def) {
|
|
162
|
-
return {
|
|
163
|
-
id: def.id,
|
|
164
|
-
name: def.name,
|
|
165
|
-
light: resolveColorSet(def.light),
|
|
166
|
-
dark: resolveColorSet(mergeDarkOverrides(def)),
|
|
167
|
-
fontSizes: { ...def.fontSizes },
|
|
168
|
-
fontFamilies: { ...def.fontFamilies },
|
|
169
|
-
spacing: def.spacing,
|
|
170
|
-
radii: { ...def.radii }
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// src/theme/tailwind-overrides.ts
|
|
175
|
-
var OVERRIDES = {
|
|
176
|
-
"--color-gray-50": "var(--color-muted)",
|
|
177
|
-
"--color-gray-100": "var(--color-muted-600)",
|
|
178
|
-
"--color-gray-200": "var(--color-border)"
|
|
179
|
-
};
|
|
180
|
-
function getInvertedStep(shade) {
|
|
181
|
-
const shadeIndex = SHADE_STEPS.indexOf(shade);
|
|
182
|
-
const invertedIndex = SHADE_STEPS.length - 1 - shadeIndex;
|
|
183
|
-
return SHADE_STEPS[invertedIndex] || 500;
|
|
184
|
-
}
|
|
185
|
-
function emitTailwindOverrides(darkMode = false) {
|
|
186
|
-
const TAILWIND_COLOR_MAP = {
|
|
187
|
-
gray: "foreground",
|
|
188
|
-
red: "destructive",
|
|
189
|
-
blue: "primary",
|
|
190
|
-
green: "accent"
|
|
191
|
-
};
|
|
192
|
-
const TAILWIND_SHADES = [
|
|
193
|
-
50,
|
|
194
|
-
100,
|
|
195
|
-
200,
|
|
196
|
-
300,
|
|
197
|
-
400,
|
|
198
|
-
500,
|
|
199
|
-
600,
|
|
200
|
-
700,
|
|
201
|
-
800,
|
|
202
|
-
900,
|
|
203
|
-
950
|
|
204
|
-
];
|
|
205
|
-
const SHADE_REMAP = {
|
|
206
|
-
50: 100,
|
|
207
|
-
950: 900
|
|
208
|
-
};
|
|
209
|
-
const lines = [];
|
|
210
|
-
for (const [twName, semantic] of Object.entries(TAILWIND_COLOR_MAP)) {
|
|
211
|
-
for (const shade of TAILWIND_SHADES) {
|
|
212
|
-
const step = SHADE_REMAP[shade] ?? shade;
|
|
213
|
-
const override = OVERRIDES[`--color-${twName}-${shade}`];
|
|
214
|
-
lines.push(
|
|
215
|
-
`--color-${twName}-${shade}: ${override ? override : `var(--color-${semantic}-${semantic === "foreground" && darkMode === true ? getInvertedStep(step) : step})`};`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
lines.push("--color-white: var(--color-background);");
|
|
220
|
-
lines.push("--color-black: var(--color-foreground);");
|
|
221
|
-
return lines;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// src/theme/css-generator.ts
|
|
225
|
-
function colorToCSS(color) {
|
|
226
|
-
const result = color.toString({ format: "oklch" });
|
|
227
|
-
if (result.includes("NaN")) {
|
|
228
|
-
console.warn(
|
|
229
|
-
"[theme] colorToCSS produced NaN, using neutral fallback:",
|
|
230
|
-
result
|
|
231
|
-
);
|
|
232
|
-
return "oklch(0.5 0 0)";
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
function camelToKebab(str) {
|
|
237
|
-
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
238
|
-
}
|
|
239
|
-
function emitColorVars(colors) {
|
|
240
|
-
const lines = [];
|
|
241
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
242
|
-
const color = colors[name];
|
|
243
|
-
lines.push(`--color-${name}: ${colorToCSS(color.base)};`);
|
|
244
|
-
lines.push(`--color-${name}-foreground: ${colorToCSS(color.foreground)};`);
|
|
245
|
-
for (const step of SHADE_STEPS) {
|
|
246
|
-
lines.push(`--color-${name}-${step}: ${colorToCSS(color.shades[step])};`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return lines;
|
|
250
|
-
}
|
|
251
|
-
function emitNonColorVars(theme) {
|
|
252
|
-
const lines = [];
|
|
253
|
-
for (const key of FONT_SIZE_KEYS) {
|
|
254
|
-
lines.push(`--font-size-${camelToKebab(key)}: ${theme.fontSizes[key]};`);
|
|
255
|
-
}
|
|
256
|
-
for (const key of FONT_FAMILY_KEYS) {
|
|
257
|
-
lines.push(`--font-${key}: ${theme.fontFamilies[key]};`);
|
|
258
|
-
}
|
|
259
|
-
lines.push(`--spacing: ${theme.spacing};`);
|
|
260
|
-
for (const key of RADIUS_KEYS) {
|
|
261
|
-
lines.push(`--radius-${camelToKebab(key)}: ${theme.radii[key]};`);
|
|
262
|
-
}
|
|
263
|
-
return lines;
|
|
264
|
-
}
|
|
265
|
-
var globalCSSOverride = [
|
|
266
|
-
"--color-background-foreground: var(--color-foreground);",
|
|
267
|
-
"--color-foreground-foreground: var(--color-background);",
|
|
268
|
-
...SEMANTIC_COLOR_NAMES.map((value) => `--${value}: var(--color-${value});`),
|
|
269
|
-
...SEMANTIC_COLOR_NAMES.map(
|
|
270
|
-
(value) => `--${value}-foreground: var(--color-${value}-foreground);`
|
|
271
|
-
),
|
|
272
|
-
"--sidebar-ring: var(--color-primary);",
|
|
273
|
-
"--sidebar-border: var(--color-border);",
|
|
274
|
-
"--sidebar-accent-foreground: var(--color-accent-foreground);",
|
|
275
|
-
"--sidebar-accent: var(--color-accent);",
|
|
276
|
-
"--sidebar-primary-foreground: var(--color-primary-foreground);",
|
|
277
|
-
"--sidebar-primary: var(--color-primary);",
|
|
278
|
-
"--sidebar-foreground: var(--color-muted-foreground);",
|
|
279
|
-
"--sidebar: var(--color-muted);",
|
|
280
|
-
"--border: var(--color-background-600);",
|
|
281
|
-
"--ring: var(--color-primary);",
|
|
282
|
-
"--popover: var(--color-background);",
|
|
283
|
-
"--popover-foreground: var(--color-foreground);",
|
|
284
|
-
"--card: var(--color-muted);",
|
|
285
|
-
"--card-foreground: var(--color-muted-foreground);",
|
|
286
|
-
"--radius-sm: var(--radius-small);",
|
|
287
|
-
"--radius-md: var(--radius-medium);",
|
|
288
|
-
"--radius-lg: var(--radius-large);",
|
|
289
|
-
"--radius-xl: var(--radius-extra-large);",
|
|
290
|
-
"--text-xs: var(--font-size-extra-small);",
|
|
291
|
-
"--text-sm: var(--font-size-small);",
|
|
292
|
-
"--text-base: var(--font-size-regular);",
|
|
293
|
-
"--text-lg: var(--font-size-large);",
|
|
294
|
-
"--text-xl: var(--font-size-extra-large);",
|
|
295
|
-
"--text-2xl: var(--font-size-giant);",
|
|
296
|
-
"--font-sans: var(--font-body);",
|
|
297
|
-
// Tailwind's font-mono is repurposed as the display/header font
|
|
298
|
-
"--font-mono: var(--font-header);"
|
|
299
|
-
];
|
|
300
|
-
var globalDarkCSSOverride = ["--border: var(--color-background-400);"];
|
|
301
|
-
function generateThemeCSS(theme, options = {}) {
|
|
302
|
-
const sel = `[data-theme="${theme.id}"]`;
|
|
303
|
-
const tw = options.mapTailwindColors ?? true;
|
|
304
|
-
const blocks = [];
|
|
305
|
-
blocks.push(`${sel} {`);
|
|
306
|
-
blocks.push(...globalCSSOverride);
|
|
307
|
-
blocks.push(...emitNonColorVars(theme));
|
|
308
|
-
blocks.push(...emitColorVars(theme.light));
|
|
309
|
-
if (tw) blocks.push(...emitTailwindOverrides());
|
|
310
|
-
blocks.push(`}`);
|
|
311
|
-
blocks.push(`${sel}[data-theme-mode="dark"] {`);
|
|
312
|
-
blocks.push(...globalDarkCSSOverride);
|
|
313
|
-
blocks.push(...emitColorVars(theme.dark));
|
|
314
|
-
if (tw) blocks.push(...emitTailwindOverrides(true));
|
|
315
|
-
blocks.push(`}`);
|
|
316
|
-
if (!options.disableAutoTheme) {
|
|
317
|
-
blocks.push(`@media (prefers-color-scheme: dark) {`);
|
|
318
|
-
blocks.push(`${sel}:not([data-theme-mode]) {`);
|
|
319
|
-
blocks.push(...globalDarkCSSOverride);
|
|
320
|
-
blocks.push(...emitColorVars(theme.dark).map((l) => `${l}`));
|
|
321
|
-
if (tw) blocks.push(...emitTailwindOverrides(true).map((l) => `${l}`));
|
|
322
|
-
blocks.push(`}`);
|
|
323
|
-
blocks.push(`}`);
|
|
324
|
-
}
|
|
325
|
-
return blocks.join("\n");
|
|
326
|
-
}
|
|
327
|
-
var DEFAULT_FONT_SIZES = {
|
|
328
|
-
extraSmall: "0.75rem",
|
|
329
|
-
small: "0.875rem",
|
|
330
|
-
regular: "1rem",
|
|
331
|
-
large: "1.125rem",
|
|
332
|
-
extraLarge: "1.25rem",
|
|
333
|
-
giant: "1.5rem"
|
|
334
|
-
};
|
|
335
|
-
var DEFAULT_FONT_FAMILIES = {
|
|
336
|
-
header: "var(--font-inter)",
|
|
337
|
-
body: "var(--font-inter)"
|
|
338
|
-
};
|
|
339
|
-
var DEFAULT_SPACING = "0.25rem";
|
|
340
|
-
var DEFAULT_RADII = {
|
|
341
|
-
small: "0.25rem",
|
|
342
|
-
medium: "0.5rem",
|
|
343
|
-
large: "0.75rem",
|
|
344
|
-
extraLarge: "1rem"
|
|
345
|
-
};
|
|
346
|
-
var DEFAULT_COLORS = {
|
|
347
|
-
background: "#ffffff",
|
|
348
|
-
foreground: "#1a1a1a",
|
|
349
|
-
primary: "#3b82f6",
|
|
350
|
-
secondary: "#6b7280",
|
|
351
|
-
accent: "#10b981",
|
|
352
|
-
muted: "#f3f4f6",
|
|
353
|
-
destructive: "#ef4444",
|
|
354
|
-
mutedForeground: "#6b7280"
|
|
355
|
-
};
|
|
356
|
-
var DEFAULT_THEME_ID = "default";
|
|
357
|
-
var DEFAULT_THEME_NAME = "Default Theme";
|
|
358
|
-
function getDefaultThemeDefinition() {
|
|
359
|
-
const bg = new Color2(DEFAULT_COLORS.background);
|
|
360
|
-
const fg = new Color2(DEFAULT_COLORS.foreground);
|
|
361
|
-
const primary = new Color2(DEFAULT_COLORS.primary);
|
|
362
|
-
const secondary = new Color2(DEFAULT_COLORS.secondary);
|
|
363
|
-
const accent = new Color2(DEFAULT_COLORS.accent);
|
|
364
|
-
const muted = new Color2(DEFAULT_COLORS.muted);
|
|
365
|
-
const destructive = new Color2(DEFAULT_COLORS.destructive);
|
|
366
|
-
const mutedFg = new Color2(DEFAULT_COLORS.mutedForeground);
|
|
367
|
-
const darkBg = new Color2("#0a0a0a");
|
|
368
|
-
const darkFg = new Color2("#fafafa");
|
|
369
|
-
const darkMuted = new Color2("#171717");
|
|
370
|
-
const darkMutedForeground = new Color2("#dddddd");
|
|
371
|
-
return {
|
|
372
|
-
id: DEFAULT_THEME_ID,
|
|
373
|
-
name: DEFAULT_THEME_NAME,
|
|
374
|
-
light: {
|
|
375
|
-
background: { base: bg, foreground: fg },
|
|
376
|
-
foreground: { base: fg, foreground: bg },
|
|
377
|
-
primary: {
|
|
378
|
-
base: primary,
|
|
379
|
-
foreground: getForegroundColor(fg, primary)
|
|
380
|
-
},
|
|
381
|
-
secondary: {
|
|
382
|
-
base: secondary,
|
|
383
|
-
foreground: getForegroundColor(fg, secondary)
|
|
384
|
-
},
|
|
385
|
-
accent: {
|
|
386
|
-
base: accent,
|
|
387
|
-
foreground: getForegroundColor(fg, accent)
|
|
388
|
-
},
|
|
389
|
-
muted: { base: muted, foreground: mutedFg },
|
|
390
|
-
destructive: {
|
|
391
|
-
base: destructive,
|
|
392
|
-
foreground: getForegroundColor(fg, destructive)
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
dark: {
|
|
396
|
-
background: { base: darkBg, foreground: darkFg },
|
|
397
|
-
foreground: { base: darkFg, foreground: darkBg },
|
|
398
|
-
muted: { base: darkMuted, foreground: darkMutedForeground }
|
|
399
|
-
},
|
|
400
|
-
fontSizes: { ...DEFAULT_FONT_SIZES },
|
|
401
|
-
fontFamilies: { ...DEFAULT_FONT_FAMILIES },
|
|
402
|
-
spacing: DEFAULT_SPACING,
|
|
403
|
-
radii: { ...DEFAULT_RADII }
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// src/theme/serialisation.ts
|
|
408
|
-
function colorToPlain(color) {
|
|
409
|
-
return {
|
|
410
|
-
l: color.oklch.l ?? 0,
|
|
411
|
-
c: color.oklch.c ?? 0,
|
|
412
|
-
h: color.oklch.h ?? 0
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
function plainToColor(plain) {
|
|
416
|
-
return new Color2("oklch", [plain.l, plain.c, plain.h]);
|
|
417
|
-
}
|
|
418
|
-
function serialiseTheme(def) {
|
|
419
|
-
const light = {};
|
|
420
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
421
|
-
light[name] = {
|
|
422
|
-
base: colorToPlain(def.light[name].base),
|
|
423
|
-
foreground: colorToPlain(def.light[name].foreground)
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
const dark = {};
|
|
427
|
-
for (const [name, value] of Object.entries(def.dark)) {
|
|
428
|
-
if (!value) continue;
|
|
429
|
-
dark[name] = {
|
|
430
|
-
...value.base ? { base: colorToPlain(value.base) } : {},
|
|
431
|
-
...value.foreground ? { foreground: colorToPlain(value.foreground) } : {}
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
return {
|
|
435
|
-
id: def.id,
|
|
436
|
-
name: def.name,
|
|
437
|
-
light,
|
|
438
|
-
dark,
|
|
439
|
-
fontSizes: { ...def.fontSizes },
|
|
440
|
-
fontFamilies: { ...def.fontFamilies },
|
|
441
|
-
spacing: def.spacing,
|
|
442
|
-
radii: { ...def.radii },
|
|
443
|
-
...def.syncWithBrandColors ? { syncWithBrandColors: true } : {}
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
function deserialiseTheme(payload) {
|
|
447
|
-
const lightRaw = payload.light ?? {};
|
|
448
|
-
const darkRaw = payload.dark ?? {};
|
|
449
|
-
const defaults = getDefaultThemeDefinition();
|
|
450
|
-
const light = {};
|
|
451
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
452
|
-
const entry = lightRaw[name];
|
|
453
|
-
if (entry) {
|
|
454
|
-
light[name] = {
|
|
455
|
-
base: plainToColor(entry.base),
|
|
456
|
-
foreground: plainToColor(entry.foreground)
|
|
457
|
-
};
|
|
458
|
-
} else {
|
|
459
|
-
console.warn(
|
|
460
|
-
`[theme] deserialiseTheme: missing light color "${name}", using default`
|
|
461
|
-
);
|
|
462
|
-
light[name] = defaults.light[name];
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
const dark = {};
|
|
466
|
-
for (const [name, value] of Object.entries(darkRaw)) {
|
|
467
|
-
if (!value) continue;
|
|
468
|
-
dark[name] = {
|
|
469
|
-
...value.base ? { base: plainToColor(value.base) } : {},
|
|
470
|
-
...value.foreground ? { foreground: plainToColor(value.foreground) } : {}
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
return {
|
|
474
|
-
id: payload.id,
|
|
475
|
-
name: payload.name,
|
|
476
|
-
light,
|
|
477
|
-
dark,
|
|
478
|
-
fontSizes: payload.fontSizes ?? DEFAULT_FONT_SIZES,
|
|
479
|
-
fontFamilies: payload.fontFamilies ?? DEFAULT_FONT_FAMILIES,
|
|
480
|
-
spacing: payload.spacing ?? DEFAULT_SPACING,
|
|
481
|
-
radii: payload.radii ?? DEFAULT_RADII,
|
|
482
|
-
...payload.syncWithBrandColors === true ? { syncWithBrandColors: true } : {}
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// src/theme/transforms.ts
|
|
487
|
-
function isNewThemeFormat(config) {
|
|
488
|
-
return config.light != null && typeof config.light === "object";
|
|
489
|
-
}
|
|
490
|
-
function legacyConfigToDefinition(id, name, config) {
|
|
491
|
-
const bg = parseColor(
|
|
492
|
-
config.base ?? config.background ?? DEFAULT_COLORS.background
|
|
493
|
-
);
|
|
494
|
-
const fg = parseColor(
|
|
495
|
-
config.text ?? config.foreground ?? DEFAULT_COLORS.foreground
|
|
496
|
-
);
|
|
497
|
-
const primary = parseColor(config.primary ?? DEFAULT_COLORS.primary);
|
|
498
|
-
const secondary = parseColor(config.secondary ?? DEFAULT_COLORS.secondary);
|
|
499
|
-
const accent = parseColor(config.accent ?? DEFAULT_COLORS.accent);
|
|
500
|
-
const muted = parseColor(config.muted ?? DEFAULT_COLORS.muted);
|
|
501
|
-
const destructive = parseColor(
|
|
502
|
-
config.destructive ?? DEFAULT_COLORS.destructive
|
|
503
|
-
);
|
|
504
|
-
const mutedFg = parseColor(
|
|
505
|
-
config.mutedForeground ?? DEFAULT_COLORS.mutedForeground
|
|
506
|
-
);
|
|
507
|
-
return {
|
|
508
|
-
id: String(id),
|
|
509
|
-
name,
|
|
510
|
-
light: {
|
|
511
|
-
background: { base: bg, foreground: fg },
|
|
512
|
-
foreground: { base: fg, foreground: bg },
|
|
513
|
-
primary: {
|
|
514
|
-
base: primary,
|
|
515
|
-
foreground: getForegroundColor(fg, primary)
|
|
516
|
-
},
|
|
517
|
-
secondary: {
|
|
518
|
-
base: secondary,
|
|
519
|
-
foreground: getForegroundColor(fg, secondary)
|
|
520
|
-
},
|
|
521
|
-
accent: {
|
|
522
|
-
base: accent,
|
|
523
|
-
foreground: getForegroundColor(fg, accent)
|
|
524
|
-
},
|
|
525
|
-
muted: { base: muted, foreground: mutedFg },
|
|
526
|
-
destructive: {
|
|
527
|
-
base: destructive,
|
|
528
|
-
foreground: getForegroundColor(fg, destructive)
|
|
529
|
-
}
|
|
530
|
-
},
|
|
531
|
-
dark: {},
|
|
532
|
-
fontSizes: {
|
|
533
|
-
extraSmall: config.extraSmall ?? DEFAULT_FONT_SIZES.extraSmall,
|
|
534
|
-
small: config.small ?? DEFAULT_FONT_SIZES.small,
|
|
535
|
-
regular: config.regular ?? DEFAULT_FONT_SIZES.regular,
|
|
536
|
-
large: config.large ?? DEFAULT_FONT_SIZES.large,
|
|
537
|
-
extraLarge: config.extraLarge ?? DEFAULT_FONT_SIZES.extraLarge,
|
|
538
|
-
giant: config.giant ?? DEFAULT_FONT_SIZES.giant
|
|
539
|
-
},
|
|
540
|
-
fontFamilies: {
|
|
541
|
-
header: config.headerFont ?? DEFAULT_FONT_FAMILIES.header,
|
|
542
|
-
body: config.bodyFont ?? DEFAULT_FONT_FAMILIES.body
|
|
543
|
-
},
|
|
544
|
-
spacing: config.globalSpacing ?? DEFAULT_SPACING,
|
|
545
|
-
radii: {
|
|
546
|
-
small: config.radiusSmall ?? DEFAULT_RADII.small,
|
|
547
|
-
medium: config.radiusMedium ?? DEFAULT_RADII.medium,
|
|
548
|
-
large: config.radiusLarge ?? DEFAULT_RADII.large,
|
|
549
|
-
extraLarge: config.radiusExtraLarge ?? DEFAULT_RADII.extraLarge
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
function buildThemeDefinition(theme) {
|
|
554
|
-
const config = theme.config ?? {};
|
|
555
|
-
if (isNewThemeFormat(config)) {
|
|
556
|
-
return deserialiseTheme({
|
|
557
|
-
...config,
|
|
558
|
-
id: String(theme.id),
|
|
559
|
-
name: theme.name ?? "Untitled Theme"
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
return legacyConfigToDefinition(
|
|
563
|
-
theme.id,
|
|
564
|
-
theme.name ?? "Untitled Theme",
|
|
565
|
-
config
|
|
566
|
-
);
|
|
567
|
-
}
|
|
568
|
-
function transformThemes(themes) {
|
|
569
|
-
return themes.flatMap((theme) => {
|
|
570
|
-
try {
|
|
571
|
-
return [buildThemeDefinition(theme)];
|
|
572
|
-
} catch (error) {
|
|
573
|
-
console.error(`[theme] Failed to build theme id=${theme.id}:`, error);
|
|
574
|
-
return [];
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
function getActiveThemeId(themes) {
|
|
579
|
-
const active = themes.find((t) => t.active) ?? themes[0];
|
|
580
|
-
return active ? String(active.id) : void 0;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/theme/theme-applicator.ts
|
|
584
|
-
var STYLE_PREFIX = "theme-style-";
|
|
585
|
-
function applyTheme(theme, options) {
|
|
586
|
-
if (typeof document === "undefined") return;
|
|
587
|
-
try {
|
|
588
|
-
const styleId = `${STYLE_PREFIX}${theme.id}`;
|
|
589
|
-
let el = document.getElementById(styleId);
|
|
590
|
-
if (!el) {
|
|
591
|
-
el = document.createElement("style");
|
|
592
|
-
el.id = styleId;
|
|
593
|
-
document.head.appendChild(el);
|
|
594
|
-
}
|
|
595
|
-
el.textContent = generateThemeCSS(theme, options);
|
|
596
|
-
} catch (error) {
|
|
597
|
-
console.error(`[theme] applyTheme failed for "${theme.id}":`, error);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
function removeTheme(themeId) {
|
|
601
|
-
if (typeof document === "undefined") return;
|
|
602
|
-
document.getElementById(`${STYLE_PREFIX}${themeId}`)?.remove();
|
|
603
|
-
}
|
|
604
|
-
function removeAllThemes() {
|
|
605
|
-
if (typeof document === "undefined") return;
|
|
606
|
-
document.querySelectorAll(`style[id^="${STYLE_PREFIX}"]`).forEach((el) => el.remove());
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
export { DEFAULT_COLORS, DEFAULT_FONT_FAMILIES, DEFAULT_FONT_SIZES, DEFAULT_RADII, DEFAULT_SPACING, DEFAULT_THEME_ID, DEFAULT_THEME_NAME, FONT_FAMILY_KEYS, FONT_SIZE_KEYS, RADIUS_KEYS, SEMANTIC_COLOR_NAMES, SHADE_STEPS, applyTheme, buildThemeDefinition, deriveDarkVariant, deserialiseTheme, generateShades, generateThemeCSS, getActiveThemeId, getDefaultThemeDefinition, getForegroundColor, mergeDarkOverrides, parseColor, removeAllThemes, removeTheme, resolveTheme, serialiseTheme, transformThemes };
|
|
610
|
-
//# sourceMappingURL=index.js.map
|
|
611
|
-
//# sourceMappingURL=index.js.map
|