labellife-design-tool 2.5.5 → 2.5.7

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