@caoguo/maplibre-ai 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +83 -0
  2. package/package.json +26 -3
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @caoguo/maplibre-ai
2
+
3
+ > 草果地图 AI 工具链 — 性能诊断 / 样式生成器 v2
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@caoguo/maplibre-ai.svg)](https://www.npmjs.com/package/@caoguo/maplibre-ai)
6
+ [![license](https://img.shields.io/npm/l/@caoguo/maplibre-ai.svg)](LICENSE)
7
+
8
+ ## 安装
9
+
10
+ ```bash
11
+ npm install @caoguo/maplibre-ai
12
+ ```
13
+
14
+ ## 功能模块
15
+
16
+ | 模块 | 导出 | 说明 |
17
+ |------|------|------|
18
+ | 诊断 | `aiDebug` | AI Debug 诊断工具(性能 Profiler / 瓦片监控 / 内存泄漏 / 优化建议) |
19
+ | 样式生成 | `styleGenerator` | 样式生成器 v2(色板提取 / 行业模板 / 品牌定制 / 运营商主题 / 昼夜切换) |
20
+
21
+ ## 快速开始
22
+
23
+ ### 性能诊断
24
+
25
+ ```ts
26
+ import { aiDebug } from '@caoguo/maplibre-ai/debug';
27
+
28
+ // 在地图实例上启动性能 Profiler
29
+ const profiler = aiDebug.startProfiler(map.instance, {
30
+ tileMonitor: true, // 瓦片加载耗时监控
31
+ memoryLeak: true, // 内存泄漏检测
32
+ fpsSampleHz: 10,
33
+ });
34
+
35
+ // 结束诊断获取报告
36
+ const report = profiler.stop();
37
+ console.log('平均 FPS', report.avgFps);
38
+ console.log('瓦片加载 P95', report.tileLoadP95);
39
+ console.log('优化建议', report.suggestions);
40
+ ```
41
+
42
+ ### 样式生成器 v2
43
+
44
+ ```ts
45
+ import { styleGenerator } from '@caoguo/maplibre-ai/stylegen';
46
+
47
+ // 从品牌色板生成完整 MapLibre 样式
48
+ const style = await styleGenerator.fromPalette({
49
+ brandColors: ['#0a0e1a', '#4a9eff', '#e8edf3'],
50
+ theme: 'dark',
51
+ industry: 'pipeline', // 管网/电网/水网 等行业模板
52
+ notoFonts: true,
53
+ });
54
+
55
+ // 从图片提取色板再生成
56
+ const palette = await styleGenerator.extractPalette('/path/to/logo.png');
57
+ const style2 = await styleGenerator.fromPalette({ brandColors: palette });
58
+ ```
59
+
60
+ ### 运营商/昼夜主题
61
+
62
+ ```ts
63
+ import { styleGenerator } from '@caoguo/maplibre-ai/stylegen';
64
+
65
+ const dayTheme = styleGenerator.operatorTheme('china-mobile', 'day');
66
+ const nightTheme = styleGenerator.operatorTheme('china-mobile', 'night');
67
+ ```
68
+
69
+ ## 设计原则
70
+
71
+ 1. **AI 增强,非 AI 替代**:诊断与样式生成加速开发流程,不替代工程师判断。
72
+ 2. **本地优先**:所有工具优先在前端运行,不依赖外部 LLM(可选项)。
73
+ 3. **可解释**:所有诊断建议附原因与修复方案链接。
74
+
75
+ ## 浏览器 / 环境要求
76
+
77
+ - 现代浏览器(Chrome 90+)
78
+ - 样式生成器需支持 `OffscreenCanvas`(Chrome 69+)
79
+ - 核心模块在 Node.js 可测(已含 16 个 vitest 用例)
80
+
81
+ ## 许可
82
+
83
+ Apache-2.0
package/package.json CHANGED
@@ -1,7 +1,30 @@
1
1
  {
2
2
  "name": "@caoguo/maplibre-ai",
3
- "version": "0.0.1",
4
- "description": "草果地图 AI 工具链 - AI Debug 诊断 + 样式生成器 v2",
3
+ "version": "0.0.2",
4
+ "description": "草果地图 AI 工具链 - 性能诊断 / 样式生成器 v2",
5
+ "license": "Apache-2.0",
6
+ "author": "caoguo <caoguo@hb.cn>",
7
+ "homepage": "https://github.com/caoguo/map/blob/main/packages/ai/README.md",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/caoguo/map.git",
11
+ "directory": "packages/ai"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/caoguo/map/issues"
15
+ },
16
+ "keywords": [
17
+ "maplibre",
18
+ "caoguo",
19
+ "gis",
20
+ "ai",
21
+ "performance-profiler",
22
+ "tile-monitor",
23
+ "memory-leak",
24
+ "style-generator",
25
+ "palette-extraction",
26
+ "industry-template"
27
+ ],
5
28
  "type": "module",
6
29
  "main": "./dist/index.cjs",
7
30
  "module": "./dist/index.js",
@@ -27,7 +50,7 @@
27
50
  "dist"
28
51
  ],
29
52
  "dependencies": {
30
- "@caoguo/theme": "0.0.1"
53
+ "@caoguo/theme": "0.0.2"
31
54
  },
32
55
  "publishConfig": {
33
56
  "access": "public",