labellife-design-tool 2.5.2 → 2.5.4

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.
@@ -417,15 +417,22 @@ function t(key, defaultValue) {
417
417
  return defaultValue || key;
418
418
  }
419
419
 
420
- // ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
421
- // Window-level singleton, same reasoning as translations/input-fields config above:
420
+ // ── Unsplash backend endpoint URLs (used by background-panel.js's Unsplash proxy calls) ─
421
+ // Window-level singletons, same reasoning as translations/input-fields config above:
422
422
  // each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
423
423
  // of this module, so a plain closure variable set from one bundle (e.g. via the host
424
424
  // app's top-level `labellife-design-tool/config` import) would never be seen by another
425
425
  // bundle (e.g. background-panel.js, built into the side-panel bundle).
426
- var API_BASE_URL_KEY = '__labellife_api_base_url__';
427
- function getApiBaseUrl() {
428
- return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
426
+ //
427
+ // The host app owns the full endpoint URL (host + path); this lib only ever appends the
428
+ // query string for the search endpoint and uses the track-download URL as given.
429
+ var UNSPLASH_SEARCH_URL_KEY = '__labellife_unsplash_search_url__';
430
+ var UNSPLASH_TRACK_DOWNLOAD_URL_KEY = '__labellife_unsplash_track_download_url__';
431
+ function getUnsplashSearchUrl() {
432
+ return typeof window !== 'undefined' && window[UNSPLASH_SEARCH_URL_KEY] || '';
433
+ }
434
+ function getUnsplashTrackDownloadUrl() {
435
+ return typeof window !== 'undefined' && window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] || '';
429
436
  }
430
437
 
431
438
  // ── Input Fields Dialog Config ───────────────────────────────────────
@@ -1018,17 +1025,18 @@ var TextSection = {
1018
1025
  // labellife backend (see labellifeBackendRepo's UnsplashBackgroundSearchView /
1019
1026
  // UnsplashTrackDownloadView). Deliberately has no internal imports so it can be unit-tested
1020
1027
  // with plain `node`, following the same convention as ./fonts.js.
1028
+ //
1029
+ // The host app owns the full endpoint URL (via setUnsplashSearchUrl/setUnsplashTrackDownloadUrl
1030
+ // in ../config) — this module only ever appends the search query string onto it.
1021
1031
 
1022
1032
  var UNSPLASH_UTM_SOURCE = 'labellife';
1023
- function buildUnsplashSearchUrl(apiBaseUrl, query) {
1033
+ function buildUnsplashSearchUrl(searchUrl, query) {
1024
1034
  var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1025
1035
  var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
1026
1036
  var trimmed = query && String(query).trim();
1027
1037
  var q = trimmed || 'gradient';
1028
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/search/?query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
1029
- }
1030
- function buildUnsplashTrackDownloadUrl(apiBaseUrl) {
1031
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/track-download/");
1038
+ var separator = searchUrl.includes('?') ? '&' : '?';
1039
+ return "".concat(searchUrl).concat(separator, "query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
1032
1040
  }
1033
1041
 
1034
1042
  // Unsplash API Guidelines require attribution links back to unsplash.com and to the
@@ -1711,7 +1719,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
1711
1719
  _context.p = 2;
1712
1720
  q = query || 'gradient';
1713
1721
  _context.n = 3;
1714
- return fetch(buildUnsplashSearchUrl(getApiBaseUrl(), q, pg, 20));
1722
+ return fetch(buildUnsplashSearchUrl(getUnsplashSearchUrl(), q, pg, 20));
1715
1723
  case 3:
1716
1724
  res = _context.v;
1717
1725
  _context.n = 4;
@@ -1973,7 +1981,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
1973
1981
  // Unsplash API Guidelines require registering a "download" whenever a photo is used.
1974
1982
  // Best-effort: don't block or fail background-setting if this ping fails.
1975
1983
  if ((_photo$links = photo.links) !== null && _photo$links !== void 0 && _photo$links.download_location) {
1976
- fetch(buildUnsplashTrackDownloadUrl(getApiBaseUrl()), {
1984
+ fetch(getUnsplashTrackDownloadUrl(), {
1977
1985
  method: 'POST',
1978
1986
  headers: {
1979
1987
  'Content-Type': 'application/json'