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.
@@ -186,20 +186,30 @@ function getCustomTheme() {
186
186
  return _customTheme;
187
187
  }
188
188
 
189
- // ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
190
- // Window-level singleton, same reasoning as translations/input-fields config above:
189
+ // ── Unsplash proxy endpoints (used by background-panel.js) ───────────────────
190
+ // The host app supplies the full endpoint URLs; the library only appends the query string.
191
+ // Window-level singletons, same reasoning as translations/input-fields config above:
191
192
  // each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
192
193
  // of this module, so a plain closure variable set from one bundle (e.g. via the host
193
194
  // app's top-level `labellife-design-tool/config` import) would never be seen by another
194
195
  // bundle (e.g. background-panel.js, built into the side-panel bundle).
195
- var API_BASE_URL_KEY = '__labellife_api_base_url__';
196
- function setApiBaseUrl(url) {
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) {
197
199
  if (typeof window !== 'undefined') {
198
- window[API_BASE_URL_KEY] = url || '';
200
+ window[UNSPLASH_SEARCH_URL_KEY] = url || '';
199
201
  }
200
202
  }
201
- function getApiBaseUrl() {
202
- 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] || '';
203
213
  }
204
214
 
205
215
  // ── Input Fields Dialog Config ───────────────────────────────────────
@@ -216,15 +226,17 @@ function getInputFieldsConfig() {
216
226
  return typeof window !== 'undefined' && window[INPUT_FIELDS_CONFIG_KEY] || {};
217
227
  }
218
228
 
219
- exports.getApiBaseUrl = getApiBaseUrl;
220
229
  exports.getCustomTheme = getCustomTheme;
221
230
  exports.getInputFieldsConfig = getInputFieldsConfig;
222
231
  exports.getTheme = getTheme;
223
232
  exports.getTranslations = getTranslations;
224
- exports.setApiBaseUrl = setApiBaseUrl;
233
+ exports.getUnsplashSearchUrl = getUnsplashSearchUrl;
234
+ exports.getUnsplashTrackDownloadUrl = getUnsplashTrackDownloadUrl;
225
235
  exports.setCustomTheme = setCustomTheme;
226
236
  exports.setInputFieldsConfig = setInputFieldsConfig;
227
237
  exports.setTheme = setTheme;
228
238
  exports.setTranslations = setTranslations;
239
+ exports.setUnsplashSearchUrl = setUnsplashSearchUrl;
240
+ exports.setUnsplashTrackDownloadUrl = setUnsplashTrackDownloadUrl;
229
241
  exports.t = t;
230
242
  //# 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,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,IAAAA,MAAM,CAAC8C,gBAAgB,CAAC,GAAGE,GAAG,IAAI,EAAE;AACtC,EAAA;AACF;AAEO,SAASC,aAAaA,GAAG;EAC9B,OAAQ,OAAOjD,MAAM,KAAK,WAAW,IAAIA,MAAM,CAAC8C,gBAAgB,CAAC,IAAK,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 proxy endpoints (used by background-panel.js) ───────────────────\n// The host app supplies the full endpoint URLs; the library only appends the query string.\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).\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,M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uBAAuB,CAAC,GAAG,EAAE;AACtC;AAEO,SAASC,oBAAoBA,CAACC,MAAM,EAAE;AAC3C,EAAA,IAAI,OAAOvD,MAAM,KAAK,WAAW,EAAE;AACjCA,IAAAA,MAAM,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/cjs/index.js CHANGED
@@ -3141,15 +3141,30 @@ function getTheme() {
3141
3141
  return _theme;
3142
3142
  }
3143
3143
 
3144
- // ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
3145
- // Window-level singleton, same reasoning as translations/input-fields config above:
3144
+ // ── Unsplash proxy endpoints (used by background-panel.js) ───────────────────
3145
+ // The host app supplies the full endpoint URLs; the library only appends the query string.
3146
+ // Window-level singletons, same reasoning as translations/input-fields config above:
3146
3147
  // each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
3147
3148
  // of this module, so a plain closure variable set from one bundle (e.g. via the host
3148
3149
  // app's top-level `labellife-design-tool/config` import) would never be seen by another
3149
3150
  // bundle (e.g. background-panel.js, built into the side-panel bundle).
