@dajiaoai/algeo-sdk 2.14.2 → 2.15.0
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/README.md +42 -1
- package/dist/algeo-sdk.cjs.js +14 -1
- package/dist/algeo-sdk.esm.js +14 -1
- package/dist/algeo-sdk.umd.js +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared.d.ts +54 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
大角几何内嵌画板 SDK,支持在任意网页中嵌入几何画板,通过 postMessage 与内嵌页通信。
|
|
4
4
|
|
|
5
|
+
当前版本:**2.15.0**。版本变更与升级注意事项见 [GitHub Release](https://github.com/dajiaoai/algeo-sdk/releases/tag/2.15.0)。
|
|
6
|
+
|
|
5
7
|
## 交流与支持
|
|
6
8
|
|
|
7
9
|
欢迎扫描下方二维码加入微信群,与我们交流 SDK 接入问题、使用反馈和功能建议。
|
|
@@ -561,6 +563,9 @@ const { output } = await presentation.repl('list');
|
|
|
561
563
|
| -------------------------------- | ------------------------------------------------------------------------------------ |
|
|
562
564
|
| `getCount()` | 获取当前已知画板数量 |
|
|
563
565
|
| `getCurrentIndex()` | 获取当前已知画板索引 |
|
|
566
|
+
| `getInfo(index?)` | 异步查询指定或当前画板信息 `{ index, exportIndex, cameraMode }`;`index` 从 0 开始,`exportIndex = index + 1`,`cameraMode` 为 `2d` 或 `3d`;自 SDK `2.15.0` 起支持 |
|
|
567
|
+
| `getViewCamera3d(index?)` | 优先读取已启用的 3D 固定视图,否则读取画板相机参数;2D 返回 `null` |
|
|
568
|
+
| `setViewCamera3d(options)` | 局部更新 3D 固定视图及启用状态,默认尺寸 1920 × 1080 |
|
|
564
569
|
| `getViewBounds(index?)` | 异步获取指定或当前画板的有限画布导出视野 `{ left, top, right, bottom, scale }`;可直接传给 `exportImage`;无限画布返回 `null` |
|
|
565
570
|
| `setViewBounds(options)` | 设置指定或当前画板的有限画布边界 |
|
|
566
571
|
| `switchTo(index)` | 切换画板 |
|
|
@@ -604,7 +609,7 @@ const images = await editor.slides.exportImage({
|
|
|
604
609
|
|
|
605
610
|
`viewBound` 的 `left`、`top`、`right`、`bottom` 均为世界坐标边界,`scale` 为可选的相机缩放比例。省略 `scale` 时使用目标画板文件中的 `camera.scale`。
|
|
606
611
|
|
|
607
|
-
3D 画板传同级的 `viewCamera3d
|
|
612
|
+
3D 画板传同级的 `viewCamera3d`,允许传入 `{}`。本次传入的字段覆盖基础视图:优先使用目标画板已启用的固定视图;未启用或没有配置时使用该画板的 `camera3d`,逻辑视口默认 `1024 × 1024` 且不截取。已关闭但保留的配置不参与读取。`width`、`height` 是完整逻辑视口尺寸;`pixelRatio` 放大最终物理像素,`scale` 决定可见世界范围。可覆盖 `projection`、`obliqueAngle`、`obliqueScaleRatio`,以及 `cropEnabled` / `crop`;单次导出的角度单位为弧度。
|
|
608
613
|
|
|
609
614
|
```ts
|
|
610
615
|
const images = await editor.slides.exportImage({
|
|
@@ -781,3 +786,39 @@ try {
|
|
|
781
786
|
| `DESTROYED` | SDK 已销毁 |
|
|
782
787
|
| `MISSING_APP_ID` | 编辑模式缺少 `auth.appId` |
|
|
783
788
|
| `BAD_REQUEST` | 非法请求(如重复 init、演示模式白名单校验未通过) |
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
### 3D 固定视图
|
|
792
|
+
|
|
793
|
+
3D 画板使用 `exportImage` 的 `contain` / `size` 模式时,视角和投影参数优先读取目标画板已启用的固定视图,未启用或没有配置时读取目标画板相机;完整内容的包围盒决定导出构图,不使用固定视图的截取范围。
|
|
794
|
+
|
|
795
|
+
`slides.getViewCamera3d(index?)` 查询指定画板的固定视图,`index` 从 0 开始,省略时查询当前画板。3D 画板优先返回已启用的固定视图;未启用或没有配置时返回画板相机已有的 offset、角度、scale 和投影参数,width、height、crop 字段省略。2D 画板返回 `null`。
|
|
796
|
+
|
|
797
|
+
`slides.setViewCamera3d({ index?, enabled?, viewCamera3d? })` 设置 3D 固定视图,支持局部更新。提供 `viewCamera3d` 时默认启用;显式指定 `enabled` 时以其为准。`enabled: false` 仅关闭,保留已有参数;单独设置 `enabled: true` 会启用已有参数,无配置时创建默认视图。参数和开关作为一次可撤销操作保存,不切换画板,也不移动编辑相机。2D 画板不能设置此配置。
|
|
798
|
+
|
|
799
|
+
```typescript
|
|
800
|
+
const view = await editor.slides.getViewCamera3d(0);
|
|
801
|
+
await editor.slides.setViewCamera3d({
|
|
802
|
+
index: 0,
|
|
803
|
+
viewCamera3d: {
|
|
804
|
+
yawDeg: 45,
|
|
805
|
+
pitchDeg: 30,
|
|
806
|
+
width: 1920,
|
|
807
|
+
height: 1080,
|
|
808
|
+
crop: { left: 240, top: 135, right: 1680, bottom: 945 },
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
await editor.slides.setViewCamera3d({ index: 0, viewCamera3d: { crop: null } });
|
|
812
|
+
await editor.slides.setViewCamera3d({ index: 0, enabled: false });
|
|
813
|
+
// 此时 getViewCamera3d(0) 返回画板 camera3d 的已有参数,不读取保留的固定视图。
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
固定视图已启用时返回的 `Partial<ViewCamera3d>` 包含 `offset`、`yawDeg`、`pitchDeg`、`scale`、`projection`、`obliqueAngleDeg`、`obliqueScaleRatio`、`width`、`height`、`crop`。设置时均为可选字段,省略字段沿用保存值。无保存值时默认:`offset: [0,0,0]`、三个角度均为 `45`、`scale: 0.1`、`projection: 'orthographic'`、`obliqueScaleRatio: 0.5`、`width: 1920`、`height: 1080`、`crop: null`。
|
|
817
|
+
|
|
818
|
+
所有角度单位为**度**,内部持久化为弧度。`projection` 支持 `orthographic`、`perspective`、`oblique`。所有数值必须有限;`scale` 范围为 `0.0001–100`,宽高为 `100–2000` 的整数,与编辑器固定视图限制一致;`obliqueScaleRatio >= 0`。
|
|
819
|
+
|
|
820
|
+
`crop` 为完整逻辑视口内的截取矩形,左上角为原点,X 向右、Y 向下,单位为逻辑像素,满足 `0 <= left < right <= width`、`0 <= top < bottom <= height`,截取宽高至少为 1 像素。传入 `crop: null` 取消截取;省略则保留。缩小视口导致原截取框越界时会报错,可同时更新或清除截取框。`pixelRatio` 仅属于单次导出,不写入固定视图。
|
|
821
|
+
|
|
822
|
+
无效索引抛出 `INVALID_SLIDE_INDEX`;设置 2D 画板抛出 `UNSUPPORTED_CAMERA_MODE`;无效配置抛出 `INVALID_VIEW_CAMERA_3D`。固定视图接口使用的度数字段与旧版 `exportImage` 相机覆盖项的弧度字段不同,不能将角度字段直接混用。
|
|
823
|
+
|
|
824
|
+
|
package/dist/algeo-sdk.cjs.js
CHANGED
|
@@ -4011,7 +4011,7 @@ function convertToLatest(content) {
|
|
|
4011
4011
|
}
|
|
4012
4012
|
|
|
4013
4013
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4014
|
-
const VERSION = '2.
|
|
4014
|
+
const VERSION = '2.15.0';
|
|
4015
4015
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4016
4016
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4017
4017
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4518,12 +4518,25 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4518
4518
|
this.slides = {
|
|
4519
4519
|
getCount: () => this.slideCount,
|
|
4520
4520
|
getCurrentIndex: () => this.currentSlideIndex,
|
|
4521
|
+
getInfo: async (index) => this.post('getSlideInfo', {
|
|
4522
|
+
...(index === undefined ? {} : { index }),
|
|
4523
|
+
}),
|
|
4521
4524
|
getViewBounds: async (index) => {
|
|
4522
4525
|
const result = await this.post('getViewBounds', {
|
|
4523
4526
|
...(index === undefined ? {} : { index }),
|
|
4524
4527
|
});
|
|
4525
4528
|
return result.viewBounds;
|
|
4526
4529
|
},
|
|
4530
|
+
getViewCamera3d: async (index) => {
|
|
4531
|
+
const result = await this.post('getViewCamera3d', {
|
|
4532
|
+
...(index === undefined ? {} : { index }),
|
|
4533
|
+
});
|
|
4534
|
+
return result.viewCamera3d;
|
|
4535
|
+
},
|
|
4536
|
+
setViewCamera3d: async (options) => {
|
|
4537
|
+
await this.post('setViewCamera3d', { ...options });
|
|
4538
|
+
await this.refreshHistoryState();
|
|
4539
|
+
},
|
|
4527
4540
|
setViewBounds: async (options) => {
|
|
4528
4541
|
await this.post('setViewBounds', { ...options });
|
|
4529
4542
|
},
|
package/dist/algeo-sdk.esm.js
CHANGED
|
@@ -4009,7 +4009,7 @@ function convertToLatest(content) {
|
|
|
4009
4009
|
}
|
|
4010
4010
|
|
|
4011
4011
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4012
|
-
const VERSION = '2.
|
|
4012
|
+
const VERSION = '2.15.0';
|
|
4013
4013
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4014
4014
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4015
4015
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4516,12 +4516,25 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4516
4516
|
this.slides = {
|
|
4517
4517
|
getCount: () => this.slideCount,
|
|
4518
4518
|
getCurrentIndex: () => this.currentSlideIndex,
|
|
4519
|
+
getInfo: async (index) => this.post('getSlideInfo', {
|
|
4520
|
+
...(index === undefined ? {} : { index }),
|
|
4521
|
+
}),
|
|
4519
4522
|
getViewBounds: async (index) => {
|
|
4520
4523
|
const result = await this.post('getViewBounds', {
|
|
4521
4524
|
...(index === undefined ? {} : { index }),
|
|
4522
4525
|
});
|
|
4523
4526
|
return result.viewBounds;
|
|
4524
4527
|
},
|
|
4528
|
+
getViewCamera3d: async (index) => {
|
|
4529
|
+
const result = await this.post('getViewCamera3d', {
|
|
4530
|
+
...(index === undefined ? {} : { index }),
|
|
4531
|
+
});
|
|
4532
|
+
return result.viewCamera3d;
|
|
4533
|
+
},
|
|
4534
|
+
setViewCamera3d: async (options) => {
|
|
4535
|
+
await this.post('setViewCamera3d', { ...options });
|
|
4536
|
+
await this.refreshHistoryState();
|
|
4537
|
+
},
|
|
4525
4538
|
setViewBounds: async (options) => {
|
|
4526
4539
|
await this.post('setViewBounds', { ...options });
|
|
4527
4540
|
},
|
package/dist/algeo-sdk.umd.js
CHANGED
|
@@ -4015,7 +4015,7 @@
|
|
|
4015
4015
|
}
|
|
4016
4016
|
|
|
4017
4017
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4018
|
-
const VERSION = '2.
|
|
4018
|
+
const VERSION = '2.15.0';
|
|
4019
4019
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4020
4020
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4021
4021
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4522,12 +4522,25 @@
|
|
|
4522
4522
|
this.slides = {
|
|
4523
4523
|
getCount: () => this.slideCount,
|
|
4524
4524
|
getCurrentIndex: () => this.currentSlideIndex,
|
|
4525
|
+
getInfo: async (index) => this.post('getSlideInfo', {
|
|
4526
|
+
...(index === undefined ? {} : { index }),
|
|
4527
|
+
}),
|
|
4525
4528
|
getViewBounds: async (index) => {
|
|
4526
4529
|
const result = await this.post('getViewBounds', {
|
|
4527
4530
|
...(index === undefined ? {} : { index }),
|
|
4528
4531
|
});
|
|
4529
4532
|
return result.viewBounds;
|
|
4530
4533
|
},
|
|
4534
|
+
getViewCamera3d: async (index) => {
|
|
4535
|
+
const result = await this.post('getViewCamera3d', {
|
|
4536
|
+
...(index === undefined ? {} : { index }),
|
|
4537
|
+
});
|
|
4538
|
+
return result.viewCamera3d;
|
|
4539
|
+
},
|
|
4540
|
+
setViewCamera3d: async (options) => {
|
|
4541
|
+
await this.post('setViewCamera3d', { ...options });
|
|
4542
|
+
await this.refreshHistoryState();
|
|
4543
|
+
},
|
|
4531
4544
|
setViewBounds: async (options) => {
|
|
4532
4545
|
await this.post('setViewBounds', { ...options });
|
|
4533
4546
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AlgeoError, EMBED_ERROR_CODES, VERSION } from './shared';
|
|
2
2
|
export type { FileContentAny, FileContentLatest, } from '@dajiaoai/algeo-protocol';
|
|
3
3
|
export { convertToLatest } from '@dajiaoai/algeo-protocol';
|
|
4
|
-
export type { AiApi, AiCancelEvent, AiRawSseEventV1, AiRequestEvent, AiRunPayloadV1, AiStreamEventV1, AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoFontConfig, AlgeoFontFormat, AlgeoFontOption, AlgeoFontResource, AlgeoFontSource, AlgeoPresentationCreateOptions, AlgeoPresentationUiConfig, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportImageFormat, ExportImageOptions, ExportImageSizeMode, ExportImageViewMode, ExportImageContainMode, ExportViewBound, ExportViewBounds, ExportViewCamera3D, ExportPadding, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, ExportLatexOptions, ExportedLatex, ExportLatexResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ResourceLibraryItem, ResourceLibraryPageInfo, ResourceLibraryProvider, ResourceLibraryQuery, ResourceLibraryQueryContext, ResourceLibraryResult, ReplResult, SetViewBoundsOptions, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
4
|
+
export type { AiApi, AiCancelEvent, AiRawSseEventV1, AiRequestEvent, AiRunPayloadV1, AiStreamEventV1, AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoFontConfig, AlgeoFontFormat, AlgeoFontOption, AlgeoFontResource, AlgeoFontSource, AlgeoPresentationCreateOptions, AlgeoPresentationUiConfig, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportImageFormat, ExportImageOptions, ExportImageSizeMode, ExportImageViewMode, ExportImageContainMode, ExportViewBound, ExportViewBounds, ExportViewCamera3D, ExportPadding, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, ExportLatexOptions, ExportedLatex, ExportLatexResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ResourceLibraryItem, ResourceLibraryPageInfo, ResourceLibraryProvider, ResourceLibraryQuery, ResourceLibraryQueryContext, ResourceLibraryResult, ReplResult, SetViewBoundsOptions, SetViewCamera3dOptions, ViewCamera3d, SlideChangeEvent, SlideIndexResult, SlideInfo, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
5
5
|
export { EmbeddedPresentation } from './embedded-presentation';
|
|
6
6
|
export { EmbeddedEditor } from './embedded-editor';
|
|
7
7
|
export { AlgeoSdk, create, createEditor, createPresentation, type EmbeddedInstance, } from './sdk';
|
package/dist/shared.d.ts
CHANGED
|
@@ -240,9 +240,46 @@ export interface SetMasterTemplateResult {
|
|
|
240
240
|
export interface SwitchSlideResult {
|
|
241
241
|
success: true;
|
|
242
242
|
}
|
|
243
|
+
export interface SlideInfo {
|
|
244
|
+
/** 画板索引,从 0 开始。 */
|
|
245
|
+
index: number;
|
|
246
|
+
/** 导出功能使用的画板索引,等于 index + 1。 */
|
|
247
|
+
exportIndex: number;
|
|
248
|
+
cameraMode: '2d' | '3d';
|
|
249
|
+
}
|
|
243
250
|
export interface GetSlideCountResult {
|
|
244
251
|
count: number;
|
|
245
252
|
}
|
|
253
|
+
/** 3D 固定视图的对外参数;角度单位为度,尺寸和截取坐标单位为逻辑像素。 */
|
|
254
|
+
export interface ViewCamera3d {
|
|
255
|
+
offset: [number, number, number];
|
|
256
|
+
yawDeg: number;
|
|
257
|
+
pitchDeg: number;
|
|
258
|
+
scale: number;
|
|
259
|
+
projection: 'orthographic' | 'perspective' | 'oblique';
|
|
260
|
+
obliqueAngleDeg: number;
|
|
261
|
+
obliqueScaleRatio: number;
|
|
262
|
+
width: number;
|
|
263
|
+
height: number;
|
|
264
|
+
/** null 表示不截取,截取坐标原点为完整视口左上角。 */
|
|
265
|
+
crop: {
|
|
266
|
+
left: number;
|
|
267
|
+
top: number;
|
|
268
|
+
right: number;
|
|
269
|
+
bottom: number;
|
|
270
|
+
} | null;
|
|
271
|
+
}
|
|
272
|
+
export interface GetViewCamera3dResult {
|
|
273
|
+
viewCamera3d: Partial<ViewCamera3d> | null;
|
|
274
|
+
}
|
|
275
|
+
export interface SetViewCamera3dOptions {
|
|
276
|
+
/** 从 0 开始;省略时操作当前画板。 */
|
|
277
|
+
index?: number;
|
|
278
|
+
/** 提供参数时默认启用;false 关闭固定视图但保留参数。 */
|
|
279
|
+
enabled?: boolean;
|
|
280
|
+
/** 局部更新;省略字段沿用保存值,无保存值时使用默认值(1920 × 1080)。 */
|
|
281
|
+
viewCamera3d?: Partial<ViewCamera3d>;
|
|
282
|
+
}
|
|
246
283
|
export interface GetViewBoundsResult {
|
|
247
284
|
/** 与 ExportImageViewMode.viewBound 格式一致,可直接传给 exportImage。 */
|
|
248
285
|
viewBounds: ExportViewBound | null;
|
|
@@ -297,6 +334,18 @@ export interface ExportViewBound {
|
|
|
297
334
|
* 3D 画板的导出相机覆盖项。未提供的字段沿用画板当前 camera3d。
|
|
298
335
|
*/
|
|
299
336
|
export interface ExportViewCamera3D {
|
|
337
|
+
projection?: 'orthographic' | 'perspective' | 'oblique';
|
|
338
|
+
/** 斜投影方向角,单位为弧度。 */
|
|
339
|
+
obliqueAngle?: number;
|
|
340
|
+
obliqueScaleRatio?: number;
|
|
341
|
+
cropEnabled?: boolean;
|
|
342
|
+
/** 完整逻辑视口内的截取范围,原点为左上角。 */
|
|
343
|
+
crop?: {
|
|
344
|
+
left: number;
|
|
345
|
+
top: number;
|
|
346
|
+
right: number;
|
|
347
|
+
bottom: number;
|
|
348
|
+
};
|
|
300
349
|
offset?: [number, number, number];
|
|
301
350
|
pitch?: number;
|
|
302
351
|
yaw?: number;
|
|
@@ -422,8 +471,13 @@ export interface DocumentApi {
|
|
|
422
471
|
export interface SlidesApi {
|
|
423
472
|
getCount(): number;
|
|
424
473
|
getCurrentIndex(): number;
|
|
474
|
+
/** 查询指定画板的信息;index 从 0 开始,省略时读取当前画板。 */
|
|
475
|
+
getInfo(index?: number): Promise<SlideInfo>;
|
|
425
476
|
getViewBounds(index?: number): Promise<ExportViewBound | null>;
|
|
426
477
|
setViewBounds(options: SetViewBoundsOptions): Promise<void>;
|
|
478
|
+
/** 优先返回已启用的 3D 固定视图,否则返回画板相机已有参数(不含宽高和截取);2D 返回 null。 */
|
|
479
|
+
getViewCamera3d(index?: number): Promise<Partial<ViewCamera3d> | null>;
|
|
480
|
+
setViewCamera3d(options: SetViewCamera3dOptions): Promise<void>;
|
|
427
481
|
switchTo(index: number): Promise<void>;
|
|
428
482
|
add(): Promise<SlideIndexResult>;
|
|
429
483
|
addAt(index: number): Promise<SlideIndexResult>;
|