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