3150
- var API_BASE_URL_KEY = '__labellife_api_base_url__';
3151
- function getApiBaseUrl() {
3152
- return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
3151
+ var UNSPLASH_SEARCH_URL_KEY = '__labellife_unsplash_search_url__';
3152
+ var UNSPLASH_TRACK_DOWNLOAD_URL_KEY = '__labellife_unsplash_track_download_url__';
3153
+ function setUnsplashSearchUrl(url) {
3154
+ if (typeof window !== 'undefined') {
3155
+ window[UNSPLASH_SEARCH_URL_KEY] = url || '';
3156
+ }
3157
+ }
3158
+ function getUnsplashSearchUrl() {
3159
+ return typeof window !== 'undefined' && window[UNSPLASH_SEARCH_URL_KEY] || '';
3160
+ }
3161
+ function setUnsplashTrackDownloadUrl(url) {
3162
+ if (typeof window !== 'undefined') {
3163
+ window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] = url || '';
3164
+ }
3165
+ }
3166
+ function getUnsplashTrackDownloadUrl() {
3167
+ return typeof window !== 'undefined' && window[UNSPLASH_TRACK_DOWNLOAD_URL_KEY] || '';
3153
3168
  }
3154
3169
 
3155
3170
  // ── Input Fields Dialog Config ───────────────────────────────────────
