@dajiaoai/algeo-sdk 2.14.0 → 2.14.1
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 +6 -19
- package/dist/algeo-sdk.cjs.js +34 -10
- package/dist/algeo-sdk.esm.js +34 -10
- package/dist/algeo-sdk.umd.js +34 -10
- package/dist/embedded-presentation.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/shared.d.ts +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -313,7 +313,7 @@ type AlgeoCreateOptions =
|
|
|
313
313
|
| ---------------- | ------------------------------ | ------ | ------------------------------------------------------ |
|
|
314
314
|
| `auth` | `{ appId: string }` | - | 编辑模式鉴权参数,其中 `appId` 会参与默认路由生成 |
|
|
315
315
|
| `shareId` | `string` | `''` | 编辑模式初始分享 ID,会映射到 `/embed/edit/:appId/:id` |
|
|
316
|
-
| `initialContent` | `
|
|
316
|
+
| `initialContent` | `FileContentAny` | - | 初始化后自动注入的文件内容;SDK 会自动转换为最新格式 |
|
|
317
317
|
| `ui` | `Partial<AlgeoEditorUiConfig>` | - | 编辑器 UI 开关配置 |
|
|
318
318
|
| `fonts` | `AlgeoFontConfig` | - | 字体资源、字体选择器列表及默认字体配置 |
|
|
319
319
|
|
|
@@ -474,26 +474,13 @@ SDK 内部已通过 `ResizeObserver` 在容器从隐藏(`display:none`,尺
|
|
|
474
474
|
|
|
475
475
|
---
|
|
476
476
|
|
|
477
|
-
##### `presentation.loadFile(content:
|
|
477
|
+
##### `presentation.loadFile(content: FileContentAny): Promise<LoadFileResult>`
|
|
478
478
|
|
|
479
|
-
|
|
479
|
+
加载完整文件数据(覆盖式)。
|
|
480
480
|
|
|
481
481
|
| 参数 | 类型 | 说明 |
|
|
482
482
|
| --------- | ------------- | ------------ |
|
|
483
|
-
| `content` | `
|
|
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
|
-
```
|
|
483
|
+
| `content` | `FileContentAny` | 协议包支持读取的文件内容对象 |
|
|
497
484
|
|
|
498
485
|
**返回值:** `{ success: true }`
|
|
499
486
|
|
|
@@ -560,8 +547,8 @@ interface FileContent {
|
|
|
560
547
|
|
|
561
548
|
| 方法 | 说明 |
|
|
562
549
|
| ---------------------- | -------------------------------- |
|
|
563
|
-
| `loadContent(content)` |
|
|
564
|
-
| `getContent()
|
|
550
|
+
| `loadContent(content: FileContentAny)` | 加载完整画板文件内容,并自动转换为最新格式 |
|
|
551
|
+
| `getContent(): Promise<FileContentLatest>` | 异步获取 iframe 当前实时画板内容 |
|
|
565
552
|
|
|
566
553
|
#### `editor.slides`
|
|
567
554
|
|
package/dist/algeo-sdk.cjs.js
CHANGED
|
@@ -3865,6 +3865,12 @@ var AlgeoError = class extends Error {
|
|
|
3865
3865
|
this.name = "AlgeoError";
|
|
3866
3866
|
}
|
|
3867
3867
|
};
|
|
3868
|
+
objectType({
|
|
3869
|
+
text: stringType().optional(),
|
|
3870
|
+
images: arrayType(stringType().trim().min(1)).optional(),
|
|
3871
|
+
openPanel: booleanType().optional(),
|
|
3872
|
+
focus: booleanType().optional()
|
|
3873
|
+
}).passthrough();
|
|
3868
3874
|
var openAiChatMessageV1Schema = objectType({
|
|
3869
3875
|
role: stringType(),
|
|
3870
3876
|
content: unionType([
|
|
@@ -3878,9 +3884,23 @@ var openAiChatMessageV1Schema = objectType({
|
|
|
3878
3884
|
name: stringType().optional()
|
|
3879
3885
|
}).passthrough();
|
|
3880
3886
|
objectType({
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3887
|
+
model: stringType().trim().min(1),
|
|
3888
|
+
input: unionType([
|
|
3889
|
+
stringType(),
|
|
3890
|
+
arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
|
|
3891
|
+
]).optional(),
|
|
3892
|
+
previous_response_id: stringType().trim().min(1).optional(),
|
|
3893
|
+
instructions: stringType().optional(),
|
|
3894
|
+
temperature: numberType().min(0).max(2).optional(),
|
|
3895
|
+
max_output_tokens: numberType().int().positive().optional(),
|
|
3896
|
+
metadata: recordType(unknownType()).optional()
|
|
3897
|
+
}).passthrough().superRefine((value, ctx) => {
|
|
3898
|
+
if (!("input" in value) && !("previous_response_id" in value)) {
|
|
3899
|
+
ctx.addIssue({
|
|
3900
|
+
code: ZodIssueCode.custom,
|
|
3901
|
+
message: "input or previous_response_id is required."
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3884
3904
|
});
|
|
3885
3905
|
objectType({
|
|
3886
3906
|
id: stringType(),
|
|
@@ -4011,7 +4031,7 @@ function convertToLatest(content) {
|
|
|
4011
4031
|
}
|
|
4012
4032
|
|
|
4013
4033
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4014
|
-
const VERSION = '2.14.
|
|
4034
|
+
const VERSION = '2.14.1';
|
|
4015
4035
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4016
4036
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4017
4037
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4466,10 +4486,13 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4466
4486
|
}
|
|
4467
4487
|
async loadFile(content) {
|
|
4468
4488
|
this.ensureWhitelistAccess('loadFile');
|
|
4469
|
-
const
|
|
4470
|
-
this.
|
|
4489
|
+
const latestContent = convertToLatest(content);
|
|
4490
|
+
const result = await this.post('loadContent', {
|
|
4491
|
+
content: latestContent,
|
|
4492
|
+
});
|
|
4493
|
+
this.currentContent = latestContent;
|
|
4471
4494
|
this.currentSlideIndex = 0;
|
|
4472
|
-
this.slideCount =
|
|
4495
|
+
this.slideCount = latestContent.slides.length;
|
|
4473
4496
|
return result;
|
|
4474
4497
|
}
|
|
4475
4498
|
async switchSlide(index) {
|
|
@@ -4790,10 +4813,11 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4790
4813
|
}
|
|
4791
4814
|
}
|
|
4792
4815
|
async loadContent(content, source) {
|
|
4793
|
-
|
|
4794
|
-
this.
|
|
4816
|
+
const latestContent = convertToLatest(content);
|
|
4817
|
+
await this.post('loadContent', { content: latestContent });
|
|
4818
|
+
this.currentContent = latestContent;
|
|
4795
4819
|
this.currentSlideIndex = 0;
|
|
4796
|
-
this.slideCount =
|
|
4820
|
+
this.slideCount = latestContent.slides.length;
|
|
4797
4821
|
await this.refreshHistoryState();
|
|
4798
4822
|
}
|
|
4799
4823
|
async switchTo(index) {
|
package/dist/algeo-sdk.esm.js
CHANGED
|
@@ -3863,6 +3863,12 @@ var AlgeoError = class extends Error {
|
|
|
3863
3863
|
this.name = "AlgeoError";
|
|
3864
3864
|
}
|
|
3865
3865
|
};
|
|
3866
|
+
objectType({
|
|
3867
|
+
text: stringType().optional(),
|
|
3868
|
+
images: arrayType(stringType().trim().min(1)).optional(),
|
|
3869
|
+
openPanel: booleanType().optional(),
|
|
3870
|
+
focus: booleanType().optional()
|
|
3871
|
+
}).passthrough();
|
|
3866
3872
|
var openAiChatMessageV1Schema = objectType({
|
|
3867
3873
|
role: stringType(),
|
|
3868
3874
|
content: unionType([
|
|
@@ -3876,9 +3882,23 @@ var openAiChatMessageV1Schema = objectType({
|
|
|
3876
3882
|
name: stringType().optional()
|
|
3877
3883
|
}).passthrough();
|
|
3878
3884
|
objectType({
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3885
|
+
model: stringType().trim().min(1),
|
|
3886
|
+
input: unionType([
|
|
3887
|
+
stringType(),
|
|
3888
|
+
arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
|
|
3889
|
+
]).optional(),
|
|
3890
|
+
previous_response_id: stringType().trim().min(1).optional(),
|
|
3891
|
+
instructions: stringType().optional(),
|
|
3892
|
+
temperature: numberType().min(0).max(2).optional(),
|
|
3893
|
+
max_output_tokens: numberType().int().positive().optional(),
|
|
3894
|
+
metadata: recordType(unknownType()).optional()
|
|
3895
|
+
}).passthrough().superRefine((value, ctx) => {
|
|
3896
|
+
if (!("input" in value) && !("previous_response_id" in value)) {
|
|
3897
|
+
ctx.addIssue({
|
|
3898
|
+
code: ZodIssueCode.custom,
|
|
3899
|
+
message: "input or previous_response_id is required."
|
|
3900
|
+
});
|
|
3901
|
+
}
|
|
3882
3902
|
});
|
|
3883
3903
|
objectType({
|
|
3884
3904
|
id: stringType(),
|
|
@@ -4009,7 +4029,7 @@ function convertToLatest(content) {
|
|
|
4009
4029
|
}
|
|
4010
4030
|
|
|
4011
4031
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4012
|
-
const VERSION = '2.14.
|
|
4032
|
+
const VERSION = '2.14.1';
|
|
4013
4033
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4014
4034
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4015
4035
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4464,10 +4484,13 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4464
4484
|
}
|
|
4465
4485
|
async loadFile(content) {
|
|
4466
4486
|
this.ensureWhitelistAccess('loadFile');
|
|
4467
|
-
const
|
|
4468
|
-
this.
|
|
4487
|
+
const latestContent = convertToLatest(content);
|
|
4488
|
+
const result = await this.post('loadContent', {
|
|
4489
|
+
content: latestContent,
|
|
4490
|
+
});
|
|
4491
|
+
this.currentContent = latestContent;
|
|
4469
4492
|
this.currentSlideIndex = 0;
|
|
4470
|
-
this.slideCount =
|
|
4493
|
+
this.slideCount = latestContent.slides.length;
|
|
4471
4494
|
return result;
|
|
4472
4495
|
}
|
|
4473
4496
|
async switchSlide(index) {
|
|
@@ -4788,10 +4811,11 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4788
4811
|
}
|
|
4789
4812
|
}
|
|
4790
4813
|
async loadContent(content, source) {
|
|
4791
|
-
|
|
4792
|
-
this.
|
|
4814
|
+
const latestContent = convertToLatest(content);
|
|
4815
|
+
await this.post('loadContent', { content: latestContent });
|
|
4816
|
+
this.currentContent = latestContent;
|
|
4793
4817
|
this.currentSlideIndex = 0;
|
|
4794
|
-
this.slideCount =
|
|
4818
|
+
this.slideCount = latestContent.slides.length;
|
|
4795
4819
|
await this.refreshHistoryState();
|
|
4796
4820
|
}
|
|
4797
4821
|
async switchTo(index) {
|
package/dist/algeo-sdk.umd.js
CHANGED
|
@@ -3869,6 +3869,12 @@
|
|
|
3869
3869
|
this.name = "AlgeoError";
|
|
3870
3870
|
}
|
|
3871
3871
|
};
|
|
3872
|
+
objectType({
|
|
3873
|
+
text: stringType().optional(),
|
|
3874
|
+
images: arrayType(stringType().trim().min(1)).optional(),
|
|
3875
|
+
openPanel: booleanType().optional(),
|
|
3876
|
+
focus: booleanType().optional()
|
|
3877
|
+
}).passthrough();
|
|
3872
3878
|
var openAiChatMessageV1Schema = objectType({
|
|
3873
3879
|
role: stringType(),
|
|
3874
3880
|
content: unionType([
|
|
@@ -3882,9 +3888,23 @@
|
|
|
3882
3888
|
name: stringType().optional()
|
|
3883
3889
|
}).passthrough();
|
|
3884
3890
|
objectType({
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3891
|
+
model: stringType().trim().min(1),
|
|
3892
|
+
input: unionType([
|
|
3893
|
+
stringType(),
|
|
3894
|
+
arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
|
|
3895
|
+
]).optional(),
|
|
3896
|
+
previous_response_id: stringType().trim().min(1).optional(),
|
|
3897
|
+
instructions: stringType().optional(),
|
|
3898
|
+
temperature: numberType().min(0).max(2).optional(),
|
|
3899
|
+
max_output_tokens: numberType().int().positive().optional(),
|
|
3900
|
+
metadata: recordType(unknownType()).optional()
|
|
3901
|
+
}).passthrough().superRefine((value, ctx) => {
|
|
3902
|
+
if (!("input" in value) && !("previous_response_id" in value)) {
|
|
3903
|
+
ctx.addIssue({
|
|
3904
|
+
code: ZodIssueCode.custom,
|
|
3905
|
+
message: "input or previous_response_id is required."
|
|
3906
|
+
});
|
|
3907
|
+
}
|
|
3888
3908
|
});
|
|
3889
3909
|
objectType({
|
|
3890
3910
|
id: stringType(),
|
|
@@ -4015,7 +4035,7 @@
|
|
|
4015
4035
|
}
|
|
4016
4036
|
|
|
4017
4037
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4018
|
-
const VERSION = '2.14.
|
|
4038
|
+
const VERSION = '2.14.1';
|
|
4019
4039
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4020
4040
|
const DEFAULT_PRESENTATION_PATH = '/embed/present';
|
|
4021
4041
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4470,10 +4490,13 @@
|
|
|
4470
4490
|
}
|
|
4471
4491
|
async loadFile(content) {
|
|
4472
4492
|
this.ensureWhitelistAccess('loadFile');
|
|
4473
|
-
const
|
|
4474
|
-
this.
|
|
4493
|
+
const latestContent = convertToLatest(content);
|
|
4494
|
+
const result = await this.post('loadContent', {
|
|
4495
|
+
content: latestContent,
|
|
4496
|
+
});
|
|
4497
|
+
this.currentContent = latestContent;
|
|
4475
4498
|
this.currentSlideIndex = 0;
|
|
4476
|
-
this.slideCount =
|
|
4499
|
+
this.slideCount = latestContent.slides.length;
|
|
4477
4500
|
return result;
|
|
4478
4501
|
}
|
|
4479
4502
|
async switchSlide(index) {
|
|
@@ -4794,10 +4817,11 @@
|
|
|
4794
4817
|
}
|
|
4795
4818
|
}
|
|
4796
4819
|
async loadContent(content, source) {
|
|
4797
|
-
|
|
4798
|
-
this.
|
|
4820
|
+
const latestContent = convertToLatest(content);
|
|
4821
|
+
await this.post('loadContent', { content: latestContent });
|
|
4822
|
+
this.currentContent = latestContent;
|
|
4799
4823
|
this.currentSlideIndex = 0;
|
|
4800
|
-
this.slideCount =
|
|
4824
|
+
this.slideCount = latestContent.slides.length;
|
|
4801
4825
|
await this.refreshHistoryState();
|
|
4802
4826
|
}
|
|
4803
4827
|
async switchTo(index) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmbeddedTarget } from './embedded-target';
|
|
2
|
-
import { AlgeoError, type AlgeoPresentationCreateOptions, type EmbeddedPresentationEventListenerMap, type EmbeddedPresentationEventMap, type EmbeddedPresentationEventName, type
|
|
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:
|
|
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,7 @@ export type AlgeoEditorSaveResult = {
|
|
|
75
75
|
export interface AlgeoEditorCreateOptions {
|
|
76
76
|
auth?: AlgeoEditorAuthOptions;
|
|
77
77
|
shareId?: string;
|
|
78
|
-
initialContent?:
|
|
78
|
+
initialContent?: FileContentAny;
|
|
79
79
|
ui?: AlgeoEditorUiConfig;
|
|
80
80
|
/** 字体资源、字体选择器列表及默认字体配置。 */
|
|
81
81
|
fonts?: AlgeoFontConfig;
|
|
@@ -414,7 +414,7 @@ export interface GetHistoryStateResult {
|
|
|
414
414
|
canRedo: boolean;
|
|
415
415
|
}
|
|
416
416
|
export interface DocumentApi {
|
|
417
|
-
loadContent(content:
|
|
417
|
+
loadContent(content: FileContentAny): Promise<void>;
|
|
418
418
|
getContent(): Promise<FileContentLatest>;
|
|
419
419
|
}
|
|
420
420
|
export interface SlidesApi {
|