@atlaskit/emoji 67.4.10 → 67.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/emoji
2
2
 
3
+ ## 67.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`630ece558fe`](https://bitbucket.org/atlassian/atlassian-frontend/commits/630ece558fe) - Added onlyFetchOnDemand config to disable fetching by default in EmojiCommonProvider
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 67.4.10
4
14
 
5
15
  ### Patch Changes
@@ -55,6 +55,7 @@ var EmojiResource = /*#__PURE__*/function (_ref) {
55
55
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initialLoaders", 0);
56
56
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "retries", new Map());
57
57
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isInitialised", false);
58
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchOnDemand", false);
58
59
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getOptimisticImageURL", function (emojiId) {
59
60
  if (_this.emojiProviderConfig.optimisticImageApi) {
60
61
  return _this.emojiProviderConfig.optimisticImageApi.getUrl(emojiId);
@@ -76,6 +77,7 @@ var EmojiResource = /*#__PURE__*/function (_ref) {
76
77
  if (config.providers.length === 0) {
77
78
  throw new Error('No providers specified');
78
79
  }
80
+ _this.fetchOnDemand = !!config.options && !!config.options.onlyFetchOnDemand;
79
81
  _this.initialLoaders = _this.emojiProviderConfig.providers.length;
80
82
  _this.activeLoaders = _this.emojiProviderConfig.providers.length;
81
83
  _this.emojiResponses = [];
@@ -96,7 +98,7 @@ var EmojiResource = /*#__PURE__*/function (_ref) {
96
98
  while (1) switch (_context.prev = _context.next) {
97
99
  case 0:
98
100
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
99
- fetchAtStart: true
101
+ fetchAtStart: !this.fetchOnDemand
100
102
  };
101
103
  if (!options.fetchAtStart) {
102
104
  _context.next = 11;
@@ -219,6 +221,11 @@ var EmojiResource = /*#__PURE__*/function (_ref) {
219
221
  }
220
222
  return fetchEmojiProvider;
221
223
  }()
224
+ }, {
225
+ key: "onlyFetchOnDemand",
226
+ value: function onlyFetchOnDemand() {
227
+ return this.fetchOnDemand;
228
+ }
222
229
  }, {
223
230
  key: "fetchByEmojiId",
224
231
  value: function () {
@@ -47,7 +47,14 @@ var EmojiContextProvider = function EmojiContextProvider(_ref) {
47
47
  }));
48
48
  return _fetchEmojiProvider.apply(this, arguments);
49
49
  }
50
- fetchEmojiProvider();
50
+ if (memoizedEmojiContextValue !== null && memoizedEmojiContextValue !== void 0 && memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand) {
51
+ var isFetchingOnDemand = memoizedEmojiContextValue === null || memoizedEmojiContextValue === void 0 ? void 0 : memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand();
52
+ if (!isFetchingOnDemand) {
53
+ fetchEmojiProvider();
54
+ }
55
+ } else {
56
+ fetchEmojiProvider();
57
+ }
51
58
  }, [memoizedEmojiContextValue]);
52
59
  return /*#__PURE__*/_react.default.createElement(_EmojiContext.EmojiContext.Provider, {
53
60
  value: memoizedEmojiContextValue
@@ -20,7 +20,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
20
20
  actionSubjectId: actionSubjectId,
21
21
  attributes: _objectSpread({
22
22
  packageName: "@atlaskit/emoji",
23
- packageVersion: "67.4.10"
23
+ packageVersion: "67.5.0"
24
24
  }, attributes)
25
25
  };
26
26
  };
