@dajiaoai/algeo-sdk 2.12.1 → 2.13.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 CHANGED
@@ -582,21 +582,21 @@ interface FileContent {
582
582
 
583
583
  所有模式均读取文件中的 `camera.scale`;文件未提供时默认为 `50`。`slideIndices` 使用从 `1` 开始的画板索引,省略时导出全部画板。
584
584
 
585
- 适合精确指定导出视野时使用 `view`。2D 画板传 `viewBounds`:
585
+ 适合精确指定导出视野时使用 `view`。2D 画板传 `viewBound`:
586
586
 
587
587
  ```ts
588
588
  const images = await editor.slides.exportImage({
589
589
  mode: 'view',
590
590
  slideIndices: [1],
591
591
  format: 'png',
592
- viewBounds: { x: -5, y: -5, width: 10, height: 10, scale: 50 },
592
+ viewBound: { left: -5, top: -5, right: 5, bottom: 5, scale: 50 },
593
593
  pixelRatio: 2,
594
594
  });
595
595
  ```
596
596
 
597
- `viewBounds` 的位置和宽高均为世界坐标,`scale` 为可选的相机缩放比例。省略 `scale` 时使用目标画板文件中的 `camera.scale`。
597
+ `viewBound` 的 `left`、`top`、`right`、`bottom` 均为世界坐标边界,`scale` 为可选的相机缩放比例。省略 `scale` 时使用目标画板文件中的 `camera.scale`。
598
598
 
599
- 3D 画板传同级的 `viewCamera3d`。其中 `width`、`height` 必填;`width`、`height` 为世界坐标视野范围。`offset`、`yaw`、`pitch`、`scale` 可选且省略时沿用文件相机;投影方式与斜投影参数始终沿用画板文件。
599
+ 3D 画板传同级的 `viewCamera3d`。其中 `width`、`height` 为逻辑输出像素,省略时均为 `1024`;`pixelRatio` 只放大最终物理像素。`offset`、`yaw`、`pitch`、`scale` 可选且省略时沿用文件相机;`scale` 独立决定相机远近与可见世界范围。投影方式与斜投影参数始终沿用画板文件。
600
600
 
601
601
  ```ts
602
602
  const images = await editor.slides.exportImage({
@@ -608,14 +608,14 @@ const images = await editor.slides.exportImage({
608
608
  yaw: Math.PI / 4,
609
609
  pitch: Math.PI / 6,
610
610
  scale: 0.2,
611
- width: 12,
612
- height: 8,
611
+ width: 1200,
612
+ height: 800,
613
613
  },
614
614
  pixelRatio: 2,
615
615
  });
616
616
  ```
617
617
 
618
- 一个 `view` 请求可以同时传 `viewBounds` 与 `viewCamera3d`,用于批量导出混合 2D/3D 画板;每张画板自动读取适用字段。2D 画板未提供 `viewBounds`、或 3D 画板未提供 `viewCamera3d` 时会报错。3D 仅支持 PNG、JPG;对 3D 画板请求 SVG 会报错。
618
+ 一个 `view` 请求可以同时传 `viewBound` 与 `viewCamera3d`,用于批量导出混合 2D/3D 画板;每张画板自动读取适用字段。2D 画板未提供 `viewBound`、或 3D 画板未提供 `viewCamera3d` 时会报错。3D 仅支持 PNG、JPG;对 3D 画板请求 SVG 会报错。
619
619
 
620
620
  适合完整包住全部内容且不限定最终宽高时使用 `contain`:
621
621
 
@@ -4011,7 +4011,7 @@ function convertToLatest(content) {
4011
4011
  }
4012
4012
 
4013
4013
  /** SDK 版本号,构建时由 rollup 注入 */
4014
- const VERSION = '2.12.1';
4014
+ const VERSION = '2.13.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';
@@ -4535,7 +4535,9 @@ class EmbeddedEditor extends EmbeddedTarget {
4535
4535
  await this.refreshHistoryState();
4536
4536
  },
4537
4537
  exportImage: async (options) => {
4538
- const result = await this.post('exportSlideImage', { options });
4538
+ const result = await this.post(options.mode === 'view' && options.viewBound !== undefined
4539
+ ? 'exportSlideImageV2'
4540
+ : 'exportSlideImage', { options });
4539
4541
  return result.images;
4540
4542
  },
4541
4543
  exportLatex: async (options) => {
@@ -4009,7 +4009,7 @@ function convertToLatest(content) {
4009
4009
  }
4010
4010
 
4011
4011
  /** SDK 版本号,构建时由 rollup 注入 */
4012
- const VERSION = '2.12.1';
4012
+ const VERSION = '2.13.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';
@@ -4533,7 +4533,9 @@ class EmbeddedEditor extends EmbeddedTarget {
4533
4533
  await this.refreshHistoryState();
4534
4534
  },
4535
4535
  exportImage: async (options) => {
4536
- const result = await this.post('exportSlideImage', { options });
4536
+ const result = await this.post(options.mode === 'view' && options.viewBound !== undefined
4537
+ ? 'exportSlideImageV2'
4538
+ : 'exportSlideImage', { options });
4537
4539
  return result.images;
4538
4540
  },
4539
4541
  exportLatex: async (options) => {
@@ -4015,7 +4015,7 @@
4015
4015
  }
4016
4016
 
4017
4017
  /** SDK 版本号,构建时由 rollup 注入 */
4018
- const VERSION = '2.12.1';
4018
+ const VERSION = '2.13.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';
@@ -4539,7 +4539,9 @@
4539
4539
  await this.refreshHistoryState();
4540
4540
  },
4541
4541
  exportImage: async (options) => {
4542
- const result = await this.post('exportSlideImage', { options });
4542
+ const result = await this.post(options.mode === 'view' && options.viewBound !== undefined
4543
+ ? 'exportSlideImageV2'
4544
+ : 'exportSlideImage', { options });
4543
4545
  return result.images;
4544
4546
  },
4545
4547
  exportLatex: async (options) => {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { AlgeoError, EMBED_ERROR_CODES, VERSION } from './shared';
2
2
  export type { 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, ExportViewBounds, ExportViewCamera3D, ExportPadding, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, ExportLatexOptions, ExportedLatex, ExportLatexResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ResourceLibraryItem, ResourceLibraryPageInfo, ResourceLibraryProvider, ResourceLibraryQuery, ResourceLibraryQueryContext, ResourceLibraryResult, ReplResult, 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, SlideChangeEvent, SlideIndexResult, 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
@@ -251,11 +251,25 @@ export type ExportImageFormat = 'png' | 'jpg' | 'svg';
251
251
  /**
252
252
  * 导出的逻辑视野区域(世界坐标)。
253
253
  */
254
+ /**
255
+ * 旧版 2D 导出视野(世界坐标)。使用时会调用兼容的 exportSlideImage 实现。
256
+ * @deprecated 请改用 ExportViewBound(left/top/right/bottom)。
257
+ */
254
258
  export interface ExportViewBounds {
255
259
  x: number;
256
260
  y: number;
257
261
  width: number;
258
262
  height: number;
263
+ scale?: number;
264
+ }
265
+ /**
266
+ * 2D 导出视野的四条世界坐标边界。
267
+ */
268
+ export interface ExportViewBound {
269
+ left: number;
270
+ top: number;
271
+ right: number;
272
+ bottom: number;
259
273
  /**
260
274
  * 相机缩放比例(每世界坐标单位对应的像素数)。
261
275
  * 省略时使用目标画板文件中的 camera.scale。
@@ -270,10 +284,10 @@ export interface ExportViewCamera3D {
270
284
  pitch?: number;
271
285
  yaw?: number;
272
286
  scale?: number;
273
- /** 3D 导出视野的世界坐标宽度。 */
274
- width: number;
275
- /** 3D 导出视野的世界坐标高度。 */
276
- height: number;
287
+ /** 3D 导出的逻辑输出宽度(px),默认 1024。 */
288
+ width?: number;
289
+ /** 3D 导出的逻辑输出高度(px),默认 1024。 */
290
+ height?: number;
277
291
  }
278
292
  /** 导出留白,单位为输出像素 px。 */
279
293
  export type ExportPadding = number | {
@@ -299,13 +313,18 @@ export interface ExportImageSizeMode extends ExportImageBaseOptions {
299
313
  minPadding?: ExportPadding;
300
314
  }
301
315
  /**
302
- * 场景二(view):viewBounds 的位置及宽高均为世界坐标。
316
+ * 场景二(view):viewBound 的四条边界均为世界坐标。
303
317
  * scale 省略时从文件的 camera.scale 读取。
304
- * 输出像素 = viewBounds 世界尺寸 x viewBounds.scale x pixelRatio。
318
+ * 输出像素 = (right - left, bottom - top) x viewBound.scale x pixelRatio。
305
319
  */
306
320
  export interface ExportImageViewMode extends ExportImageBaseOptions {
307
321
  mode: 'view';
308
- /** 2D 画板的世界坐标视野。 */
322
+ /** 2D 画板的世界坐标视野;使用新宿主导出实现。 */
323
+ viewBound?: ExportViewBound;
324
+ /**
325
+ * 2D 画板的旧版世界坐标视野;使用兼容的旧宿主导出实现。
326
+ * @deprecated 请改用 viewBound。
327
+ */
309
328
  viewBounds?: ExportViewBounds;
310
329
  /** 3D 画板的相机视野。 */
311
330
  viewCamera3d?: ExportViewCamera3D;
@@ -395,7 +414,7 @@ export interface SlidesApi {
395
414
  * 导出画板图片。支持三种 mode:
396
415
  * - size:目标输出宽高、minPadding 与图形包围盒
397
416
  * 自动计算 pixelRatio,使图形完整 contain 在可用区域。
398
- * - view:指定视野 viewBounds 与 pixelRatio
417
+ * - view:指定视野 viewBound 与 pixelRatio
399
418
  * - contain:由 pixelRatio 与绝对 px padding 自动计算最终宽高。
400
419
  *
401
420
  * 旧的扁平 ExportSlideImageOptions 已废弃,实现层不再接受;请改用上述三模式 ExportImageOptions。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dajiaoai/algeo-sdk",
3
- "version": "2.12.1",
3
+ "version": "2.13.0",
4
4
  "description": "大角几何内嵌画板 SDK,支持 iframe 挂载与 postMessage 通信",
5
5
  "main": "dist/algeo-sdk.cjs.js",
6
6
  "module": "dist/algeo-sdk.esm.js",