@innovastudio/contentbox 1.5.78 → 1.5.79

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
3
  "type": "module",
4
- "version": "1.5.78",
4
+ "version": "1.5.79",
5
5
  "description": "",
6
6
  "main": "public/contentbox/contentbox.esm.js",
7
7
  "files": [
@@ -51,7 +51,7 @@
51
51
  "ws": "^8.13.0"
52
52
  },
53
53
  "dependencies": {
54
- "@innovastudio/contentbuilder": "^1.4.99",
54
+ "@innovastudio/contentbuilder": "^1.4.100",
55
55
  "js-beautify": "^1.14.0"
56
56
  }
57
57
  }
@@ -97131,31 +97131,56 @@ class ContentBuilder {
97131
97131
  }
97132
97132
  }
97133
97133
  }
97134
+ async upscaleImage(src, callback) {
97135
+ const width = 512;
97136
+ const height = 512;
97137
+ const img = new Image();
97138
+ img.src = src;
97139
+ img.onload = async () => {
97140
+ const canvas = document.createElement('canvas');
97141
+ canvas.width = width;
97142
+ canvas.height = height;
97143
+ const ctx = canvas.getContext('2d');
97144
+ ctx.drawImage(img, 0, 0, width, height);
97145
+ const resizedBase64 = canvas.toDataURL('image/jpeg');
97146
+ let image = resizedBase64;
97147
+ image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
97148
+ const messages = {
97149
+ image: image,
97150
+ folder_path: ''
97151
+ };
97152
+ const response = await fetch(this.upscaleImageUrl, {
97153
+ signal: this.signal,
97154
+ // Abort
97155
+ method: 'POST',
97156
+ headers: {
97157
+ 'Content-Type': 'application/json'
97158
+ },
97159
+ body: JSON.stringify(messages)
97160
+ });
97161
+ const result = await response.json();
97162
+ callback([result.url]);
97163
+ };
97164
+ }
97134
97165
  async generateImage(prompt, callback) {
97135
97166
  this.controller = new AbortController(); // Create a new AbortController
97136
97167
  this.signal = this.controller.signal; // Get a new signal object
97137
97168
 
97138
- let model = 'realistic-vision-v3';
97139
- let negative_prompt = '';
97140
- if (model.includes('realistic-vision')) {
97141
- if (negative_prompt === '') negative_prompt = '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';
97142
- }
97143
- let width = 1024;
97144
- let height = 1024;
97145
- let steps = 25;
97146
- let guidance = 7.5;
97147
- let scheduler = 'dpmsolver++';
97148
- let output_format = 'jpeg';
97169
+ let model = this.imageModel || 'realistic-vision-v3';
97170
+ 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';
97171
+ let steps = this.imageSteps || 25;
97172
+ let guidance = this.imageGuidance || 7.5;
97173
+ let scheduler = this.imageScheduler || 'dpmsolver++';
97149
97174
  const messages = {
97150
- model: 'realistic-vision-v3',
97175
+ model,
97151
97176
  prompt: prompt,
97152
- negative_prompt: negative_prompt,
97153
- width: width,
97154
- height: height,
97155
- steps: steps,
97156
- guidance: guidance,
97157
- scheduler: scheduler,
97158
- output_format: output_format,
97177
+ negative_prompt,
97178
+ width: 512,
97179
+ height: 512,
97180
+ steps,
97181
+ guidance,
97182
+ scheduler,
97183
+ output_format: 'jpeg',
97159
97184
  folder_path: ''
97160
97185
  };
97161
97186
  try {
@@ -97175,7 +97200,9 @@ class ContentBuilder {
97175
97200
  return;
97176
97201
  }
97177
97202
  const imageUrl = result.url;
97178
- callback([imageUrl]);
97203
+
97204
+ //callback([imageUrl]);
97205
+ this.upscaleImage(imageUrl, callback);
97179
97206
  } catch (error) {
97180
97207
  if (error.name === 'AbortError') ; else {
97181
97208
  // CORS or code errors goes here
@@ -111430,6 +111457,12 @@ ${blockContent}
111430
111457
 
111431
111458
  if (tagName === 'img') {
111432
111459
  this.builder.editor.saveForUndo();
111460
+
111461
+ elm.onload = async () => {
111462
+ let divImageResizer = document.querySelector('#divImageResizer');
111463
+ if (divImageResizer) divImageResizer.click();
111464
+ };
111465
+
111433
111466
  elm.setAttribute('src', src); //Trigger Change event
111434
111467
 
111435
111468
  this.builder.onChange();
@@ -117820,8 +117853,15 @@ class ContentBox {
117820
117853
  // renameFileUrl: '',
117821
117854
  // getMmodelsUrl: '',
117822
117855
  // textToImageUrl: '', // To enable AI image generation
117823
- // upscaleImageUrl: '',
117856
+ // upscaleImageUrl: '', // To enable AI image generation
117824
117857
  // controlNetUrl: '',
117858
+ // saveTextUrl: '',
117859
+ // viewImageUrl: '',
117860
+ // imageModel: 'realistic-vision-v3',
117861
+ // imageNegativePrompt: '',
117862
+ // imageSteps: 25,
117863
+ // imageGuidance: 7.5,
117864
+ // imageScheduler: 'dpmsolver++',
117825
117865
  speechTranscribeUrl: '',
117826
117866
  // http://localhost:8081
117827
117867
  autoSendDelay: 4000,
@@ -118386,7 +118426,13 @@ Add an image for each feature.`, 'Revise the headline, paragraph, and all the te
118386
118426
  textToImageUrl: this.settings.textToImageUrl,
118387
118427
  upscaleImageUrl: this.settings.upscaleImageUrl,
118388
118428
  controlNetUrl: this.settings.controlNetUrl,
118389
- imageViewUrl: this.settings.imageViewUrl,
118429
+ saveTextUrl: this.settings.saveTextUrl,
118430
+ viewImageUrl: this.settings.viewImageUrl,
118431
+ imageModel: this.settings.imageModel,
118432
+ imageNegativePrompt: this.settings.imageNegativePrompt,
118433
+ imageSteps: this.settings.imageSteps,
118434
+ imageGuidance: this.settings.imageGuidance,
118435
+ imageScheduler: this.settings.imageScheduler,
118390
118436
  assetPanelReverse: this.settings.assetPanelReverse,
118391
118437
  assetFilesOnly: this.settings.assetFilesOnly,
118392
118438
  assetRefreshButton: this.settings.assetRefreshButton,