@box3/web-sdk
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -967,17 +967,2 @@ import Events$1 from 'events'; | ||
})(ContentType$1 || (ContentType$1 = {})); | ||
var ModelType; | ||
(function (ModelType) { | ||
/** | ||
* 私有模型 | ||
*/ | ||
ModelType[ModelType["Private"] = 0] = "Private"; | ||
/** | ||
* 公共模型 | ||
*/ | ||
ModelType[ModelType["Public"] = 1] = "Public"; | ||
/** | ||
* 项目模型 | ||
*/ | ||
ModelType[ModelType["Project"] = 2] = "Project"; | ||
})(ModelType || (ModelType = {})); | ||
var Permissions; | ||
@@ -1007,3 +992,3 @@ (function (Permissions) { | ||
class Content extends HttpClient { | ||
class MaasContent extends HttpClient { | ||
getContentInfo(contentId, params = {}) { | ||
@@ -1030,2 +1015,10 @@ return this.request(Object.assign({ | ||
} | ||
getPartnerPublicConfig(query, params = {}) { | ||
return this.request(Object.assign({ | ||
query, | ||
path: '/partner/config-no-auth', | ||
method: 'GET', | ||
type: ContentType.Json | ||
}, params)); | ||
} | ||
getContentId(query, params = {}) { | ||
@@ -1041,3 +1034,3 @@ return this.request(Object.assign({ | ||
class Auth extends HttpClient { | ||
class MaasAuth extends HttpClient { | ||
parseQueries(query) { | ||
@@ -1073,2 +1066,28 @@ const { | ||
/* eslint-disable */ | ||
/* tslint:disable */ | ||
/* | ||
* --------------------------------------------------------------- | ||
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## | ||
* ## ## | ||
* ## AUTHOR: acacode ## | ||
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ## | ||
* --------------------------------------------------------------- | ||
*/ | ||
var ModelType; | ||
(function (ModelType) { | ||
/** | ||
* 私有模型 | ||
*/ | ||
ModelType[ModelType["Private"] = 0] = "Private"; | ||
/** | ||
* 公共模型 | ||
*/ | ||
ModelType[ModelType["Public"] = 1] = "Public"; | ||
/** | ||
* 项目模型 | ||
*/ | ||
ModelType[ModelType["Project"] = 2] = "Project"; | ||
})(ModelType || (ModelType = {})); | ||
var AppType; | ||
@@ -1115,2 +1134,3 @@ (function (AppType) { | ||
AppEventType["Custom"] = "custom"; | ||
AppEventType["Tool"] = "tool"; | ||
})(AppEventType || (AppEventType = {})); | ||
@@ -1131,4 +1151,2 @@ | ||
this.reconnectOnLoad = () => __awaiter$2(this, void 0, void 0, function* () { | ||
const reconnection = this.reconnect(); | ||
this.loadingProcess = reconnection; | ||
const cancelPromise = new Promise(resolve => this.cancel = () => { | ||
@@ -1155,15 +1173,8 @@ resolve({ | ||
}); | ||
const res = yield Promise.race([reconnection, cancelPromise, timeoutPromise]); | ||
if (error(res)) { | ||
this.events.emit('error', { | ||
type: ErrorEventType.App, | ||
msg: `${res.body.type}, ${res.body.msg}` | ||
}); | ||
return; | ||
} | ||
const confirmLoaded = yield this.confirmToolLoaded(cancelPromise, timeoutPromise); | ||
this.loadingProcess = this.confirmToolLoaded(cancelPromise, timeoutPromise); | ||
const confirmLoaded = yield this.loadingProcess; | ||
if (error(confirmLoaded)) { | ||
this.events.emit('error', { | ||
type: ErrorEventType.App, | ||
msg: `${confirmLoaded.body.type}` | ||
msg: `${confirmLoaded.body.type}, ${confirmLoaded.body.msg}` | ||
}); | ||
@@ -1397,2 +1408,8 @@ return; | ||
}); | ||
this.tool.eventOn('fromEngine', msg => { | ||
this.events.emit('app', { | ||
type: AppEventType.Tool, | ||
msg | ||
}); | ||
}); | ||
} | ||
@@ -1507,41 +1524,2 @@ getVoxelEditorUrl(params) { | ||
} | ||
reconnect() { | ||
return __awaiter$2(this, void 0, void 0, function* () { | ||
if (!this.tool.iframeElement) { | ||
return { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Failed to reconnect with undefined iframe' | ||
} | ||
}; | ||
} | ||
try { | ||
const res = yield this.tool.iframe.connect({ | ||
current: 'parent', | ||
eventsOn: () => undefined, | ||
iframe: this.tool.iframeElement, | ||
timeout: this.timeout | ||
}); | ||
return !res ? { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Cannot connect tool' | ||
} | ||
} : { | ||
isSuccess: true | ||
}; | ||
} catch (err) { | ||
console.error('Reconnect error', err); | ||
return { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Tool connect error' | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
postMessage(message) { | ||
@@ -1567,4 +1545,4 @@ return __awaiter$2(this, void 0, void 0, function* () { | ||
}); | ||
this.auth = new Auth(this.axiosInstance); | ||
this.content = new Content(this.axiosInstance); | ||
this.auth = new MaasAuth(this.axiosInstance); | ||
this.content = new MaasContent(this.axiosInstance); | ||
} | ||
@@ -1571,0 +1549,0 @@ } |
@@ -976,17 +976,2 @@ 'use strict'; | ||
})(ContentType$1 || (ContentType$1 = {})); | ||
var ModelType; | ||
(function (ModelType) { | ||
/** | ||
* 私有模型 | ||
*/ | ||
ModelType[ModelType["Private"] = 0] = "Private"; | ||
/** | ||
* 公共模型 | ||
*/ | ||
ModelType[ModelType["Public"] = 1] = "Public"; | ||
/** | ||
* 项目模型 | ||
*/ | ||
ModelType[ModelType["Project"] = 2] = "Project"; | ||
})(ModelType || (ModelType = {})); | ||
var Permissions; | ||
@@ -1016,3 +1001,3 @@ (function (Permissions) { | ||
class Content extends HttpClient { | ||
class MaasContent extends HttpClient { | ||
getContentInfo(contentId, params = {}) { | ||
@@ -1039,2 +1024,10 @@ return this.request(Object.assign({ | ||
} | ||
getPartnerPublicConfig(query, params = {}) { | ||
return this.request(Object.assign({ | ||
query, | ||
path: '/partner/config-no-auth', | ||
method: 'GET', | ||
type: ContentType.Json | ||
}, params)); | ||
} | ||
getContentId(query, params = {}) { | ||
@@ -1050,3 +1043,3 @@ return this.request(Object.assign({ | ||
class Auth extends HttpClient { | ||
class MaasAuth extends HttpClient { | ||
parseQueries(query) { | ||
@@ -1082,2 +1075,28 @@ const { | ||
/* eslint-disable */ | ||
/* tslint:disable */ | ||
/* | ||
* --------------------------------------------------------------- | ||
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## | ||
* ## ## | ||
* ## AUTHOR: acacode ## | ||
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ## | ||
* --------------------------------------------------------------- | ||
*/ | ||
var ModelType; | ||
(function (ModelType) { | ||
/** | ||
* 私有模型 | ||
*/ | ||
ModelType[ModelType["Private"] = 0] = "Private"; | ||
/** | ||
* 公共模型 | ||
*/ | ||
ModelType[ModelType["Public"] = 1] = "Public"; | ||
/** | ||
* 项目模型 | ||
*/ | ||
ModelType[ModelType["Project"] = 2] = "Project"; | ||
})(ModelType || (ModelType = {})); | ||
exports.AppType = void 0; | ||
@@ -1124,2 +1143,3 @@ (function (AppType) { | ||
AppEventType["Custom"] = "custom"; | ||
AppEventType["Tool"] = "tool"; | ||
})(exports.AppEventType || (exports.AppEventType = {})); | ||
@@ -1140,4 +1160,2 @@ | ||
this.reconnectOnLoad = () => __awaiter$2(this, void 0, void 0, function* () { | ||
const reconnection = this.reconnect(); | ||
this.loadingProcess = reconnection; | ||
const cancelPromise = new Promise(resolve => this.cancel = () => { | ||
@@ -1164,15 +1182,8 @@ resolve({ | ||
}); | ||
const res = yield Promise.race([reconnection, cancelPromise, timeoutPromise]); | ||
if (error(res)) { | ||
this.events.emit('error', { | ||
type: exports.ErrorEventType.App, | ||
msg: `${res.body.type}, ${res.body.msg}` | ||
}); | ||
return; | ||
} | ||
const confirmLoaded = yield this.confirmToolLoaded(cancelPromise, timeoutPromise); | ||
this.loadingProcess = this.confirmToolLoaded(cancelPromise, timeoutPromise); | ||
const confirmLoaded = yield this.loadingProcess; | ||
if (error(confirmLoaded)) { | ||
this.events.emit('error', { | ||
type: exports.ErrorEventType.App, | ||
msg: `${confirmLoaded.body.type}` | ||
msg: `${confirmLoaded.body.type}, ${confirmLoaded.body.msg}` | ||
}); | ||
@@ -1406,2 +1417,8 @@ return; | ||
}); | ||
this.tool.eventOn('fromEngine', msg => { | ||
this.events.emit('app', { | ||
type: exports.AppEventType.Tool, | ||
msg | ||
}); | ||
}); | ||
} | ||
@@ -1516,41 +1533,2 @@ getVoxelEditorUrl(params) { | ||
} | ||
reconnect() { | ||
return __awaiter$2(this, void 0, void 0, function* () { | ||
if (!this.tool.iframeElement) { | ||
return { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Failed to reconnect with undefined iframe' | ||
} | ||
}; | ||
} | ||
try { | ||
const res = yield this.tool.iframe.connect({ | ||
current: 'parent', | ||
eventsOn: () => undefined, | ||
iframe: this.tool.iframeElement, | ||
timeout: this.timeout | ||
}); | ||
return !res ? { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Cannot connect tool' | ||
} | ||
} : { | ||
isSuccess: true | ||
}; | ||
} catch (err) { | ||
console.error('Reconnect error', err); | ||
return { | ||
isSuccess: false, | ||
body: { | ||
type: ErrorType.ReloadError, | ||
msg: 'Tool connect error' | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
postMessage(message) { | ||
@@ -1576,4 +1554,4 @@ return __awaiter$2(this, void 0, void 0, function* () { | ||
}); | ||
this.auth = new Auth(this.axiosInstance); | ||
this.content = new Content(this.axiosInstance); | ||
this.auth = new MaasAuth(this.axiosInstance); | ||
this.content = new MaasContent(this.axiosInstance); | ||
} | ||
@@ -1580,0 +1558,0 @@ } |
@@ -1,7 +0,7 @@ | ||
import { Auth, Content } from '@box/apis'; | ||
import { MaasAuth, MaasContent } from '@box/apis'; | ||
export declare class APIS { | ||
private axiosInstance; | ||
auth: Auth; | ||
content: Content; | ||
auth: MaasAuth; | ||
content: MaasContent; | ||
constructor(backendServerUrl: string); | ||
} |
@@ -29,4 +29,3 @@ import type { SDKResult } from '../result/interface'; | ||
private reconnectOnLoad; | ||
private reconnect; | ||
postMessage(message: Object): Promise<SDKResult>; | ||
} |
@@ -40,2 +40,6 @@ import type { EmitEventType, EventsType, Parent } from '@box/sdk'; | ||
}; | ||
fromEngine: { | ||
type: string; | ||
value: Object; | ||
}; | ||
} | ||
@@ -42,0 +46,0 @@ export interface AppEvent extends EventsType { |
@@ -7,3 +7,4 @@ export declare enum ErrorEventType { | ||
Reload = "reload", | ||
Custom = "custom" | ||
Custom = "custom", | ||
Tool = "tool" | ||
} |
@@ -14,6 +14,10 @@ import { AppEventType, ErrorEventType } from './defs'; | ||
}; | ||
export declare type AppToolEvent = { | ||
type: AppEventType.Tool; | ||
msg: Object; | ||
}; | ||
declare type AppEvent = { | ||
type: AppEventType.Reload; | ||
msg?: string; | ||
} | AppCustomEvent; | ||
} | AppCustomEvent | AppToolEvent; | ||
declare type OptionalIfUndefined<T> = undefined extends T ? [param?: T] : [param: T]; | ||
@@ -20,0 +24,0 @@ export interface IEvents { |
{ | ||
"name": "@box3/web-sdk", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "An sdk for using createra applications.", | ||
@@ -8,9 +8,2 @@ "main": "build/index.js", | ||
"types": "build/types/index.d.ts", | ||
"scripts": { | ||
"dev": "rollup -c rollup.config.js -w", | ||
"build": "rm -rf build && rollup -c rollup.config.js", | ||
"build:watch": "rushx build", | ||
"prepublishOnly": "npm run build", | ||
"release": "npm run build && npm publish" | ||
}, | ||
"author": "Code Infinity", | ||
@@ -27,4 +20,4 @@ "license": "UNLICENSED", | ||
"@rollup/plugin-typescript": "8.3.2", | ||
"@box/sdk": "workspace:1.3.0", | ||
"@box/apis": "workspace:0.1.0", | ||
"@box/sdk": "1.3.0", | ||
"@box/apis": "0.1.0", | ||
"tslib": "2.3.1" | ||
@@ -35,3 +28,9 @@ }, | ||
"events": "3.3.0" | ||
}, | ||
"scripts": { | ||
"dev": "rollup -c rollup.config.js -w", | ||
"build": "rm -rf build && rollup -c rollup.config.js", | ||
"build:watch": "rushx build", | ||
"release": "npm run build && npm publish" | ||
} | ||
} | ||
} |
121180
3339