simple-photo-gallery 2.0.11-rc.4 → 2.0.11-rc.6

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/dist/index.cjs CHANGED
@@ -109,10 +109,10 @@ async function generateBlurHash(imagePath, componentX = 4, componentY = 3) {
109
109
  // src/modules/build/utils/index.ts
110
110
  path7__default.default.dirname(new URL((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname);
111
111
  async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPath, ui) {
112
- ui.start(`Creating social media card image`);
112
+ ui?.start(`Creating social media card image`);
113
113
  const headerBasename = path7__default.default.basename(headerPhotoPath, path7__default.default.extname(headerPhotoPath));
114
114
  if (fs8__default.default.existsSync(ouputPath)) {
115
- ui.success(`Social media card image already exists`);
115
+ ui?.success(`Social media card image already exists`);
116
116
  return headerBasename;
117
117
  }
118
118
  const image = await loadImage(headerPhotoPath);
@@ -131,23 +131,23 @@ async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPa
131
131
  `;
132
132
  const finalImageBuffer = await sharp2__default.default(resizedImageBuffer).composite([{ input: buffer.Buffer.from(svgText), top: 0, left: 0 }]).jpeg({ quality: 90 }).toBuffer();
133
133
  await sharp2__default.default(finalImageBuffer).toFile(outputPath);
134
- ui.success(`Created social media card image successfully`);
134
+ ui?.success(`Created social media card image successfully`);
135
135
  return headerBasename;
136
136
  }
137
137
  async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
138
- ui.start(`Creating optimized header images`);
138
+ ui?.start(`Creating optimized header images`);
139
139
  const image = await loadImage(headerPhotoPath);
140
140
  const headerBasename = path7__default.default.basename(headerPhotoPath, path7__default.default.extname(headerPhotoPath));
141
141
  const generatedFiles = [];
142
- ui.debug("Generating blurhash for header image");
142
+ ui?.debug("Generating blurhash for header image");
143
143
  const blurHash = await generateBlurHash(headerPhotoPath);
144
144
  const landscapeYFactor = 3 / 4;
145
145
  for (const width of HEADER_IMAGE_LANDSCAPE_WIDTHS) {
146
- ui.debug(`Creating landscape header image ${width}`);
146
+ ui?.debug(`Creating landscape header image ${width}`);
147
147
  const avifFilename = `${headerBasename}_landscape_${width}.avif`;
148
148
  const jpgFilename = `${headerBasename}_landscape_${width}.jpg`;
149
149
  if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, avifFilename))) {
150
- ui.debug(`Landscape header image ${width} AVIF already exists`);
150
+ ui?.debug(`Landscape header image ${width} AVIF already exists`);
151
151
  } else {
152
152
  await cropAndResizeImage(
153
153
  image.clone(),
@@ -159,7 +159,7 @@ async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
159
159
  }
160
160
  generatedFiles.push(avifFilename);
161
161
  if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, jpgFilename))) {
162
- ui.debug(`Landscape header image ${width} JPG already exists`);
162
+ ui?.debug(`Landscape header image ${width} JPG already exists`);
163
163
  } else {
164
164
  await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, jpgFilename), width, width * landscapeYFactor, "jpg");
165
165
  }
@@ -167,23 +167,23 @@ async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
167
167
  }
168
168
  const portraitYFactor = 4 / 3;
169
169
  for (const width of HEADER_IMAGE_PORTRAIT_WIDTHS) {
170
- ui.debug(`Creating portrait header image ${width}`);
170
+ ui?.debug(`Creating portrait header image ${width}`);
171
171
  const avifFilename = `${headerBasename}_portrait_${width}.avif`;
172
172
  const jpgFilename = `${headerBasename}_portrait_${width}.jpg`;
173
173
  if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, avifFilename))) {
174
- ui.debug(`Portrait header image ${width} AVIF already exists`);
174
+ ui?.debug(`Portrait header image ${width} AVIF already exists`);
175
175
  } else {
176
176
  await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, avifFilename), width, width * portraitYFactor, "avif");
177
177
  }
178
178
  generatedFiles.push(avifFilename);
179
179
  if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, jpgFilename))) {
180
- ui.debug(`Portrait header image ${width} JPG already exists`);
180
+ ui?.debug(`Portrait header image ${width} JPG already exists`);
181
181
  } else {
182
182
  await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, jpgFilename), width, width * portraitYFactor, "jpg");
183
183
  }
184
184
  generatedFiles.push(jpgFilename);
185
185
  }
186
- ui.success(`Created optimized header image successfully`);
186
+ ui?.success(`Created optimized header image successfully`);
187
187
  return { headerBasename, generatedFiles, blurHash };
188
188
  }
189
189
  function hasOldHeaderImages(outputFolder, currentHeaderBasename) {
@@ -201,9 +201,9 @@ function hasOldHeaderImages(outputFolder, currentHeaderBasename) {
201
201
  return false;
202
202
  }
203
203
  function cleanupOldHeaderImages(outputFolder, currentHeaderBasename, ui) {
204
- ui.start(`Cleaning up old header images`);
204
+ ui?.start(`Cleaning up old header images`);
205
205
  if (!fs8__default.default.existsSync(outputFolder)) {
206
- ui.debug(`Output folder ${outputFolder} does not exist, skipping cleanup`);
206
+ ui?.debug(`Output folder ${outputFolder} does not exist, skipping cleanup`);
207
207
  return;
208
208
  }
209
209
  const files = fs8__default.default.readdirSync(outputFolder);
@@ -213,20 +213,20 @@ function cleanupOldHeaderImages(outputFolder, currentHeaderBasename, ui) {
213
213
  const portraitMatch = file.match(/^(.+)_portrait_\d+\.(avif|jpg)$/);
214
214
  if (landscapeMatch && landscapeMatch[1] !== currentHeaderBasename) {
215
215
  const filePath = path7__default.default.join(outputFolder, file);
216
- ui.debug(`Deleting old landscape header image: ${file}`);
216
+ ui?.debug(`Deleting old landscape header image: ${file}`);
217
217
  fs8__default.default.unlinkSync(filePath);
218
218
  deletedCount++;
219
219
  } else if (portraitMatch && portraitMatch[1] !== currentHeaderBasename) {
220
220
  const filePath = path7__default.default.join(outputFolder, file);
221
- ui.debug(`Deleting old portrait header image: ${file}`);
221
+ ui?.debug(`Deleting old portrait header image: ${file}`);
222
222
  fs8__default.default.unlinkSync(filePath);
223
223
  deletedCount++;
224
224
  }
225
225
  }
226
226
  if (deletedCount > 0) {
227
- ui.success(`Deleted ${deletedCount} old header image(s)`);
227
+ ui?.success(`Deleted ${deletedCount} old header image(s)`);
228
228
  } else {
229
- ui.debug(`No old header images to clean up`);
229
+ ui?.debug(`No old header images to clean up`);
230
230
  }
231
231
  }
232
232
  function findGalleries(basePath, recursive) {
@@ -641,7 +641,7 @@ async function processVideo(videoPath, thumbnailPath, thumbnailPathRetina, thumb
641
641
  lastMediaTimestamp: fileMtime.toISOString()
642
642
  };
643
643
  }
644
- async function processMediaFile(mediaFile, mediaBasePath, galleryDir, thumbnailsPath, thumbnailSize, ui) {
644
+ async function processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbnailSize, ui) {
645
645
  try {
646
646
  const filePath = path7__default.default.resolve(path7__default.default.join(mediaBasePath, mediaFile.filename));
647
647
  const fileName = mediaFile.filename;
@@ -694,14 +694,7 @@ async function processGalleryThumbnails(galleryDir, ui) {
694
694
  let processedCount = 0;
695
695
  for (const section of galleryData.sections) {
696
696
  for (const [index, mediaFile] of section.images.entries()) {
697
- section.images[index] = await processMediaFile(
698
- mediaFile,
699
- mediaBasePath,
700
- galleryDir,
701
- thumbnailsPath,
702
- thumbnailSize,
703
- ui
704
- );
697
+ section.images[index] = await processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbnailSize, ui);
705
698
  }
706
699
  processedCount += section.images.length;
707
700
  }
@@ -896,26 +889,26 @@ async function cleanGallery(galleryDir, ui) {
896
889
  if (fs8__default.default.existsSync(indexHtmlPath)) {
897
890
  try {
898
891
  fs8__default.default.rmSync(indexHtmlPath);
899
- ui.debug(`Removed: ${indexHtmlPath}`);
892
+ ui?.debug(`Removed: ${indexHtmlPath}`);
900
893
  filesRemoved++;
901
894
  } catch (error) {
902
- ui.warn(`Failed to remove index.html: ${error}`);
895
+ ui?.warn(`Failed to remove index.html: ${error}`);
903
896
  }
904
897
  }
905
898
  const galleryPath = path7__default.default.join(galleryDir, "gallery");
906
899
  if (fs8__default.default.existsSync(galleryPath)) {
907
900
  try {
908
901
  fs8__default.default.rmSync(galleryPath, { recursive: true, force: true });
909
- ui.debug(`Removed directory: ${galleryPath}`);
902
+ ui?.debug(`Removed directory: ${galleryPath}`);
910
903
  filesRemoved++;
911
904
  } catch (error) {
912
- ui.warn(`Failed to remove gallery directory: ${error}`);
905
+ ui?.warn(`Failed to remove gallery directory: ${error}`);
913
906
  }
914
907
  }
915
908
  if (filesRemoved > 0) {
916
- ui.success(`Cleaned gallery at: ${galleryDir}`);
909
+ ui?.success(`Cleaned gallery at: ${galleryDir}`);
917
910
  } else {
918
- ui.info(`No gallery files found at: ${galleryDir}`);
911
+ ui?.info(`No gallery files found at: ${galleryDir}`);
919
912
  }
920
913
  return { processedGalleryCount: filesRemoved };
921
914
  }
@@ -1179,7 +1172,7 @@ async function waitForUpdateCheck(checkPromise) {
1179
1172
  // package.json
1180
1173
  var package_default = {
1181
1174
  name: "simple-photo-gallery",
1182
- version: "2.0.11-rc.4"};
1175
+ version: "2.0.11-rc.6"};
1183
1176
 
1184
1177
  // src/index.ts
1185
1178
  var program = new commander.Command();