@magiclabs.ai/magicbook-client 0.7.4-canary → 0.7.4
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 +6 -7
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
bookDesignRequestSchema: () => bookDesignRequestSchema,
|
|
33
33
|
bookPropsSchema: () => bookPropsSchema,
|
|
34
34
|
bookSizes: () => bookSizes,
|
|
35
|
-
|
|
35
|
+
canSubmitDesignRequest: () => canSubmitDesignRequest,
|
|
36
36
|
cancelledEventDetail: () => cancelledEventDetail,
|
|
37
37
|
canvasSchema: () => canvasSchema,
|
|
38
38
|
coverTypes: () => coverTypes,
|
|
@@ -86,7 +86,7 @@ var states = [
|
|
|
86
86
|
var statesToCloseWS = ["error", "timeout", "ready", "cancelled"];
|
|
87
87
|
var statesToReport = ["error", "timeout"];
|
|
88
88
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
89
|
-
var
|
|
89
|
+
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
90
90
|
var occasions = [
|
|
91
91
|
"baby",
|
|
92
92
|
"birthday",
|
|
@@ -4148,7 +4148,7 @@ var Images = class {
|
|
|
4148
4148
|
length;
|
|
4149
4149
|
designRequestState;
|
|
4150
4150
|
async add(image) {
|
|
4151
|
-
if (!
|
|
4151
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4152
4152
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4153
4153
|
} else {
|
|
4154
4154
|
this.images.push(image);
|
|
@@ -4292,7 +4292,7 @@ var DesignRequest = class {
|
|
|
4292
4292
|
return options;
|
|
4293
4293
|
}
|
|
4294
4294
|
async submit(submitDesignRequestProps) {
|
|
4295
|
-
if (!
|
|
4295
|
+
if (!canSubmitDesignRequest(this.state)) {
|
|
4296
4296
|
throw new Error("You need to wait for the current design request to be ready before submitting a new one");
|
|
4297
4297
|
} else {
|
|
4298
4298
|
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
@@ -4302,7 +4302,6 @@ var DesignRequest = class {
|
|
|
4302
4302
|
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4303
4303
|
);
|
|
4304
4304
|
this.getProgress();
|
|
4305
|
-
this.updateDesignRequest({ state: states[1] });
|
|
4306
4305
|
return this;
|
|
4307
4306
|
}
|
|
4308
4307
|
}
|
|
@@ -4371,7 +4370,7 @@ var DesignRequest = class {
|
|
|
4371
4370
|
let timeout;
|
|
4372
4371
|
this.webSocket.onmessage = async (event) => {
|
|
4373
4372
|
const detail = JSON.parse(event.data);
|
|
4374
|
-
if (this.state !== detail.slug) {
|
|
4373
|
+
if (this.state !== detail.slug || detail.slug === "submitted") {
|
|
4375
4374
|
timeout && clearTimeout(timeout);
|
|
4376
4375
|
timeout = this.timeoutHandler();
|
|
4377
4376
|
await this.eventHandler(detail);
|
|
@@ -4984,7 +4983,7 @@ var MagicBookClient = class {
|
|
|
4984
4983
|
bookDesignRequestSchema,
|
|
4985
4984
|
bookPropsSchema,
|
|
4986
4985
|
bookSizes,
|
|
4987
|
-
|
|
4986
|
+
canSubmitDesignRequest,
|
|
4988
4987
|
cancelledEventDetail,
|
|
4989
4988
|
canvasSchema,
|
|
4990
4989
|
coverTypes,
|