@@ -30,6 +30,7 @@ export class EmojiResource extends AbstractResource {
30
30
  _defineProperty(this, "initialLoaders", 0);
31
31
  _defineProperty(this, "retries", new Map());
32
32
  _defineProperty(this, "isInitialised", false);
33
+ _defineProperty(this, "fetchOnDemand", false);
33
34
  _defineProperty(this, "getOptimisticImageURL", emojiId => {
34
35
  if (this.emojiProviderConfig.optimisticImageApi) {
35
36
  return this.emojiProviderConfig.optimisticImageApi.getUrl(emojiId);
@@ -49,6 +50,7 @@ export class EmojiResource extends AbstractResource {
49
50
  if (config.providers.length === 0) {
50
51
  throw new Error('No providers specified');
51
52
  }
53
+ this.fetchOnDemand = !!config.options && !!config.options.onlyFetchOnDemand;
52
54
  this.initialLoaders = this.emojiProviderConfig.providers.length;
53
55
  this.activeLoaders = this.emojiProviderConfig.providers.length;
54
56
  this.emojiResponses = [];
@@ -59,7 +61,7 @@ export class EmojiResource extends AbstractResource {
59
61
  * @returns Promise<EmojiProvider>
60
62
  */
61
63
  async getEmojiProvider(options = {
62
- fetchAtStart: true
64
+ fetchAtStart: !this.fetchOnDemand
63
65
  }) {
64
66
  if (options.fetchAtStart) {
65
67
  try {
@@ -118,6 +120,9 @@ export class EmojiResource extends AbstractResource {
118
120
  }
119
121
  return Promise.resolve(this.emojiRepository);
120
122
  }
123
+ onlyFetchOnDemand() {
124
+ return this.fetchOnDemand;
125
+ }
121
126
  async fetchByEmojiId(emojiId, optimistic) {
122
127
  // Check if repository exists and emoji is defined.
123
128
  if (this.isLoaded() && this.isRepositoryAvailable(this.emojiRepository)) {
@@ -15,7 +15,14 @@ export const EmojiContextProvider = ({
15
15
  debug('fetchEmojiProvider error catched from outside', error);
16
16
  }
17
17
  }
18
- fetchEmojiProvider();
18
+ if (memoizedEmojiContextValue !== null && memoizedEmojiContextValue !== void 0 && memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand) {
19
+ const isFetchingOnDemand = memoizedEmojiContextValue === null || memoizedEmojiContextValue === void 0 ? void 0 : memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand();
20
+ if (!isFetchingOnDemand) {
21
+ fetchEmojiProvider();
22
+ }
23
+ } else {
24
+ fetchEmojiProvider();
25
+ }
19
26
  }, [memoizedEmojiContextValue]);
20
27
  return /*#__PURE__*/React.createElement(EmojiContext.Provider, {
21
28
  value: memoizedEmojiContextValue
@@ -7,7 +7,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
7
7
  actionSubjectId,
8
8
  attributes: {
9
9
  packageName: "@atlaskit/emoji",
10
- packageVersion: "67.4.10",
10
+ packageVersion: "67.5.0",
11
11
  ...attributes
12
12
  }
13
13
  });
@@ -47,6 +47,7 @@ export var EmojiResource = /*#__PURE__*/function (_ref) {
47
47
  _defineProperty(_assertThisInitialized(_this), "initialLoaders", 0);
48
48
  _defineProperty(_assertThisInitialized(_this), "retries", new Map());
49
49
  _defineProperty(_assertThisInitialized(_this), "isInitialised", false);
50
+ _defineProperty(_assertThisInitialized(_this), "fetchOnDemand", false);
50
51
  _defineProperty(_assertThisInitialized(_this), "getOptimisticImageURL", function (emojiId) {
51
52
  if (_this.emojiProviderConfig.optimisticImageApi) {
52
53
  return _this.emojiProviderConfig.optimisticImageApi.getUrl(emojiId);
@@ -68,6 +69,7 @@ export var EmojiResource = /*#__PURE__*/function (_ref) {
68
69
  if (config.providers.length === 0) {
69
70
  throw new Error('No providers specified');
70
71
  }
72
+ _this.fetchOnDemand = !!config.options && !!config.options.onlyFetchOnDemand;
71
73
  _this.initialLoaders = _this.emojiProviderConfig.providers.length;
72
74
  _this.activeLoaders = _this.emojiProviderConfig.providers.length;
73
75
  _this.emojiResponses = [];
@@ -88,7 +90,7 @@ export var EmojiResource = /*#__PURE__*/function (_ref) {
88
90
  while (1) switch (_context.prev = _context.next) {
89
91
  case 0:
90
92
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
91
- fetchAtStart: true
93
+ fetchAtStart: !this.fetchOnDemand
92
94
  };
93
95
  if (!options.fetchAtStart) {
94
96
  _context.next = 11;
@@ -211,6 +213,11 @@ export var EmojiResource = /*#__PURE__*/function (_ref) {
211
213
  }
212
214
  return fetchEmojiProvider;
213
215
  }()
216
+ }, {
217
+ key: "onlyFetchOnDemand",
218
+ value: function onlyFetchOnDemand() {
219
+ return this.fetchOnDemand;
220
+ }
214
221
  }, {
215
222
  key: "fetchByEmojiId",
216
223
  value: function () {
@@ -37,7 +37,14 @@ export var EmojiContextProvider = function EmojiContextProvider(_ref) {
37
37
  }));
38
38
  return _fetchEmojiProvider.apply(this, arguments);
39
39
  }
40
- fetchEmojiProvider();
40
+ if (memoizedEmojiContextValue !== null && memoizedEmojiContextValue !== void 0 && memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand) {
41
+ var isFetchingOnDemand = memoizedEmojiContextValue === null || memoizedEmojiContextValue === void 0 ? void 0 : memoizedEmojiContextValue.emoji.emojiProvider.onlyFetchOnDemand();
42
+ if (!isFetchingOnDemand) {
43
+ fetchEmojiProvider();
44
+ }
45
+ } else {
46
+ fetchEmojiProvider();
47
+ }
41
48
  }, [memoizedEmojiContextValue]);
42
49
  return /*#__PURE__*/React.createElement(EmojiContext.Provider, {
43
50
  value: memoizedEmojiContextValue
@@ -12,7 +12,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
12
12
  actionSubjectId: actionSubjectId,
13
13
  attributes: _objectSpread({
14
14
  packageName: "@atlaskit/emoji",
15
- packageVersion: "67.4.10"
15
+ packageVersion: "67.5.0"
16
16
  }, attributes)
17
17
  };
18
18
  };
@@ -3,7 +3,7 @@ import { CategoryId } from '../components/picker/categories';
3
3
  import { EmojiDescription, EmojiId, EmojiProvider, EmojiResponse, EmojiSearchResult, EmojiUpload, OptionalEmojiDescription, OptionalEmojiDescriptionWithVariations, OptionalUser, SearchOptions, ToneSelection, UploadingEmojiProvider, User } from '../types';
4
4
  import EmojiRepository from './EmojiRepository';
5
5
  import SiteEmojiResource from './media/SiteEmojiResource';
6
- import { OptimisticImageApiLoaderConfig, SingleEmojiApiLoaderConfig } from './EmojiUtils';
6
+ import { OptimisticImageApiLoaderConfig, Options, SingleEmojiApiLoaderConfig } from './EmojiUtils';
7
7
  interface GetEmojiProviderOptions {
8
8
  /**
9
9
  * Whether fetch emoji provider at start
@@ -23,6 +23,11 @@ export interface EmojiResourceConfig {
23
23
  * providers when performing shortName based look up.
24
24
  */
25
25
  providers: ServiceConfig[];
26
+ /**
27
+ * Additional configuration:
28
+ * * On-demand Fetching - Useful for when a product may prefer manually controlling when providers are fetched
29
+ */
30
+ options?: Options;
26
31
  /**
27
32
  * Must be set to true to enable upload support in the emoji components.
28
33
  *
@@ -80,6 +85,7 @@ export declare class EmojiResource extends AbstractResource<string, EmojiSearchR
80
85
  protected selectedTone: ToneSelection;
81
86
  protected currentUser?: User;
82
87
  protected isInitialised: boolean;
88
+ protected fetchOnDemand: boolean;
83
89
  protected emojiResponses: EmojiResponse[];
84
90
  emojiProviderConfig: EmojiResourceConfig;
85
91
  constructor(config: EmojiResourceConfig);
@@ -90,6 +96,7 @@ export declare class EmojiResource extends AbstractResource<string, EmojiSearchR
90
96
  getEmojiProvider(options?: GetEmojiProviderOptions): Promise<EmojiProvider>;
91
97
  private fetchIndividualProvider;
92
98
  fetchEmojiProvider(force?: boolean): Promise<EmojiRepository | undefined>;
99
+ onlyFetchOnDemand(): boolean;
93
100
  fetchByEmojiId(emojiId: EmojiId, optimistic: boolean): Promise<OptionalEmojiDescriptionWithVariations>;
94
101
  private getProviderType;
95
102
  protected initEmojiRepository(emojiResponses: EmojiResponse[]): void;
@@ -3,6 +3,9 @@ import { AltRepresentations, EmojiDescription, EmojiDescriptionWithVariations, E
3
3
  export interface EmojiLoaderConfig extends ServiceConfig {
4
4
  getRatio?: () => number;
5
5
  }
6
+ export interface Options {
7
+ onlyFetchOnDemand?: boolean;
8
+ }
6
9
  export interface SingleEmojiApiLoaderConfig extends Omit<ServiceConfig, 'url'> {
7
10
  getUrl: (emojiId: EmojiId) => string;
8
11
  }
@@ -121,6 +121,12 @@ export interface EmojiProvider extends Provider<string, EmojiSearchResult, any,
121
121
  * Returns a constructed URL to fetch emoji media asset if 'optimisticImageApi' config has been provided
122
122
  */
123
123
  getOptimisticImageURL(emojiId: EmojiId): string | undefined;
124
+ /**
125
+ * @return a boolean indicating whether providers should be fetched on-demand only, and automatic fetches prevented
126
+ *
127
+ * Optional.
128
+ */
129
+ onlyFetchOnDemand?(): boolean;
124
130
  }
125
131
  export interface UploadingEmojiProvider extends EmojiProvider {
126
132
  /**
@@ -3,7 +3,7 @@ import { CategoryId } from '../components/picker/categories';
3
3
  import { EmojiDescription, EmojiId, EmojiProvider, EmojiResponse, EmojiSearchResult, EmojiUpload, OptionalEmojiDescription, OptionalEmojiDescriptionWithVariations, OptionalUser, SearchOptions, ToneSelection, UploadingEmojiProvider, User } from '../types';
4
4
  import EmojiRepository from './EmojiRepository';
5
5
  import SiteEmojiResource from './media/SiteEmojiResource';
6
- import { OptimisticImageApiLoaderConfig, SingleEmojiApiLoaderConfig } from './EmojiUtils';
6
+ import { OptimisticImageApiLoaderConfig, Options, SingleEmojiApiLoaderConfig } from './EmojiUtils';
7
7
  interface GetEmojiProviderOptions {
8
8
  /**
9
9
  * Whether fetch emoji provider at start
@@ -23,6 +23,11 @@ export interface EmojiResourceConfig {
23
23
  * providers when performing shortName based look up.
24
24
  */
25
25
  providers: ServiceConfig[];
26
+ /**
27
+ * Additional configuration:
28
+ * * On-demand Fetching - Useful for when a product may prefer manually controlling when providers are fetched
29
+ */
30
+ options?: Options;
26
31
  /**
27
32
  * Must be set to true to enable upload support in the emoji components.
28
33
  *
@@ -80,6 +85,7 @@ export declare class EmojiResource extends AbstractResource<string, EmojiSearchR
80
85
  protected selectedTone: ToneSelection;
81
86
  protected currentUser?: User;
82
87
  protected isInitialised: boolean;
88
+ protected fetchOnDemand: boolean;
83
89
  protected emojiResponses: EmojiResponse[];
84
90
  emojiProviderConfig: EmojiResourceConfig;
85
91
  constructor(config: EmojiResourceConfig);
@@ -90,6 +96,7 @@ export declare class EmojiResource extends AbstractResource<string, EmojiSearchR
90
96
  getEmojiProvider(options?: GetEmojiProviderOptions): Promise<EmojiProvider>;
91
97
  private fetchIndividualProvider;
92
98
  fetchEmojiProvider(force?: boolean): Promise<EmojiRepository | undefined>;
99
+ onlyFetchOnDemand(): boolean;
93
100
  fetchByEmojiId(emojiId: EmojiId, optimistic: boolean): Promise<OptionalEmojiDescriptionWithVariations>;
94
101
  private getProviderType;
95
102
  protected initEmojiRepository(emojiResponses: EmojiResponse[]): void;
@@ -3,6 +3,9 @@ import { AltRepresentations, EmojiDescription, EmojiDescriptionWithVariations, E
3
3
  export interface EmojiLoaderConfig extends ServiceConfig {
4
4
  getRatio?: () => number;
5
5
  }
6
+ export interface Options {
7
+ onlyFetchOnDemand?: boolean;
8
+ }
6
9
  export interface SingleEmojiApiLoaderConfig extends Omit<ServiceConfig, 'url'> {
7
10
  getUrl: (emojiId: EmojiId) => string;
8
11
  }
@@ -121,6 +121,12 @@ export interface EmojiProvider extends Provider<string, EmojiSearchResult, any,
121
121
  * Returns a constructed URL to fetch emoji media asset if 'optimisticImageApi' config has been provided
122
122
  */
123
123
  getOptimisticImageURL(emojiId: EmojiId): string | undefined;
124
+ /**
125
+ * @return a boolean indicating whether providers should be fetched on-demand only, and automatic fetches prevented
126
+ *
127
+ * Optional.
128
+ */
129
+ onlyFetchOnDemand?(): boolean;
124
130
  }
125
131
  export interface UploadingEmojiProvider extends EmojiProvider {
126
132
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/emoji",
3
- "version": "67.4.10",
3
+ "version": "67.5.0",
4
4
  "description": "Fabric emoji React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/analytics-next": "^9.1.0",
37
- "@atlaskit/button": "^16.9.0",
37
+ "@atlaskit/button": "^16.10.0",
38
38
  "@atlaskit/icon": "^21.12.0",
39
39
  "@atlaskit/media-client": "^24.0.0",
40
40
  "@atlaskit/spinner": "^15.5.0",
package/report.api.md CHANGED
@@ -291,6 +291,7 @@ export interface EmojiProvider
291
291
  emoji: EmojiDescription,
292
292
  useAlt?: boolean,
293
293
  ): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
294
+ onlyFetchOnDemand?(): boolean;
294
295
  optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
295
296
  recordSelection?(emoji: EmojiDescription): Promise<any>;
296
297
  setSelectedTone(tone: ToneSelection): void;
@@ -384,6 +385,8 @@ class EmojiResource_2
384
385
  // (undocumented)
385
386
  fetchEmojiProvider(force?: boolean): Promise<EmojiRepository | undefined>;
386
387
  // (undocumented)
388
+ protected fetchOnDemand: boolean;
389
+ // (undocumented)
387
390
  filter(query?: string, options?: SearchOptions): void;
388
391
  // (undocumented)
389
392
  findByEmojiId(
@@ -438,6 +441,8 @@ class EmojiResource_2
438
441
  // (undocumented)
439
442
  protected notifyResult(result: EmojiSearchResult): void;
440
443
  // (undocumented)
444
+ onlyFetchOnDemand(): boolean;
445
+ // (undocumented)
441
446
  optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
442
447
  // (undocumented)
443
448
  protected recordConfig?: ServiceConfig;
@@ -461,6 +466,7 @@ export interface EmojiResourceConfig {
461
466
  allowUpload?: boolean;
462
467
  currentUser?: User;
463
468
  optimisticImageApi?: OptimisticImageApiLoaderConfig;
469
+ options?: Options;
464
470
  providers: ServiceConfig[];
465
471
  recordConfig?: ServiceConfig;
466
472
  singleEmojiApi?: SingleEmojiApiLoaderConfig;
@@ -978,6 +984,12 @@ export type OptionalEmojiDescriptionWithVariations =
978
984
  // @public (undocumented)
979
985
  export type OptionalUser = User | undefined;
980
986
 
987
+ // @public (undocumented)
988
+ interface Options {
989
+ // (undocumented)
990
+ onlyFetchOnDemand?: boolean;
991
+ }
992
+
981
993
  // @public (undocumented)
982
994
  interface PickerRefHandler {
983
995
  // (undocumented)
@@ -229,6 +229,7 @@ export interface EmojiProvider extends Provider<string, EmojiSearchResult, any,
229
229
  getOptimisticImageURL(emojiId: EmojiId): string | undefined;
230
230
  getSelectedTone(): ToneSelection;
231
231
  loadMediaEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
232
+ onlyFetchOnDemand?(): boolean;
232
233
  optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
233
234
  recordSelection?(emoji: EmojiDescription): Promise<any>;
234
235
  setSelectedTone(tone: ToneSelection): void;
@@ -300,6 +301,8 @@ class EmojiResource_2 extends AbstractResource<string, EmojiSearchResult, any, u
300
301
  // (undocumented)
301
302
  fetchEmojiProvider(force?: boolean): Promise<EmojiRepository | undefined>;
302
303
  // (undocumented)
304
+ protected fetchOnDemand: boolean;
305
+ // (undocumented)
303
306
  filter(query?: string, options?: SearchOptions): void;
304
307
  // (undocumented)
305
308
  findByEmojiId(emojiId: EmojiId): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
@@ -338,6 +341,8 @@ class EmojiResource_2 extends AbstractResource<string, EmojiSearchResult, any, u
338
341
  // (undocumented)
339
342
  protected notifyResult(result: EmojiSearchResult): void;
340
343
  // (undocumented)
344
+ onlyFetchOnDemand(): boolean;
345
+ // (undocumented)
341
346
  optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
342
347
  // (undocumented)
343
348
  protected recordConfig?: ServiceConfig;
@@ -361,6 +366,7 @@ export interface EmojiResourceConfig {
361
366
  allowUpload?: boolean;
362
367
  currentUser?: User;
363
368
  optimisticImageApi?: OptimisticImageApiLoaderConfig;
369
+ options?: Options;
364
370
  providers: ServiceConfig[];
365
371
  recordConfig?: ServiceConfig;
366
372
  singleEmojiApi?: SingleEmojiApiLoaderConfig;
@@ -855,6 +861,12 @@ export type OptionalEmojiDescriptionWithVariations = EmojiDescriptionWithVariati
855
861
  // @public (undocumented)
856
862
  export type OptionalUser = User | undefined;
857
863
 
864
+ // @public (undocumented)
865
+ interface Options {
866
+ // (undocumented)
867
+ onlyFetchOnDemand?: boolean;
868
+ }
869
+
858
870
  // @public (undocumented)
859
871
  interface PickerRefHandler {
860
872
  // (undocumented)