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