@dajiaoai/algeo-sdk 2.14.0 → 2.14.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.
package/README.md CHANGED
@@ -313,10 +313,13 @@ type AlgeoCreateOptions =
313
313
  | ---------------- | ------------------------------ | ------ | ------------------------------------------------------ |
314
314
  | `auth` | `{ appId: string }` | - | 编辑模式鉴权参数,其中 `appId` 会参与默认路由生成 |
315
315
  | `shareId` | `string` | `''` | 编辑模式初始分享 ID,会映射到 `/embed/edit/:appId/:id` |
316
- | `initialContent` | `FileContentLatest` | - | 初始化后自动注入的文件内容 |
316
+ | `initialContent` | `FileContentAny` | - | 初始化后自动注入的文件内容;SDK 会自动转换为最新格式 |
317
+ | `initialMode` | `'2d' \| '3d'` | `'2d'` | 空白画板模式,仅在没有初始内容或分享文件时生效 |
317
318
  | `ui` | `Partial<AlgeoEditorUiConfig>` | - | 编辑器 UI 开关配置 |
318
319
  | `fonts` | `AlgeoFontConfig` | - | 字体资源、字体选择器列表及默认字体配置 |
319
320
 
321
+ 初始化优先级:`initialContent` > `shareId` > 指定 `initialMode` 的空画板。提供 `initialContent` 时不会请求分享文件;加载已有内容时保留内容中的画板模式。
322
+
320
323
  **AlgeoEditorUiConfig:**
321
324
 
322
325
  | 属性 | 类型 | 默认值 | 说明 |
