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.
@@ -184,20 +184,32 @@ function getCustomTheme() {
184
184
  return _customTheme;
185
185
  }
186
186
 
187
- // ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
188
- // Window-level singleton, same reasoning as translations/input-fields config above:
187
+ // ── Unsplash backend endpoint URLs (used by background-panel.js's Unsplash proxy calls) ─
188
+ // Window-level singletons, same reasoning as translations/input-fields config above:
189
189
  // each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
190
190
  // of this module, so a plain closure variable set from one bundle (e.g. via the host
191
191
  // app's top-level `labellife-design-tool/config` import) would never be seen by another
192
192
  // bundle (e.g. background-panel.js, built into the side-panel bundle).
193
- var API_BASE_URL_KEY = '__labellife_api_base_url__';
194
- function setApiBaseUrl(url) {
193
+ //
194
+ // The host app owns the full endpoint URL (host + path); this lib only ever appends the
195
+ // query string for the search endpoint and uses the track-download URL as given.
196
+ var UNSPLASH_SEARCH_URL_KEY = '__labellife_unsplash_search_url__';
197
+ var UNSPLASH_TRACK_DOWNLOAD_URL_KEY = '__labellife_unsplash_track_download_url__';
198
+ function setUnsplashSearchUrl(url) {
195
199
  if (typeof window !== 'undefined') {
196
- window[API_BASE_URL_KEY] = url || '';
200
+ window[UNSPLASH_SEARCH_URL_KEY] = url || '';
197
201
  }
198
202
  }
199
- function getApiBaseUrl() {
200
- return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
203
+ function getUnsplashSearchUrl() {
204
+ return typeof window !== 'undefined' && window[UNSPLASH_SEARCH_URL_KEY] || '';
205
+ }
206
+ function setUnsplashTrackDownloadUrl(url) {
207
+ if (typeof window !== 'undefined') {
208
+ window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] = url || '';
209
+ }
210
+ }
211
+ function getUnsplashTrackDownloadUrl() {
212
+ return typeof window !== 'undefined' && window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] || '';
201
213
  }
202
214
 
203
215
  // ── Input Fields Dialog Config ───────────────────────────────────────
@@ -214,5 +226,5 @@ function getInputFieldsConfig() {
214
226
  return typeof window !== 'undefined' && window[INPUT_FIELDS_CONFIG_KEY] || {};
215
227
  }
216
228
 
