@atomm-developer/generator-sdk 1.0.5 → 1.0.6
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
|
@@ -4,16 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
The Atomm Generator Open Platform SDK provides core capabilities for third-party generator developers, including authentication, cloud storage, history, credits, billing, export, and template protocols.
|
|
6
6
|
|
|
7
|
+
For a standardized host layout with built-in login, template actions, and floating export entry, use the companion package `@atomm-developer/generator-workbench`.
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
# Via npm/pnpm/yarn
|
|
11
13
|
pnpm add @atomm-developer/generator-sdk
|
|
14
|
+
pnpm add @atomm-developer/generator-workbench
|
|
12
15
|
|
|
13
16
|
# Via CDN (for plain HTML)
|
|
14
17
|
# <script src="https://static-res.atomm.com/scripts/js/generator-sdk/index.umd.js"></script>
|
|
18
|
+
# <script src="https://static-res.atomm.com/scripts/js/generator-sdk/generator-workbench/index.umd.js"></script>
|
|
15
19
|
```
|
|
16
20
|
|
|
21
|
+
## Package Roles
|
|
22
|
+
|
|
23
|
+
- `@atomm-developer/generator-sdk`: platform capability layer such as auth, export, template, billing, and history.
|
|
24
|
+
- `@atomm-developer/generator-workbench`: official host shell that mounts the runtime canvas and parameter panel into a unified layout.
|
|
25
|
+
|
|
17
26
|
## Quick Start
|
|
18
27
|
|
|
19
28
|
### Initialization
|
|
@@ -25,6 +34,9 @@ const sdk = GeneratorSDK.init({
|
|
|
25
34
|
appKey: 'your_app_key', // Get from developer console
|
|
26
35
|
env: 'prod', // 'dev' | 'test' | 'pre' | 'prod'
|
|
27
36
|
});
|
|
37
|
+
|
|
38
|
+
console.log(sdk.getAppKey());
|
|
39
|
+
console.log(GeneratorSDK.getAppKey());
|
|
28
40
|
```
|
|
29
41
|
|
|
30
42
|
### Core Modules
|
|
@@ -84,6 +96,27 @@ await sdk.export.openInStudio();
|
|
|
84
96
|
|
|
85
97
|
For detailed API references and integration guides, please visit our [Documentation Portal](https://github.com/atomm-inc/generator-sdk/tree/main/docs).
|
|
86
98
|
|
|
99
|
+
## Repository Build
|
|
100
|
+
|
|
101
|
+
This repository now builds both the SDK bundle and the `generator-workbench` UMD asset through the root build chain:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pnpm build
|
|
105
|
+
pnpm type-check
|
|
106
|
+
pnpm test:workbench
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`pnpm deploy:cdn` uploads both `generator-sdk` and `generator-workbench` CDN assets to `static-res.atomm.com`.
|
|
110
|
+
|
|
111
|
+
If you need to publish both packages from the repository root, use:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pnpm deploy
|
|
115
|
+
pnpm deploy:workbench
|
|
116
|
+
# or
|
|
117
|
+
pnpm deploy:all
|
|
118
|
+
```
|
|
119
|
+
|
|
87
120
|
## License
|
|
88
121
|
|
|
89
122
|
MIT
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { t as toUtf8, f as fromUtf8 } from "./index-
|
|
4
|
+
import { t as toUtf8, f as fromUtf8 } from "./index-DP-Q2Dkh.js";
|
|
5
5
|
class EventStreamSerde {
|
|
6
6
|
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
|
|
7
7
|
__publicField(this, "marshaller");
|
|
@@ -10002,6 +10002,25 @@ class AuthModule {
|
|
|
10002
10002
|
getToken() {
|
|
10003
10003
|
return getToken(this.appKey);
|
|
10004
10004
|
}
|
|
10005
|
+
/**
|
|
10006
|
+
* 外部传入 token,同步到本地缓存并刷新登录状态
|
|
10007
|
+
*/
|
|
10008
|
+
async syncToken(token) {
|
|
10009
|
+
const normalizedToken = token.trim();
|
|
10010
|
+
if (!normalizedToken) {
|
|
10011
|
+
throw new Error("Token is required");
|
|
10012
|
+
}
|
|
10013
|
+
try {
|
|
10014
|
+
setToken(this.appKey, normalizedToken);
|
|
10015
|
+
this.passportClient.token = normalizedToken;
|
|
10016
|
+
const userInfo = await this._fetchUserInfo(normalizedToken);
|
|
10017
|
+
this._setLoginStatus(userInfo);
|
|
10018
|
+
return this.getStatus();
|
|
10019
|
+
} catch (error) {
|
|
10020
|
+
this._clearLoginStatus();
|
|
10021
|
+
throw error;
|
|
10022
|
+
}
|
|
10023
|
+
}
|
|
10005
10024
|
/**
|
|
10006
10025
|
* 弹出登录弹窗
|
|
10007
10026
|
* 登录成功后 resolve UserInfo,用户取消则 reject
|
|
@@ -12265,7 +12284,7 @@ class HttpProtocol extends SerdeContext {
|
|
|
12265
12284
|
});
|
|
12266
12285
|
}
|
|
12267
12286
|
async loadEventStreamCapability() {
|
|
12268
|
-
const { EventStreamSerde } = await import("./index-
|
|
12287
|
+
const { EventStreamSerde } = await import("./index-6H3DQX8m.js");
|
|
12269
12288
|
return new EventStreamSerde({
|
|
12270
12289
|
marshaller: this.getEventStreamMarshaller(),
|
|
12271
12290
|
serializer: this.serializer,
|
|
@@ -81267,7 +81286,7 @@ class TemplateModule {
|
|
|
81267
81286
|
}
|
|
81268
81287
|
}
|
|
81269
81288
|
const instanceCache = /* @__PURE__ */ new Map();
|
|
81270
|
-
class
|
|
81289
|
+
const _GeneratorSDK = class _GeneratorSDK {
|
|
81271
81290
|
constructor(options) {
|
|
81272
81291
|
/** 登录/退出/用户信息 */
|
|
81273
81292
|
__publicField(this, "auth");
|
|
@@ -81299,6 +81318,12 @@ class GeneratorSDK {
|
|
|
81299
81318
|
this.export = new ExportModule(appKey, env, http);
|
|
81300
81319
|
this.template = new TemplateModule();
|
|
81301
81320
|
}
|
|
81321
|
+
/**
|
|
81322
|
+
* 返回当前 SDK 实例绑定的 appKey
|
|
81323
|
+
*/
|
|
81324
|
+
getAppKey() {
|
|
81325
|
+
return this.appKey;
|
|
81326
|
+
}
|
|
81302
81327
|
// ─────────────────────────────────────────────
|
|
81303
81328
|
// 静态工厂方法
|
|
81304
81329
|
// ─────────────────────────────────────────────
|
|
@@ -81318,23 +81343,34 @@ class GeneratorSDK {
|
|
|
81318
81343
|
}
|
|
81319
81344
|
const env = options.env ?? "prod";
|
|
81320
81345
|
const cacheKey = `${options.appKey}::${env}`;
|
|
81346
|
+
_GeneratorSDK.lastInitializedAppKey = options.appKey;
|
|
81321
81347
|
if (instanceCache.has(cacheKey)) {
|
|
81322
81348
|
return instanceCache.get(cacheKey);
|
|
81323
81349
|
}
|
|
81324
|
-
const instance = new
|
|
81350
|
+
const instance = new _GeneratorSDK({ appKey: options.appKey, env });
|
|
81325
81351
|
instanceCache.set(cacheKey, instance);
|
|
81326
81352
|
console.info(
|
|
81327
81353
|
`[GeneratorSDK] initialized (appKey: ${options.appKey}, env: ${env})`
|
|
81328
81354
|
);
|
|
81329
81355
|
return instance;
|
|
81330
81356
|
}
|
|
81357
|
+
/**
|
|
81358
|
+
* 返回最近一次初始化使用的 appKey
|
|
81359
|
+
*/
|
|
81360
|
+
static getAppKey() {
|
|
81361
|
+
return _GeneratorSDK.lastInitializedAppKey;
|
|
81362
|
+
}
|
|
81331
81363
|
/**
|
|
81332
81364
|
* 清除实例缓存(测试场景使用)
|
|
81333
81365
|
*/
|
|
81334
81366
|
static _clearCache() {
|
|
81335
81367
|
instanceCache.clear();
|
|
81368
|
+
_GeneratorSDK.lastInitializedAppKey = null;
|
|
81336
81369
|
}
|
|
81337
|
-
}
|
|
81370
|
+
};
|
|
81371
|
+
/** 最近一次初始化使用的 appKey,供全局场景读取 */
|
|
81372
|
+
__publicField(_GeneratorSDK, "lastInitializedAppKey", null);
|
|
81373
|
+
let GeneratorSDK = _GeneratorSDK;
|
|
81338
81374
|
const withBilling = async (billing, action5, options) => {
|
|
81339
81375
|
var _a2;
|
|
81340
81376
|
const check = billing.check();
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare type AuthChangeCallback = (status: AuthStatus) => void;
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Auth 模块
|
|
8
|
-
* 对外暴露:getStatus / login / logout / onChange / getToken
|
|
8
|
+
* 对外暴露:getStatus / login / logout / onChange / getToken / syncToken
|
|
9
9
|
*/
|
|
10
10
|
declare class AuthModule {
|
|
11
11
|
private readonly appKey;
|
|
@@ -23,6 +23,10 @@ declare class AuthModule {
|
|
|
23
23
|
* 未登录时返回空字符串
|
|
24
24
|
*/
|
|
25
25
|
getToken(): string;
|
|
26
|
+
/**
|
|
27
|
+
* 外部传入 token,同步到本地缓存并刷新登录状态
|
|
28
|
+
*/
|
|
29
|
+
syncToken(token: string): Promise<AuthStatus>;
|
|
26
30
|
/**
|
|
27
31
|
* 弹出登录弹窗
|
|
28
32
|
* 登录成功后 resolve UserInfo,用户取消则 reject
|
|
@@ -477,6 +481,8 @@ export declare interface ExportProvider {
|
|
|
477
481
|
export declare type ExportPurpose = 'download' | 'studio' | 'cover';
|
|
478
482
|
|
|
479
483
|
export declare class GeneratorSDK {
|
|
484
|
+
/** 最近一次初始化使用的 appKey,供全局场景读取 */
|
|
485
|
+
private static lastInitializedAppKey;
|
|
480
486
|
/** 登录/退出/用户信息 */
|
|
481
487
|
readonly auth: AuthModule;
|
|
482
488
|
/** 云保存/恢复/删除 */
|
|
@@ -494,6 +500,10 @@ export declare class GeneratorSDK {
|
|
|
494
500
|
private readonly appKey;
|
|
495
501
|
private readonly env;
|
|
496
502
|
private constructor();
|
|
503
|
+
/**
|
|
504
|
+
* 返回当前 SDK 实例绑定的 appKey
|
|
505
|
+
*/
|
|
506
|
+
getAppKey(): string;
|
|
497
507
|
/**
|
|
498
508
|
* 初始化 SDK,返回 SDK 实例
|
|
499
509
|
*
|
|
@@ -505,6 +515,10 @@ export declare class GeneratorSDK {
|
|
|
505
515
|
* ```
|
|
506
516
|
*/
|
|
507
517
|
static init(options: SdkInitOptions): GeneratorSDK;
|
|
518
|
+
/**
|
|
519
|
+
* 返回最近一次初始化使用的 appKey
|
|
520
|
+
*/
|
|
521
|
+
static getAppKey(): string | null;
|
|
508
522
|
/**
|
|
509
523
|
* 清除实例缓存(测试场景使用)
|
|
510
524
|
*/
|
package/dist/index.es.js
CHANGED