agentcss 0.25.2 → 0.25.4
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/01-tokens/tokens.css +1 -1
- package/API.md +13 -5
- package/CHANGELOG.md +199 -0
- package/CONTRIBUTING.md +5 -5
- package/README.zh-CN.md +3 -3
- package/ai/cli.js +5 -1
- package/ai/components.json +1 -1
- package/ai/tokens.json +100 -99
- package/ai/tokens.schema.json +96 -50
- package/dist/COSTS.md +7 -7
- package/docs/ACCESSIBILITY.md +1 -1
- package/docs/GUIDANCE.md +82 -0
- package/docs/LESSONS.md +182 -0
- package/index.html +1 -1
- package/llms-full.txt +1 -1
- package/package.json +4 -2
- package/types/index.d.ts +126 -2
package/types/index.d.ts
CHANGED
|
@@ -390,6 +390,114 @@ export interface FlipApi {
|
|
|
390
390
|
remove(container: HTMLElement, el: HTMLElement, done?: () => void): void;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
+
/* ============================================================================
|
|
394
|
+
* 资产 / 主题:`01-tokens/`、`09-assets/`、`04-recipes/` 的公开对象
|
|
395
|
+
*
|
|
396
|
+
* 🔴 为什么单列一段(0.25.2 的缺陷,0.25.3 补):这 8 个对象都挂在 window 上,
|
|
397
|
+
* 但本文件里一个都没有 ⇒ `window.Theme.set('dark')` 在 TS 项目里直接报
|
|
398
|
+
* "属性不存在",用户只能写 `(window as any).Theme` —— 等于绕过类型系统。
|
|
399
|
+
* 其中 `Upload` 更明显:`esm/upload.mjs` 是**存在**的,运行时能 import,
|
|
400
|
+
* 类型里却看不见。
|
|
401
|
+
*
|
|
402
|
+
* ⚠️ 本文件从前在这里写过一句「behavior-api 门禁核对源码 / esm 入口 /
|
|
403
|
+
* 本文件声明三者集合相等」—— 那句话**不成立**:那道门禁只比源码与 esm/,
|
|
404
|
+
* 从不读本文件(0.25.3 核实过)。现在由 `05-audit/types-globals-gate.py` 判:
|
|
405
|
+
* 源码里每个 `window.X =` / `global.X =` 都必须在这里有声明,
|
|
406
|
+
* 反过来每条声明也必须有源码依据。
|
|
407
|
+
*
|
|
408
|
+
* 为什么这 7 个不给 `export declare const`:`esm/` 里没有它们的包装模块
|
|
409
|
+
* (只有 16 个行为脚本 + upload)。声明一个运行时取不到的具名导出,
|
|
410
|
+
* 正是本库最反对的「幻觉 API」。它们只能走 `window.X`。
|
|
411
|
+
* ========================================================================== */
|
|
412
|
+
export type ThemeMode = 'light' | 'dark' | 'auto';
|
|
413
|
+
|
|
414
|
+
export interface ThemeApi {
|
|
415
|
+
/** 读当前**模式**(不是"现在是深还是浅"):auto 也算一种模式 */
|
|
416
|
+
get(): ThemeMode;
|
|
417
|
+
/** 当前实际渲染是不是深色(auto 模式下由系统决定) */
|
|
418
|
+
isDark(): boolean;
|
|
419
|
+
set(mode: ThemeMode): void;
|
|
420
|
+
toggle(): void;
|
|
421
|
+
/** 三态循环:auto → light → dark → auto */
|
|
422
|
+
cycle(): void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface ChartApi {
|
|
426
|
+
draw(el: Element): void;
|
|
427
|
+
/** `draw` 的语义别名:数据变了,重画一次 */
|
|
428
|
+
emit(el: Element): void;
|
|
429
|
+
/** 画一个区域里所有 `.sparkline[data-spark]` */
|
|
430
|
+
update(root?: ParentNode): void;
|
|
431
|
+
/** ⚠️ 只有浏览器支持 ResizeObserver 时才存在(老 WebView 里是 undefined) */
|
|
432
|
+
observe?(el?: Element): void;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface ChartAdapterPalette {
|
|
436
|
+
accent: string;
|
|
437
|
+
danger: string;
|
|
438
|
+
success: string;
|
|
439
|
+
warn: string;
|
|
440
|
+
info: string;
|
|
441
|
+
[key: string]: string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export interface ChartAdapterApi {
|
|
445
|
+
/** 读某个作用域下的 CSS 变量值(`ctx` 决定用哪套主题) */
|
|
446
|
+
cssVar(name: string, fallback?: string, ctx?: Element): string;
|
|
447
|
+
palette(ctx?: Element): ChartAdapterPalette;
|
|
448
|
+
seriesColors(n: number, p: ChartAdapterPalette): string[];
|
|
449
|
+
/** 生成 ECharts 主题对象;`name` 形如 `fe-light` / `fe-dark` */
|
|
450
|
+
theme(name: string, p?: ChartAdapterPalette | null, ctx?: Element): object;
|
|
451
|
+
themeName(ctx?: Element): string;
|
|
452
|
+
defaults(option?: object, ctx?: Element): object;
|
|
453
|
+
create(dom: HTMLElement, opt?: object): unknown;
|
|
454
|
+
/** 主题切换后重设;主题名变了会重建实例(ECharts 的主题在 init 时绑定) */
|
|
455
|
+
refresh(inst: unknown): unknown;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export interface ModelViewerInstance {
|
|
459
|
+
build(): void;
|
|
460
|
+
makeIdle(): void;
|
|
461
|
+
fail(msg?: string): void;
|
|
462
|
+
status(text: string): void;
|
|
463
|
+
load(): void;
|
|
464
|
+
boot(): void;
|
|
465
|
+
initScene(): void;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface BarApi {
|
|
469
|
+
draw(opt: {
|
|
470
|
+
host: HTMLElement;
|
|
471
|
+
/** 🔴 必填:本库铁律三,量程不得自动适配(漏了会抛错,不会悄悄自适应) */
|
|
472
|
+
max: number;
|
|
473
|
+
series?: unknown[];
|
|
474
|
+
height?: number;
|
|
475
|
+
mode?: 'group' | 'stack';
|
|
476
|
+
}): void;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface ScientificPlotApi {
|
|
480
|
+
render(el: Element, spec?: object): void;
|
|
481
|
+
/** 判据 / 单测用的真值入口;不承诺稳定,改版可能变 */
|
|
482
|
+
__internals: object;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface ShellNavInstance {
|
|
486
|
+
/** 已开着就直接返回现有句柄(重复点不该叠两层遮罩) */
|
|
487
|
+
open(): unknown;
|
|
488
|
+
close(): void;
|
|
489
|
+
destroy(): void;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface UploadInstance {
|
|
493
|
+
/** 收下一批文件(拖放入口,也是公开 API) */
|
|
494
|
+
add(incoming: FileList | File[], dirCount?: number): void;
|
|
495
|
+
render(): void;
|
|
496
|
+
setState(state: string): void;
|
|
497
|
+
setProgress(index: number, pct: number): void;
|
|
498
|
+
removeAt(index: number): void;
|
|
499
|
+
}
|
|
500
|
+
|
|
393
501
|
/* ============================================================================
|
|
394
502
|
* 全局命名空间(组件脚本是 IIFE,挂到 window)
|
|
395
503
|
* ========================================================================== */
|
|
@@ -412,6 +520,18 @@ export interface FrontendLibGlobal {
|
|
|
412
520
|
Toc: TocApi;
|
|
413
521
|
Reveal: RevealApi;
|
|
414
522
|
FLIP: FlipApi;
|
|
523
|
+
/* ---- 资产 / 主题(没有 esm 入口,只能走 window.X) ---- */
|
|
524
|
+
Theme: ThemeApi;
|
|
525
|
+
Chart: ChartApi;
|
|
526
|
+
ChartAdapter: ChartAdapterApi;
|
|
527
|
+
/** construct 形态:`new window.ModelViewer(node)` */
|
|
528
|
+
ModelViewer: new (node: HTMLElement) => ModelViewerInstance;
|
|
529
|
+
Bar: BarApi;
|
|
530
|
+
ScientificPlot: ScientificPlotApi;
|
|
531
|
+
/** construct 形态:`new window.ShellNav(root, opts)` */
|
|
532
|
+
ShellNav: new (root: HTMLElement, opts?: object) => ShellNavInstance;
|
|
533
|
+
/** construct 形态:`new window.Upload(root, opts)` */
|
|
534
|
+
Upload: new (root: HTMLElement, opts?: object) => UploadInstance;
|
|
415
535
|
}
|
|
416
536
|
|
|
417
537
|
declare global {
|
|
@@ -426,7 +546,8 @@ export declare const Dropdown: FrontendLibGlobal['Dropdown'];
|
|
|
426
546
|
export declare const Tree: FrontendLibGlobal['Tree'];
|
|
427
547
|
/* 与 `global.X = …` 一一对应(16 个行为脚本全部覆盖)。
|
|
428
548
|
证据:`esm/` 下的 16 个 .mjs 由 `05-audit/gen-esm.py` 从源码生成,
|
|
429
|
-
`behavior-api` 门禁核对「源码导出
|
|
549
|
+
`behavior-api` 门禁核对「源码导出 ↔ esm 入口」两者集合相等
|
|
550
|
+
(⚠️ 它**不读本文件**;本文件的声明由 `types-globals-gate.py` 判)。 */
|
|
430
551
|
export declare const Accordion: FrontendLibGlobal['Accordion'];
|
|
431
552
|
export declare const Tabs: FrontendLibGlobal['Tabs'];
|
|
432
553
|
export declare const Nav: FrontendLibGlobal['Nav'];
|
|
@@ -437,4 +558,7 @@ export declare const Tooltip: TooltipApi;
|
|
|
437
558
|
export declare const Popover: PopoverApi;
|
|
438
559
|
export declare const Toc: TocApi;
|
|
439
560
|
export declare const Reveal: RevealApi;
|
|
440
|
-
export declare const FLIP: FlipApi;
|
|
561
|
+
export declare const FLIP: FlipApi;
|
|
562
|
+
/* Upload 有 esm 入口(`esm/upload.mjs`)⇒ 可以具名导出;
|
|
563
|
+
其余 7 个资产/主题对象没有包装模块,只在 FrontendLibGlobal 里声明。 */
|
|
564
|
+
export declare const Upload: FrontendLibGlobal['Upload'];
|