217
- export { getApiBaseUrl, getCustomTheme, getInputFieldsConfig, getTheme, getTranslations, setApiBaseUrl, setCustomTheme, setInputFieldsConfig, setTheme, setTranslations, t };
229
+ export { getCustomTheme, getInputFieldsConfig, getTheme, getTranslations, getUnsplashSearchUrl, getUnsplashTrackDownloadUrl, setCustomTheme, setInputFieldsConfig, setTheme, setTranslations, setUnsplashSearchUrl, setUnsplashTrackDownloadUrl, t };
218
230
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/utils/l10n.js","../../src/config.js"],"sourcesContent":["// Use a window-level singleton so that all Rollup bundles (config, toolbar,\n// side-panel, canvas) share the same translations object. Without this each\n// bundle gets its own copy of this module with a separate local variable.\nconst GLOBAL_KEY = '__labellife_translations__';\nif (typeof window !== 'undefined' && !window[GLOBAL_KEY]) {\n window[GLOBAL_KEY] = {};\n}\n\nfunction _get() {\n return (typeof window !== 'undefined' && window[GLOBAL_KEY]) || {};\n}\n\nfunction deepMerge(target, source) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (\n source[key] &&\n typeof source[key] === 'object' &&\n !Array.isArray(source[key]) &&\n target[key] &&\n typeof target[key] === 'object' &&\n !Array.isArray(target[key])\n ) {\n result[key] = deepMerge(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n\nexport function setTranslations(newTranslations) {\n if (typeof window !== 'undefined') {\n window[GLOBAL_KEY] = deepMerge(_get(), newTranslations);\n }\n}\n\nexport function getTranslations() {\n return _get();\n}\n\nexport function t(key, defaultValue) {\n // Support dot-notation paths like 'toolbar.duration'\n const parts = key.split('.');\n let current = _get();\n for (const part of parts) {\n if (current == null || typeof current !== 'object') {\n return defaultValue || key;\n }\n current = current[part];\n }\n if (current !== undefined && current !== null && typeof current !== 'object') {\n return current;\n }\n return defaultValue || key;\n}\n","import { setTranslations as _setTranslations, getTranslations, t } from './utils/l10n';\n\nlet _theme = 'light';\nlet _customTheme = {};\n\nexport function setTranslations(translations) {\n _setTranslations(translations);\n}\n\nexport { getTranslations, t };\n\nexport function setTheme(theme) {\n _theme = theme;\n}\n\nexport function getTheme() {\n return _theme;\n}\n\nexport function setCustomTheme(customTheme) {\n _customTheme = { ..._customTheme, ...customTheme };\n}\n\nexport function getCustomTheme() {\n return _customTheme;\n}\n\n// ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─\n// Window-level singleton, same reasoning as translations/input-fields config above:\n// each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy\n// of this module, so a plain closure variable set from one bundle (e.g. via the host\n// app's top-level `labellife-design-tool/config` import) would never be seen by another\n// bundle (e.g. background-panel.js, built into the side-panel bundle).\nconst API_BASE_URL_KEY = '__labellife_api_base_url__';\n\nexport function setApiBaseUrl(url) {\n if (typeof window !== 'undefined') {\n window[API_BASE_URL_KEY] = url || '';\n }\n}\n\nexport function getApiBaseUrl() {\n return (typeof window !== 'undefined' && window[API_BASE_URL_KEY]) || '';\n}\n\n// ── Input Fields Dialog Config ───────────────────────────────────────\nconst INPUT_FIELDS_CONFIG_KEY = '__labellife_input_fields_config__';\nif (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {\n window[INPUT_FIELDS_CONFIG_KEY] = {};\n}\n\nexport function setInputFieldsConfig(config) {\n if (typeof window !== 'undefined') {\n window[INPUT_FIELDS_CONFIG_KEY] = { ...window[INPUT_FIELDS_CONFIG_KEY], ...config };\n }\n}\n\nexport function getInputFieldsConfig() {\n return (typeof window !== 'undefined' && window[INPUT_FIELDS_CONFIG_KEY]) || {};\n}\n"],"names":["GLOBAL_KEY","window","_get","deepMerge","target","source","result","_objectSpread","_i","_Object$keys","Object","keys","length","key","_typeof","Array","isArray","setTranslations","newTranslations","getTranslations","t","defaultValue","parts","split","current","_iterator","_createForOfIteratorHelper","_step","s","n","done","part","value","err","e","f","undefined","_theme","_customTheme","translations","_setTranslations","setTheme","theme","getTheme","setCustomTheme","customTheme","getCustomTheme","API_BASE_URL_KEY","setApiBaseUrl","url","getApiBaseUrl","INPUT_FIELDS_CONFIG_KEY","setInputFieldsConfig","config","getInputFieldsConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAMA,UAAU,GAAG,4BAA4B;AAC/C,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACD,UAAU,CAAC,EAAE;AACxDC,EAAAA,MAAM,CAACD,UAAU,CAAC,GAAG,EAAE;AACzB;AAEA,SAASE,IAAIA,GAAG;EACd,OAAQ,OAAOD,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACD,UAAU,CAAC,IAAK,EAAE;AACpE;AAEA,SAASG,SAASA,CAACC,MAAM,EAAEC,MAAM,EAAE;AACjC,EAAA,IAAMC,MAAM,GAAAC,cAAA,CAAA,EAAA,EAAQH,MAAM,CAAE;AAC5B,EAAA,KAAA,IAAAI,EAAA,GAAA,CAAA,EAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACN,MAAM,CAAC,EAAAG,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,EAAA,EAAE;AAAlC,IAAA,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA,CAAA;IACZ,IACEH,MAAM,CAACQ,GAAG,CAAC,IACXC,OAAA,CAAOT,MAAM,CAACQ,GAAG,CAAC,MAAK,QAAQ,IAC/B,CAACE,KAAK,CAACC,OAAO,CAACX,MAAM,CAACQ,GAAG,CAAC,CAAC,IAC3BT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AAK,EAAE;AAC1E;;AAEA;AACA,IAAMI,uBAAuB,GAAG,mCAAmC;AACnE,IAAI,OAAOlD,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACkD,uBAAuB,CAAC,EAAE;AACrElD,EAAAA,MAAM,CAACkD,uBAAuB,CAAC,GAAG,EAAE;AACtC;AAEO,SAASC,oBAAoBA,CAACC,MAAM,EAAE;AAC3C,EAAA,IAAI,OAAOpD,MAAM,KAAK,WAAW,EAAE;AACjCA,IAAAA,MAAM,CAACkD,uBAAuB,CAAC,GAAA5C,cAAA,CAAAA,cAAA,CAAA,EAAA,EAAQN,MAAM,CAACkD,uBAAuB,CAAC,CAAA,EAAKE,MAAM,CAAE;AACrF,EAAA;AACF;AAEO,SAASC,oBAAoBA,GAAG;EACrC,OAAQ,OAAOrD,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACkD,uBAAuB,CAAC,IAAK,EAAE;AACjF;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/utils/l10n.js","../../src/config.js"],"sourcesContent":["// Use a window-level singleton so that all Rollup bundles (config, toolbar,\n// side-panel, canvas) share the same translations object. Without this each\n// bundle gets its own copy of this module with a separate local variable.\nconst GLOBAL_KEY = '__labellife_translations__';\nif (typeof window !== 'undefined' && !window[GLOBAL_KEY]) {\n window[GLOBAL_KEY] = {};\n}\n\nfunction _get() {\n return (typeof window !== 'undefined' && window[GLOBAL_KEY]) || {};\n}\n\nfunction deepMerge(target, source) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (\n source[key] &&\n typeof source[key] === 'object' &&\n !Array.isArray(source[key]) &&\n target[key] &&\n typeof target[key] === 'object' &&\n !Array.isArray(target[key])\n ) {\n result[key] = deepMerge(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n\nexport function setTranslations(newTranslations) {\n if (typeof window !== 'undefined') {\n window[GLOBAL_KEY] = deepMerge(_get(), newTranslations);\n }\n}\n\nexport function getTranslations() {\n return _get();\n}\n\nexport function t(key, defaultValue) {\n // Support dot-notation paths like 'toolbar.duration'\n const parts = key.split('.');\n let current = _get();\n for (const part of parts) {\n if (current == null || typeof current !== 'object') {\n return defaultValue || key;\n }\n current = current[part];\n }\n if (current !== undefined && current !== null && typeof current !== 'object') {\n return current;\n }\n return defaultValue || key;\n}\n","import { setTranslations as _setTranslations, getTranslations, t } from './utils/l10n';\n\nlet _theme = 'light';\nlet _customTheme = {};\n\nexport function setTranslations(translations) {\n _setTranslations(translations);\n}\n\nexport { getTranslations, t };\n\nexport function setTheme(theme) {\n _theme = theme;\n}\n\nexport function getTheme() {\n return _theme;\n}\n\nexport function setCustomTheme(customTheme) {\n _customTheme = { ..._customTheme, ...customTheme };\n}\n\nexport function getCustomTheme() {\n return _customTheme;\n}\n\n// ── Unsplash backend endpoint URLs (used by background-panel.js's Unsplash proxy calls) ─\n// Window-level singletons, same reasoning as translations/input-fields config above:\n// each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy\n// of this module, so a plain closure variable set from one bundle (e.g. via the host\n// app's top-level `labellife-design-tool/config` import) would never be seen by another\n// bundle (e.g. background-panel.js, built into the side-panel bundle).\n//\n// The host app owns the full endpoint URL (host + path); this lib only ever appends the\n// query string for the search endpoint and uses the track-download URL as given.\nconst UNSPLASH_SEARCH_URL_KEY = '__labellife_unsplash_search_url__';\nconst UNSPLASH_TRACK_DOWNLOAD_URL_KEY = '__labellife_unsplash_track_download_url__';\n\nexport function setUnsplashSearchUrl(url) {\n if (typeof window !== 'undefined') {\n window[UNSPLASH_SEARCH_URL_KEY] = url || '';\n }\n}\n\nexport function getUnsplashSearchUrl() {\n return (typeof window !== 'undefined' && window[UNSPLASH_SEARCH_URL_KEY]) || '';\n}\n\nexport function setUnsplashTrackDownloadUrl(url) {\n if (typeof window !== 'undefined') {\n window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] = url || '';\n }\n}\n\nexport function getUnsplashTrackDownloadUrl() {\n return (typeof window !== 'undefined' && window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY]) || '';\n}\n\n// ── Input Fields Dialog Config ───────────────────────────────────────\nconst INPUT_FIELDS_CONFIG_KEY = '__labellife_input_fields_config__';\nif (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {\n window[INPUT_FIELDS_CONFIG_KEY] = {};\n}\n\nexport function setInputFieldsConfig(config) {\n if (typeof window !== 'undefined') {\n window[INPUT_FIELDS_CONFIG_KEY] = { ...window[INPUT_FIELDS_CONFIG_KEY], ...config };\n }\n}\n\nexport function getInputFieldsConfig() {\n return (typeof window !== 'undefined' && window[INPUT_FIELDS_CONFIG_KEY]) || {};\n}\n"],"names":["GLOBAL_KEY","window","_get","deepMerge","target","source","result","_objectSpread","_i","_Object$keys","Object","keys","length","key","_typeof","Array","isArray","setTranslations","newTranslations","getTranslations","t","defaultValue","parts","split","current","_iterator","_createForOfIteratorHelper","_step","s","n","done","part","value","err","e","f","undefined","_theme","_customTheme","translations","_setTranslations","setTheme","theme","getTheme","setCustomTheme","customTheme","getCustomTheme","UNSPLASH_SEARCH_URL_KEY","UNSPLASH_TRACK_DOWNLOAD_URL_KEY","setUnsplashSearchUrl","url","getUnsplashSearchUrl","setUnsplashTrackDownloadUrl","getUnsplashTrackDownloadUrl","INPUT_FIELDS_CONFIG_KEY","setInputFieldsConfig","config","getInputFieldsConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAMA,UAAU,GAAG,4BAA4B;AAC/C,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACD,UAAU,CAAC,EAAE;AACxDC,EAAAA,MAAM,CAACD,UAAU,CAAC,GAAG,EAAE;AACzB;AAEA,SAASE,IAAIA,GAAG;EACd,OAAQ,OAAOD,MAAM,KAAK,WAAW,IAA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M,CAACqD,uBAAuB,CAAC,GAAA/C,cAAA,CAAAA,cAAA,CAAA,EAAA,EAAQN,MAAM,CAACqD,uBAAuB,CAAC,CAAA,EAAKE,MAAM,CAAE;AACrF,EAAA;AACF;AAEO,SAASC,oBAAoBA,GAAG;EACrC,OAAQ,OAAOxD,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACqD,uBAAuB,CAAC,IAAK,EAAE;AACjF;;;;"}
package/dist/esm/index.js CHANGED
@@ -651,6 +651,35 @@ function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
651
651
  };
