@independo/capacitor-emoji-picker 1.3.3 → 1.3.4-dev.1

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.
package/dist/plugin.js CHANGED
@@ -96,15 +96,25 @@ var capacitorEmojiPicker = (function (exports, core) {
96
96
  return url;
97
97
  }
98
98
 
99
- /** Registers `<emoji-picker>` (if needed) and creates the element. */
100
- async function defaultCreatePickerElement() {
99
+ /**
100
+ * Registers `<emoji-picker>` (if needed) and creates the element with its locale and data source.
101
+ *
102
+ * The element's constructor queues the creation of its database in a microtask, with whatever
103
+ * `locale` and `dataSource` are set by then - the jsDelivr default unless something else is.
104
+ * Both are therefore set in the same synchronous step as `createElement`, before anything is
105
+ * awaited, so that database is the only one and no request goes to the CDN.
106
+ */
107
+ async function defaultCreatePickerElement(props) {
101
108
  try {
102
109
  await Promise.resolve().then(function () { return index; });
103
- return document.createElement('emoji-picker');
104
110
  }
105
111
  catch (_a) {
106
112
  throw new Error(ErrorCodes.NOT_IMPLEMENTED);
107
113
  }
114
+ const picker = document.createElement('emoji-picker');
115
+ picker.dataSource = props.dataSource;
116
+ picker.locale = props.locale;
117
+ return picker;
108
118
  }
109
119
  /**
110
120
  * `emoji-picker-element`'s internal `Database` runs a background `fetch(dataSource, { method: 'HEAD' })`
@@ -339,9 +349,12 @@ var capacitorEmojiPicker = (function (exports, core) {
339
349
  }
340
350
  let picker;
341
351
  try {
342
- picker = await this.createPickerElement();
352
+ // Resolved before the element exists, so it never starts with the default data source
353
+ // (see `defaultCreatePickerElement`).
354
+ const dataSource = await this.getDataSourceUrl(locale);
355
+ picker = await this.createPickerElement({ locale, dataSource });
356
+ picker.dataSource = dataSource;
343
357
  picker.locale = locale;
344
- picker.dataSource = await this.getDataSourceUrl(locale);
345
358
  picker.classList.add(resolvedTheme);
346
359
  }
347
360
  catch (_f) {