@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 CHANGED
@@ -25,13 +25,39 @@ __export(src_exports, {
25
25
  ImageServer: () => ImageServer,
26
26
  Images: () => Images,
27
27
  MagicBookClient: () => MagicBookClient,
28
+ assetSchema: () => assetSchema,
29
+ bookCreationRequestSchema: () => bookCreationRequestSchema,
30
+ bookSizes: () => bookSizes,
31
+ cancelledEventDetail: () => cancelledEventDetail,
32
+ canvasSchema: () => canvasSchema,
33
+ coverTypes: () => coverTypes,
28
34
  designOptionsSchema: () => designOptionsSchema,
29
35
  designOptionsServerSchema: () => designOptionsServerSchema,
36
+ embellishmentLevels: () => embellishmentLevels,
37
+ imageAssignmentSchema: () => imageAssignmentSchema,
38
+ imageDensities: () => imageDensities,
30
39
  imageDensityOptionSchema: () => imageDensityOptionSchema,
31
40
  imageDensityOptionServerSchema: () => imageDensityOptionServerSchema,
32
41
  imageDensityOptionsSchema: () => imageDensityOptionsSchema,
33
42
  imageDensityOptionsServerSchema: () => imageDensityOptionsServerSchema,
34
- imageServerSchema: () => imageServerSchema
43
+ imageFilteringLevels: () => imageFilteringLevels,
44
+ imageServerSchema: () => imageServerSchema,
45
+ isDesignRequestSubmitted: () => isDesignRequestSubmitted,
46
+ magicShopBookSchema: () => magicShopBookSchema,
47
+ occasions: () => occasions,
48
+ pageSchema: () => pageSchema,
49
+ pageTypes: () => pageTypes,
50
+ photoMetadataSchema: () => photoMetadataSchema,
51
+ photoStripSchema: () => photoStripSchema,
52
+ positionSchema: () => positionSchema,
53
+ propertySchema: () => propertySchema,
54
+ reportingDataSchema: () => reportingDataSchema,
55
+ states: () => states,
56
+ statesToCloseWS: () => statesToCloseWS,
57
+ statesToReport: () => statesToReport,
58
+ styles: () => styles,
59
+ textStickerLevels: () => textStickerLevels,
60
+ timeoutEventDetail: () => timeoutEventDetail
35
61
  });
36
62
  module.exports = __toCommonJS(src_exports);
37
63
 
@@ -246,13 +272,13 @@ var imageDensities = ["low", "medium", "high"];
246
272
  var imageFilteringLevels = ["best", "most", "all"];
247
273
  var embellishmentLevels = ["none", "few", "lots"];
248
274
  var textStickerLevels = ["none", "few", "lots"];