652
652
  }
653
653
 
654
+ // Minimum axis-aligned (pre-rotation) box size that, once rotated by rotationDeg around
655
+ // its own center, still fully covers a boxWidth x boxHeight area. Used so "Fit to page"
656
+ // can keep an image's existing rotation instead of resetting it — the unrotated image is
657
+ // sized against this larger box instead of the page itself.
658
+ function rotatedCoverBox(boxWidth, boxHeight, rotationDeg) {
659
+ var rad = rotationDeg * Math.PI / 180;
660
+ var cos = Math.abs(Math.cos(rad));
661
+ var sin = Math.abs(Math.sin(rad));
662
+ return {
663
+ width: boxWidth * cos + boxHeight * sin,
664
+ height: boxWidth * sin + boxHeight * cos
665
+ };
666
+ }
667
+
668
+ // Top-left (x, y) position such that a width x height rect, rotated by rotationDeg using
669
+ // Konva's convention (rotation pivots around (x, y), i.e. the rect's own pre-rotation
670
+ // top-left corner, not its center), ends up centered within a boxWidth x boxHeight area.
671
+ function centerRotatedPosition(boxWidth, boxHeight, width, height, rotationDeg) {
672
+ var rad = rotationDeg * Math.PI / 180;
673
+ var cos = Math.cos(rad);
674
+ var sin = Math.sin(rad);
675
+ var halfWidth = width / 2;
676
+ var halfHeight = height / 2;
677
+ return {
678
+ x: boxWidth / 2 - (halfWidth * cos - halfHeight * sin),
679
+ y: boxHeight / 2 - (halfWidth * sin + halfHeight * cos)
680
+ };
681
+ }
682
+
654
683
  // Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
