@atlaskit/media-common 12.2.0 → 12.3.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,13 @@
1
1
  # @atlaskit/media-common
2
2
 
3
+ ## 12.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#177492](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/177492)
8
+ [`d7167fba38657`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d7167fba38657) -
9
+ Added useStaticCallback hook to enable shared hook functionality
10
+
3
11
  ## 12.2.0
4
12
 
5
13
  ### Minor Changes
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useStaticCallback", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useStaticCallback.useStaticCallback;
10
+ }
11
+ });
12
+ var _useStaticCallback = require("./useStaticCallback");
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useStaticCallback = void 0;
7
+ var _react = require("react");
8
+ var useStaticCallback = exports.useStaticCallback = function useStaticCallback(callback) {
9
+ var callbackRef = (0, _react.useRef)(callback);
10
+ callbackRef.current = callback;
11
+ return (0, _react.useCallback)(function () {
12
+ return callbackRef.current.apply(callbackRef, arguments);
13
+ }, []);
14
+ };
package/dist/cjs/index.js CHANGED
@@ -147,6 +147,12 @@ Object.defineProperty(exports, "pick", {
147
147
  return _helpers.pick;
148
148
  }
149
149
  });
150
+ Object.defineProperty(exports, "useStaticCallback", {
151
+ enumerable: true,
152
+ get: function get() {
153
+ return _hooks.useStaticCallback;
154
+ }
155
+ });
150
156
  Object.defineProperty(exports, "withMediaAnalyticsContext", {
151
157
  enumerable: true,
152
158
  get: function get() {
@@ -158,4 +164,5 @@ var _mediaFeatureFlags = require("./mediaFeatureFlags");
158
164
  var _withMediaAnalyticsContext = require("./analytics/withMediaAnalyticsContext");
159
165
  var _constants = require("./analytics/constants");
160
166
  var _mediaTypeUtils = require("./mediaTypeUtils");
161
- var _helpers = require("./utils/helpers");
167
+ var _helpers = require("./utils/helpers");
168
+ var _hooks = require("./hooks");
@@ -0,0 +1 @@
1
+ export { useStaticCallback } from './useStaticCallback';
@@ -0,0 +1,6 @@
1
+ import { useCallback, useRef } from 'react';
2
+ export const useStaticCallback = callback => {
3
+ const callbackRef = useRef(callback);
4
+ callbackRef.current = callback;
5
+ return useCallback((...args) => callbackRef.current(...args), []);
6
+ };
@@ -15,4 +15,5 @@ export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext
15
15
  // Analytics constants
16
16
  export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
17
17
  export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
18
- export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
18
+ export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
19
+ export { useStaticCallback } from './hooks';
@@ -0,0 +1 @@
1
+ export { useStaticCallback } from './useStaticCallback';
@@ -0,0 +1,8 @@
1
+ import { useCallback, useRef } from 'react';
2
+ export var useStaticCallback = function useStaticCallback(callback) {
3
+ var callbackRef = useRef(callback);
4
+ callbackRef.current = callback;
5
+ return useCallback(function () {
6
+ return callbackRef.current.apply(callbackRef, arguments);
7
+ }, []);
8
+ };
package/dist/esm/index.js CHANGED
@@ -15,4 +15,5 @@ export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext
15
15
  // Analytics constants
16
16
  export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
17
17
  export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
18
- export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
18
+ export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
19
+ export { useStaticCallback } from './hooks';
@@ -0,0 +1 @@
1
+ export { useStaticCallback } from './useStaticCallback';
@@ -0,0 +1 @@
1
+ export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => (...args: Params) => Result;
@@ -13,3 +13,4 @@ export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
13
13
  export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './mediaTypeUtils';
14
14
  export type SSR = 'client' | 'server';
15
15
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId, } from './utils/helpers';
16
+ export { useStaticCallback } from './hooks';
@@ -0,0 +1 @@
1
+ export { useStaticCallback } from './useStaticCallback';
@@ -0,0 +1 @@
1
+ export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => (...args: Params) => Result;
@@ -13,3 +13,4 @@ export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
13
13
  export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './mediaTypeUtils';
14
14
  export type SSR = 'client' | 'server';
15
15
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId, } from './utils/helpers';
16
+ export { useStaticCallback } from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "12.2.0",
3
+ "version": "12.3.0",
4
4
  "description": "Includes common utilities used by other media packages",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"