simple-photo-gallery 2.0.14-rc.1 → 2.0.15-rc.18

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
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var process4 = require('process');
4
+ var process3 = require('process');
5
5
  var commander = require('commander');
6
6
  var consola = require('consola');
7
7
  var child_process = require('child_process');
8
8
  var fs8 = require('fs');
9
- var path = require('path');
9
+ var path7 = require('path');
10
10
  var buffer = require('buffer');
11
- var url = require('url');
12
11
  var sharp2 = require('sharp');
13
12
  var blurhash = require('blurhash');
14
13
  var common = require('@simple-photo-gallery/common');
@@ -19,12 +18,11 @@ var Conf = require('conf');
19
18
  var axios = require('axios');
20
19
  var semverParser = require('semver-parser');
21
20
 
22
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
23
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
22
 
25
- var process4__default = /*#__PURE__*/_interopDefault(process4);
23
+ var process3__default = /*#__PURE__*/_interopDefault(process3);
26
24
  var fs8__default = /*#__PURE__*/_interopDefault(fs8);
27
- var path__default = /*#__PURE__*/_interopDefault(path);
25
+ var path7__default = /*#__PURE__*/_interopDefault(path7);
28
26
  var sharp2__default = /*#__PURE__*/_interopDefault(sharp2);
29
27
  var ExifReader__default = /*#__PURE__*/_interopDefault(ExifReader);
30
28
  var ffprobe__default = /*#__PURE__*/_interopDefault(ffprobe);
@@ -92,44 +90,9 @@ async function generateBlurHash(imagePath, componentX = 4, componentY = 3) {
92
90
  }
93
91
 
94
92
  // src/modules/build/utils/index.ts
