Skip to content

Commit

Permalink
bug fixed for exports
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsboost committed Sep 2, 2024
1 parent a0cd3e0 commit ad30a77
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 212 deletions.
346 changes: 173 additions & 173 deletions dist/App.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/App.min.js.map

Large diffs are not rendered by default.

44 changes: 26 additions & 18 deletions src/App-backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7937,23 +7937,32 @@ ${app.summary} ${app.description}
"type": "image/png",
"purpose": "any"
}));
for (const size of sizes) {
const canvas = document.createElement('canvas');
canvas.width = parseInt(size.split('x')[0]);
canvas.height = parseInt(size.split('x')[1]);
const ctx = canvas.getContext('2d');

// Draw logo on canvas at the desired size
const img = new Image();
img.src = base64Logo;
img.onload = function() {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
imageResources.push({ url: canvas.toDataURL('image/png'), fileName: `logo-${size}.png` });
};

// Clean up canvas element
canvas.remove();
}
// Helper function to create resized images
const createResizedImage = (size) => {
return new Promise((resolve, reject) => {
const canvas = document.createElement('canvas');
canvas.width = parseInt(size.split('x')[0]);
canvas.height = parseInt(size.split('x')[1]);
const ctx = canvas.getContext('2d');

const img = new Image();
img.src = base64Logo;
img.onload = function() {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
const base64Image = canvas.toDataURL('image/png').replace(/^data:image\/png;base64,/, '');
zip.folder('imgs').file(`logo-${size}.png`, base64Image, { base64: true });
resolve();
};
img.onerror = reject;

// Clean up canvas element
canvas.remove();
});
};

// Create all resized images
await Promise.all(sizes.map(createResizedImage));

zip.file(`manifest.json`, JSON.stringify({
"theme_color": "#13171f",
Expand Down Expand Up @@ -8028,11 +8037,10 @@ workbox.routing.registerRoute(

// Save image files to ZIP
if (imageResources.length > 0) {
const imgFolder = zip.folder('imgs');
try {
for (const { url, fileName } of imageResources) {
const base64Image = await getBase64Media(url);
imgFolder.file(fileName, base64Image, { base64: true });
zip.folder('imgs').file(fileName, base64Image, { base64: true });
}
} catch (error) {
console.error('Error adding images to ZIP:', error);
Expand Down
44 changes: 26 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7937,23 +7937,32 @@ ${app.summary} ${app.description}
"type": "image/png",
"purpose": "any"
}));
for (const size of sizes) {
const canvas = document.createElement('canvas');
canvas.width = parseInt(size.split('x')[0]);
canvas.height = parseInt(size.split('x')[1]);
const ctx = canvas.getContext('2d');

// Draw logo on canvas at the desired size
const img = new Image();
img.src = base64Logo;
img.onload = function() {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
imageResources.push({ url: canvas.toDataURL('image/png'), fileName: `logo-${size}.png` });
};

// Clean up canvas element
canvas.remove();
}
// Helper function to create resized images
const createResizedImage = (size) => {
return new Promise((resolve, reject) => {
const canvas = document.createElement('canvas');
canvas.width = parseInt(size.split('x')[0]);
canvas.height = parseInt(size.split('x')[1]);
const ctx = canvas.getContext('2d');

const img = new Image();
img.src = base64Logo;
img.onload = function() {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
const base64Image = canvas.toDataURL('image/png').replace(/^data:image\/png;base64,/, '');
zip.folder('imgs').file(`logo-${size}.png`, base64Image, { base64: true });
resolve();
};
img.onerror = reject;

// Clean up canvas element
canvas.remove();
});
};

// Create all resized images
await Promise.all(sizes.map(createResizedImage));

zip.file(`manifest.json`, JSON.stringify({
"theme_color": "#13171f",
Expand Down Expand Up @@ -8028,11 +8037,10 @@ workbox.routing.registerRoute(

// Save image files to ZIP
if (imageResources.length > 0) {
const imgFolder = zip.folder('imgs');
try {
for (const { url, fileName } of imageResources) {
const base64Image = await getBase64Media(url);
imgFolder.file(fileName, base64Image, { base64: true });
zip.folder('imgs').file(fileName, base64Image, { base64: true });
}
} catch (error) {
console.error('Error adding images to ZIP:', error);
Expand Down

0 comments on commit ad30a77

Please sign in to comment.