@dsrcjs/ai-widget 0.0.0-stage → 1.0.5
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 +64 -0
- package/README.md +296 -2
- package/dist/ai-dana-chat.js +76 -0
- package/dist/avatar/model.d.ts +12 -0
- package/dist/drag.d.ts +44 -0
- package/dist/echarts-B6eiFnZN.js +18 -0
- package/dist/i18n.d.ts +287 -0
- package/dist/index-D2Riqtpn.js +19 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +1 -0
- package/dist/markdown-impl-Cu_bBFxI.js +34 -0
- package/dist/stream-entry-CNdFWIwY.js +8 -0
- package/dist/theme.d.ts +82 -0
- package/package.json +36 -4
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme engine. Four layers, highest first: site CSS vars `--aid-*` (resolved in styles.css) > JS `theme` option >
|
|
3
|
+
* admin `WidgetSite.theme` > kit tokens. This module merges the two object layers and turns the result into the
|
|
4
|
+
* kit's HSL-triplet variables (`--primary: 201, 100%, 29%`), which the root element gets as inline style.
|
|
5
|
+
*/
|
|
6
|
+
export type Scheme = 'light' | 'dark' | 'auto';
|
|
7
|
+
export interface ThemeOptions {
|
|
8
|
+
/** Any CSS colour the parser understands: `#0a6`, `#00aa66cc`, `rgb()`, `hsl()`, a few names. */
|
|
9
|
+
primary?: string;
|
|
10
|
+
/** CSS length, a number means px. */
|
|
11
|
+
radius?: string | number;
|
|
12
|
+
/** `font-family` value; by default the widget uses a system font stack (Inter is not embedded). */
|
|
13
|
+
font?: string;
|
|
14
|
+
scheme?: Scheme;
|
|
15
|
+
logoUrl?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Launcher look: just the icon (default) or the icon with `launcherLabel` (default: localized «Ask a question»). */
|
|
18
|
+
launcher?: LauncherVariant;
|
|
19
|
+
launcherLabel?: string;
|
|
20
|
+
/** Launcher corners: `circle` (default), `rounded`, `square`. */
|
|
21
|
+
launcherShape?: LauncherShape;
|
|
22
|
+
/** Window colours (any CSS colour the parser understands); unset ones follow the kit and the scheme. */
|
|
23
|
+
background?: string;
|
|
24
|
+
foreground?: string;
|
|
25
|
+
/** Assistant bubble and other muted surfaces. */
|
|
26
|
+
bubble?: string;
|
|
27
|
+
border?: string;
|
|
28
|
+
/** Window size and launcher placement, px; site CSS `--aid-window-*` / `--aid-offset-*` still wins. */
|
|
29
|
+
windowWidth?: number;
|
|
30
|
+
windowHeight?: number;
|
|
31
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
32
|
+
offsetX?: number;
|
|
33
|
+
offsetY?: number;
|
|
34
|
+
}
|
|
35
|
+
export type LauncherVariant = 'icon' | 'label';
|
|
36
|
+
export type LauncherShape = 'circle' | 'rounded' | 'square';
|
|
37
|
+
export interface Rgba {
|
|
38
|
+
r: number;
|
|
39
|
+
g: number;
|
|
40
|
+
b: number;
|
|
41
|
+
a: number;
|
|
42
|
+
}
|
|
43
|
+
export interface Hsla {
|
|
44
|
+
h: number;
|
|
45
|
+
s: number;
|
|
46
|
+
l: number;
|
|
47
|
+
a: number;
|
|
48
|
+
}
|
|
49
|
+
export declare const hslToRgb: ({ h, s, l, a }: Hsla) => Rgba;
|
|
50
|
+
export declare const rgbToHsl: ({ r, g, b, a }: Rgba) => Hsla;
|
|
51
|
+
/** Like parseColor, but `hsl()` input keeps its exact values instead of a round trip through 8-bit RGB. */
|
|
52
|
+
export declare const parseHsl: (input: string) => Hsla | null;
|
|
53
|
+
/** Small dependency-free parser: hex (3/4/6/8), rgb[a](), hsl[a]() in comma or space syntax, a few names. */
|
|
54
|
+
export declare const parseColor: (input: string) => Rgba | null;
|
|
55
|
+
/** WCAG 2.x relative luminance. */
|
|
56
|
+
export declare const luminance: ({ r, g, b }: Rgba) => number;
|
|
57
|
+
export declare const contrastRatio: (a: Rgba, b: Rgba) => number;
|
|
58
|
+
/** The kit's token format: `201, 100%, 29%` (with `, 0.1` alpha when not opaque). */
|
|
59
|
+
export declare const toHslTriplet: ({ h, s, l, a }: Hsla) => string;
|
|
60
|
+
export interface Palette {
|
|
61
|
+
primary: string;
|
|
62
|
+
primaryHovered: string;
|
|
63
|
+
primaryPressed: string;
|
|
64
|
+
primaryForeground: string;
|
|
65
|
+
secondary: string;
|
|
66
|
+
ring: string;
|
|
67
|
+
}
|
|
68
|
+
/** Derived colours for one primary; `null` when the value is not a colour the parser knows. */
|
|
69
|
+
export declare const derivePalette: (primary: string) => Palette | null;
|
|
70
|
+
/** Merge layers lowest first (`resolveTheme(admin, js)`); `undefined` and empty strings do not override. */
|
|
71
|
+
export declare const resolveTheme: (...layers: (ThemeOptions | null | undefined)[]) => ThemeOptions;
|
|
72
|
+
/**
|
|
73
|
+
* Inline variables for the root element. Kit tokens (`--primary`…) override the kit stylesheet; site CSS still wins,
|
|
74
|
+
* because the stylesheet reads `var(--aid-primary, hsl(var(--primary)))`. Radius and font go through `--radius` and
|
|
75
|
+
* `--aid-theme-font`, read the same way.
|
|
76
|
+
*/
|
|
77
|
+
export declare const themeToVars: (theme: ThemeOptions) => Record<string, string>;
|
|
78
|
+
export declare const resolveScheme: (scheme: Scheme | undefined, prefersDark: boolean) => "light" | "dark";
|
|
79
|
+
/** Writes the variables, removing the ones a previous theme set and this one does not. */
|
|
80
|
+
export declare const applyVars: (el: HTMLElement, next: Record<string, string>, prev?: Record<string, string>) => void;
|
|
81
|
+
/** `.dark` on the widget root switches the kit tokens (`.aid-root.dark`) and Tailwind `dark:` variants. */
|
|
82
|
+
export declare const applyScheme: (el: HTMLElement, scheme: "light" | "dark") => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsrcjs/ai-widget",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "AI-Dana chat widget: one script tag or mount(), Shadow DOM, React inside",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.12"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./ai-dana-chat.js": "./dist/ai-dana-chat.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/*.js",
|
|
22
|
+
"dist/index.d.ts",
|
|
23
|
+
"dist/drag.d.ts",
|
|
24
|
+
"dist/i18n.d.ts",
|
|
25
|
+
"dist/theme.d.ts",
|
|
26
|
+
"dist/avatar/model.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"./dist/ai-dana-chat.js",
|
|
30
|
+
"./dist/index.js"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"echarts": "^5.6.0"
|
|
37
|
+
}
|
|
38
|
+
}
|