@magiclabs.ai/magicbook-client 0.6.10 → 0.6.12-canary
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/index.cjs +70 -13
- package/index.cjs.map +1 -1
- package/index.d.cts +1624 -1
- package/index.d.ts +1624 -1
- package/index.js +43 -12
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -209,13 +209,13 @@ var imageDensities = ["low", "medium", "high"];
|
|
|
209
209
|
var imageFilteringLevels = ["best", "most", "all"];
|
|
210
210
|
var embellishmentLevels = ["none", "few", "lots"];
|
|
211
211
|
var textStickerLevels = ["none", "few", "lots"];
|
|
212
|
-
var
|
|
212
|
+
var timeoutEventDetail = {
|
|
213
213
|
state: "timeout",
|
|
214
214
|
slug: "timeout",
|
|
215
215
|
progress: 100,
|
|
216
216
|
message: "Design timed out"
|
|
217
217
|
};
|
|
218
|
-
var
|
|
218
|
+
var cancelledEventDetail = {
|
|
219
219
|
state: "cancelled",
|
|
220
220
|
slug: "cancelled",
|
|
221
221
|
progress: 100,
|
|
@@ -4013,6 +4013,7 @@ var bookDesignRequestSchema = z.object({
|
|
|
4013
4013
|
var BookPropsSchema = z.object({
|
|
4014
4014
|
id: z.string().optional(),
|
|
4015
4015
|
title: z.string(),
|
|
4016
|
+
subtitle: z.string().optional(),
|
|
4016
4017
|
design_request: bookDesignRequestSchema,
|
|
4017
4018
|
state: z.enum(states).optional(),
|
|
4018
4019
|
guid: z.string().optional(),
|
|
@@ -4021,6 +4022,7 @@ var BookPropsSchema = z.object({
|
|
|
4021
4022
|
var Book = class {
|
|
4022
4023
|
id;
|
|
4023
4024
|
title;
|
|
4025
|
+
subtitle;
|
|
4024
4026
|
design_request;
|
|
4025
4027
|
state;
|
|
4026
4028
|
guid;
|
|
@@ -4028,6 +4030,7 @@ var Book = class {
|
|
|
4028
4030
|
constructor(props) {
|
|
4029
4031
|
this.id = props.id || "";
|
|
4030
4032
|
this.title = props.title;
|
|
4033
|
+
this.subtitle = props.subtitle;
|
|
4031
4034
|
this.design_request = new BookDesignRequest(props.design_request);
|
|
4032
4035
|
this.state = props.state;
|
|
4033
4036
|
this.guid = props.guid;
|
|
@@ -4130,9 +4133,9 @@ var designOptionsServerSchema = z.object({
|
|
|
4130
4133
|
});
|
|
4131
4134
|
|
|
4132
4135
|
// ../../core/config.ts
|
|
4133
|
-
var defaultApiHost = "
|
|
4134
|
-
var defaultWebSocketHost = "wss://
|
|
4135
|
-
var designRequestTimeout = parseInt("
|
|
4136
|
+
var defaultApiHost = "http://localhost:2812";
|
|
4137
|
+
var defaultWebSocketHost = "wss://localhost:2812";
|
|
4138
|
+
var designRequestTimeout = parseInt(""?.toString() || "3000");
|
|
4136
4139
|
|
|
4137
4140
|
// ../../core/models/design-request/index.ts
|
|
4138
4141
|
var DesignRequestOptions = {
|
|
@@ -4154,6 +4157,7 @@ var DesignRequest = class {
|
|
|
4154
4157
|
this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
|
|
4155
4158
|
this.state = designRequestProps?.state || states[0];
|
|
4156
4159
|
this.title = designRequestProps?.title || "";
|
|
4160
|
+
this.subtitle = designRequestProps?.subtitle;
|
|
4157
4161
|
this.occasion = designRequestProps?.occasion || occasions[0];
|
|
4158
4162
|
this.style = designRequestProps?.style || parseInt(Object.keys(styles)[0]);
|
|
4159
4163
|
this.bookSize = designRequestProps?.bookSize || bookSizes[0];
|
|
@@ -4166,10 +4170,10 @@ var DesignRequest = class {
|
|
|
4166
4170
|
this.images = new Images(this.client, this.parentId);
|
|
4167
4171
|
}
|
|
4168
4172
|
webSocket;
|
|
4169
|
-
// private events: DesignRequestEvent[]
|
|
4170
4173
|
state;
|
|
4171
4174
|
parentId;
|
|
4172
4175
|
title;
|
|
4176
|
+
subtitle;
|
|
4173
4177
|
occasion;
|
|
4174
4178
|
style;
|
|
4175
4179
|
bookSize;
|
|
@@ -4230,7 +4234,7 @@ var DesignRequest = class {
|
|
|
4230
4234
|
(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps()
|
|
4231
4235
|
);
|
|
4232
4236
|
this.state = "cancelled";
|
|
4233
|
-
await this.eventHandler(
|
|
4237
|
+
await this.eventHandler(cancelledEventDetail);
|
|
4234
4238
|
return this;
|
|
4235
4239
|
}
|
|
4236
4240
|
}
|
|
@@ -4243,7 +4247,6 @@ var DesignRequest = class {
|
|
|
4243
4247
|
}
|
|
4244
4248
|
async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
|
|
4245
4249
|
const customEvent = new CustomEvent(type, { detail });
|
|
4246
|
-
window.dispatchEvent(customEvent);
|
|
4247
4250
|
if (statesToCloseWS.includes(detail.slug)) {
|
|
4248
4251
|
this.webSocket.close();
|
|
4249
4252
|
if (statesToReport.includes(detail.slug)) {
|
|
@@ -4254,20 +4257,21 @@ var DesignRequest = class {
|
|
|
4254
4257
|
}
|
|
4255
4258
|
}
|
|
4256
4259
|
this.state = detail.slug;
|
|
4260
|
+
window.dispatchEvent(customEvent);
|
|
4257
4261
|
}
|
|
4258
4262
|
timeoutHandler() {
|
|
4259
4263
|
return setTimeout(async () => {
|
|
4260
|
-
await this.eventHandler(
|
|
4264
|
+
await this.eventHandler(timeoutEventDetail);
|
|
4261
4265
|
}, designRequestTimeout);
|
|
4262
4266
|
}
|
|
4263
4267
|
async getProgress() {
|
|
4264
4268
|
let timeout;
|
|
4265
|
-
this.webSocket.onmessage = (event) => {
|
|
4269
|
+
this.webSocket.onmessage = async (event) => {
|
|
4266
4270
|
const detail = JSON.parse(event.data);
|
|
4267
4271
|
if (this.state !== detail.slug) {
|
|
4268
4272
|
timeout && clearTimeout(timeout);
|
|
4269
4273
|
timeout = this.timeoutHandler();
|
|
4270
|
-
this.eventHandler(detail);
|
|
4274
|
+
await this.eventHandler(detail);
|
|
4271
4275
|
}
|
|
4272
4276
|
};
|
|
4273
4277
|
this.webSocket.onclose = () => clearTimeout(timeout);
|
|
@@ -4284,6 +4288,7 @@ var DesignRequest = class {
|
|
|
4284
4288
|
id: designRequest.parentId,
|
|
4285
4289
|
guid: designRequest.guid,
|
|
4286
4290
|
title: designRequest.title,
|
|
4291
|
+
subtitle: designRequest.subtitle,
|
|
4287
4292
|
design_request: bookDesignRequest,
|
|
4288
4293
|
state: designRequest.state
|
|
4289
4294
|
});
|
|
@@ -4811,12 +4816,38 @@ export {
|
|
|
4811
4816
|
ImageServer,
|
|
4812
4817
|
Images,
|
|
4813
4818
|
MagicBookClient,
|
|
4819
|
+
assetSchema,
|
|
4820
|
+
bookCreationRequestSchema,
|
|
4821
|
+
bookSizes,
|
|
4822
|
+
cancelledEventDetail,
|
|
4823
|
+
canvasSchema,
|
|
4824
|
+
coverTypes,
|
|
4814
4825
|
designOptionsSchema,
|
|
4815
4826
|
designOptionsServerSchema,
|
|
4827
|
+
embellishmentLevels,
|
|
4828
|
+
imageAssignmentSchema,
|
|
4829
|
+
imageDensities,
|
|
4816
4830
|
imageDensityOptionSchema,
|
|
4817
4831
|
imageDensityOptionServerSchema,
|
|
4818
4832
|
imageDensityOptionsSchema,
|
|
4819
4833
|
imageDensityOptionsServerSchema,
|
|
4820
|
-
|
|
4834
|
+
imageFilteringLevels,
|
|
4835
|
+
imageServerSchema,
|
|
4836
|
+
isDesignRequestSubmitted,
|
|
4837
|
+
magicShopBookSchema,
|
|
4838
|
+
occasions,
|
|
4839
|
+
pageSchema,
|
|
4840
|
+
pageTypes,
|
|
4841
|
+
photoMetadataSchema,
|
|
4842
|
+
photoStripSchema,
|
|
4843
|
+
positionSchema,
|
|
4844
|
+
propertySchema,
|
|
4845
|
+
reportingDataSchema,
|
|
4846
|
+
states,
|
|
4847
|
+
statesToCloseWS,
|
|
4848
|
+
statesToReport,
|
|
4849
|
+
styles,
|
|
4850
|
+
textStickerLevels,
|
|
4851
|
+
timeoutEventDetail
|
|
4821
4852
|
};
|
|
4822
4853
|
//# sourceMappingURL=index.js.map
|