95
- var __dirname$1 = path__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
96
- var SOCIAL_CARD_FONT_RELATIVE_PATH = path__default.default.join("assets", "fonts", "dejavu", "DejaVuSans-Bold.ttf");
97
- var socialCardFontBase64;
98
- function resolveFromCurrentDir(...segments) {
99
- return path__default.default.resolve(__dirname$1, ...segments);
100
- }
101
- function findSocialCardFontPath() {
102
- const fontCandidates = [
103
- resolveFromCurrentDir("../../../../", SOCIAL_CARD_FONT_RELATIVE_PATH),
104
- path__default.default.resolve(__dirname$1, "../", SOCIAL_CARD_FONT_RELATIVE_PATH),
105
- path__default.default.resolve(__dirname$1, "../../", SOCIAL_CARD_FONT_RELATIVE_PATH),
106
- path__default.default.resolve(process4__default.default.cwd(), SOCIAL_CARD_FONT_RELATIVE_PATH),
107
- path__default.default.resolve(process4__default.default.cwd(), "../", SOCIAL_CARD_FONT_RELATIVE_PATH),
108
- path__default.default.resolve(process4__default.default.cwd(), "../simple-photo-gallery/", SOCIAL_CARD_FONT_RELATIVE_PATH)
109
- ];
110
- for (const candidate of fontCandidates) {
111
- if (fs8__default.default.existsSync(candidate)) {
112
- return candidate;
113
- }
114
- }
115
- return null;
116
- }
117
- function getSocialCardFontBase64() {
118
- if (socialCardFontBase64 !== void 0) {
119
- return socialCardFontBase64;
120
- }
121
- const fontPath = findSocialCardFontPath();
122
- console.log("DBG:", { fontPath, dirname: __dirname$1, cwd: process4__default.default.cwd() });
123
- if (!fontPath) {
124
- socialCardFontBase64 = null;
125
- return null;
126
- }
127
- socialCardFontBase64 = fs8__default.default.readFileSync(fontPath).toString("base64");
128
- return socialCardFontBase64;
129
- }
130
93
  async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPath, ui) {
131
94
  ui?.start(`Creating social media card image`);
132
- const headerBasename = path__default.default.basename(headerPhotoPath, path__default.default.extname(headerPhotoPath));
95
+ const headerBasename = path7__default.default.basename(headerPhotoPath, path7__default.default.extname(headerPhotoPath));
133
96
  if (fs8__default.default.existsSync(ouputPath)) {
134
97
  ui?.success(`Social media card image already exists`);
135
98
  return headerBasename;
@@ -138,21 +101,11 @@ async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPa
138
101
  const resizedImageBuffer = await image.resize(1200, 631, { fit: "cover" }).jpeg({ quality: 90 }).toBuffer();
139
102
  const outputPath = ouputPath;
140
103
  await sharp2__default.default(resizedImageBuffer).toFile(outputPath);
141
- const fontBase64 = getSocialCardFontBase64();
142
- const fontFace = fontBase64 ? `
143
- @font-face {
144
- font-family: 'DejaVu Sans';
145
- src: url('data:font/ttf;base64,${fontBase64}') format('truetype');
146
- font-weight: 700;
147
- font-style: normal;
148
- }` : "";
149
- const fontFamily = fontBase64 ? "'DejaVu Sans', Arial, sans-serif" : "Arial, sans-serif";
150
104
  const svgText = `
151
105
  <svg width="1200" height="631" xmlns="http://www.w3.org/2000/svg">
152
106
  <defs>
153
107
  <style>
154
- ${fontFace}
155
- .title { font-family: ${fontFamily}; font-size: 96px; font-weight: bold; fill: white; stroke: black; stroke-width: 5; paint-order: stroke; text-anchor: middle; }
108
+ .title { font-family: 'Arial, sans-serif'; font-size: 96px; font-weight: bold; fill: white; stroke: black; stroke-width: 5; paint-order: stroke; text-anchor: middle; }
156
109
  </style>
157
110
  </defs>
158
111
  <text x="600" y="250" class="title">${title}</text>
@@ -166,7 +119,7 @@ async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPa
166
119
  async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
167
120
  ui?.start(`Creating optimized header images`);
168
121
  const image = await loadImage(headerPhotoPath);
169
- const headerBasename = path__default.default.basename(headerPhotoPath, path__default.default.extname(headerPhotoPath));
122
+ const headerBasename = path7__default.default.basename(headerPhotoPath, path7__default.default.extname(headerPhotoPath));
170
123
  const generatedFiles = [];
171
124
  ui?.debug("Generating blurhash for header image");
172
125
  const blurHash = await generateBlurHash(headerPhotoPath);
@@ -175,22 +128,22 @@ async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
175
128
  ui?.debug(`Creating landscape header image ${width}`);
176
129
  const avifFilename = `${headerBasename}_landscape_${width}.avif`;
177
130
  const jpgFilename = `${headerBasename}_landscape_${width}.jpg`;
178
- if (fs8__default.default.existsSync(path__default.default.join(outputFolder, avifFilename))) {
131
+ if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, avifFilename))) {
179
132
  ui?.debug(`Landscape header image ${width} AVIF already exists`);
180
133
  } else {
181
134
  await cropAndResizeImage(
182
135
  image.clone(),
183
- path__default.default.join(outputFolder, avifFilename),
136
+ path7__default.default.join(outputFolder, avifFilename),
184
137
  width,
185
138
  width * landscapeYFactor,
186
139
  "avif"
187
140
  );
188
141
  }
189
142
  generatedFiles.push(avifFilename);
190
- if (fs8__default.default.existsSync(path__default.default.join(outputFolder, jpgFilename))) {
143
+ if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, jpgFilename))) {
191
144
  ui?.debug(`Landscape header image ${width} JPG already exists`);
192
145
  } else {
193
- await cropAndResizeImage(image.clone(), path__default.default.join(outputFolder, jpgFilename), width, width * landscapeYFactor, "jpg");
146
+ await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, jpgFilename), width, width * landscapeYFactor, "jpg");
194
147
  }
195
148
  generatedFiles.push(jpgFilename);
196
149
  }
@@ -199,16 +152,16 @@ async function createOptimizedHeaderImage(headerPhotoPath, outputFolder, ui) {
199
152
  ui?.debug(`Creating portrait header image ${width}`);
200
153
  const avifFilename = `${headerBasename}_portrait_${width}.avif`;
201
154
  const jpgFilename = `${headerBasename}_portrait_${width}.jpg`;
202
- if (fs8__default.default.existsSync(path__default.default.join(outputFolder, avifFilename))) {
155
+ if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, avifFilename))) {
203
156
  ui?.debug(`Portrait header image ${width} AVIF already exists`);
204
157
  } else {
205
- await cropAndResizeImage(image.clone(), path__default.default.join(outputFolder, avifFilename), width, width * portraitYFactor, "avif");
158
+ await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, avifFilename), width, width * portraitYFactor, "avif");
206
159
  }
207
160
  generatedFiles.push(avifFilename);
208
- if (fs8__default.default.existsSync(path__default.default.join(outputFolder, jpgFilename))) {
161
+ if (fs8__default.default.existsSync(path7__default.default.join(outputFolder, jpgFilename))) {
209
162
  ui?.debug(`Portrait header image ${width} JPG already exists`);
210
163
  } else {
211
- await cropAndResizeImage(image.clone(), path__default.default.join(outputFolder, jpgFilename), width, width * portraitYFactor, "jpg");
164
+ await cropAndResizeImage(image.clone(), path7__default.default.join(outputFolder, jpgFilename), width, width * portraitYFactor, "jpg");
212
165
  }
213
166
  generatedFiles.push(jpgFilename);
214
167
  }
@@ -241,12 +194,12 @@ function cleanupOldHeaderImages(outputFolder, currentHeaderBasename, ui) {
241
194
  const landscapeMatch = file.match(/^(.+)_landscape_\d+\.(avif|jpg)$/);
242
195
  const portraitMatch = file.match(/^(.+)_portrait_\d+\.(avif|jpg)$/);
243
196
  if (landscapeMatch && landscapeMatch[1] !== currentHeaderBasename) {
244
- const filePath = path__default.default.join(outputFolder, file);
197
+ const filePath = path7__default.default.join(outputFolder, file);
245
198
  ui?.debug(`Deleting old landscape header image: ${file}`);
246
199
  fs8__default.default.unlinkSync(filePath);
247
200
  deletedCount++;
248
201
  } else if (portraitMatch && portraitMatch[1] !== currentHeaderBasename) {
249
- const filePath = path__default.default.join(outputFolder, file);
202
+ const filePath = path7__default.default.join(outputFolder, file);
250
203
  ui?.debug(`Deleting old portrait header image: ${file}`);
251
204
  fs8__default.default.unlinkSync(filePath);
252
205
  deletedCount++;
@@ -260,7 +213,7 @@ function cleanupOldHeaderImages(outputFolder, currentHeaderBasename, ui) {
260
213
  }
261
214
  function findGalleries(basePath, recursive) {
262
215
  const galleryDirs = [];
263
- const galleryJsonPath = path__default.default.join(basePath, "gallery", "gallery.json");
216
+ const galleryJsonPath = path7__default.default.join(basePath, "gallery", "gallery.json");
264
217
  if (fs8__default.default.existsSync(galleryJsonPath)) {
265
218
  galleryDirs.push(basePath);
266
219
  }
@@ -269,7 +222,7 @@ function findGalleries(basePath, recursive) {
269
222
  const entries = fs8__default.default.readdirSync(basePath, { withFileTypes: true });
270
223
  for (const entry of entries) {
271
224
  if (entry.isDirectory() && entry.name !== "gallery") {
272
- const subPath = path__default.default.join(basePath, entry.name);
225
+ const subPath = path7__default.default.join(basePath, entry.name);
273
226
  const subResults = findGalleries(subPath, recursive);
274
227
  galleryDirs.push(...subResults);
275
228
  }
@@ -328,20 +281,20 @@ function migrateGalleryJson(deprecatedGalleryData, galleryJsonPath, ui) {
328
281
  ui.start("Old gallery.json format detected. Migrating gallery.json to the new data format.");
329
282
  let mediaBasePath;
330
283
  const imagePath = deprecatedGalleryData.sections[0].images[0].path;
331
- if (imagePath && imagePath !== path__default.default.join("..", path__default.default.basename(imagePath))) {
332
- mediaBasePath = path__default.default.resolve(path__default.default.join(path__default.default.dirname(galleryJsonPath)), path__default.default.dirname(imagePath));
284
+ if (imagePath && imagePath !== path7__default.default.join("..", path7__default.default.basename(imagePath))) {
285
+ mediaBasePath = path7__default.default.resolve(path7__default.default.join(path7__default.default.dirname(galleryJsonPath)), path7__default.default.dirname(imagePath));
333
286
  }
334
287
  const sections = deprecatedGalleryData.sections.map((section) => ({
335
288
  ...section,
336
289
  images: section.images.map((image) => ({
337
290
  ...image,
338
291
  path: void 0,
339
- filename: path__default.default.basename(image.path)
292
+ filename: path7__default.default.basename(image.path)
340
293
  }))
341
294
  }));
342
295
  const galleryData = {
343
296
  ...deprecatedGalleryData,
344
- headerImage: path__default.default.basename(deprecatedGalleryData.headerImage),
297
+ headerImage: path7__default.default.basename(deprecatedGalleryData.headerImage),
345
298
  sections,
346
299
  mediaBasePath
347
300
  };
@@ -353,7 +306,7 @@ function migrateGalleryJson(deprecatedGalleryData, galleryJsonPath, ui) {
353
306
  return galleryData;
354
307
  }
355
308
  function getMediaFileType(fileName) {
356
- const ext = path__default.default.extname(fileName).toLowerCase();
309
+ const ext = path7__default.default.extname(fileName).toLowerCase();
357
310
  if (IMAGE_EXTENSIONS.has(ext)) return "image";
358
311
  if (VIDEO_EXTENSIONS.has(ext)) return "video";
359
312
  return null;
@@ -381,7 +334,7 @@ async function scanDirectory(dirPath, ui) {
381
334
  mediaFiles.push(mediaFile);
382
335
  }
383
336
  } else if (entry.isDirectory() && entry.name !== "gallery") {
384
- subGalleryDirectories.push(path__default.default.join(dirPath, entry.name));
337
+ subGalleryDirectories.push(path7__default.default.join(dirPath, entry.name));
385
338
  }
386
339
  }
387
340
  } catch (error) {
@@ -417,12 +370,12 @@ async function getGallerySettingsFromUser(galleryName, defaultImage, ui) {
417
370
  return { title, description, url, headerImage };
418
371
  }
419
372
  async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalleries = [], useDefaultSettings, ctaBanner, ui) {
420
- const galleryDir = path__default.default.dirname(galleryJsonPath);
421
- const isSameLocation = path__default.default.relative(scanPath, path__default.default.join(galleryDir, "..")) === "";
373
+ const galleryDir = path7__default.default.dirname(galleryJsonPath);
374
+ const isSameLocation = path7__default.default.relative(scanPath, path7__default.default.join(galleryDir, "..")) === "";
422
375
  const mediaBasePath = isSameLocation ? void 0 : scanPath;
423
376
  const relativeSubGalleries = subGalleries.map((subGallery) => ({
424
377
  ...subGallery,
425
- headerImage: subGallery.headerImage ? path__default.default.relative(galleryDir, subGallery.headerImage) : ""
378
+ headerImage: subGallery.headerImage ? path7__default.default.relative(galleryDir, subGallery.headerImage) : ""
426
379
  }));
427
380
  let galleryData = {
428
381
  title: "My Gallery",
@@ -445,8 +398,8 @@ async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalle
445
398
  galleryData = {
446
399
  ...galleryData,
447
400
  ...await getGallerySettingsFromUser(
448
- path__default.default.basename(path__default.default.join(galleryDir, "..")),
449
- path__default.default.basename(mediaFiles[0]?.filename || ""),
401
+ path7__default.default.basename(path7__default.default.join(galleryDir, "..")),
402
+ path7__default.default.basename(mediaFiles[0]?.filename || ""),
450
403
  ui
451
404
  )
452
405
  };
@@ -454,8 +407,8 @@ async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalle
454
407
  await fs8.promises.writeFile(galleryJsonPath, JSON.stringify(galleryData, null, 2));
455
408
  }
456
409
  async function galleryExists(outputPath) {
457
- const galleryPath = path__default.default.join(outputPath, "gallery");
458
- const galleryJsonPath = path__default.default.join(galleryPath, "gallery.json");
410
+ const galleryPath = path7__default.default.join(outputPath, "gallery");
411
+ const galleryJsonPath = path7__default.default.join(galleryPath, "gallery.json");
459
412
  try {
460
413
  await fs8.promises.access(galleryJsonPath);
461
414
  return true;
@@ -474,7 +427,7 @@ async function processDirectory(scanPath, outputPath, recursive, useDefaultSetti
474
427
  for (const subGalleryDir of subGalleryDirectories) {
475
428
  const result2 = await processDirectory(
476
429
  subGalleryDir,
477
- path__default.default.join(outputPath, path__default.default.basename(subGalleryDir)),
430
+ path7__default.default.join(outputPath, path7__default.default.basename(subGalleryDir)),
478
431
  recursive,
479
432
  useDefaultSettings,
480
433
  force,
@@ -489,8 +442,8 @@ async function processDirectory(scanPath, outputPath, recursive, useDefaultSetti
489
442
  }
490
443
  }
491
444
  if (mediaFiles.length > 0 || subGalleries.length > 0) {
492
- const galleryPath = path__default.default.join(outputPath, "gallery");
493
- const galleryJsonPath = path__default.default.join(galleryPath, "gallery.json");
445
+ const galleryPath = path7__default.default.join(outputPath, "gallery");
446
+ const galleryJsonPath = path7__default.default.join(galleryPath, "gallery.json");
494
447
  const exists = await galleryExists(outputPath);
495
448
  if (exists && !force) {
496
449
  const shouldOverride = await ui.prompt(`Gallery already exists at ${galleryJsonPath}. Do you want to override it?`, {
@@ -515,19 +468,19 @@ async function processDirectory(scanPath, outputPath, recursive, useDefaultSetti
515
468
  }
516
469
  const result = { totalFiles, totalGalleries };
517
470
  if (mediaFiles.length > 0 || subGalleries.length > 0) {
518
- const dirName = path__default.default.basename(scanPath);
471
+ const dirName = path7__default.default.basename(scanPath);
519
472
  result.subGallery = {
520
473
  title: capitalizeTitle(dirName),
521
474
  headerImage: mediaFiles[0]?.filename || "",
522
- path: path__default.default.join("..", dirName)
475
+ path: path7__default.default.join("..", dirName)
523
476
  };
524
477
  }
525
478
  return result;
526
479
  }
527
480
  async function init(options, ui) {
528
481
  try {
529
- const scanPath = path__default.default.resolve(options.photos);
530
- const outputPath = options.gallery ? path__default.default.resolve(options.gallery) : scanPath;
482
+ const scanPath = path7__default.default.resolve(options.photos);
483
+ const outputPath = options.gallery ? path7__default.default.resolve(options.gallery) : scanPath;
531
484
  const result = await processDirectory(
532
485
  scanPath,
533
486
  outputPath,
@@ -651,7 +604,7 @@ async function processImage(imagePath, thumbnailPath, thumbnailPathRetina, thumb
651
604
  const blurHash = await generateBlurHash(thumbnailPath);
652
605
  return {
653
606
  type: "image",
654
- filename: path__default.default.basename(imagePath),
607
+ filename: path7__default.default.basename(imagePath),
655
608
  alt: description,
656
609
  width: imageDimensions.width,
657
610
  height: imageDimensions.height,
@@ -682,7 +635,7 @@ async function processVideo(videoPath, thumbnailPath, thumbnailPathRetina, thumb
682
635
  const blurHash = await generateBlurHash(thumbnailPath);
683
636
  return {
684
637
  type: "video",
685
- filename: path__default.default.basename(videoPath),
638
+ filename: path7__default.default.basename(videoPath),
686
639
  alt: void 0,
687
640
  width: videoDimensions.width,
688
641
  height: videoDimensions.height,
@@ -698,11 +651,11 @@ async function processVideo(videoPath, thumbnailPath, thumbnailPathRetina, thumb
698
651
  }
699
652
  async function processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbnailSize, ui) {
700
653
  try {
701
- const filePath = path__default.default.resolve(path__default.default.join(mediaBasePath, mediaFile.filename));
654
+ const filePath = path7__default.default.resolve(path7__default.default.join(mediaBasePath, mediaFile.filename));
702
655
  const fileName = mediaFile.filename;
703
- const fileNameWithoutExt = path__default.default.parse(fileName).name;
656
+ const fileNameWithoutExt = path7__default.default.parse(fileName).name;
704
657
  const thumbnailFileName = `${fileNameWithoutExt}.avif`;
705
- const thumbnailPath = path__default.default.join(thumbnailsPath, thumbnailFileName);
658
+ const thumbnailPath = path7__default.default.join(thumbnailsPath, thumbnailFileName);
706
659
  const thumbnailPathRetina = thumbnailPath.replace(".avif", "@2x.avif");
707
660
  const lastMediaTimestamp = mediaFile.lastMediaTimestamp ? new Date(mediaFile.lastMediaTimestamp) : void 0;
708
661
  const verbose = ui.level === consola.LogLevels.debug;
@@ -728,8 +681,8 @@ async function processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbn
728
681
  }
729
682
  updatedMediaFile.filename = mediaFile.filename;
730
683
  if (updatedMediaFile.thumbnail) {
731
- updatedMediaFile.thumbnail.path = path__default.default.basename(thumbnailPath);
732
- updatedMediaFile.thumbnail.pathRetina = path__default.default.basename(thumbnailPathRetina);
684
+ updatedMediaFile.thumbnail.path = path7__default.default.basename(thumbnailPath);
685
+ updatedMediaFile.thumbnail.pathRetina = path7__default.default.basename(thumbnailPathRetina);
733
686
  if (mediaFile.thumbnail?.baseUrl) {
734
687
  updatedMediaFile.thumbnail.baseUrl = mediaFile.thumbnail.baseUrl;
735
688
  }
@@ -744,14 +697,14 @@ async function processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbn
744
697
  }
745
698
  }
746
699
  async function processGalleryThumbnails(galleryDir, ui) {
747
- const galleryJsonPath = path__default.default.join(galleryDir, "gallery", "gallery.json");
748
- const thumbnailsPath = path__default.default.join(galleryDir, "gallery", "images");
700
+ const galleryJsonPath = path7__default.default.join(galleryDir, "gallery", "gallery.json");
701
+ const thumbnailsPath = path7__default.default.join(galleryDir, "gallery", "images");
749
702
  ui.start(`Creating thumbnails: ${galleryDir}`);
750
703
  try {
751
704
  fs8__default.default.mkdirSync(thumbnailsPath, { recursive: true });
752
705
  const galleryData = parseGalleryJson(galleryJsonPath, ui);
753
706
  const thumbnailSize = galleryData.thumbnailSize || DEFAULT_THUMBNAIL_SIZE;
754
- const mediaBasePath = galleryData.mediaBasePath ?? path__default.default.join(galleryDir);
707
+ const mediaBasePath = galleryData.mediaBasePath ?? path7__default.default.join(galleryDir);
755
708
  let processedCount = 0;
756
709
  for (const section of galleryData.sections) {
757
710
  for (const [index, mediaFile] of section.images.entries()) {
@@ -798,8 +751,8 @@ function copyPhotos(galleryData, galleryDir, ui) {
798
751
  for (const section of galleryData.sections) {
799
752
  for (const image of section.images) {
800
753
  if (galleryData.mediaBasePath) {
801
- const sourcePath = path__default.default.join(galleryData.mediaBasePath, image.filename);
802
- const destPath = path__default.default.join(galleryDir, image.filename);
754
+ const sourcePath = path7__default.default.join(galleryData.mediaBasePath, image.filename);
755
+ const destPath = path7__default.default.join(galleryDir, image.filename);
803
756
  ui.debug(`Copying photo to ${destPath}`);
804
757
  fs8__default.default.copyFileSync(sourcePath, destPath);
805
758
  }
@@ -838,17 +791,17 @@ async function scanAndAppendNewFiles(galleryDir, galleryJsonPath, galleryData, u
838
791
  }
839
792
  async function buildGallery(galleryDir, templateDir, scan, shouldCreateThumbnails, ui, baseUrl, thumbsBaseUrl) {
840
793
  ui.start(`Building gallery ${galleryDir}`);
841
- const galleryJsonPath = path__default.default.join(galleryDir, "gallery", "gallery.json");
794
+ const galleryJsonPath = path7__default.default.join(galleryDir, "gallery", "gallery.json");
842
795
  let galleryData = parseGalleryJson(galleryJsonPath, ui);
843
796
  if (scan) {
844
797
  galleryData = await scanAndAppendNewFiles(galleryDir, galleryJsonPath, galleryData, ui);
845
798
  }
846
- const socialMediaCardImagePath = path__default.default.join(galleryDir, "gallery", "images", "social-media-card.jpg");
799
+ const socialMediaCardImagePath = path7__default.default.join(galleryDir, "gallery", "images", "social-media-card.jpg");
847
800
  const mediaBasePath = galleryData.mediaBasePath;
848
801
  const mediaBaseUrl = baseUrl || galleryData.mediaBaseUrl;
849
- const headerImagePath = mediaBasePath ? path__default.default.join(mediaBasePath, galleryData.headerImage) : path__default.default.resolve(galleryDir, galleryData.headerImage);
850
- const imagesFolder = path__default.default.join(galleryDir, "gallery", "images");
851
- const currentHeaderBasename = path__default.default.basename(headerImagePath, path__default.default.extname(headerImagePath));
802
+ const headerImagePath = mediaBasePath ? path7__default.default.join(mediaBasePath, galleryData.headerImage) : path7__default.default.resolve(galleryDir, galleryData.headerImage);
803
+ const imagesFolder = path7__default.default.join(galleryDir, "gallery", "images");
804
+ const currentHeaderBasename = path7__default.default.basename(headerImagePath, path7__default.default.extname(headerImagePath));
852
805
  if (shouldCreateThumbnails) {
853
806
  if (!fs8__default.default.existsSync(imagesFolder)) {
854
807
  fs8__default.default.mkdirSync(imagesFolder, { recursive: true });
@@ -891,7 +844,7 @@ async function buildGallery(galleryDir, templateDir, scan, shouldCreateThumbnail
891
844
  }
892
845
  if (!galleryData.metadata.image) {
893
846
  ui.debug("Updating gallery.json with social media card URL");
894
- galleryData.metadata.image = thumbsBaseUrl ? `${thumbsBaseUrl}/${path__default.default.basename(socialMediaCardImagePath)}` : `${galleryData.url || ""}/${path__default.default.relative(galleryDir, socialMediaCardImagePath)}`;
847
+ galleryData.metadata.image = thumbsBaseUrl ? `${thumbsBaseUrl}/${path7__default.default.basename(socialMediaCardImagePath)}` : `${galleryData.url || ""}/${path7__default.default.relative(galleryDir, socialMediaCardImagePath)}`;
895
848
  fs8__default.default.writeFileSync(galleryJsonPath, JSON.stringify(galleryData, null, 2));
896
849
  }
897
850
  if (shouldCreateThumbnails) {
@@ -899,20 +852,20 @@ async function buildGallery(galleryDir, templateDir, scan, shouldCreateThumbnail
899
852
  }
900
853
  ui.debug("Building gallery from template");
901
854
  try {
902
- process4__default.default.env.GALLERY_JSON_PATH = galleryJsonPath;
903
- process4__default.default.env.GALLERY_OUTPUT_DIR = path__default.default.join(galleryDir, "gallery");
855
+ process3__default.default.env.GALLERY_JSON_PATH = galleryJsonPath;
856
+ process3__default.default.env.GALLERY_OUTPUT_DIR = path7__default.default.join(galleryDir, "gallery");
904
857
  child_process.execSync("npx astro build", { cwd: templateDir, stdio: ui.level === consola.LogLevels.debug ? "inherit" : "ignore" });
905
858
  } catch (error) {
906
859
  ui.error(`Build failed for ${galleryDir}`);
907
860
  throw error;
908
861
  }
909
- const outputDir = path__default.default.join(galleryDir, "gallery");
910
- const buildDir = path__default.default.join(outputDir, "_build");
862
+ const outputDir = path7__default.default.join(galleryDir, "gallery");
863
+ const buildDir = path7__default.default.join(outputDir, "_build");
911
864
  ui.debug(`Copying build output to ${outputDir}`);
912
865
  fs8__default.default.cpSync(buildDir, outputDir, { recursive: true });
913
866
  ui.debug("Moving index.html to gallery directory");
914
- fs8__default.default.copyFileSync(path__default.default.join(outputDir, "index.html"), path__default.default.join(galleryDir, "index.html"));
915
- fs8__default.default.rmSync(path__default.default.join(outputDir, "index.html"));
867
+ fs8__default.default.copyFileSync(path7__default.default.join(outputDir, "index.html"), path7__default.default.join(galleryDir, "index.html"));
868
+ fs8__default.default.rmSync(path7__default.default.join(outputDir, "index.html"));
916
869
  ui.debug("Cleaning up build directory");
917
870
  fs8__default.default.rmSync(buildDir, { recursive: true, force: true });
918
871
  ui.success(`Gallery built successfully`);
@@ -925,12 +878,12 @@ async function build(options, ui) {
925
878
  return { processedGalleryCount: 0 };
926
879
  }
927
880
  const themePath = await undefined("@simple-photo-gallery/theme-modern/package.json");
928
- const themeDir = path__default.default.dirname(new URL(themePath).pathname);
881
+ const themeDir = path7__default.default.dirname(new URL(themePath).pathname);
929
882
  let totalGalleries = 0;
930
883
  for (const dir of galleryDirs) {
931
- const baseUrl = options.baseUrl ? `${options.baseUrl}${path__default.default.relative(options.gallery, dir)}` : void 0;
932
- const thumbsBaseUrl = options.thumbsBaseUrl ? `${options.thumbsBaseUrl}${path__default.default.relative(options.gallery, dir)}` : void 0;
933
- await buildGallery(path__default.default.resolve(dir), themeDir, options.scan, options.thumbnails, ui, baseUrl, thumbsBaseUrl);
884
+ const baseUrl = options.baseUrl ? `${options.baseUrl}${path7__default.default.relative(options.gallery, dir)}` : void 0;
885
+ const thumbsBaseUrl = options.thumbsBaseUrl ? `${options.thumbsBaseUrl}${path7__default.default.relative(options.gallery, dir)}` : void 0;
886
+ await buildGallery(path7__default.default.resolve(dir), themeDir, options.scan, options.thumbnails, ui, baseUrl, thumbsBaseUrl);
934
887
  ++totalGalleries;
935
888
  }
936
889
  ui.box(`Built ${totalGalleries} ${totalGalleries === 1 ? "gallery" : "galleries"} successfully`);
@@ -946,7 +899,7 @@ async function build(options, ui) {
946
899
  }
947
900
  async function cleanGallery(galleryDir, ui) {
948
901
  let filesRemoved = 0;
949
- const indexHtmlPath = path__default.default.join(galleryDir, "index.html");
902
+ const indexHtmlPath = path7__default.default.join(galleryDir, "index.html");
950
903
  if (fs8__default.default.existsSync(indexHtmlPath)) {
951
904
  try {
952
905
  fs8__default.default.rmSync(indexHtmlPath);
@@ -956,7 +909,7 @@ async function cleanGallery(galleryDir, ui) {
956
909
  ui?.warn(`Failed to remove index.html: ${error}`);
957
910
  }
958
911
  }
959
- const galleryPath = path__default.default.join(galleryDir, "gallery");
912
+ const galleryPath = path7__default.default.join(galleryDir, "gallery");
960
913
  if (fs8__default.default.existsSync(galleryPath)) {
961
914
  try {
962
915
  fs8__default.default.rmSync(galleryPath, { recursive: true, force: true });
@@ -975,7 +928,7 @@ async function cleanGallery(galleryDir, ui) {
975
928
  }
976
929
  async function clean(options, ui) {
977
930
  try {
978
- const basePath = path__default.default.resolve(options.gallery);
931
+ const basePath = path7__default.default.resolve(options.gallery);
979
932
  if (!fs8__default.default.existsSync(basePath)) {
980
933
  ui.error(`Directory does not exist: ${basePath}`);
981
934
  return { processedGalleryCount: 0 };
@@ -1024,7 +977,7 @@ var ApiTelemetryClient = class {
1024
977
  axios__default.default.post(this.endpoint, event, {
1025
978
  headers: {
1026
979
  "content-type": "application/json",
1027
- "user-agent": `simple-photo-gallery/${event.packageVersion} (${process4__default.default.platform}; ${process4__default.default.arch})`
980
+ "user-agent": `simple-photo-gallery/${event.packageVersion} (${process3__default.default.platform}; ${process3__default.default.arch})`
1028
981
  }
1029
982
  });
1030
983
  } catch {
@@ -1034,7 +987,7 @@ var ApiTelemetryClient = class {
1034
987
  var ConsoleTelemetryClient = class {
1035
988
  async record(event) {
1036
989
  const serialized = JSON.stringify(event, null, 2);
1037
- process4.stdout.write(`TELEMETRY EVENT: ${serialized}
990
+ process3.stdout.write(`TELEMETRY EVENT: ${serialized}
1038
991
  `);
1039
992
  }
1040
993
  };