249
- var timeoutMessage = {
275
+ var timeoutEventDetail = {
250
276
  state: "timeout",
251
277
  slug: "timeout",
252
278
  progress: 100,
253
279
  message: "Design timed out"
254
280
  };
255
- var cancelledMessage = {
281
+ var cancelledEventDetail = {
256
282
  state: "cancelled",
257
283
  slug: "cancelled",
258
284
  progress: 100,
@@ -4050,6 +4076,7 @@ var bookDesignRequestSchema = z.object({
4050
4076
  var BookPropsSchema = z.object({
4051
4077
  id: z.string().optional(),
4052
4078
  title: z.string(),
4079
+ subtitle: z.string().optional(),
4053
4080
  design_request: bookDesignRequestSchema,
4054
4081
  state: z.enum(states).optional(),
4055
4082
  guid: z.string().optional(),
@@ -4058,6 +4085,7 @@ var BookPropsSchema = z.object({
4058
4085
  var Book = class {
4059
4086
  id;
4060
4087
  title;
4088
+ subtitle;
4061
4089
  design_request;
4062
4090
  state;
4063
4091
  guid;
@@ -4065,6 +4093,7 @@ var Book = class {
4065
4093
  constructor(props) {
4066
4094
  this.id = props.id || "";
4067
4095
  this.title = props.title;
4096
+ this.subtitle = props.subtitle;
4068
4097
  this.design_request = new BookDesignRequest(props.design_request);
4069
4098
  this.state = props.state;
4070
4099
  this.guid = props.guid;
@@ -4167,9 +4196,9 @@ var designOptionsServerSchema = z.object({
4167
4196
  });
4168
4197
 
4169
4198
  // ../../core/config.ts
4170
- var defaultApiHost = "https://api.sfly-sls.magicbook.io";
4171
- var defaultWebSocketHost = "wss://socket.sfly-sls.magicbook.io";
4172
- var designRequestTimeout = parseInt("30000"?.toString() || "3000");
4199
+ var defaultApiHost = "http://localhost:2812";
4200
+ var defaultWebSocketHost = "wss://localhost:2812";
4201
+ var designRequestTimeout = parseInt(""?.toString() || "3000");
4173
4202
 
4174
4203
  // ../../core/models/design-request/index.ts
4175
4204
  var DesignRequestOptions = {
@@ -4191,6 +4220,7 @@ var DesignRequest = class {
4191
4220
  this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
4192
4221
  this.state = designRequestProps?.state || states[0];
4193
4222
  this.title = designRequestProps?.title || "";
4223
+ this.subtitle = designRequestProps?.subtitle;
4194
4224
  this.occasion = designRequestProps?.occasion || occasions[0];
4195
4225
  this.style = designRequestProps?.style || parseInt(Object.keys(styles)[0]);
4196
4226
  this.bookSize = designRequestProps?.bookSize || bookSizes[0];
@@ -4203,10 +4233,10 @@ var DesignRequest = class {
4203
4233
  this.images = new Images(this.client, this.parentId);
4204
4234
  }
4205
4235
  webSocket;
4206
- // private events: DesignRequestEvent[]
4207
4236
  state;
4208
4237
  parentId;
4209
4238
  title;
4239
+ subtitle;
4210
4240
  occasion;
4211
4241
  style;
4212
4242
  bookSize;
@@ -4267,7 +4297,7 @@ var DesignRequest = class {
4267
4297
  (await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps()
4268
4298
  );
4269
4299
  this.state = "cancelled";
4270
- await this.eventHandler(cancelledMessage);
4300
+ await this.eventHandler(cancelledEventDetail);
4271
4301
  return this;
4272
4302
  }
4273
4303
  }
@@ -4280,7 +4310,6 @@ var DesignRequest = class {
4280
4310
  }
4281
4311
  async eventHandler(detail, type = "MagicBook.designRequestUpdated") {
4282
4312
  const customEvent = new CustomEvent(type, { detail });
4283
- window.dispatchEvent(customEvent);
4284
4313
  if (statesToCloseWS.includes(detail.slug)) {
4285
4314
  this.webSocket.close();
4286
4315
  if (statesToReport.includes(detail.slug)) {
@@ -4291,20 +4320,21 @@ var DesignRequest = class {
4291
4320
  }
4292
4321
  }
4293
4322
  this.state = detail.slug;
4323
+ window.dispatchEvent(customEvent);
4294
4324
  }
4295
4325
  timeoutHandler() {
4296
4326
  return setTimeout(async () => {
4297
- await this.eventHandler(timeoutMessage);
4327
+ await this.eventHandler(timeoutEventDetail);
4298
4328
  }, designRequestTimeout);
4299
4329
  }
4300
4330
  async getProgress() {
4301
4331
  let timeout;
4302
- this.webSocket.onmessage = (event) => {
4332
+ this.webSocket.onmessage = async (event) => {
4303
4333
  const detail = JSON.parse(event.data);
4304
4334
  if (this.state !== detail.slug) {
4305
4335
  timeout && clearTimeout(timeout);
4306
4336
  timeout = this.timeoutHandler();
4307
- this.eventHandler(detail);
4337
+ await this.eventHandler(detail);
4308
4338
  }
4309
4339
  };
4310
4340
  this.webSocket.onclose = () => clearTimeout(timeout);
@@ -4321,6 +4351,7 @@ var DesignRequest = class {
4321
4351
  id: designRequest.parentId,
4322
4352
  guid: designRequest.guid,
4323
4353
  title: designRequest.title,
4354
+ subtitle: designRequest.subtitle,
4324
4355
  design_request: bookDesignRequest,
4325
4356
  state: designRequest.state
4326
4357
  });
@@ -4849,12 +4880,38 @@ var MagicBookClient = class {
4849
4880
  ImageServer,
4850
4881
  Images,
4851
4882
  MagicBookClient,
4883
+ assetSchema,
4884
+ bookCreationRequestSchema,
4885
+ bookSizes,
4886
+ cancelledEventDetail,
4887
+ canvasSchema,
4888
+ coverTypes,
4852
4889
  designOptionsSchema,
4853
4890
  designOptionsServerSchema,
4891
+ embellishmentLevels,
4892
+ imageAssignmentSchema,
4893
+ imageDensities,
4854
4894
  imageDensityOptionSchema,
4855
4895
  imageDensityOptionServerSchema,
4856
4896
  imageDensityOptionsSchema,
4857
4897
  imageDensityOptionsServerSchema,
4858
- imageServerSchema
4898
+ imageFilteringLevels,
4899
+ imageServerSchema,
4900
+ isDesignRequestSubmitted,
4901
+ magicShopBookSchema,
4902
+ occasions,
4903
+ pageSchema,
4904
+ pageTypes,
4905
+ photoMetadataSchema,
4906
+ photoStripSchema,
4907
+ positionSchema,
4908
+ propertySchema,
4909
+ reportingDataSchema,
4910
+ states,
4911
+ statesToCloseWS,
4912
+ statesToReport,
4913
+ styles,
4914
+ textStickerLevels,
4915
+ timeoutEventDetail
4859
4916
  });
4860
4917
  //# sourceMappingURL=index.cjs.map