@@ -474,26 +477,13 @@ SDK 内部已通过 `ResizeObserver` 在容器从隐藏(`display:none`,尺
474
477
 
475
478
  ---
476
479
 
477
- ##### `presentation.loadFile(content: FileContent): Promise<LoadFileResult>`
480
+ ##### `presentation.loadFile(content: FileContentAny): Promise<LoadFileResult>`
478
481
 
479
- 加载完整文件数据(覆盖式),需符合 FileContentLatest 格式。
482
+ 加载完整文件数据(覆盖式)。
480
483
 
481
484
  | 参数 | 类型 | 说明 |
482
485
  | --------- | ------------- | ------------ |
483
- | `content` | `FileContent` | 文件内容对象 |
484
-
485
- **FileContent 结构:**
486
-
487
- ```typescript
488
- interface FileContent {
489
- slides: unknown[]; // 画板数据数组
490
- messages: unknown[]; // 消息数据(最新版本为会话数组)
491
- metadata: {
492
- version: string; // 如 '11'
493
- shareOptions?: unknown;
494
- };
495
- }
496
- ```
486
+ | `content` | `FileContentAny` | 协议包支持读取的文件内容对象 |
497
487
 
498
488
  **返回值:** `{ success: true }`
499
489
 
@@ -519,24 +509,26 @@ interface FileContent {
519
509
 
520
510
  ---
521
511
 
522
- ##### `presentation.repl(command: string): Promise<ReplResult>`
512
+ ##### `editor.repl(command: string): Promise<ReplResult>`
523
513
 
524
- 执行 REPL 指令,返回面向 AI 的文档/文本内容。需先通过 `loadShareById` 或 `loadFile` 加载内容后,部分指令才有数据可查。
514
+ 执行 REPL 指令,返回 `{ output: string }`。修改支持撤销、重做,调用后自动同步画板和历史状态。
525
515
 
526
- | 参数 | 类型 | 说明 |
527
- | --------- | -------- | --------- |
528
- | `command` | `string` | REPL 指令 |
516
+ ```ts
517
+ const { output } = await editor.repl('def A := Point(0,0)');
518
+ await editor.history.undo();
519
+ ```
529
520
 
530
- **常用指令:**
521
+ 调用不触发 `contentChange` / `slideChange`,读取最新内容请用 `editor.document.getContent()`。执行失败时,已完成的修改不会自动回滚。
522
+
523
+ ##### `presentation.repl(command: string): Promise<ReplResult>`
531
524
 
532
- | 指令 | 说明 |
533
- | ------------- | ----------------------------- |
534
- | `help` | 查看 REPL 帮助 |
535
- | `list` | 列出当前画板中的对象 |
536
- | `list_slides` | 列出所有画板 |
537
- | `eval` | 执行表达式(具体用法见 help) |
525
+ 执行 REPL 指令,返回 `{ output: string }`。查询已有内容前,可通过 `loadShareById` 或 `loadFile` 加载画板。
526
+
527
+ ```ts
528
+ const { output } = await presentation.repl('list');
529
+ ```
538
530
 
539
- **返回值:** `{ output: string }` — 指令输出的文本内容
531
+ 两种模式均可通过 `repl('help')` 查看命令帮助,或参考 [REPL 指令实验室](examples/20-repl.html)。
540
532
 
541
533
  ---
542
534
 
@@ -560,8 +552,8 @@ interface FileContent {
560
552
 
561
553
  | 方法 | 说明 |
562
554
  | ---------------------- | -------------------------------- |
563
- | `loadContent(content)` | 加载完整画板文件内容 |
564
- | `getContent()` | 异步获取 iframe 当前实时画板内容 |
555
+ | `loadContent(content: FileContentAny)` | 加载完整画板文件内容,并自动转换为最新格式 |
556
+ | `getContent(): Promise<FileContentLatest>` | 异步获取 iframe 当前实时画板内容 |
565
557
 
566
558
  #### `editor.slides`
567
559
 
@@ -4011,7 +4011,7 @@ function convertToLatest(content) {
4011
4011
  }
4012
4012
 
4013
4013
  /** SDK 版本号,构建时由 rollup 注入 */
4014
- const VERSION = '2.14.0';
4014
+ const VERSION = '2.14.2';
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';
@@ -4132,10 +4132,10 @@ function buildEmbedSrc(options) {
4132
4132
  const path = getEmbedPath(mode);
4133
4133
  const appId = options.auth?.appId?.trim() ?? '';
4134
4134
  const initialId = options.initialId?.trim();
4135
- if (!initialId) {
4136
- return `${baseUrl}${path}/${encodeURIComponent(appId)}`;
4137
- }
4138
- return `${baseUrl}${path}/${encodeURIComponent(appId)}/${encodeURIComponent(initialId)}`;
4135
+ const src = `${baseUrl}${path}/${encodeURIComponent(appId)}${initialId ? `/${encodeURIComponent(initialId)}` : ''}`;
4136
+ return mode === 'editor' && options.cameraMode
4137
+ ? `${src}?cameraMode=${encodeURIComponent(options.cameraMode)}`
4138
+ : src;
4139
4139
  }
4140
4140
 
4141
4141
  class EmbeddedTarget {
@@ -4466,10 +4466,13 @@ class EmbeddedPresentation extends EmbeddedTarget {
4466
4466
  }
4467
4467
  async loadFile(content) {
4468
4468
  this.ensureWhitelistAccess('loadFile');
4469
- const result = await this.post('loadContent', { content });
4470
- this.currentContent = content;
4469
+ const latestContent = convertToLatest(content);
4470
+ const result = await this.post('loadContent', {
4471
+ content: latestContent,
4472
+ });
4473
+ this.currentContent = latestContent;
4471
4474
  this.currentSlideIndex = 0;
4472
- this.slideCount = content.slides.length;
4475
+ this.slideCount = latestContent.slides.length;
4473
4476
  return result;
4474
4477
  }
4475
4478
  async switchSlide(index) {
@@ -4604,6 +4607,30 @@ class EmbeddedEditor extends EmbeddedTarget {
4604
4607
  },
4605
4608
  };
4606
4609
  }
4610
+ /** Execute a REPL command and synchronize editor state before resolving. */
4611
+ async repl(command) {
4612
+ try {
4613
+ const result = await this.post('repl', { command });
4614
+ this.applyReplState(result.state);
4615
+ return { output: result.output };
4616
+ }
4617
+ catch (error) {
4618
+ // REPL execution can fail after applying some operations.
4619
+ if (error instanceof AlgeoError) {
4620
+ const details = error.details;
4621
+ if (details?.state)
4622
+ this.applyReplState(details.state);
4623
+ }
4624
+ throw error;
4625
+ }
4626
+ }
4627
+ applyReplState(state) {
4628
+ this.currentContent = undefined;
4629
+ this.slideCount = state.slideCount;
4630
+ this.currentSlideIndex = state.currentSlideIndex;
4631
+ this.historyCount = state.historyCount;
4632
+ this.historyCurrentIndex = state.historyCurrentIndex;
4633
+ }
4607
4634
  async initialize(options = {}, baseUrl) {
4608
4635
  if (!options.auth?.appId?.trim()) {
4609
4636
  throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
@@ -4616,7 +4643,8 @@ class EmbeddedEditor extends EmbeddedTarget {
4616
4643
  await this.init({
4617
4644
  baseUrl,
4618
4645
  auth: options.auth,
4619
- initialId: options.shareId,
4646
+ initialId: options.initialContent ? undefined : options.shareId,
4647
+ cameraMode: options.initialContent ? undefined : options.initialMode,
4620
4648
  });
4621
4649
  if (options.fonts) {
4622
4650
  await this.post('setFontConfig', { config: options.fonts });
@@ -4790,10 +4818,11 @@ class EmbeddedEditor extends EmbeddedTarget {
4790
4818
  }
4791
4819
  }
4792
4820
  async loadContent(content, source) {
4793
- await this.post('loadContent', { content });
4794
- this.currentContent = content;
4821
+ const latestContent = convertToLatest(content);
4822
+ await this.post('loadContent', { content: latestContent });
4823
+ this.currentContent = latestContent;
4795
4824
  this.currentSlideIndex = 0;
4796
- this.slideCount = content.slides.length;
4825
+ this.slideCount = latestContent.slides.length;
4797
4826
  await this.refreshHistoryState();
4798
4827
  }
4799
4828
  async switchTo(index) {
@@ -4009,7 +4009,7 @@ function convertToLatest(content) {
4009
4009
  }
4010
4010
 
4011
4011
  /** SDK 版本号,构建时由 rollup 注入 */
4012
- const VERSION = '2.14.0';
4012
+ const VERSION = '2.14.2';
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';
@@ -4130,10 +4130,10 @@ function buildEmbedSrc(options) {
4130
4130
  const path = getEmbedPath(mode);
4131
4131
  const appId = options.auth?.appId?.trim() ?? '';
4132
4132
  const initialId = options.initialId?.trim();
4133
- if (!initialId) {
4134
- return `${baseUrl}${path}/${encodeURIComponent(appId)}`;
4135
- }
4136
- return `${baseUrl}${path}/${encodeURIComponent(appId)}/${encodeURIComponent(initialId)}`;
4133
+ const src = `${baseUrl}${path}/${encodeURIComponent(appId)}${initialId ? `/${encodeURIComponent(initialId)}` : ''}`;
4134
+ return mode === 'editor' && options.cameraMode
4135
+ ? `${src}?cameraMode=${encodeURIComponent(options.cameraMode)}`
4136
+ : src;
4137
4137
  }
4138
4138
 
4139
4139
  class EmbeddedTarget {
@@ -4464,10 +4464,13 @@ class EmbeddedPresentation extends EmbeddedTarget {
4464
4464
  }
4465
4465
  async loadFile(content) {
4466
4466
  this.ensureWhitelistAccess('loadFile');
4467
- const result = await this.post('loadContent', { content });
4468
- this.currentContent = content;
4467
+ const latestContent = convertToLatest(content);
4468
+ const result = await this.post('loadContent', {
4469
+ content: latestContent,
4470
+ });
4471
+ this.currentContent = latestContent;
4469
4472
  this.currentSlideIndex = 0;
4470
- this.slideCount = content.slides.length;
4473
+ this.slideCount = latestContent.slides.length;
4471
4474
  return result;
4472
4475
  }
4473
4476
  async switchSlide(index) {
@@ -4602,6 +4605,30 @@ class EmbeddedEditor extends EmbeddedTarget {
4602
4605
  },
4603
4606
  };
4604
4607
  }
4608
+ /** Execute a REPL command and synchronize editor state before resolving. */
4609
+ async repl(command) {
4610
+ try {
4611
+ const result = await this.post('repl', { command });
4612
+ this.applyReplState(result.state);
4613
+ return { output: result.output };
4614
+ }
4615
+ catch (error) {
4616
+ // REPL execution can fail after applying some operations.
4617
+ if (error instanceof AlgeoError) {
4618
+ const details = error.details;
4619
+ if (details?.state)
4620
+ this.applyReplState(details.state);
4621
+ }
4622
+ throw error;
4623
+ }
4624
+ }
4625
+ applyReplState(state) {
4626
+ this.currentContent = undefined;
4627
+ this.slideCount = state.slideCount;
4628
+ this.currentSlideIndex = state.currentSlideIndex;
4629
+ this.historyCount = state.historyCount;
4630
+ this.historyCurrentIndex = state.historyCurrentIndex;
4631
+ }
4605
4632
  async initialize(options = {}, baseUrl) {
4606
4633
  if (!options.auth?.appId?.trim()) {
4607
4634
  throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
@@ -4614,7 +4641,8 @@ class EmbeddedEditor extends EmbeddedTarget {
4614
4641
  await this.init({
4615
4642
  baseUrl,
4616
4643
  auth: options.auth,
4617
- initialId: options.shareId,
4644
+ initialId: options.initialContent ? undefined : options.shareId,
4645
+ cameraMode: options.initialContent ? undefined : options.initialMode,
4618
4646
  });
4619
4647
  if (options.fonts) {
4620
4648
  await this.post('setFontConfig', { config: options.fonts });
@@ -4788,10 +4816,11 @@ class EmbeddedEditor extends EmbeddedTarget {
4788
4816
  }
4789
4817
  }
4790
4818
  async loadContent(content, source) {
4791
- await this.post('loadContent', { content });
4792
- this.currentContent = content;
4819
+ const latestContent = convertToLatest(content);
4820
+ await this.post('loadContent', { content: latestContent });
4821
+ this.currentContent = latestContent;
4793
4822
  this.currentSlideIndex = 0;
4794
- this.slideCount = content.slides.length;
4823
+ this.slideCount = latestContent.slides.length;
4795
4824
  await this.refreshHistoryState();
4796
4825
  }
4797
4826
  async switchTo(index) {
@@ -4015,7 +4015,7 @@
4015
4015
  }
4016
4016
 
4017
4017
  /** SDK 版本号,构建时由 rollup 注入 */
4018
- const VERSION = '2.14.0';
4018
+ const VERSION = '2.14.2';
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';
@@ -4136,10 +4136,10 @@
4136
4136
  const path = getEmbedPath(mode);
4137
4137
  const appId = options.auth?.appId?.trim() ?? '';
4138
4138
  const initialId = options.initialId?.trim();
4139
- if (!initialId) {
4140
- return `${baseUrl}${path}/${encodeURIComponent(appId)}`;
4141
- }
4142
- return `${baseUrl}${path}/${encodeURIComponent(appId)}/${encodeURIComponent(initialId)}`;
4139
+ const src = `${baseUrl}${path}/${encodeURIComponent(appId)}${initialId ? `/${encodeURIComponent(initialId)}` : ''}`;
4140
+ return mode === 'editor' && options.cameraMode
4141
+ ? `${src}?cameraMode=${encodeURIComponent(options.cameraMode)}`
4142
+ : src;
4143
4143
  }
4144
4144
 
4145
4145
  class EmbeddedTarget {
@@ -4470,10 +4470,13 @@
4470
4470
  }
4471
4471
  async loadFile(content) {
4472
4472
  this.ensureWhitelistAccess('loadFile');
4473
- const result = await this.post('loadContent', { content });
4474
- this.currentContent = content;
4473
+ const latestContent = convertToLatest(content);
4474
+ const result = await this.post('loadContent', {
4475
+ content: latestContent,
4476
+ });
4477
+ this.currentContent = latestContent;
4475
4478
  this.currentSlideIndex = 0;
4476
- this.slideCount = content.slides.length;
4479
+ this.slideCount = latestContent.slides.length;
4477
4480
  return result;
4478
4481
  }
4479
4482
  async switchSlide(index) {
@@ -4608,6 +4611,30 @@
4608
4611
  },
4609
4612
  };
4610
4613
  }
4614
+ /** Execute a REPL command and synchronize editor state before resolving. */
4615
+ async repl(command) {
4616
+ try {
4617
+ const result = await this.post('repl', { command });
4618
+ this.applyReplState(result.state);
4619
+ return { output: result.output };
4620
+ }
4621
+ catch (error) {
4622
+ // REPL execution can fail after applying some operations.
4623
+ if (error instanceof AlgeoError) {
4624
+ const details = error.details;
4625
+ if (details?.state)
4626
+ this.applyReplState(details.state);
4627
+ }
4628
+ throw error;
4629
+ }
4630
+ }
4631
+ applyReplState(state) {
4632
+ this.currentContent = undefined;
4633
+ this.slideCount = state.slideCount;
4634
+ this.currentSlideIndex = state.currentSlideIndex;
4635
+ this.historyCount = state.historyCount;
4636
+ this.historyCurrentIndex = state.historyCurrentIndex;
4637
+ }
4611
4638
  async initialize(options = {}, baseUrl) {
4612
4639
  if (!options.auth?.appId?.trim()) {
4613
4640
  throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
@@ -4620,7 +4647,8 @@
4620
4647
  await this.init({
4621
4648
  baseUrl,
4622
4649
  auth: options.auth,
4623
- initialId: options.shareId,
4650
+ initialId: options.initialContent ? undefined : options.shareId,
4651
+ cameraMode: options.initialContent ? undefined : options.initialMode,
4624
4652
  });
4625
4653
  if (options.fonts) {
4626
4654
  await this.post('setFontConfig', { config: options.fonts });
@@ -4794,10 +4822,11 @@
4794
4822
  }
4795
4823
  }
4796
4824
  async loadContent(content, source) {
4797
- await this.post('loadContent', { content });
4798
- this.currentContent = content;
4825
+ const latestContent = convertToLatest(content);
4826
+ await this.post('loadContent', { content: latestContent });
4827
+ this.currentContent = latestContent;
4799
4828
  this.currentSlideIndex = 0;
4800
- this.slideCount = content.slides.length;
4829
+ this.slideCount = latestContent.slides.length;
4801
4830
  await this.refreshHistoryState();
4802
4831
  }
4803
4832
  async switchTo(index) {
@@ -1,5 +1,5 @@
1
1
  import { EmbeddedTarget } from './embedded-target';
2
- import { type AiApi, type AiCancelEvent, type AlgeoEditorCreateOptions, type ContentChangeEvent, type DocumentApi, type EmbedRequestMessage, type EmbeddedEditorEventListenerMap, type EmbeddedEditorEventMap, type EmbeddedEditorEventName, type HistoryApi, type ModeApi, type SaveEvent, type SlidesApi } from './shared';
2
+ import { type AiApi, type AiCancelEvent, type ReplResult, type AlgeoEditorCreateOptions, type ContentChangeEvent, type DocumentApi, type EmbedRequestMessage, type EmbeddedEditorEventListenerMap, type EmbeddedEditorEventMap, type EmbeddedEditorEventName, type HistoryApi, type ModeApi, type SaveEvent, type SlidesApi } from './shared';
3
3
  export declare class EmbeddedEditor extends EmbeddedTarget<EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedEditorEventListenerMap> {
4
4
  private resourceLibrary?;
5
5
  private readonly resourceLibraryRequests;
@@ -16,6 +16,9 @@ export declare class EmbeddedEditor extends EmbeddedTarget<EmbeddedEditorEventMa
16
16
  private uiConfig;
17
17
  private activeAiRun?;
18
18
  constructor(container: HTMLElement);
19
+ /** Execute a REPL command and synchronize editor state before resolving. */
20
+ repl(command: string): Promise<ReplResult>;
21
+ private applyReplState;
19
22
  initialize(options?: AlgeoEditorCreateOptions, baseUrl?: string): Promise<void>;
20
23
  protected handleEventMessage(event: ContentChangeEvent | SaveEvent | {
21
24
  type: 'slideChange';
@@ -1,5 +1,5 @@
1
1
  import { EmbeddedTarget } from './embedded-target';
2
- import { AlgeoError, type AlgeoPresentationCreateOptions, type EmbeddedPresentationEventListenerMap, type EmbeddedPresentationEventMap, type EmbeddedPresentationEventName, type FileContentLatest, type GetSlideCountResult, type LoadFileResult, type LoadShareByIdResult, type PresentationModeApi, type ReplResult, type SwitchSlideResult } from './shared';
2
+ import { AlgeoError, type AlgeoPresentationCreateOptions, type EmbeddedPresentationEventListenerMap, type EmbeddedPresentationEventMap, type EmbeddedPresentationEventName, type FileContentAny, type GetSlideCountResult, type LoadFileResult, type LoadShareByIdResult, type PresentationModeApi, type ReplResult, type SwitchSlideResult } from './shared';
3
3
  export declare class EmbeddedPresentation extends EmbeddedTarget<EmbeddedPresentationEventMap, EmbeddedPresentationEventName, EmbeddedPresentationEventListenerMap> {
4
4
  readonly mode: PresentationModeApi;
5
5
  private currentContent?;
@@ -13,7 +13,7 @@ export declare class EmbeddedPresentation extends EmbeddedTarget<EmbeddedPresent
13
13
  setWhitelistError(error: AlgeoError): void;
14
14
  private ensureWhitelistAccess;
15
15
  loadShareById(id: string): Promise<LoadShareByIdResult>;
16
- loadFile(content: FileContentLatest): Promise<LoadFileResult>;
16
+ loadFile(content: FileContentAny): Promise<LoadFileResult>;
17
17
  switchSlide(index: number): Promise<SwitchSlideResult>;
18
18
  getSlideCount(): Promise<GetSlideCountResult>;
19
19
  repl(command: string): Promise<ReplResult>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AlgeoError, EMBED_ERROR_CODES, VERSION } from './shared';
2
- export type { FileContentLatest } from '@dajiaoai/algeo-protocol';
2
+ export type { FileContentAny, FileContentLatest, } from '@dajiaoai/algeo-protocol';
3
3
  export { convertToLatest } from '@dajiaoai/algeo-protocol';
4
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';
5
5
  export { EmbeddedPresentation } from './embedded-presentation';
package/dist/shared.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { AlgeoError, type AlgeoErrorPayload, type AiRunPayloadV1, type AiStreamEventV1, type EmbedReadyMessage, type EmbedResponseMessage, type FileContentLatest, EMBED_ERROR_CODES } from '@dajiaoai/algeo-protocol';
1
+ import { AlgeoError, type AlgeoErrorPayload, type AiRunPayloadV1, type AiStreamEventV1, type EmbedReadyMessage, type EmbedResponseMessage, type FileContentAny, type FileContentLatest, EMBED_ERROR_CODES } from '@dajiaoai/algeo-protocol';
2
2
  /** SDK 版本号,构建时由 rollup 注入 */
3
3
  export declare const VERSION = "__ALGEO_SDK_VERSION__";
4
4
  /** 从协议层 re-export,供外部使用 */
5
- export type { FileContentLatest, AlgeoErrorPayload };
5
+ export type { FileContentAny, FileContentLatest, AlgeoErrorPayload };
6
6
  export type { AiRawSseEventV1, AiResponseRecordV1, AiRunPayloadV1, AiStreamEventV1, GeometryOpV1, OpenAiChatMessageV1, } from '@dajiaoai/algeo-protocol';
7
7
  export { AlgeoError, EMBED_ERROR_CODES };
8
8
  export declare const EMBED_TIMEOUT_MS = 30000;
@@ -75,7 +75,9 @@ export type AlgeoEditorSaveResult = {
75
75
  export interface AlgeoEditorCreateOptions {
76
76
  auth?: AlgeoEditorAuthOptions;
77
77
  shareId?: string;
78
- initialContent?: FileContentLatest;
78
+ initialContent?: FileContentAny;
79
+ /** 空白画板模式,默认 2d。初始化优先级:initialContent > shareId > 空白画板。 */
80
+ initialMode?: '2d' | '3d';
79
81
  ui?: AlgeoEditorUiConfig;
80
82
  /** 字体资源、字体选择器列表及默认字体配置。 */
81
83
  fonts?: AlgeoFontConfig;
@@ -414,7 +416,7 @@ export interface GetHistoryStateResult {
414
416
  canRedo: boolean;
415
417
  }
416
418
  export interface DocumentApi {
417
- loadContent(content: FileContentLatest): Promise<void>;
419
+ loadContent(content: FileContentAny): Promise<void>;
418
420
  getContent(): Promise<FileContentLatest>;
419
421
  }
420
422
  export interface SlidesApi {
@@ -478,6 +480,7 @@ export declare function normalizeMode(mode?: AlgeoEmbedMode): AlgeoEmbedMode;
478
480
  export declare function getEmbedPath(mode: AlgeoEmbedMode): string;
479
481
  export interface EmbedInitOptions extends AlgeoSdkOptions {
480
482
  auth?: AlgeoEditorAuthOptions;
483
+ cameraMode?: '2d' | '3d';
481
484
  }
482
485
  export declare function buildEmbedSrc(options: EmbedInitOptions): string;
483
486
  export type KnownEventName = 'ready' | 'contentChange' | 'slideChange' | 'save' | 'aiRequest' | 'aiCancel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dajiaoai/algeo-sdk",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "大角几何内嵌画板 SDK,支持 iframe 挂载与 postMessage 通信",
5
5
  "main": "dist/algeo-sdk.cjs.js",
6
6
  "module": "dist/algeo-sdk.esm.js",