@dajiaoai/algeo-sdk 2.5.0 → 2.6.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 +16 -15
- package/dist/algeo-sdk.cjs.js +8 -3
- package/dist/algeo-sdk.esm.js +8 -3
- package/dist/algeo-sdk.umd.js +8 -3
- package/dist/embedded-target.d.ts +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
npm install @dajiaoai/algeo-sdk
|
|
12
12
|
|
|
13
13
|
# 安装指定版本(推荐生产环境锁定版本)
|
|
14
|
-
npm install @dajiaoai/algeo-sdk@2.
|
|
14
|
+
npm install @dajiaoai/algeo-sdk@2.6.0
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
在 `package.json` 中:
|
|
@@ -19,7 +19,7 @@ npm install @dajiaoai/algeo-sdk@2.5.0
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dajiaoai/algeo-sdk": "2.
|
|
22
|
+
"@dajiaoai/algeo-sdk": "2.6.0" // 精确版本,生产推荐
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
```
|
|
@@ -29,7 +29,7 @@ npm install @dajiaoai/algeo-sdk@2.5.0
|
|
|
29
29
|
```json
|
|
30
30
|
{
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dajiaoai/algeo-sdk": "^2.
|
|
32
|
+
"@dajiaoai/algeo-sdk": "^2.6.0" // 兼容 2.x 的更新
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
```
|
|
@@ -39,14 +39,14 @@ npm install @dajiaoai/algeo-sdk@2.5.0
|
|
|
39
39
|
**unpkg**:
|
|
40
40
|
|
|
41
41
|
```html
|
|
42
|
-
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@2.
|
|
42
|
+
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@2.6.0/dist/algeo-sdk.umd.js"></script>
|
|
43
43
|
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@latest/dist/algeo-sdk.umd.js"></script>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
**jsDelivr**:
|
|
47
47
|
|
|
48
48
|
```html
|
|
49
|
-
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@2.
|
|
49
|
+
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@2.6.0/dist/algeo-sdk.umd.js"></script>
|
|
50
50
|
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@latest/dist/algeo-sdk.umd.js"></script>
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -410,16 +410,17 @@ interface FileContent {
|
|
|
410
410
|
|
|
411
411
|
#### `editor.slides`
|
|
412
412
|
|
|
413
|
-
| 方法 | 说明
|
|
414
|
-
| -------------------------------- |
|
|
415
|
-
| `getCount()` | 获取当前已知画板数量
|
|
416
|
-
| `getCurrentIndex()` | 获取当前已知画板索引
|
|
417
|
-
| `switchTo(index)` | 切换画板
|
|
418
|
-
| `add()` | 在末尾新增画板
|
|
419
|
-
| `addAt(index)` | 在指定位置新增画板
|
|
420
|
-
| `remove(index)` | 删除指定画板
|
|
421
|
-
| `duplicate(index, targetIndex?)` | 复制画板
|
|
422
|
-
| `reorder(fromIndex, toIndex)` | 重排画板
|
|
413
|
+
| 方法 | 说明 |
|
|
414
|
+
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
415
|
+
| `getCount()` | 获取当前已知画板数量 |
|
|
416
|
+
| `getCurrentIndex()` | 获取当前已知画板索引 |
|
|
417
|
+
| `switchTo(index)` | 切换画板 |
|
|
418
|
+
| `add()` | 在末尾新增画板 |
|
|
419
|
+
| `addAt(index)` | 在指定位置新增画板 |
|
|
420
|
+
| `remove(index)` | 删除指定画板 |
|
|
421
|
+
| `duplicate(index, targetIndex?)` | 复制画板 |
|
|
422
|
+
| `reorder(fromIndex, toIndex)` | 重排画板 |
|
|
423
|
+
| `exportImage(options?)` | 导出画板为图片,返回 `ExportedSlideImage[]`,每项含 `index`、`blob`、`format`、`width`、`height`。可选参数 `slideIndices`(1-based,不传则导出全部)、`format`(`'png'`/`'jpg'`)、`width`、`height`、`quality`(0~1,仅 jpg)、`autoFit`、`padding` |
|
|
423
424
|
|
|
424
425
|
#### `editor.history`
|
|
425
426
|
|
package/dist/algeo-sdk.cjs.js
CHANGED
|
@@ -3897,7 +3897,7 @@ objectType({
|
|
|
3897
3897
|
});
|
|
3898
3898
|
|
|
3899
3899
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3900
|
-
const VERSION = '2.
|
|
3900
|
+
const VERSION = '2.6.0';
|
|
3901
3901
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3902
3902
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3903
3903
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4129,9 +4129,10 @@ class EmbeddedTarget {
|
|
|
4129
4129
|
window.addEventListener('message', this.messageHandler);
|
|
4130
4130
|
});
|
|
4131
4131
|
}
|
|
4132
|
-
post(type, payload) {
|
|
4132
|
+
post(type, payload, options = {}) {
|
|
4133
4133
|
const requestId = generateRequestId();
|
|
4134
4134
|
const msg = { type, requestId, ...payload };
|
|
4135
|
+
const timeoutMs = options.timeoutMs ?? EMBED_TIMEOUT_MS;
|
|
4135
4136
|
return new Promise((resolve, reject) => {
|
|
4136
4137
|
if (this.destroyed) {
|
|
4137
4138
|
reject(new AlgeoError('SDK 已销毁', EMBED_ERROR_CODES.DESTROYED));
|
|
@@ -4156,7 +4157,7 @@ class EmbeddedTarget {
|
|
|
4156
4157
|
this.pending.delete(requestId);
|
|
4157
4158
|
reject(new AlgeoError('请求超时', EMBED_ERROR_CODES.TIMEOUT));
|
|
4158
4159
|
}
|
|
4159
|
-
},
|
|
4160
|
+
}, timeoutMs);
|
|
4160
4161
|
});
|
|
4161
4162
|
}
|
|
4162
4163
|
async destroy() {
|
|
@@ -4279,6 +4280,10 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4279
4280
|
}
|
|
4280
4281
|
await this.refreshHistoryState();
|
|
4281
4282
|
},
|
|
4283
|
+
exportImage: async (options) => {
|
|
4284
|
+
const result = await this.post('exportSlideImage', { options: options ?? {} });
|
|
4285
|
+
return result.images;
|
|
4286
|
+
},
|
|
4282
4287
|
};
|
|
4283
4288
|
this.history = {
|
|
4284
4289
|
getCount: () => this.historyCount,
|
package/dist/algeo-sdk.esm.js
CHANGED
|
@@ -3895,7 +3895,7 @@ objectType({
|
|
|
3895
3895
|
});
|
|
3896
3896
|
|
|
3897
3897
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3898
|
-
const VERSION = '2.
|
|
3898
|
+
const VERSION = '2.6.0';
|
|
3899
3899
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3900
3900
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3901
3901
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4127,9 +4127,10 @@ class EmbeddedTarget {
|
|
|
4127
4127
|
window.addEventListener('message', this.messageHandler);
|
|
4128
4128
|
});
|
|
4129
4129
|
}
|
|
4130
|
-
post(type, payload) {
|
|
4130
|
+
post(type, payload, options = {}) {
|
|
4131
4131
|
const requestId = generateRequestId();
|
|
4132
4132
|
const msg = { type, requestId, ...payload };
|
|
4133
|
+
const timeoutMs = options.timeoutMs ?? EMBED_TIMEOUT_MS;
|
|
4133
4134
|
return new Promise((resolve, reject) => {
|
|
4134
4135
|
if (this.destroyed) {
|
|
4135
4136
|
reject(new AlgeoError('SDK 已销毁', EMBED_ERROR_CODES.DESTROYED));
|
|
@@ -4154,7 +4155,7 @@ class EmbeddedTarget {
|
|
|
4154
4155
|
this.pending.delete(requestId);
|
|
4155
4156
|
reject(new AlgeoError('请求超时', EMBED_ERROR_CODES.TIMEOUT));
|
|
4156
4157
|
}
|
|
4157
|
-
},
|
|
4158
|
+
}, timeoutMs);
|
|
4158
4159
|
});
|
|
4159
4160
|
}
|
|
4160
4161
|
async destroy() {
|
|
@@ -4277,6 +4278,10 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4277
4278
|
}
|
|
4278
4279
|
await this.refreshHistoryState();
|
|
4279
4280
|
},
|
|
4281
|
+
exportImage: async (options) => {
|
|
4282
|
+
const result = await this.post('exportSlideImage', { options: options ?? {} });
|
|
4283
|
+
return result.images;
|
|
4284
|
+
},
|
|
4280
4285
|
};
|
|
4281
4286
|
this.history = {
|
|
4282
4287
|
getCount: () => this.historyCount,
|
package/dist/algeo-sdk.umd.js
CHANGED
|
@@ -3901,7 +3901,7 @@
|
|
|
3901
3901
|
});
|
|
3902
3902
|
|
|
3903
3903
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3904
|
-
const VERSION = '2.
|
|
3904
|
+
const VERSION = '2.6.0';
|
|
3905
3905
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3906
3906
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3907
3907
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4133,9 +4133,10 @@
|
|
|
4133
4133
|
window.addEventListener('message', this.messageHandler);
|
|
4134
4134
|
});
|
|
4135
4135
|
}
|
|
4136
|
-
post(type, payload) {
|
|
4136
|
+
post(type, payload, options = {}) {
|
|
4137
4137
|
const requestId = generateRequestId();
|
|
4138
4138
|
const msg = { type, requestId, ...payload };
|
|
4139
|
+
const timeoutMs = options.timeoutMs ?? EMBED_TIMEOUT_MS;
|
|
4139
4140
|
return new Promise((resolve, reject) => {
|
|
4140
4141
|
if (this.destroyed) {
|
|
4141
4142
|
reject(new AlgeoError('SDK 已销毁', EMBED_ERROR_CODES.DESTROYED));
|
|
@@ -4160,7 +4161,7 @@
|
|
|
4160
4161
|
this.pending.delete(requestId);
|
|
4161
4162
|
reject(new AlgeoError('请求超时', EMBED_ERROR_CODES.TIMEOUT));
|
|
4162
4163
|
}
|
|
4163
|
-
},
|
|
4164
|
+
}, timeoutMs);
|
|
4164
4165
|
});
|
|
4165
4166
|
}
|
|
4166
4167
|
async destroy() {
|
|
@@ -4283,6 +4284,10 @@
|
|
|
4283
4284
|
}
|
|
4284
4285
|
await this.refreshHistoryState();
|
|
4285
4286
|
},
|
|
4287
|
+
exportImage: async (options) => {
|
|
4288
|
+
const result = await this.post('exportSlideImage', { options: options ?? {} });
|
|
4289
|
+
return result.images;
|
|
4290
|
+
},
|
|
4286
4291
|
};
|
|
4287
4292
|
this.history = {
|
|
4288
4293
|
getCount: () => this.historyCount,
|
|
@@ -28,6 +28,8 @@ export declare abstract class EmbeddedTarget<EventMap extends {
|
|
|
28
28
|
private cleanupIframe;
|
|
29
29
|
private resetRuntimeState;
|
|
30
30
|
protected init(options: EmbedInitOptions): Promise<void>;
|
|
31
|
-
protected post<T>(type: string, payload: Record<string, unknown
|
|
31
|
+
protected post<T>(type: string, payload: Record<string, unknown>, options?: {
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
}): Promise<T>;
|
|
32
34
|
destroy(): Promise<void>;
|
|
33
35
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AlgeoError, EMBED_ERROR_CODES, VERSION } from './shared';
|
|
2
2
|
export type { FileContentV10 } from '@dajiaoai/algeo-protocol';
|
|
3
|
-
export type { AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoPresentationCreateOptions, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, ReadyEvent, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
3
|
+
export type { AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoPresentationCreateOptions, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, ReadyEvent, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
4
4
|
export { EmbeddedPresentation } from './embedded-presentation';
|
|
5
5
|
export { EmbeddedEditor } from './embedded-editor';
|
|
6
6
|
export { AlgeoSdk, create, createEditor, createPresentation, type EmbeddedInstance, } from './sdk';
|
package/dist/shared.d.ts
CHANGED
|
@@ -118,6 +118,25 @@ export interface ReplResult {
|
|
|
118
118
|
export interface SlideIndexResult {
|
|
119
119
|
index: number;
|
|
120
120
|
}
|
|
121
|
+
export interface ExportSlideImageOptions {
|
|
122
|
+
slideIndices?: number[];
|
|
123
|
+
format?: 'png' | 'jpg';
|
|
124
|
+
width?: number;
|
|
125
|
+
height?: number;
|
|
126
|
+
quality?: number;
|
|
127
|
+
autoFit?: boolean;
|
|
128
|
+
padding?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface ExportedSlideImage {
|
|
131
|
+
index: number;
|
|
132
|
+
blob: Blob;
|
|
133
|
+
format: 'png' | 'jpg';
|
|
134
|
+
width: number;
|
|
135
|
+
height: number;
|
|
136
|
+
}
|
|
137
|
+
export interface ExportSlideImageResult {
|
|
138
|
+
images: ExportedSlideImage[];
|
|
139
|
+
}
|
|
121
140
|
export interface GetContentResult {
|
|
122
141
|
content: FileContentV10;
|
|
123
142
|
}
|
|
@@ -140,6 +159,7 @@ export interface SlidesApi {
|
|
|
140
159
|
remove(index: number): Promise<void>;
|
|
141
160
|
duplicate(index: number, targetIndex?: number): Promise<SlideIndexResult>;
|
|
142
161
|
reorder(fromIndex: number, toIndex: number): Promise<void>;
|
|
162
|
+
exportImage(options?: ExportSlideImageOptions): Promise<ExportedSlideImage[]>;
|
|
143
163
|
}
|
|
144
164
|
export interface HistoryApi {
|
|
145
165
|
getCount(): number;
|