655
684
  // Mirrors the existing auto-crop calculation in canvas/image-element.js.
656
685
  function coverFitCrop(boxWidth, boxHeight, naturalWidth, naturalHeight) {
@@ -3110,15 +3139,22 @@ function getTheme() {
3110
3139
  return _theme;
3111
3140
  }
3112
3141
 
3113
- // ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
3114
- // Window-level singleton, same reasoning as translations/input-fields config above:
3142
+ // ── Unsplash backend endpoint URLs (used by background-panel.js's Unsplash proxy calls) ─
3143
+ // Window-level singletons, same reasoning as translations/input-fields config above:
3115
3144
  // each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
3116
3145
  // of this module, so a plain closure variable set from one bundle (e.g. via the host
3117
3146
  // app's top-level `labellife-design-tool/config` import) would never be seen by another
3118
3147
  // bundle (e.g. background-panel.js, built into the side-panel bundle).
3119
- var API_BASE_URL_KEY = '__labellife_api_base_url__';
3120
- function getApiBaseUrl() {
3121
- return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
3148
+ //
3149
+ // The host app owns the full endpoint URL (host + path); this lib only ever appends the
3150
+ // query string for the search endpoint and uses the track-download URL as given.
3151
+ var UNSPLASH_SEARCH_URL_KEY = '__labellife_unsplash_search_url__';
3152
+ var UNSPLASH_TRACK_DOWNLOAD_URL_KEY = '__labellife_unsplash_track_download_url__';
3153
+ function getUnsplashSearchUrl() {
3154
+ return typeof window !== 'undefined' && window[UNSPLASH_SEARCH_URL_KEY] || '';
3155
+ }
3156
+ function getUnsplashTrackDownloadUrl() {
3157
+ return typeof window !== 'undefined' && window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] || '';
3122
3158
  }
3123
3159
 
3124
3160
  // ── Input Fields Dialog Config ───────────────────────────────────────
@@ -3719,17 +3755,18 @@ var TextSection = {
3719
3755
  // labellife backend (see labellifeBackendRepo's UnsplashBackgroundSearchView /
3720
3756
  // UnsplashTrackDownloadView). Deliberately has no internal imports so it can be unit-tested
3721
3757
  // with plain `node`, following the same convention as ./fonts.js.
3758
+ //
3759
+ // The host app owns the full endpoint URL (via setUnsplashSearchUrl/setUnsplashTrackDownloadUrl
3760
+ // in ../config) — this module only ever appends the search query string onto it.
3722
3761
 
3723
3762
  var UNSPLASH_UTM_SOURCE = 'labellife';
3724
- function buildUnsplashSearchUrl(apiBaseUrl, query) {
3763
+ function buildUnsplashSearchUrl(searchUrl, query) {
3725
3764
  var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
3726
3765
  var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
3727
3766
  var trimmed = query && String(query).trim();
3728
3767
  var q = trimmed || 'gradient';
3729
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/search/?query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
3730
- }
3731
- function buildUnsplashTrackDownloadUrl(apiBaseUrl) {
3732
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/track-download/");
3768
+ var separator = searchUrl.includes('?') ? '&' : '?';
3769
+ return "".concat(searchUrl).concat(separator, "query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
3733
3770
  }
3734
3771
 
3735
3772
  // Unsplash API Guidelines require attribution links back to unsplash.com and to the
@@ -4412,7 +4449,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
4412
4449
  _context.p = 2;
4413
4450
  q = query || 'gradient';
4414
4451
  _context.n = 3;
4415
- return fetch(buildUnsplashSearchUrl(getApiBaseUrl(), q, pg, 20));
4452
+ return fetch(buildUnsplashSearchUrl(getUnsplashSearchUrl(), q, pg, 20));
4416
4453
  case 3:
4417
4454
  res = _context.v;
4418
4455
  _context.n = 4;
@@ -4674,7 +4711,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
4674
4711
  // Unsplash API Guidelines require registering a "download" whenever a photo is used.
4675
4712
  // Best-effort: don't block or fail background-setting if this ping fails.
4676
4713
  if ((_photo$links = photo.links) !== null && _photo$links !== void 0 && _photo$links.download_location) {
4677
- fetch(buildUnsplashTrackDownloadUrl(getApiBaseUrl()), {
4714
+ fetch(getUnsplashTrackDownloadUrl(), {
4678
4715
  method: 'POST',
4679
4716
  headers: {
4680
4717
  'Content-Type': 'application/json'
@@ -9389,27 +9426,32 @@ var ImageToolbar = observer(function (_ref5) {
9389
9426
  // smallest size that fully covers the page, centered. No crop is applied — if the
9390
9427
  // aspect ratio doesn't match the page, the image simply overflows the page bounds
9391
9428
  // on two sides (same as manually resizing it to cover), rather than permanently
9392
- // cropping away image data.
9429
+ // cropping away image data. Existing rotation is kept as-is (not reset) — the fit is
9430
+ // computed against the larger box a rotated rect needs to still cover the (unrotated)
9431
+ // page, so a rotated image stays rotated and centered instead of flying off-canvas.
9432
+ var rotation = element.rotation || 0;
9393
9433
  var updates = {
9394
9434
  cropX: 0,
9395
9435
  cropY: 0,
9396
9436
  cropWidth: 1,
9397
9437
  cropHeight: 1
9398
9438
  };
9439
+ var required = rotatedCoverBox(store.width, store.height, rotation);
9399
9440
  if (element._naturalWidth && element._naturalHeight) {
9400
- var _coverFitSize = coverFitSize(store.width, store.height, element._naturalWidth, element._naturalHeight),
9441
+ var _coverFitSize = coverFitSize(required.width, required.height, element._naturalWidth, element._naturalHeight),
9401
9442
  width = _coverFitSize.width,
9402
9443
  height = _coverFitSize.height;
9403
9444
  updates.width = width;
9404
9445
  updates.height = height;
9405
- updates.x = (store.width - width) / 2;
9406
- updates.y = (store.height - height) / 2;
9407
9446
  } else {
9408
- updates.x = 0;
9409
- updates.y = 0;
9410
- updates.width = store.width;
9411
- updates.height = store.height;
9447
+ updates.width = required.width;
9448
+ updates.height = required.height;
9412
9449
  }
9450
+ var _centerRotatedPositio = centerRotatedPosition(store.width, store.height, updates.width, updates.height, rotation),
9451
+ x = _centerRotatedPositio.x,
9452
+ y = _centerRotatedPositio.y;
9453
+ updates.x = x;
9454
+ updates.y = y;
9413
9455
  element.set(updates);
9414
9456
  store.history.addUndoState();
9415
9457
  };