@@ -1061,11 +1014,11 @@ var TelemetryService = class {
1061
1014
  if (override) {
1062
1015
  return override === "1";
1063
1016
  }
1064
- if (process4__default.default.env.CI || process4__default.default.env.DO_NOT_TRACK) {
1017
+ if (process3__default.default.env.CI || process3__default.default.env.DO_NOT_TRACK) {
1065
1018
  return false;
1066
1019
  }
1067
- if (process4__default.default.env.SPG_TELEMETRY) {
1068
- return process4__default.default.env.SPG_TELEMETRY === "1";
1020
+ if (process3__default.default.env.SPG_TELEMETRY) {
1021
+ return process3__default.default.env.SPG_TELEMETRY === "1";
1069
1022
  }
1070
1023
  const stored = this.getStoredPreference();
1071
1024
  if (stored === void 0) {
@@ -1107,7 +1060,7 @@ var TelemetryService = class {
1107
1060
  durationMs: now - startedAt,
1108
1061
  packageName: this.packageName,
1109
1062
  packageVersion: this.packageVersion,
1110
- nodeVersion: process4__default.default.version,
1063
+ nodeVersion: process3__default.default.version,
1111
1064
  osPlatform: os__default.default.platform(),
1112
1065
  osRelease: os__default.default.release(),
1113
1066
  osArch: os__default.default.arch(),
@@ -1141,7 +1094,7 @@ var TelemetryService = class {
1141
1094
  /** Returns the telemetry client. */
1142
1095
  getClient() {
1143
1096
  if (!this.client) {
1144
- switch (process4__default.default.env.SPG_TELEMETRY_PROVIDER) {
1097
+ switch (process3__default.default.env.SPG_TELEMETRY_PROVIDER) {
1145
1098
  case "none": {
1146
1099
  this.client = void 0;
1147
1100
  break;
@@ -1233,7 +1186,7 @@ async function waitForUpdateCheck(checkPromise) {
1233
1186
  // package.json
1234
1187
  var package_default = {
1235
1188
  name: "simple-photo-gallery",
1236
- version: "2.0.14-rc.1"};
1189
+ version: "2.0.15-rc.18"};
1237
1190
 
1238
1191
  // src/index.ts
1239
1192
  var program = new commander.Command();
@@ -1275,7 +1228,7 @@ function withCommandContext(handler) {
1275
1228
  } catch (error) {
1276
1229
  ui.debug(error);
1277
1230
  errorInfo = error instanceof Error ? { name: error.name, message: error.message } : { name: "UnknownError", message: String(error) };
1278
- process4__default.default.exitCode = 1;
1231
+ process3__default.default.exitCode = 1;
1279
1232
  }
1280
1233
  const updateInfo = await waitForUpdateCheck(updateCheckPromise);
1281
1234
  if (updateInfo) {
@@ -1297,14 +1250,14 @@ function withCommandContext(handler) {
1297
1250
  program.command("init").description("Initialize a gallery by scaning a folder for images and videos").option(
1298
1251
  "-p, --photos <path>",
1299
1252
  "Path to the folder where the photos are stored. Default: current working directory",
1300
- process4__default.default.cwd()
1253
+ process3__default.default.cwd()
1301
1254
  ).option(
1302
1255
  "-g, --gallery <path>",
1303
1256
  "Path to the directory where the gallery will be initialized. Default: same directory as the photos folder"
1304
1257
  ).option("-r, --recursive", "Recursively create galleries from all photos subdirectories", false).option("-d, --default", "Use default gallery settings instead of asking the user", false).option("-f, --force", "Force override existing galleries without asking", false).option("--cta-banner", "Add a Simple Photo Gallery call-to-action banner to the end of the gallery", false).action(withCommandContext((options, ui) => init(options, ui)));
1305
- program.command("thumbnails").description("Create thumbnails for all media files in the gallery").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).action(withCommandContext((options, ui) => thumbnails(options, ui)));
1306
- program.command("build").description("Build the HTML gallery in the specified directory").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).option("-b, --base-url <url>", "Base URL where the photos are hosted").option("-t, --thumbs-base-url <url>", "Base URL where the thumbnails are hosted").option("--no-thumbnails", "Skip creating thumbnails when building the gallery", true).option("--no-scan", "Do not scan for new photos when building the gallery", true).action(withCommandContext((options, ui) => build(options, ui)));
1307
- program.command("clean").description("Remove all gallery files and folders (index.html, gallery/)").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Clean subdirectories recursively", false).action(withCommandContext((options, ui) => clean(options, ui)));
1258
+ program.command("thumbnails").description("Create thumbnails for all media files in the gallery").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).action(withCommandContext((options, ui) => thumbnails(options, ui)));
1259
+ program.command("build").description("Build the HTML gallery in the specified directory").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).option("-b, --base-url <url>", "Base URL where the photos are hosted").option("-t, --thumbs-base-url <url>", "Base URL where the thumbnails are hosted").option("--no-thumbnails", "Skip creating thumbnails when building the gallery", true).option("--no-scan", "Do not scan for new photos when building the gallery", true).action(withCommandContext((options, ui) => build(options, ui)));
1260
+ program.command("clean").description("Remove all gallery files and folders (index.html, gallery/)").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Clean subdirectories recursively", false).action(withCommandContext((options, ui) => clean(options, ui)));
1308
1261
  program.command("telemetry").description("Manage anonymous telemetry preferences. Use 1 to enable, 0 to disable, or no argument to check status").option("-s, --state <state>", "Enable (1) or disable (0) telemetry", parseTelemetryOption).action(withCommandContext((options, ui) => telemetry(options, ui, telemetryService)));
1309
1262
  program.parse();
1310
1263
  //# sourceMappingURL=index.cjs.map