@innovastudio/contentbox 1.6.130 → 1.6.131

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.d.ts CHANGED
@@ -107,8 +107,6 @@ interface ContentBoxOptions {
107
107
  mediaSelectMaxWidth?: string;
108
108
  otherSelectMaxWidth?: string;
109
109
 
110
- assetPanelFullScreen?: boolean;
111
-
112
110
  codeEditorWidth?: string;
113
111
  codeEditorHeight?: string;
114
112
  codeEditorMaxWidth?: string;
@@ -262,23 +260,6 @@ interface ContentBoxOptions {
262
260
  sendCommandUrl?: string;
263
261
  hideImageGeneration?: boolean;
264
262
 
265
- listFilesUrl?: string;
266
- listFoldersUrl?: string;
267
- deleteFilesUrl?: string;
268
- moveFilesUrl?: string;
269
- createFolderUrl?: string;
270
- uploadFilesUrl?: string;
271
- renameFileUrl?: string;
272
-
273
- getMmodelsUrl?: string;
274
- textToImageUrl?: string;
275
- upscaleImageUrl?: string;
276
- controlNetUrl?: string;
277
- saveTextUrl?: string;
278
- viewUrl?: string;
279
- viewFileUrl?: string;
280
-
281
- imageModel?: string;
282
263
  imageNegativePrompt?: string;
283
264
 
284
265
  imageSteps?: number;
@@ -319,6 +300,24 @@ interface ContentBoxOptions {
319
300
  commandInfoCanvasMode?: any[];
320
301
  onStartRequest?: () => void;
321
302
 
303
+ imageModel?: string;
304
+ defaultImageGenerationProvider?: string;
305
+
306
+ //-- Asset Manager
307
+ listFilesUrl?: string;
308
+ listFoldersUrl?: string;
309
+ deleteFilesUrl?: string;
310
+ moveFilesUrl?: string;
311
+ createFolderUrl?: string;
312
+ uploadFilesUrl?: string;
313
+ renameFileUrl?: string;
314
+ getMmodelsUrl?: string;
315
+ textToImageUrl?: string;
316
+ upscaleImageUrl?: string;
317
+ controlNetUrl?: string;
318
+ saveTextUrl?: string;
319
+ viewUrl?: string;
320
+ viewFileUrl?: string;
322
321
  assetFolderTree?: boolean;
323
322
  assetFilesOnly?: boolean;
324
323
  assetPanelReverse?: boolean;
@@ -328,6 +327,8 @@ interface ContentBoxOptions {
328
327
  assetLocale?: string;
329
328
  assetDateShortOptions?: any[];
330
329
  assetDateLongOptions?: any[];
330
+ assetPanelFullScreen?: boolean;
331
+ //---
331
332
 
332
333
  //-- Form Builder
333
334
  defaultTextGenerationProvider?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
3
  "type": "module",
4
- "version": "1.6.130",
4
+ "version": "1.6.131",
5
5
  "description": "",
6
6
  "main": "public/contentbox/contentbox.esm.js",
7
7
  "types": "index.d.ts",
@@ -59,7 +59,7 @@
59
59
  "ws": "^8.13.0"
60
60
  },
61
61
  "dependencies": {
62
- "@innovastudio/contentbuilder": "^1.5.120",
62
+ "@innovastudio/contentbuilder": "^1.5.124",
63
63
  "js-beautify": "^1.14.0",
64
64
  "sortablejs": "^1.15.2"
65
65
  }
@@ -31731,25 +31731,23 @@ class Util$1 {
31731
31731
  if (item.classList.contains('is-row-tool')) return;
31732
31732
  if (item.classList.contains('is-col-tool')) return;
31733
31733
  if (item.classList.contains('is-rowadd-tool')) return;
31734
+ item.style.width = '';
31735
+ item.style.flex = '';
31736
+ // if(item.getAttribute('data-html')) {
31737
+ // // Don't change width on custom block
31738
+ // if(!item.style.width) { // But if width is not set, add default 50%
31739
+ // item.style.width = '50%';
31740
+ // item.style.flex = '0 0 auto';
31741
+ // }
31742
+ // if(this.getAllColumns(row).length === 1) { // only 1 col in a row
31743
+ // item.style.width = '';
31744
+ // item.style.flex = '';
31745
+ // }
31746
+ // } else {
31747
+ // item.style.width = '';
31748
+ // item.style.flex = '';
31749
+ // }
31734
31750
 
31735
- // item.style.width = '';
31736
- // item.style.flex = '';
31737
- if (item.getAttribute('data-html')) {
31738
- // Don't change width on custom block
31739
- if (!item.style.width) {
31740
- // But if width is not set, add default 50%
31741
- item.style.width = '50%';
31742
- item.style.flex = '0 0 auto';
31743
- }
31744
- if (this.getAllColumns(row).length === 1) {
31745
- // only 1 col in a row
31746
- item.style.width = '';
31747
- item.style.flex = '';
31748
- }
31749
- } else {
31750
- item.style.width = '';
31751
- item.style.flex = '';
31752
- }
31753
31751
  if (item.classList.contains('sm-hidden')) {
31754
31752
  smHidden = true;
31755
31753
  }
@@ -124457,11 +124455,151 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
124457
124455
  }
124458
124456
  return closestRatio;
124459
124457
  }
124458
+ async waitingResultFal(jsonBody, requestId) {
124459
+ jsonBody.request_id = requestId;
124460
+ const getResultEndpoint = (model, requestId) => {
124461
+ let endpoint = `https://queue.fal.run/${model}/requests/${requestId}`;
124462
+ let firstTwoParts = model.split('/').slice(0, 2).join('/');
124463
+ endpoint = endpoint.replace('{MODEL}', firstTwoParts);
124464
+ return endpoint;
124465
+ };
124466
+ const resultEndpoint = getResultEndpoint(jsonBody.model, requestId);
124467
+ jsonBody.endpoint = resultEndpoint;
124468
+ let url = this.getResultUrl_Fal;
124469
+ let headers = {
124470
+ ...this.headers,
124471
+ ...this.defaultHeaders
124472
+ };
124473
+ const response = await fetch(url, {
124474
+ signal: this.signal,
124475
+ method: 'POST',
124476
+ headers,
124477
+ body: JSON.stringify(jsonBody)
124478
+ });
124479
+ // const result = await response.json();
124480
+ let text = await response.text(); // Read response as text first
124481
+ let result;
124482
+ try {
124483
+ result = JSON.parse(text); // Attempt to parse JSON
124484
+ } catch (e) {
124485
+ // console.log(text);
124486
+ return;
124487
+ }
124488
+ if (!result.error) {
124489
+ const data = result.data;
124490
+ let output = [];
124491
+ let output2 = [];
124492
+ data.entries && data.entries.forEach(item => {
124493
+ output.push(item.url);
124494
+ output2.push(item.file_url);
124495
+ });
124496
+ return {
124497
+ mediaGenerated: true,
124498
+ status: 'success',
124499
+ output,
124500
+ output2
124501
+ };
124502
+ } else {
124503
+ return {
124504
+ mediaGenerated: false,
124505
+ status: 'error',
124506
+ message: result.error //this.out('Request failed.')
124507
+ };
124508
+ }
124509
+ }
124510
+
124511
+ async generateImage_Fal(prompt, callback) {
124512
+ this.controller = new AbortController();
124513
+ this.signal = this.controller.signal;
124514
+ let model = this.imageModel || 'flux-schnell';
124515
+ let jsonBody = {};
124516
+ jsonBody.model = model;
124517
+ jsonBody.customData = this.customData;
124518
+ jsonBody.endpoint = `https://queue.fal.run/${model}`;
124519
+ jsonBody.payload = {
124520
+ prompt
124521
+ };
124522
+ let url = this.generateMediaUrl_Fal;
124523
+ let headers = {
124524
+ ...this.headers,
124525
+ ...this.defaultHeaders
124526
+ };
124527
+ const response = await fetch(url, {
124528
+ signal: this.signal,
124529
+ method: 'POST',
124530
+ headers,
124531
+ body: JSON.stringify(jsonBody)
124532
+ });
124533
+ const result = await response.json();
124534
+ if (result.error) {
124535
+ // console.log(result.error);
124536
+ this.dictation.finish();
124537
+ }
124538
+ let requestId = result.request_id;
124539
+ const getStatusEndpoint = (model, requestId) => {
124540
+ let endpoint = `https://queue.fal.run/${model}/requests/${requestId}`;
124541
+ let firstTwoParts = model.split('/').slice(0, 2).join('/');
124542
+ endpoint = endpoint.replace('{MODEL}', firstTwoParts);
124543
+ return endpoint;
124544
+ };
124545
+ const statusEndpoint = getStatusEndpoint(model, requestId);
124546
+ let inputCheckStatus = {
124547
+ model,
124548
+ endpoint: statusEndpoint,
124549
+ request_id: requestId
124550
+ // customData: this.customData
124551
+ };
124552
+
124553
+ let status;
124554
+ do {
124555
+ const response = await fetch(this.checkRequestStatusUrl_Fal, {
124556
+ signal: this.signal,
124557
+ method: 'POST',
124558
+ headers,
124559
+ body: JSON.stringify(inputCheckStatus)
124560
+ });
124561
+ const result = await response.json();
124562
+ if (result.ok && result.status) {
124563
+ // From endpoint that uses SDK
124564
+ status = result.status;
124565
+ } else if (result.data) {
124566
+ // From endpoint that uses API
124567
+ let data = result.data;
124568
+ if (data.image || data.audio || data.audio_file || data.video) {
124569
+ status = 'COMPLETED';
124570
+ } else if (data.detail && typeof data.detail === 'string' && data.detail.startsWith('Request is still in progress')) {
124571
+ //Request is still in progress
124572
+ status = 'IN_PROGRESS';
124573
+ } else if (data.status && !data.error) {
124574
+ status = data.status;
124575
+ }
124576
+ }
124577
+ if (!status) {
124578
+ // const message = result.error || (result.data && JSON.stringify(result.data)) || this.out('Request failed.');
124579
+ // console.log(message);
124580
+ return;
124581
+ }
124582
+ if (status !== 'COMPLETED') {
124583
+ await new Promise(resolve => setTimeout(resolve, 5000)); // Wait before retrying
124584
+ }
124585
+ } while (status !== 'COMPLETED');
124586
+ if (status === 'COMPLETED') {
124587
+ const mediaResult = await this.waitingResultFal(jsonBody, requestId);
124588
+ if (mediaResult.output && mediaResult.output.length === 1) {
124589
+ let imageUrl = mediaResult.output[0];
124590
+ callback(imageUrl);
124591
+ }
124592
+ }
124593
+ }
124460
124594
  async generateImage(prompt, callback) {
124595
+ if (this.defaultImageGenerationProvider === 'fal') {
124596
+ this.generateImage_Fal(prompt, callback);
124597
+ return;
124598
+ }
124461
124599
  this.controller = new AbortController(); // Create a new AbortController
124462
124600
  this.signal = this.controller.signal; // Get a new signal object
124463
124601
 
124464
- let model = this.imageModel || 'realistic-vision-v3';
124602
+ let model = this.imageModel || 'flux-schnell'; //realistic-vision-v3
124465
124603
  let negative_prompt = this.imageNegativePrompt || 'duplicate, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, bad_prompt_version2, bad-hands-5, badhandv4, bad anatomy, deformed, mutated, amputated, missing finger, extra finger, fused fingers, missing leg, extra leg, fused legs, missing digit, extra digit, fused digits, missing hand, extra hand, fused hands, missing arm, extra arm, fused arms, missing limb, extra limb, fused limbs, fused bodies, merged bodies, extra bodies, dual bodies, extra navel, elongated body, missing joint, extra joint, fused joints, deformed hip, twisted limbs, twisted legs, twisted arms, missing head, extra head, double head, twins, missing ear, extra ear, deformed ear, black and white, monochrome, multiple views, blurry, text, signature, head out of frame, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, grayscale, glans, bad hands, error, extra digit, fewer digits, cropped, jpeg artifacts, watermark, username, bad feet, poorly drawn hands, poorly drawn face, mutation, too many fingers, long neck, long body, long arms, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross proportions, cropped head , bad eyes, extra breast, missing breast, fused breasts, unnatural proportions, necklace';
124466
124604
  let steps = this.imageSteps || 25;
124467
124605
  let guidance = this.imageGuidance || 7.5;
@@ -160564,6 +160702,10 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
160564
160702
  imageGuidance: this.settings.imageGuidance,
160565
160703
  imageScheduler: this.settings.imageScheduler,
160566
160704
  imageAutoUpscale: this.settings.imageAutoUpscale,
160705
+ defaultImageGenerationProvider: this.settings.defaultImageGenerationProvider,
160706
+ generateMediaUrl_Fal: this.settings.generateMediaUrl_Fal,
160707
+ checkRequestStatusUrl_Fal: this.settings.checkRequestStatusUrl_Fal,
160708
+ getResultUrl_Fal: this.settings.getResultUrl_Fal,
160567
160709
  assetPanelReverse: this.settings.assetPanelReverse,
160568
160710
  assetFilesOnly: this.settings.assetFilesOnly,
160569
160711
  assetRefreshButton: this.settings.assetRefreshButton,