@@ -3752,15 +3767,15 @@ var TextSection = {
3752
3767
  // with plain `node`, following the same convention as ./fonts.js.
3753
3768
 
3754
3769
  var UNSPLASH_UTM_SOURCE = 'labellife';
3755
- function buildUnsplashSearchUrl(apiBaseUrl, query) {
3770
+
3771
+ // `searchUrl` is the full endpoint supplied by the host app; only the query string is appended.
3772
+ function buildUnsplashSearchUrl(searchUrl, query) {
3756
3773
  var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
3757
3774
  var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
3758
3775
  var trimmed = query && String(query).trim();
3759
3776
  var q = trimmed || 'gradient';
3760
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/search/?query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
3761
- }
3762
- function buildUnsplashTrackDownloadUrl(apiBaseUrl) {
3763
- return "".concat(apiBaseUrl, "/api/polotno/unsplash/track-download/");
3777
+ var separator = searchUrl.includes('?') ? '&' : '?';
3778
+ return "".concat(searchUrl).concat(separator, "query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
3764
3779
  }
3765
3780
 
3766
3781
  // Unsplash API Guidelines require attribution links back to unsplash.com and to the
@@ -4443,7 +4458,7 @@ var BackgroundPanelContent = mobxReactLite.observer(function (_ref5) {
4443
4458
  _context.p = 2;
4444
4459
  q = query || 'gradient';
4445
4460
  _context.n = 3;
4446
- return fetch(buildUnsplashSearchUrl(getApiBaseUrl(), q, pg, 20));
4461
+ return fetch(buildUnsplashSearchUrl(getUnsplashSearchUrl(), q, pg, 20));
4447
4462
  case 3:
4448
4463
  res = _context.v;
4449
4464
  _context.n = 4;
@@ -4705,7 +4720,7 @@ var BackgroundPanelContent = mobxReactLite.observer(function (_ref5) {
4705
4720
  // Unsplash API Guidelines require registering a "download" whenever a photo is used.
4706
4721
  // Best-effort: don't block or fail background-setting if this ping fails.
4707
4722
  if ((_photo$links = photo.links) !== null && _photo$links !== void 0 && _photo$links.download_location) {
4708
- fetch(buildUnsplashTrackDownloadUrl(getApiBaseUrl()), {
4723
+ fetch(getUnsplashTrackDownloadUrl(), {
4709
4724
  method: 'POST',
4710
4725
  headers: {
4711
4726
  'Content-Type': 'application/json'
@@ -11566,6 +11581,34 @@ function syncHeightKeepingCenter(element, newHeight) {
11566
11581
  y: element.y - deltaY
11567
11582
  });
11568
11583
  }
11584
+
11585
+ // Safari can resolve document.fonts.load() (and fire loadingdone) before the canvas
11586
+ // actually renders with the new face, so a re-measure at that moment still gets
11587
+ // fallback-font widths. Poll until canvas text width differs from the plain fallback's
11588
+ // (i.e. the face is really in use), capped so system fonts / fonts that happen to match
11589
+ // the fallback's metrics can't loop forever. Resolves either way.
11590
+ var FONT_READY_MAX_FRAMES = 30;
11591
+ function waitForCanvasFont(fontSpec, family, sample, isCancelled) {
11592
+ return new Promise(function (resolve) {
11593
+ var ctx = document.createElement('canvas').getContext('2d');
11594
+ var text = sample || 'Hamburgefonstiv';
11595
+ var widthWith = function widthWith(font) {
11596
+ ctx.font = font;
11597
+ return ctx.measureText(text).width;
11598
+ };
11599
+ var frames = 0;
11600
+ var _check = function check() {
11601
+ if (isCancelled() || frames >= FONT_READY_MAX_FRAMES) return resolve();
11602
+ var withFont = widthWith("".concat(fontSpec, " \"").concat(family, "\", serif"));
11603
+ var withFallbackSerif = widthWith("".concat(fontSpec, " serif"));
11604
+ var withFallbackSans = widthWith("".concat(fontSpec, " sans-serif"));
11605
+ if (withFont !== withFallbackSerif || withFont !== withFallbackSans) return resolve();
11606
+ frames += 1;
11607
+ requestAnimationFrame(_check);
11608
+ };
11609
+ _check();
11610
+ });
11611
+ }
11569
11612
  var TextElementComponent = mobxReactLite.observer(function (_ref) {
11570
11613
  var _element$backgroundOp;
11571
11614
  var element = _ref.element;
@@ -11620,9 +11663,14 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11620
11663
 
11621
11664
  // Any font finishing a load (covers fonts requested elsewhere, e.g. store.loadFont).
11622
11665
  React.useEffect(function () {
11666
+ // Two frames' delay: Safari's canvas can still be on the fallback at event time.
11623
11667
  var onFontLoaded = function onFontLoaded() {
11624
- var _relayoutRef$current;
11625
- return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
11668
+ return requestAnimationFrame(function () {
11669
+ return requestAnimationFrame(function () {
11670
+ var _relayoutRef$current;
11671
+ return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
11672
+ });
11673
+ });
11626
11674
  };
11627
11675
  document.fonts.addEventListener('loadingdone', onFontLoaded);
11628
11676
  return function () {
@@ -11639,7 +11687,12 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11639
11687
  var cancelled = false;
11640
11688
  var style = element.fontStyle === 'italic' ? 'italic ' : '';
11641
11689
  var weight = element.fontWeight && element.fontWeight !== 'normal' ? "".concat(element.fontWeight, " ") : '';
11642
- document.fonts.load("".concat(style).concat(weight, "16px \"").concat(element.fontFamily, "\""), element.text || element.placeholder || '').then(function () {
11690
+ var sample = element.text || element.placeholder || '';
11691
+ document.fonts.load("".concat(style).concat(weight, "16px \"").concat(element.fontFamily, "\""), sample).then(function () {
11692
+ return waitForCanvasFont("".concat(style).concat(weight, "16px"), element.fontFamily, sample, function () {
11693
+ return cancelled;
11694
+ });
11695
+ }).then(function () {
11643
11696
  var _relayoutRef$current2;
11644
11697
  if (!cancelled) (_relayoutRef$current2 = relayoutRef.current) === null || _relayoutRef$current2 === void 0 || _relayoutRef$current2.call(relayoutRef);
11645
11698
  })["catch"](function () {});
@@ -14109,6 +14162,8 @@ exports.getImageSize = getImageSize;
14109
14162
  exports.getInputFieldsConfig = getInputFieldsConfig;
14110
14163
  exports.getTheme = getTheme;
14111
14164
  exports.getTranslations = getTranslations;
14165
+ exports.getUnsplashSearchUrl = getUnsplashSearchUrl;
14166
+ exports.getUnsplashTrackDownloadUrl = getUnsplashTrackDownloadUrl;
14112
14167
  exports.loadGoogleFont = loadGoogleFont;
14113
14168
  exports.loadImage = loadImage;
14114
14169
  exports.popupActionButtonSx = popupActionButtonSx;
@@ -14116,6 +14171,8 @@ exports.pxToUnit = pxToUnit;
14116
14171
  exports.setInputFieldsConfig = setInputFieldsConfig;
14117
14172
  exports.setTheme = setTheme;
14118
14173
  exports.setTranslations = setTranslations;
14174
+ exports.setUnsplashSearchUrl = setUnsplashSearchUrl;
14175
+ exports.setUnsplashTrackDownloadUrl = setUnsplashTrackDownloadUrl;
14119
14176
  exports.t = t;
14120
14177
  exports.unitToPx = unitToPx;
14121
14178
  //# sourceMappingURL=index.js.map