cesium_dev_kit 1.1.22 → 1.1.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/CHANGELOG.md +60 -0
- package/README.md +293 -291
- package/README.zh-CN.md +274 -0
- package/SECURITY.md +21 -0
- package/dist/Analysis-BLpVrGfg.d.mts +143 -0
- package/dist/Analysis-DmO1gtgS.d.ts +143 -0
- package/dist/Base-DH8H9suE.d.mts +635 -0
- package/dist/Base-DH8H9suE.d.ts +635 -0
- package/dist/Base-_BOXyMdS.d.ts +43 -0
- package/dist/Base-skqjcPfo.d.mts +43 -0
- package/dist/Control-B7AMFmHe.d.ts +98 -0
- package/dist/Control-BrpRU7RP.d.mts +98 -0
- package/dist/CustomCesiumPlugin-BqgAvlhi.d.ts +29 -0
- package/dist/CustomCesiumPlugin-CKYQ-7i9.d.mts +29 -0
- package/dist/Draw-1NhPP8z3.d.mts +490 -0
- package/dist/Draw-DRh7yNzc.d.ts +490 -0
- package/dist/Graphics-CuFNsQ3b.d.ts +1565 -0
- package/dist/Graphics-QE3Gb43w.d.mts +1565 -0
- package/dist/Material-CeZ4l-tY.d.mts +165 -0
- package/dist/Material-Cqbyf2Pn.d.ts +165 -0
- package/dist/Math3d-0nO-vFbT.d.mts +179 -0
- package/dist/Math3d-t635PYzU.d.ts +179 -0
- package/dist/PassEffect-DEFyytQZ.d.ts +41 -0
- package/dist/PassEffect-DEgElnVk.d.mts +41 -0
- package/dist/Plugin-BPCX0zTu.d.mts +197 -0
- package/dist/Plugin-DnYT0bue.d.ts +197 -0
- package/dist/Primitive-BNXp-9_6.d.mts +199 -0
- package/dist/Primitive-UEAuUimH.d.ts +199 -0
- package/dist/ThreeJs-BAlEWxa1.d.mts +44 -0
- package/dist/ThreeJs-DpAcw_qf.d.ts +44 -0
- package/dist/analysis.cjs +145 -0
- package/dist/analysis.cjs.map +1 -0
- package/dist/analysis.d.mts +6 -0
- package/dist/analysis.d.ts +6 -0
- package/dist/analysis.mjs +145 -0
- package/dist/analysis.mjs.map +1 -0
- package/dist/control.cjs +140 -0
- package/dist/control.cjs.map +1 -0
- package/dist/control.d.mts +4 -0
- package/dist/control.d.ts +4 -0
- package/dist/control.mjs +140 -0
- package/dist/control.mjs.map +1 -0
- package/dist/custom-cesium-plugin.cjs +507 -0
- package/dist/custom-cesium-plugin.cjs.map +1 -0
- package/dist/custom-cesium-plugin.d.mts +4 -0
- package/dist/custom-cesium-plugin.d.ts +4 -0
- package/dist/custom-cesium-plugin.mjs +507 -0
- package/dist/custom-cesium-plugin.mjs.map +1 -0
- package/dist/default-static.cjs +3 -0
- package/dist/default-static.cjs.map +1 -0
- package/dist/default-static.d.mts +37 -0
- package/dist/default-static.d.ts +37 -0
- package/dist/default-static.mjs +3 -0
- package/dist/default-static.mjs.map +1 -0
- package/dist/draw.cjs +140 -0
- package/dist/draw.cjs.map +1 -0
- package/dist/draw.d.mts +6 -0
- package/dist/draw.d.ts +6 -0
- package/dist/draw.mjs +140 -0
- package/dist/draw.mjs.map +1 -0
- package/dist/graphics.cjs +140 -0
- package/dist/graphics.cjs.map +1 -0
- package/dist/graphics.d.mts +19 -0
- package/dist/graphics.d.ts +19 -0
- package/dist/graphics.mjs +140 -0
- package/dist/graphics.mjs.map +1 -0
- package/dist/index.cjs +1030 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +338 -0
- package/dist/index.d.ts +338 -0
- package/dist/index.mjs +1030 -0
- package/dist/index.mjs.map +1 -0
- package/dist/material.cjs +391 -0
- package/dist/material.cjs.map +1 -0
- package/dist/material.d.mts +4 -0
- package/dist/material.d.ts +4 -0
- package/dist/material.mjs +391 -0
- package/dist/material.mjs.map +1 -0
- package/dist/pass-effect.cjs +416 -0
- package/dist/pass-effect.cjs.map +1 -0
- package/dist/pass-effect.d.mts +4 -0
- package/dist/pass-effect.d.ts +4 -0
- package/dist/pass-effect.mjs +416 -0
- package/dist/pass-effect.mjs.map +1 -0
- package/dist/plugin.cjs +141 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.mts +4 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.mjs +141 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/primitive.cjs +370 -0
- package/dist/primitive.cjs.map +1 -0
- package/dist/primitive.d.mts +4 -0
- package/dist/primitive.d.ts +4 -0
- package/dist/primitive.mjs +370 -0
- package/dist/primitive.mjs.map +1 -0
- package/dist/three.cjs +140 -0
- package/dist/three.cjs.map +1 -0
- package/dist/three.d.mts +4 -0
- package/dist/three.d.ts +4 -0
- package/dist/three.mjs +140 -0
- package/dist/three.mjs.map +1 -0
- package/package.json +289 -46
- package/dist/index.js +0 -1
- package/dist/index.min.js +0 -1
- package/dist/index.umd.js +0 -1
- package/index.js +0 -37
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { C as CesiumGlobal, V as Viewer, S as StaticResourceConf, B as BaseInstance } from './Base-DH8H9suE.mjs';
|
|
2
|
+
import { M as MaterialInstance } from './Material-CeZ4l-tY.mjs';
|
|
3
|
+
export { a as Material } from './Material-CeZ4l-tY.mjs';
|
|
4
|
+
import { G as GraphicsInstance } from './Graphics-QE3Gb43w.mjs';
|
|
5
|
+
import { M as Math2dInstance, D as DrawInstance, A as AttackArrowInstance, S as StraightArrowInstance, P as PincerArrowInstance } from './Draw-1NhPP8z3.mjs';
|
|
6
|
+
export { a as AttackArrow, b as Draw, c as Math2d, d as PincerArrow, e as StraightArrow } from './Draw-1NhPP8z3.mjs';
|
|
7
|
+
import { P as PrimitiveInstance } from './Primitive-BNXp-9_6.mjs';
|
|
8
|
+
export { a as Primitive } from './Primitive-BNXp-9_6.mjs';
|
|
9
|
+
import { C as CustomCesiumPluginInstance } from './CustomCesiumPlugin-CKYQ-7i9.mjs';
|
|
10
|
+
export { a as CustomCesiumPlugin } from './CustomCesiumPlugin-CKYQ-7i9.mjs';
|
|
11
|
+
import { P as PassEffectInstance } from './PassEffect-DEgElnVk.mjs';
|
|
12
|
+
export { a as PassEffect } from './PassEffect-DEgElnVk.mjs';
|
|
13
|
+
import { M as Math3dInstance } from './Math3d-0nO-vFbT.mjs';
|
|
14
|
+
export { a as Math3d } from './Math3d-0nO-vFbT.mjs';
|
|
15
|
+
import { C as ControlInstance } from './Control-BrpRU7RP.mjs';
|
|
16
|
+
export { a as Control } from './Control-BrpRU7RP.mjs';
|
|
17
|
+
import { P as PluginInstance } from './Plugin-BPCX0zTu.mjs';
|
|
18
|
+
export { a as Plugin } from './Plugin-BPCX0zTu.mjs';
|
|
19
|
+
import { A as AnalysisInstance } from './Analysis-BLpVrGfg.mjs';
|
|
20
|
+
export { a as Analysis } from './Analysis-BLpVrGfg.mjs';
|
|
21
|
+
import { T as ThreeJsInstance } from './ThreeJs-BAlEWxa1.mjs';
|
|
22
|
+
export { a as ThreeJs } from './ThreeJs-BAlEWxa1.mjs';
|
|
23
|
+
export { DEFAULT_STATIC_BASE, createDefaultStatic, defaultStatic } from './default-static.mjs';
|
|
24
|
+
export { Graphics } from './graphics.mjs';
|
|
25
|
+
import 'cesium';
|
|
26
|
+
import './Base-skqjcPfo.mjs';
|
|
27
|
+
|
|
28
|
+
/** Shaders 实例类型 */
|
|
29
|
+
interface ShadersInstance {
|
|
30
|
+
_getFlowLineShader(): any;
|
|
31
|
+
_getDynamicLineShader(options?: any): any;
|
|
32
|
+
_getDynamicLightLineShader(options?: any): any;
|
|
33
|
+
_getDirectionWallShader(options?: any): any;
|
|
34
|
+
_getCircleFadeShader(options?: any): any;
|
|
35
|
+
_getDynamicCircleShader(options?: any): any;
|
|
36
|
+
_getRadarScanShader(options?: any): any;
|
|
37
|
+
_getCircleScanShader(options?: any): any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 统一错误类型与错误上报出口。
|
|
42
|
+
*
|
|
43
|
+
* 设计目标:
|
|
44
|
+
* 1. 不再 `throw '字符串'`:所有库内主动抛出的错误都带稳定的 `code`,
|
|
45
|
+
* 使用方可以按 code 做分支处理,而不用匹配错误文案。
|
|
46
|
+
* 2. 不再吞掉异常:原本的 `catch {}` 改为 {@link reportError},
|
|
47
|
+
* 默认走 `console.warn` 并带上上下文,使用方也可以通过
|
|
48
|
+
* {@link setErrorHandler} 接管(上报监控、弹提示等)。
|
|
49
|
+
*/
|
|
50
|
+
/** 错误码(稳定契约,新增只会追加) */
|
|
51
|
+
type CesiumDevKitErrorCode =
|
|
52
|
+
/** 未传入 Cesium 全局对象 */
|
|
53
|
+
'MISSING_CESIUM'
|
|
54
|
+
/** 既没有 containerId 也没有传入 viewer */
|
|
55
|
+
| 'MISSING_VIEWER'
|
|
56
|
+
/** 参数非法 */
|
|
57
|
+
| 'INVALID_ARGUMENT'
|
|
58
|
+
/** 影像图层创建 / 加载失败 */
|
|
59
|
+
| 'IMAGERY_FAILED'
|
|
60
|
+
/** 可选依赖(echarts / dat.gui / libgif / three)未安装 */
|
|
61
|
+
| 'OPTIONAL_DEPENDENCY_MISSING'
|
|
62
|
+
/** 当前环境不支持(如 SSR / Node 下调用了需要 DOM 的能力) */
|
|
63
|
+
| 'UNSUPPORTED_ENVIRONMENT'
|
|
64
|
+
/** 实例已销毁后继续调用 */
|
|
65
|
+
| 'DISPOSED'
|
|
66
|
+
/** Cesium 版本 / 内部 API 不兼容 */
|
|
67
|
+
| 'UNSUPPORTED_CESIUM_VERSION'
|
|
68
|
+
/** 其它内部错误 */
|
|
69
|
+
| 'INTERNAL';
|
|
70
|
+
/** CesiumDevKitError 构造参数 */
|
|
71
|
+
interface CesiumDevKitErrorOptions {
|
|
72
|
+
/** 原始错误(会被挂到 `cause` 上,便于排查) */
|
|
73
|
+
cause?: unknown;
|
|
74
|
+
/** 附加上下文(provider 类型、url、参数名等) */
|
|
75
|
+
details?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 库统一错误类型。
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* try {
|
|
82
|
+
* await kit.base.addImageryProviderAsync({ type: 'X', option: {} })
|
|
83
|
+
* } catch (err) {
|
|
84
|
+
* if (isCesiumDevKitError(err) && err.code === 'IMAGERY_FAILED') {
|
|
85
|
+
* // 降级到备用底图
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
declare class CesiumDevKitError extends Error {
|
|
90
|
+
/** 稳定错误码 */
|
|
91
|
+
readonly code: CesiumDevKitErrorCode;
|
|
92
|
+
/** 附加上下文 */
|
|
93
|
+
readonly details?: Record<string, unknown>;
|
|
94
|
+
/** 原始错误 */
|
|
95
|
+
readonly cause?: unknown;
|
|
96
|
+
constructor(code: CesiumDevKitErrorCode, message: string, options?: CesiumDevKitErrorOptions);
|
|
97
|
+
}
|
|
98
|
+
/** 判断是否为库内抛出的结构化错误(跨包实例 / 多副本场景同样有效) */
|
|
99
|
+
declare function isCesiumDevKitError(value: unknown): value is CesiumDevKitError;
|
|
100
|
+
/** 错误上报上下文 */
|
|
101
|
+
interface ErrorReportContext {
|
|
102
|
+
/** 出错的能力/模块,如 'graphics.createPointGraphics' */
|
|
103
|
+
scope?: string;
|
|
104
|
+
/** 其它附加上下文 */
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 自定义错误处理器。
|
|
109
|
+
* 返回值会被忽略;处理器内部抛错不会影响主流程。
|
|
110
|
+
*/
|
|
111
|
+
type CesiumDevKitErrorHandler = (error: unknown, context?: ErrorReportContext) => void;
|
|
112
|
+
/**
|
|
113
|
+
* 注册全局错误处理器(传 null 恢复默认的 console.warn)。
|
|
114
|
+
*
|
|
115
|
+
* 适合接入 Sentry 等监控:
|
|
116
|
+
* ```ts
|
|
117
|
+
* setErrorHandler((err, ctx) => Sentry.captureException(err, { extra: ctx }))
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function setErrorHandler(handler: CesiumDevKitErrorHandler | null): void;
|
|
121
|
+
/** 获取当前注册的错误处理器(未注册时为 null) */
|
|
122
|
+
declare function getErrorHandler(): CesiumDevKitErrorHandler | null;
|
|
123
|
+
/**
|
|
124
|
+
* 上报一个非致命错误。
|
|
125
|
+
*
|
|
126
|
+
* 用于原本 `catch {}` 的位置:既不打断主流程,也不让问题彻底消失。
|
|
127
|
+
* 已注册 {@link setErrorHandler} 时交给使用方,否则 `console.warn`。
|
|
128
|
+
*/
|
|
129
|
+
declare function reportError(error: unknown, context?: ErrorReportContext): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 注意:库内不再内置 Cesium Ion token。
|
|
133
|
+
* 请通过 `extraConfig.AccessToken` 传入,或在应用入口自行设置
|
|
134
|
+
* `Cesium.Ion.defaultAccessToken`,避免使用库作者的配额且便于轮换。
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* 初始化参数中的额外配置
|
|
138
|
+
*/
|
|
139
|
+
interface ExtraConfig {
|
|
140
|
+
/** 认证 token */
|
|
141
|
+
AccessToken?: string;
|
|
142
|
+
/** 显示 logo,默认 true(传 false 隐藏 logo) */
|
|
143
|
+
logo?: boolean;
|
|
144
|
+
/** 是否开启深度检测,默认 false */
|
|
145
|
+
depthTest?: boolean;
|
|
146
|
+
/** 其它自定义配置 */
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* imageryProvider 配置项
|
|
151
|
+
*/
|
|
152
|
+
interface ImageryProviderConf {
|
|
153
|
+
/** Provider 类型:WebMapTileServiceImageryProvider/UrlTemplateImageryProvider/TileMapServiceImageryProvider */
|
|
154
|
+
type: string;
|
|
155
|
+
/** 对应 provider 的参数配置 */
|
|
156
|
+
option?: Record<string, unknown>;
|
|
157
|
+
/** 兼容旧版本的配置字段(与 option 等价) */
|
|
158
|
+
classConfig?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 运行环境判断:是否处于浏览器 / 有 DOM 的环境。
|
|
163
|
+
*
|
|
164
|
+
* 库本身允许在 Node / SSR 中 `import`(顶层不访问 window/document),
|
|
165
|
+
* 但创建 viewer、操作 DOM 的能力必须在浏览器里调用。
|
|
166
|
+
*/
|
|
167
|
+
declare function isBrowser(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* 断言当前处于浏览器环境。
|
|
170
|
+
* @param feature - 能力名称,用于错误信息
|
|
171
|
+
*/
|
|
172
|
+
declare function assertBrowser(feature: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* 创建 kit 上下文所需参数。
|
|
175
|
+
*
|
|
176
|
+
* `CreateKitOptions` 继承本接口,因此 `createKit` 与 `createContext` 用同一套参数。
|
|
177
|
+
*/
|
|
178
|
+
interface CesiumContextOptions {
|
|
179
|
+
/** Cesium 全局命名空间(与 `Cesium` 二选一,必须提供一个) */
|
|
180
|
+
cesiumGlobal?: CesiumGlobal;
|
|
181
|
+
/** `cesiumGlobal` 的别名,便于 `createKit({ Cesium })` 写法 */
|
|
182
|
+
Cesium?: CesiumGlobal;
|
|
183
|
+
/** 全局 THREE 对象(使用 three 相关能力时传入) */
|
|
184
|
+
threeGlobal?: any;
|
|
185
|
+
/** `threeGlobal` 的别名 */
|
|
186
|
+
three?: any;
|
|
187
|
+
/** 挂载 viewer 的 dom id 或元素(不传 `viewer` 时必传) */
|
|
188
|
+
containerId?: string | HTMLElement;
|
|
189
|
+
/** 挂载 three 容器的 dom id 或元素 */
|
|
190
|
+
threeContainerId?: string | HTMLElement;
|
|
191
|
+
/** 外部已创建好的 viewer(传入后 kit 不会销毁它) */
|
|
192
|
+
viewer?: Viewer;
|
|
193
|
+
/** cesium Viewer 构造参数 */
|
|
194
|
+
viewerConfig?: Record<string, unknown>;
|
|
195
|
+
/** 额外配置(AccessToken / logo / depthTest ...) */
|
|
196
|
+
extraConfig?: ExtraConfig;
|
|
197
|
+
/** 影像 provider 配置,透传给 Viewer 构造参数 */
|
|
198
|
+
imageryProvider?: Record<string, ImageryProviderConf | unknown>;
|
|
199
|
+
/** 初始化后追加的影像图层 */
|
|
200
|
+
MapImageryList?: ImageryProviderConf[];
|
|
201
|
+
/** 自定义静态资源配置(优先级高于 `assetsBaseUrl`) */
|
|
202
|
+
defaultStatic?: StaticResourceConf;
|
|
203
|
+
/**
|
|
204
|
+
* 静态资源基础地址,等价于 `createDefaultStatic(assetsBaseUrl)`。
|
|
205
|
+
* 传空字符串表示使用站点相对路径(需自行托管 public/static)。
|
|
206
|
+
*/
|
|
207
|
+
assetsBaseUrl?: string;
|
|
208
|
+
/**
|
|
209
|
+
* 非致命错误处理器,等价于全局 `setErrorHandler`。
|
|
210
|
+
* 用于接管库内被 catch 掉的错误(销毁失败、可选依赖缺失等)。
|
|
211
|
+
*/
|
|
212
|
+
onError?: CesiumDevKitErrorHandler;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 一次 kit 实例的运行时上下文。
|
|
216
|
+
*
|
|
217
|
+
* 所有模块共享同一个 context,模块内部不再依赖模块级全局变量,
|
|
218
|
+
* 因此同一个页面可以安全地同时存在多个 kit / 多个 viewer。
|
|
219
|
+
*/
|
|
220
|
+
interface CesiumContext {
|
|
221
|
+
/** 注入的 Cesium 全局对象 */
|
|
222
|
+
readonly Cesium: CesiumGlobal;
|
|
223
|
+
/** 本次 kit 使用的 viewer */
|
|
224
|
+
readonly viewer: Viewer;
|
|
225
|
+
/** 静态资源(图标 / 天空盒等)配置 */
|
|
226
|
+
readonly defaultStatic: StaticResourceConf;
|
|
227
|
+
/** 静态资源前缀(`defaultStatic.baseService`) */
|
|
228
|
+
readonly assetsBaseUrl: string;
|
|
229
|
+
/** three 全局对象(未传入时为 undefined) */
|
|
230
|
+
readonly three?: any;
|
|
231
|
+
/** viewer 是否由 kit 创建(决定 dispose 时是否销毁) */
|
|
232
|
+
readonly ownsViewer: boolean;
|
|
233
|
+
/** 挂载容器(外部传入 viewer 时可能为 undefined) */
|
|
234
|
+
readonly containerId?: string | HTMLElement;
|
|
235
|
+
/** three 容器 */
|
|
236
|
+
readonly threeContainerId?: string | HTMLElement;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 创建(或接管)viewer,并组装出上下文。
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* const ctx = createContext({ Cesium, containerId: 'cesiumContainer', assetsBaseUrl: '/static/' })
|
|
243
|
+
* ctx.viewer // 可直接使用
|
|
244
|
+
*/
|
|
245
|
+
declare function createContext(options: CesiumContextOptions): CesiumContext;
|
|
246
|
+
/** 释放上下文:仅销毁 kit 自己创建的 viewer */
|
|
247
|
+
declare function disposeContext(context: CesiumContext | null | undefined): void;
|
|
248
|
+
|
|
249
|
+
/** 创建 kit 的参数,与 {@link CesiumContextOptions} 一致 */
|
|
250
|
+
type CreateKitOptions = CesiumContextOptions;
|
|
251
|
+
/** kit 内所有模块实例 */
|
|
252
|
+
interface ResModulesType {
|
|
253
|
+
/** cesium viewer 实例 */
|
|
254
|
+
viewer: CesiumContext['viewer'];
|
|
255
|
+
/** 本次 kit 的运行时上下文 */
|
|
256
|
+
context: CesiumContext;
|
|
257
|
+
/**
|
|
258
|
+
* 销毁 kit 持有的资源(幂等)。
|
|
259
|
+
*
|
|
260
|
+
* - viewer 由 kit 创建:调用 `viewer.destroy()`;
|
|
261
|
+
* - viewer 由外部传入:只清理 kit 自己添加的监听 / 实体,不动外部 viewer。
|
|
262
|
+
*/
|
|
263
|
+
dispose: () => void;
|
|
264
|
+
/** 是否已释放 */
|
|
265
|
+
isDisposed: () => boolean;
|
|
266
|
+
/** 材质模块 */
|
|
267
|
+
material: MaterialInstance & BaseInstance & ShadersInstance;
|
|
268
|
+
/** 图形模块 */
|
|
269
|
+
graphics: GraphicsInstance & BaseInstance;
|
|
270
|
+
/** 数学 3d 计算工具 */
|
|
271
|
+
math3d: Math3dInstance & BaseInstance;
|
|
272
|
+
/** 数学 2d 计算工具 */
|
|
273
|
+
math2d: Math2dInstance;
|
|
274
|
+
/** 图元模块 */
|
|
275
|
+
primitive: PrimitiveInstance & BaseInstance;
|
|
276
|
+
/** 绘制模块 */
|
|
277
|
+
draw: DrawInstance & BaseInstance & Math3dInstance & Math2dInstance;
|
|
278
|
+
/** 后置处理模块 */
|
|
279
|
+
passEffect: PassEffectInstance & BaseInstance & ShadersInstance;
|
|
280
|
+
/** 自定义扩展(传感器)模块 */
|
|
281
|
+
customCesiumPlugin: CustomCesiumPluginInstance & BaseInstance;
|
|
282
|
+
/** 场景控制模块 */
|
|
283
|
+
control: ControlInstance & BaseInstance;
|
|
284
|
+
/** 插件模块 */
|
|
285
|
+
plugin: PluginInstance & BaseInstance & GraphicsInstance;
|
|
286
|
+
/** 基础模块 */
|
|
287
|
+
base: BaseInstance;
|
|
288
|
+
/** 分析模块 */
|
|
289
|
+
analysis: AnalysisInstance & BaseInstance & DrawInstance & PluginInstance;
|
|
290
|
+
/** 标绘(攻击箭头)模块 */
|
|
291
|
+
attackArrowObj: AttackArrowInstance;
|
|
292
|
+
/** 标绘(直线箭头)模块 */
|
|
293
|
+
straightArrowObj: StraightArrowInstance;
|
|
294
|
+
/** 标绘(钳击箭头)模块 */
|
|
295
|
+
pincerArrowObj: PincerArrowInstance;
|
|
296
|
+
/** threejs 集成模块 */
|
|
297
|
+
threeJs: ThreeJsInstance;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* 创建一个 Cesium 开发套件实例(推荐入口)。
|
|
301
|
+
*
|
|
302
|
+
* 相比 `new initCesium(...)`:
|
|
303
|
+
* - 不依赖模块级全局状态,同一页面可并存多个 kit / 多个 viewer;
|
|
304
|
+
* - 返回带 `context` 的显式上下文,便于测试与依赖注入;
|
|
305
|
+
* - `dispose()` 有明确契约:自己创建的 viewer 才销毁。
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* import * as Cesium from 'cesium'
|
|
309
|
+
* import { createKit } from 'cesium_dev_kit'
|
|
310
|
+
*
|
|
311
|
+
* const kit = createKit({
|
|
312
|
+
* Cesium,
|
|
313
|
+
* containerId: 'cesiumContainer',
|
|
314
|
+
* assetsBaseUrl: '/static/',
|
|
315
|
+
* viewerConfig: { infoBox: false }
|
|
316
|
+
* })
|
|
317
|
+
*
|
|
318
|
+
* kit.graphics.getPointGraphics({ ... })
|
|
319
|
+
*
|
|
320
|
+
* // 组件卸载时
|
|
321
|
+
* kit.dispose()
|
|
322
|
+
*/
|
|
323
|
+
declare function createKit(options: CreateKitOptions): ResModulesType;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* initCesium 的参数(兼容旧入口,字段与 `CreateKitOptions` 一致)
|
|
327
|
+
*/
|
|
328
|
+
type InitCesiumOptions = CreateKitOptions;
|
|
329
|
+
|
|
330
|
+
/** initCesium 同时支持函数调用与 new 调用(兼容历史用法) */
|
|
331
|
+
interface InitCesiumConstructor {
|
|
332
|
+
(options: InitCesiumOptions): ResModulesType;
|
|
333
|
+
new (options: InitCesiumOptions): ResModulesType;
|
|
334
|
+
prototype: ResModulesType;
|
|
335
|
+
}
|
|
336
|
+
declare const initCesium: InitCesiumConstructor;
|
|
337
|
+
|
|
338
|
+
export { type CesiumContext, type CesiumContextOptions, CesiumDevKitError, type CesiumDevKitErrorCode, type CesiumDevKitErrorHandler, CesiumGlobal, type CreateKitOptions, type ResModulesType, assertBrowser, createContext, createKit, disposeContext, getErrorHandler, initCesium, isBrowser, isCesiumDevKitError, reportError, setErrorHandler };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { C as CesiumGlobal, V as Viewer, S as StaticResourceConf, B as BaseInstance } from './Base-DH8H9suE.js';
|
|
2
|
+
import { M as MaterialInstance } from './Material-Cqbyf2Pn.js';
|
|
3
|
+
export { a as Material } from './Material-Cqbyf2Pn.js';
|
|
4
|
+
import { G as GraphicsInstance } from './Graphics-CuFNsQ3b.js';
|
|
5
|
+
import { M as Math2dInstance, D as DrawInstance, A as AttackArrowInstance, S as StraightArrowInstance, P as PincerArrowInstance } from './Draw-DRh7yNzc.js';
|
|
6
|
+
export { a as AttackArrow, b as Draw, c as Math2d, d as PincerArrow, e as StraightArrow } from './Draw-DRh7yNzc.js';
|
|
7
|
+
import { P as PrimitiveInstance } from './Primitive-UEAuUimH.js';
|
|
8
|
+
export { a as Primitive } from './Primitive-UEAuUimH.js';
|
|
9
|
+
import { C as CustomCesiumPluginInstance } from './CustomCesiumPlugin-BqgAvlhi.js';
|
|
10
|
+
export { a as CustomCesiumPlugin } from './CustomCesiumPlugin-BqgAvlhi.js';
|
|
11
|
+
import { P as PassEffectInstance } from './PassEffect-DEFyytQZ.js';
|
|
12
|
+
export { a as PassEffect } from './PassEffect-DEFyytQZ.js';
|
|
13
|
+
import { M as Math3dInstance } from './Math3d-t635PYzU.js';
|
|
14
|
+
export { a as Math3d } from './Math3d-t635PYzU.js';
|
|
15
|
+
import { C as ControlInstance } from './Control-B7AMFmHe.js';
|
|
16
|
+
export { a as Control } from './Control-B7AMFmHe.js';
|
|
17
|
+
import { P as PluginInstance } from './Plugin-DnYT0bue.js';
|
|
18
|
+
export { a as Plugin } from './Plugin-DnYT0bue.js';
|
|
19
|
+
import { A as AnalysisInstance } from './Analysis-DmO1gtgS.js';
|
|
20
|
+
export { a as Analysis } from './Analysis-DmO1gtgS.js';
|
|
21
|
+
import { T as ThreeJsInstance } from './ThreeJs-DpAcw_qf.js';
|
|
22
|
+
export { a as ThreeJs } from './ThreeJs-DpAcw_qf.js';
|
|
23
|
+
export { DEFAULT_STATIC_BASE, createDefaultStatic, defaultStatic } from './default-static.js';
|
|
24
|
+
export { Graphics } from './graphics.js';
|
|
25
|
+
import 'cesium';
|
|
26
|
+
import './Base-_BOXyMdS.js';
|
|
27
|
+
|
|
28
|
+
/** Shaders 实例类型 */
|
|
29
|
+
interface ShadersInstance {
|
|
30
|
+
_getFlowLineShader(): any;
|
|
31
|
+
_getDynamicLineShader(options?: any): any;
|
|
32
|
+
_getDynamicLightLineShader(options?: any): any;
|
|
33
|
+
_getDirectionWallShader(options?: any): any;
|
|
34
|
+
_getCircleFadeShader(options?: any): any;
|
|
35
|
+
_getDynamicCircleShader(options?: any): any;
|
|
36
|
+
_getRadarScanShader(options?: any): any;
|
|
37
|
+
_getCircleScanShader(options?: any): any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 统一错误类型与错误上报出口。
|
|
42
|
+
*
|
|
43
|
+
* 设计目标:
|
|
44
|
+
* 1. 不再 `throw '字符串'`:所有库内主动抛出的错误都带稳定的 `code`,
|
|
45
|
+
* 使用方可以按 code 做分支处理,而不用匹配错误文案。
|
|
46
|
+
* 2. 不再吞掉异常:原本的 `catch {}` 改为 {@link reportError},
|
|
47
|
+
* 默认走 `console.warn` 并带上上下文,使用方也可以通过
|
|
48
|
+
* {@link setErrorHandler} 接管(上报监控、弹提示等)。
|
|
49
|
+
*/
|
|
50
|
+
/** 错误码(稳定契约,新增只会追加) */
|
|
51
|
+
type CesiumDevKitErrorCode =
|
|
52
|
+
/** 未传入 Cesium 全局对象 */
|
|
53
|
+
'MISSING_CESIUM'
|
|
54
|
+
/** 既没有 containerId 也没有传入 viewer */
|
|
55
|
+
| 'MISSING_VIEWER'
|
|
56
|
+
/** 参数非法 */
|
|
57
|
+
| 'INVALID_ARGUMENT'
|
|
58
|
+
/** 影像图层创建 / 加载失败 */
|
|
59
|
+
| 'IMAGERY_FAILED'
|
|
60
|
+
/** 可选依赖(echarts / dat.gui / libgif / three)未安装 */
|
|
61
|
+
| 'OPTIONAL_DEPENDENCY_MISSING'
|
|
62
|
+
/** 当前环境不支持(如 SSR / Node 下调用了需要 DOM 的能力) */
|
|
63
|
+
| 'UNSUPPORTED_ENVIRONMENT'
|
|
64
|
+
/** 实例已销毁后继续调用 */
|
|
65
|
+
| 'DISPOSED'
|
|
66
|
+
/** Cesium 版本 / 内部 API 不兼容 */
|
|
67
|
+
| 'UNSUPPORTED_CESIUM_VERSION'
|
|
68
|
+
/** 其它内部错误 */
|
|
69
|
+
| 'INTERNAL';
|
|
70
|
+
/** CesiumDevKitError 构造参数 */
|
|
71
|
+
interface CesiumDevKitErrorOptions {
|
|
72
|
+
/** 原始错误(会被挂到 `cause` 上,便于排查) */
|
|
73
|
+
cause?: unknown;
|
|
74
|
+
/** 附加上下文(provider 类型、url、参数名等) */
|
|
75
|
+
details?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 库统一错误类型。
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* try {
|
|
82
|
+
* await kit.base.addImageryProviderAsync({ type: 'X', option: {} })
|
|
83
|
+
* } catch (err) {
|
|
84
|
+
* if (isCesiumDevKitError(err) && err.code === 'IMAGERY_FAILED') {
|
|
85
|
+
* // 降级到备用底图
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
declare class CesiumDevKitError extends Error {
|
|
90
|
+
/** 稳定错误码 */
|
|
91
|
+
readonly code: CesiumDevKitErrorCode;
|
|
92
|
+
/** 附加上下文 */
|
|
93
|
+
readonly details?: Record<string, unknown>;
|
|
94
|
+
/** 原始错误 */
|
|
95
|
+
readonly cause?: unknown;
|
|
96
|
+
constructor(code: CesiumDevKitErrorCode, message: string, options?: CesiumDevKitErrorOptions);
|
|
97
|
+
}
|
|
98
|
+
/** 判断是否为库内抛出的结构化错误(跨包实例 / 多副本场景同样有效) */
|
|
99
|
+
declare function isCesiumDevKitError(value: unknown): value is CesiumDevKitError;
|
|
100
|
+
/** 错误上报上下文 */
|
|
101
|
+
interface ErrorReportContext {
|
|
102
|
+
/** 出错的能力/模块,如 'graphics.createPointGraphics' */
|
|
103
|
+
scope?: string;
|
|
104
|
+
/** 其它附加上下文 */
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 自定义错误处理器。
|
|
109
|
+
* 返回值会被忽略;处理器内部抛错不会影响主流程。
|
|
110
|
+
*/
|
|
111
|
+
type CesiumDevKitErrorHandler = (error: unknown, context?: ErrorReportContext) => void;
|
|
112
|
+
/**
|
|
113
|
+
* 注册全局错误处理器(传 null 恢复默认的 console.warn)。
|
|
114
|
+
*
|
|
115
|
+
* 适合接入 Sentry 等监控:
|
|
116
|
+
* ```ts
|
|
117
|
+
* setErrorHandler((err, ctx) => Sentry.captureException(err, { extra: ctx }))
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function setErrorHandler(handler: CesiumDevKitErrorHandler | null): void;
|
|
121
|
+
/** 获取当前注册的错误处理器(未注册时为 null) */
|
|
122
|
+
declare function getErrorHandler(): CesiumDevKitErrorHandler | null;
|
|
123
|
+
/**
|
|
124
|
+
* 上报一个非致命错误。
|
|
125
|
+
*
|
|
126
|
+
* 用于原本 `catch {}` 的位置:既不打断主流程,也不让问题彻底消失。
|
|
127
|
+
* 已注册 {@link setErrorHandler} 时交给使用方,否则 `console.warn`。
|
|
128
|
+
*/
|
|
129
|
+
declare function reportError(error: unknown, context?: ErrorReportContext): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 注意:库内不再内置 Cesium Ion token。
|
|
133
|
+
* 请通过 `extraConfig.AccessToken` 传入,或在应用入口自行设置
|
|
134
|
+
* `Cesium.Ion.defaultAccessToken`,避免使用库作者的配额且便于轮换。
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* 初始化参数中的额外配置
|
|
138
|
+
*/
|
|
139
|
+
interface ExtraConfig {
|
|
140
|
+
/** 认证 token */
|
|
141
|
+
AccessToken?: string;
|
|
142
|
+
/** 显示 logo,默认 true(传 false 隐藏 logo) */
|
|
143
|
+
logo?: boolean;
|
|
144
|
+
/** 是否开启深度检测,默认 false */
|
|
145
|
+
depthTest?: boolean;
|
|
146
|
+
/** 其它自定义配置 */
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* imageryProvider 配置项
|
|
151
|
+
*/
|
|
152
|
+
interface ImageryProviderConf {
|
|
153
|
+
/** Provider 类型:WebMapTileServiceImageryProvider/UrlTemplateImageryProvider/TileMapServiceImageryProvider */
|
|
154
|
+
type: string;
|
|
155
|
+
/** 对应 provider 的参数配置 */
|
|
156
|
+
option?: Record<string, unknown>;
|
|
157
|
+
/** 兼容旧版本的配置字段(与 option 等价) */
|
|
158
|
+
classConfig?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 运行环境判断:是否处于浏览器 / 有 DOM 的环境。
|
|
163
|
+
*
|
|
164
|
+
* 库本身允许在 Node / SSR 中 `import`(顶层不访问 window/document),
|
|
165
|
+
* 但创建 viewer、操作 DOM 的能力必须在浏览器里调用。
|
|
166
|
+
*/
|
|
167
|
+
declare function isBrowser(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* 断言当前处于浏览器环境。
|
|
170
|
+
* @param feature - 能力名称,用于错误信息
|
|
171
|
+
*/
|
|
172
|
+
declare function assertBrowser(feature: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* 创建 kit 上下文所需参数。
|
|
175
|
+
*
|
|
176
|
+
* `CreateKitOptions` 继承本接口,因此 `createKit` 与 `createContext` 用同一套参数。
|
|
177
|
+
*/
|
|
178
|
+
interface CesiumContextOptions {
|
|
179
|
+
/** Cesium 全局命名空间(与 `Cesium` 二选一,必须提供一个) */
|
|
180
|
+
cesiumGlobal?: CesiumGlobal;
|
|
181
|
+
/** `cesiumGlobal` 的别名,便于 `createKit({ Cesium })` 写法 */
|
|
182
|
+
Cesium?: CesiumGlobal;
|
|
183
|
+
/** 全局 THREE 对象(使用 three 相关能力时传入) */
|
|
184
|
+
threeGlobal?: any;
|
|
185
|
+
/** `threeGlobal` 的别名 */
|
|
186
|
+
three?: any;
|
|
187
|
+
/** 挂载 viewer 的 dom id 或元素(不传 `viewer` 时必传) */
|
|
188
|
+
containerId?: string | HTMLElement;
|
|
189
|
+
/** 挂载 three 容器的 dom id 或元素 */
|
|
190
|
+
threeContainerId?: string | HTMLElement;
|
|
191
|
+
/** 外部已创建好的 viewer(传入后 kit 不会销毁它) */
|
|
192
|
+
viewer?: Viewer;
|
|
193
|
+
/** cesium Viewer 构造参数 */
|
|
194
|
+
viewerConfig?: Record<string, unknown>;
|
|
195
|
+
/** 额外配置(AccessToken / logo / depthTest ...) */
|
|
196
|
+
extraConfig?: ExtraConfig;
|
|
197
|
+
/** 影像 provider 配置,透传给 Viewer 构造参数 */
|
|
198
|
+
imageryProvider?: Record<string, ImageryProviderConf | unknown>;
|
|
199
|
+
/** 初始化后追加的影像图层 */
|
|
200
|
+
MapImageryList?: ImageryProviderConf[];
|
|
201
|
+
/** 自定义静态资源配置(优先级高于 `assetsBaseUrl`) */
|
|
202
|
+
defaultStatic?: StaticResourceConf;
|
|
203
|
+
/**
|
|
204
|
+
* 静态资源基础地址,等价于 `createDefaultStatic(assetsBaseUrl)`。
|
|
205
|
+
* 传空字符串表示使用站点相对路径(需自行托管 public/static)。
|
|
206
|
+
*/
|
|
207
|
+
assetsBaseUrl?: string;
|
|
208
|
+
/**
|
|
209
|
+
* 非致命错误处理器,等价于全局 `setErrorHandler`。
|
|
210
|
+
* 用于接管库内被 catch 掉的错误(销毁失败、可选依赖缺失等)。
|
|
211
|
+
*/
|
|
212
|
+
onError?: CesiumDevKitErrorHandler;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 一次 kit 实例的运行时上下文。
|
|
216
|
+
*
|
|
217
|
+
* 所有模块共享同一个 context,模块内部不再依赖模块级全局变量,
|
|
218
|
+
* 因此同一个页面可以安全地同时存在多个 kit / 多个 viewer。
|
|
219
|
+
*/
|
|
220
|
+
interface CesiumContext {
|
|
221
|
+
/** 注入的 Cesium 全局对象 */
|
|
222
|
+
readonly Cesium: CesiumGlobal;
|
|
223
|
+
/** 本次 kit 使用的 viewer */
|
|
224
|
+
readonly viewer: Viewer;
|
|
225
|
+
/** 静态资源(图标 / 天空盒等)配置 */
|
|
226
|
+
readonly defaultStatic: StaticResourceConf;
|
|
227
|
+
/** 静态资源前缀(`defaultStatic.baseService`) */
|
|
228
|
+
readonly assetsBaseUrl: string;
|
|
229
|
+
/** three 全局对象(未传入时为 undefined) */
|
|
230
|
+
readonly three?: any;
|
|
231
|
+
/** viewer 是否由 kit 创建(决定 dispose 时是否销毁) */
|
|
232
|
+
readonly ownsViewer: boolean;
|
|
233
|
+
/** 挂载容器(外部传入 viewer 时可能为 undefined) */
|
|
234
|
+
readonly containerId?: string | HTMLElement;
|
|
235
|
+
/** three 容器 */
|
|
236
|
+
readonly threeContainerId?: string | HTMLElement;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 创建(或接管)viewer,并组装出上下文。
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* const ctx = createContext({ Cesium, containerId: 'cesiumContainer', assetsBaseUrl: '/static/' })
|
|
243
|
+
* ctx.viewer // 可直接使用
|
|
244
|
+
*/
|
|
245
|
+
declare function createContext(options: CesiumContextOptions): CesiumContext;
|
|
246
|
+
/** 释放上下文:仅销毁 kit 自己创建的 viewer */
|
|
247
|
+
declare function disposeContext(context: CesiumContext | null | undefined): void;
|
|
248
|
+
|
|
249
|
+
/** 创建 kit 的参数,与 {@link CesiumContextOptions} 一致 */
|
|
250
|
+
type CreateKitOptions = CesiumContextOptions;
|
|
251
|
+
/** kit 内所有模块实例 */
|
|
252
|
+
interface ResModulesType {
|
|
253
|
+
/** cesium viewer 实例 */
|
|
254
|
+
viewer: CesiumContext['viewer'];
|
|
255
|
+
/** 本次 kit 的运行时上下文 */
|
|
256
|
+
context: CesiumContext;
|
|
257
|
+
/**
|
|
258
|
+
* 销毁 kit 持有的资源(幂等)。
|
|
259
|
+
*
|
|
260
|
+
* - viewer 由 kit 创建:调用 `viewer.destroy()`;
|
|
261
|
+
* - viewer 由外部传入:只清理 kit 自己添加的监听 / 实体,不动外部 viewer。
|
|
262
|
+
*/
|
|
263
|
+
dispose: () => void;
|
|
264
|
+
/** 是否已释放 */
|
|
265
|
+
isDisposed: () => boolean;
|
|
266
|
+
/** 材质模块 */
|
|
267
|
+
material: MaterialInstance & BaseInstance & ShadersInstance;
|
|
268
|
+
/** 图形模块 */
|
|
269
|
+
graphics: GraphicsInstance & BaseInstance;
|
|
270
|
+
/** 数学 3d 计算工具 */
|
|
271
|
+
math3d: Math3dInstance & BaseInstance;
|
|
272
|
+
/** 数学 2d 计算工具 */
|
|
273
|
+
math2d: Math2dInstance;
|
|
274
|
+
/** 图元模块 */
|
|
275
|
+
primitive: PrimitiveInstance & BaseInstance;
|
|
276
|
+
/** 绘制模块 */
|
|
277
|
+
draw: DrawInstance & BaseInstance & Math3dInstance & Math2dInstance;
|
|
278
|
+
/** 后置处理模块 */
|
|
279
|
+
passEffect: PassEffectInstance & BaseInstance & ShadersInstance;
|
|
280
|
+
/** 自定义扩展(传感器)模块 */
|
|
281
|
+
customCesiumPlugin: CustomCesiumPluginInstance & BaseInstance;
|
|
282
|
+
/** 场景控制模块 */
|
|
283
|
+
control: ControlInstance & BaseInstance;
|
|
284
|
+
/** 插件模块 */
|
|
285
|
+
plugin: PluginInstance & BaseInstance & GraphicsInstance;
|
|
286
|
+
/** 基础模块 */
|
|
287
|
+
base: BaseInstance;
|
|
288
|
+
/** 分析模块 */
|
|
289
|
+
analysis: AnalysisInstance & BaseInstance & DrawInstance & PluginInstance;
|
|
290
|
+
/** 标绘(攻击箭头)模块 */
|
|
291
|
+
attackArrowObj: AttackArrowInstance;
|
|
292
|
+
/** 标绘(直线箭头)模块 */
|
|
293
|
+
straightArrowObj: StraightArrowInstance;
|
|
294
|
+
/** 标绘(钳击箭头)模块 */
|
|
295
|
+
pincerArrowObj: PincerArrowInstance;
|
|
296
|
+
/** threejs 集成模块 */
|
|
297
|
+
threeJs: ThreeJsInstance;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* 创建一个 Cesium 开发套件实例(推荐入口)。
|
|
301
|
+
*
|
|
302
|
+
* 相比 `new initCesium(...)`:
|
|
303
|
+
* - 不依赖模块级全局状态,同一页面可并存多个 kit / 多个 viewer;
|
|
304
|
+
* - 返回带 `context` 的显式上下文,便于测试与依赖注入;
|
|
305
|
+
* - `dispose()` 有明确契约:自己创建的 viewer 才销毁。
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* import * as Cesium from 'cesium'
|
|
309
|
+
* import { createKit } from 'cesium_dev_kit'
|
|
310
|
+
*
|
|
311
|
+
* const kit = createKit({
|
|
312
|
+
* Cesium,
|
|
313
|
+
* containerId: 'cesiumContainer',
|
|
314
|
+
* assetsBaseUrl: '/static/',
|
|
315
|
+
* viewerConfig: { infoBox: false }
|
|
316
|
+
* })
|
|
317
|
+
*
|
|
318
|
+
* kit.graphics.getPointGraphics({ ... })
|
|
319
|
+
*
|
|
320
|
+
* // 组件卸载时
|
|
321
|
+
* kit.dispose()
|
|
322
|
+
*/
|
|
323
|
+
declare function createKit(options: CreateKitOptions): ResModulesType;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* initCesium 的参数(兼容旧入口,字段与 `CreateKitOptions` 一致)
|
|
327
|
+
*/
|
|
328
|
+
type InitCesiumOptions = CreateKitOptions;
|
|
329
|
+
|
|
330
|
+
/** initCesium 同时支持函数调用与 new 调用(兼容历史用法) */
|
|
331
|
+
interface InitCesiumConstructor {
|
|
332
|
+
(options: InitCesiumOptions): ResModulesType;
|
|
333
|
+
new (options: InitCesiumOptions): ResModulesType;
|
|
334
|
+
prototype: ResModulesType;
|
|
335
|
+
}
|
|
336
|
+
declare const initCesium: InitCesiumConstructor;
|
|
337
|
+
|
|
338
|
+
export { type CesiumContext, type CesiumContextOptions, CesiumDevKitError, type CesiumDevKitErrorCode, type CesiumDevKitErrorHandler, CesiumGlobal, type CreateKitOptions, type ResModulesType, assertBrowser, createContext, createKit, disposeContext, getErrorHandler, initCesium, isBrowser, isCesiumDevKitError, reportError, setErrorHandler };
|