@atlaskit/media-common 12.3.1 → 13.0.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,21 @@
1
1
  # @atlaskit/media-common
2
2
 
3
+ ## 13.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`bc6f294d90d3f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bc6f294d90d3f) -
8
+ Upgrade immer dependency to 11.1.4 (COMMIT-24745). Addresses dependency debt and version conflicts
9
+ for downstream consumers. Uses `produce` API which is compatible across v8–v11.
10
+
11
+ ## 12.4.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`c90ccf0c600ee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c90ccf0c600ee) -
16
+ Enable cross product/cross client copy and paste of Media files by including clientId during Copy
17
+ operations.
18
+
3
19
  ## 12.3.1
4
20
 
5
21
  ### Patch Changes
@@ -597,7 +613,6 @@
597
613
  members (see below). Extra entry point `mediaTypeUtils` for all of them is added.
598
614
 
599
615
  New members:
600
-
601
616
  - getMediaTypeFromMimeType
602
617
  - isImageMimeTypeSupportedByBrowser
603
618
  - isDocumentMimeTypeSupportedByBrowser
@@ -828,5 +843,4 @@
828
843
 
829
844
  Create @atlaskit/media-common- Updated dependencies
830
845
  [168b5f90e5](https://bitbucket.org/atlassian/atlassian-frontend/commits/168b5f90e5):
831
-
832
846
  - @atlaskit/docs@8.5.1
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setClientIdForFile = exports.getClientIdForFile = exports.extractClientIdsFromHtml = exports.clearClientIdCache = void 0;
7
+ /**
8
+ * Cache for storing fileId to clientId mapping during paste operations.
9
+ * This avoids the need to store clientId in ADF schema attributes.
10
+ *
11
+ * Used for cross-client copy/paste scenarios
12
+ *
13
+ * Entries are one-time use (consumed on read), with a max size limit
14
+ * to guard against build-up if entries are never consumed (should not happpen).
15
+ */
16
+
17
+ var CLIENT_ID_CACHE_MAX_SIZE = 100;
18
+ var clientIdCache = new Map();
19
+ var setClientIdForFile = exports.setClientIdForFile = function setClientIdForFile(fileId, clientId) {
20
+ clientIdCache.set(fileId, clientId);
21
+
22
+ // Evict oldest entries if cache exceeds max size
23
+ if (clientIdCache.size > CLIENT_ID_CACHE_MAX_SIZE) {
24
+ var oldestKey = clientIdCache.keys().next().value;
25
+ if (oldestKey !== undefined) {
26
+ clientIdCache.delete(oldestKey);
27
+ }
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Retrieve and consume clientId for a file ID (called during copyFile)
33
+ * Returns undefined if not found.
34
+ */
35
+ var getClientIdForFile = exports.getClientIdForFile = function getClientIdForFile(fileId) {
36
+ var clientId = clientIdCache.get(fileId);
37
+ // Consume the entry after reading (one-time use)
38
+ if (clientId) {
39
+ clientIdCache.delete(fileId);
40
+ }
41
+ return clientId;
42
+ };
43
+
44
+ /**
45
+ * Clear all cached clientIds (for testing purposes)
46
+ */
47
+ var clearClientIdCache = exports.clearClientIdCache = function clearClientIdCache() {
48
+ clientIdCache.clear();
49
+ };
50
+
51
+ /**
52
+ * Used to store fileId to clientId mappings on paste of Editor PM Node
53
+ */
54
+ var extractClientIdsFromHtml = exports.extractClientIdsFromHtml = function extractClientIdsFromHtml(html) {
55
+ if (!html || !html.includes('data-client-id')) {
56
+ return;
57
+ }
58
+ var mediaTagRegex = /<[^>]*data-node-type="media(?:Inline)?"[^>]*>/g;
59
+ var match;
60
+ while ((match = mediaTagRegex.exec(html)) !== null) {
61
+ var _exec, _exec2;
62
+ var tag = match[0];
63
+ var fileId = (_exec = /data-id="([^"]*)"/.exec(tag)) === null || _exec === void 0 ? void 0 : _exec[1];
64
+ var clientId = (_exec2 = /data-client-id="([^"]*)"/.exec(tag)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
65
+ if (fileId && clientId) {
66
+ setClientIdForFile(fileId, clientId);
67
+ }
68
+ }
69
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "clearClientIdCache", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _clientIdCache.clearClientIdCache;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "extractClientIdsFromHtml", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _clientIdCache.extractClientIdsFromHtml;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getClientIdForFile", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _clientIdCache.getClientIdForFile;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "setClientIdForFile", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _clientIdCache.setClientIdForFile;
28
+ }
29
+ });
30
+ var _clientIdCache = require("./clientIdCache");
package/dist/cjs/index.js CHANGED
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "ANALYTICS_MEDIA_CHANNEL", {
9
9
  return _constants.ANALYTICS_MEDIA_CHANNEL;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "clearClientIdCache", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _copyIntent.clearClientIdCache;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "debounce", {
13
19
  enumerable: true,
14
20
  get: function get() {
@@ -27,12 +33,24 @@ Object.defineProperty(exports, "downloadUrl", {
27
33
  return _downloadUrl.downloadUrl;
28
34
  }
29
35
  });
36
+ Object.defineProperty(exports, "extractClientIdsFromHtml", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _copyIntent.extractClientIdsFromHtml;
40
+ }
41
+ });
30
42
  Object.defineProperty(exports, "filterFeatureFlagNames", {
31
43
  enumerable: true,
32
44
  get: function get() {
33
45
  return _mediaFeatureFlags.filterFeatureFlagNames;
34
46
  }
35
47
  });
48
+ Object.defineProperty(exports, "getClientIdForFile", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _copyIntent.getClientIdForFile;
52
+ }
53
+ });
36
54
  Object.defineProperty(exports, "getFeatureFlagKeysAllProducts", {
37
55
  enumerable: true,
38
56
  get: function get() {
@@ -147,6 +165,12 @@ Object.defineProperty(exports, "pick", {
147
165
  return _helpers.pick;
148
166
  }
149
167
  });
168
+ Object.defineProperty(exports, "setClientIdForFile", {
169
+ enumerable: true,
170
+ get: function get() {
171
+ return _copyIntent.setClientIdForFile;
172
+ }
173
+ });
150
174
  Object.defineProperty(exports, "useStaticCallback", {
151
175
  enumerable: true,
152
176
  get: function get() {
@@ -165,4 +189,5 @@ var _withMediaAnalyticsContext = require("./analytics/withMediaAnalyticsContext"
165
189
  var _constants = require("./analytics/constants");
166
190
  var _mediaTypeUtils = require("./mediaTypeUtils");
167
191
  var _helpers = require("./utils/helpers");
168
- var _hooks = require("./hooks");
192
+ var _hooks = require("./hooks");
193
+ var _copyIntent = require("./copyIntent");
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Cache for storing fileId to clientId mapping during paste operations.
3
+ * This avoids the need to store clientId in ADF schema attributes.
4
+ *
5
+ * Used for cross-client copy/paste scenarios
6
+ *
7
+ * Entries are one-time use (consumed on read), with a max size limit
8
+ * to guard against build-up if entries are never consumed (should not happpen).
9
+ */
10
+
11
+ const CLIENT_ID_CACHE_MAX_SIZE = 100;
12
+ const clientIdCache = new Map();
13
+ export const setClientIdForFile = (fileId, clientId) => {
14
+ clientIdCache.set(fileId, clientId);
15
+
16
+ // Evict oldest entries if cache exceeds max size
17
+ if (clientIdCache.size > CLIENT_ID_CACHE_MAX_SIZE) {
18
+ const oldestKey = clientIdCache.keys().next().value;
19
+ if (oldestKey !== undefined) {
20
+ clientIdCache.delete(oldestKey);
21
+ }
22
+ }
23
+ };
24
+
25
+ /**
26
+ * Retrieve and consume clientId for a file ID (called during copyFile)
27
+ * Returns undefined if not found.
28
+ */
29
+ export const getClientIdForFile = fileId => {
30
+ const clientId = clientIdCache.get(fileId);
31
+ // Consume the entry after reading (one-time use)
32
+ if (clientId) {
33
+ clientIdCache.delete(fileId);
34
+ }
35
+ return clientId;
36
+ };
37
+
38
+ /**
39
+ * Clear all cached clientIds (for testing purposes)
40
+ */
41
+ export const clearClientIdCache = () => {
42
+ clientIdCache.clear();
43
+ };
44
+
45
+ /**
46
+ * Used to store fileId to clientId mappings on paste of Editor PM Node
47
+ */
48
+ export const extractClientIdsFromHtml = html => {
49
+ if (!html || !html.includes('data-client-id')) {
50
+ return;
51
+ }
52
+ const mediaTagRegex = /<[^>]*data-node-type="media(?:Inline)?"[^>]*>/g;
53
+ let match;
54
+ while ((match = mediaTagRegex.exec(html)) !== null) {
55
+ var _exec, _exec2;
56
+ const tag = match[0];
57
+ const fileId = (_exec = /data-id="([^"]*)"/.exec(tag)) === null || _exec === void 0 ? void 0 : _exec[1];
58
+ const clientId = (_exec2 = /data-client-id="([^"]*)"/.exec(tag)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
59
+ if (fileId && clientId) {
60
+ setClientIdForFile(fileId, clientId);
61
+ }
62
+ }
63
+ };
@@ -0,0 +1 @@
1
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml } from './clientIdCache';
@@ -16,4 +16,7 @@ export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext
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
18
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
19
- export { useStaticCallback } from './hooks';
19
+ export { useStaticCallback } from './hooks';
20
+
21
+ // Cross-client copy/paste utilities
22
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml } from './copyIntent';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Cache for storing fileId to clientId mapping during paste operations.
3
+ * This avoids the need to store clientId in ADF schema attributes.
4
+ *
5
+ * Used for cross-client copy/paste scenarios
6
+ *
7
+ * Entries are one-time use (consumed on read), with a max size limit
8
+ * to guard against build-up if entries are never consumed (should not happpen).
9
+ */
10
+
11
+ var CLIENT_ID_CACHE_MAX_SIZE = 100;
12
+ var clientIdCache = new Map();
13
+ export var setClientIdForFile = function setClientIdForFile(fileId, clientId) {
14
+ clientIdCache.set(fileId, clientId);
15
+
16
+ // Evict oldest entries if cache exceeds max size
17
+ if (clientIdCache.size > CLIENT_ID_CACHE_MAX_SIZE) {
18
+ var oldestKey = clientIdCache.keys().next().value;
19
+ if (oldestKey !== undefined) {
20
+ clientIdCache.delete(oldestKey);
21
+ }
22
+ }
23
+ };
24
+
25
+ /**
26
+ * Retrieve and consume clientId for a file ID (called during copyFile)
27
+ * Returns undefined if not found.
28
+ */
29
+ export var getClientIdForFile = function getClientIdForFile(fileId) {
30
+ var clientId = clientIdCache.get(fileId);
31
+ // Consume the entry after reading (one-time use)
32
+ if (clientId) {
33
+ clientIdCache.delete(fileId);
34
+ }
35
+ return clientId;
36
+ };
37
+
38
+ /**
39
+ * Clear all cached clientIds (for testing purposes)
40
+ */
41
+ export var clearClientIdCache = function clearClientIdCache() {
42
+ clientIdCache.clear();
43
+ };
44
+
45
+ /**
46
+ * Used to store fileId to clientId mappings on paste of Editor PM Node
47
+ */
48
+ export var extractClientIdsFromHtml = function extractClientIdsFromHtml(html) {
49
+ if (!html || !html.includes('data-client-id')) {
50
+ return;
51
+ }
52
+ var mediaTagRegex = /<[^>]*data-node-type="media(?:Inline)?"[^>]*>/g;
53
+ var match;
54
+ while ((match = mediaTagRegex.exec(html)) !== null) {
55
+ var _exec, _exec2;
56
+ var tag = match[0];
57
+ var fileId = (_exec = /data-id="([^"]*)"/.exec(tag)) === null || _exec === void 0 ? void 0 : _exec[1];
58
+ var clientId = (_exec2 = /data-client-id="([^"]*)"/.exec(tag)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
59
+ if (fileId && clientId) {
60
+ setClientIdForFile(fileId, clientId);
61
+ }
62
+ }
63
+ };
@@ -0,0 +1 @@
1
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml } from './clientIdCache';
package/dist/esm/index.js CHANGED
@@ -16,4 +16,7 @@ export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext
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
18
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId } from './utils/helpers';
19
- export { useStaticCallback } from './hooks';
19
+ export { useStaticCallback } from './hooks';
20
+
21
+ // Cross-client copy/paste utilities
22
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml } from './copyIntent';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Cache for storing fileId to clientId mapping during paste operations.
3
+ * This avoids the need to store clientId in ADF schema attributes.
4
+ *
5
+ * Used for cross-client copy/paste scenarios
6
+ *
7
+ * Entries are one-time use (consumed on read), with a max size limit
8
+ * to guard against build-up if entries are never consumed (should not happpen).
9
+ */
10
+ export declare const setClientIdForFile: (fileId: string, clientId: string) => void;
11
+ /**
12
+ * Retrieve and consume clientId for a file ID (called during copyFile)
13
+ * Returns undefined if not found.
14
+ */
15
+ export declare const getClientIdForFile: (fileId: string) => string | undefined;
16
+ /**
17
+ * Clear all cached clientIds (for testing purposes)
18
+ */
19
+ export declare const clearClientIdCache: () => void;
20
+ /**
21
+ * Used to store fileId to clientId mappings on paste of Editor PM Node
22
+ */
23
+ export declare const extractClientIdsFromHtml: (html: string) => void;
@@ -0,0 +1 @@
1
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml, } from './clientIdCache';
@@ -14,3 +14,4 @@ export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocument
14
14
  export type SSR = 'client' | 'server';
15
15
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId, } from './utils/helpers';
16
16
  export { useStaticCallback } from './hooks';
17
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml, } from './copyIntent';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Cache for storing fileId to clientId mapping during paste operations.
3
+ * This avoids the need to store clientId in ADF schema attributes.
4
+ *
5
+ * Used for cross-client copy/paste scenarios
6
+ *
7
+ * Entries are one-time use (consumed on read), with a max size limit
8
+ * to guard against build-up if entries are never consumed (should not happpen).
9
+ */
10
+ export declare const setClientIdForFile: (fileId: string, clientId: string) => void;
11
+ /**
12
+ * Retrieve and consume clientId for a file ID (called during copyFile)
13
+ * Returns undefined if not found.
14
+ */
15
+ export declare const getClientIdForFile: (fileId: string) => string | undefined;
16
+ /**
17
+ * Clear all cached clientIds (for testing purposes)
18
+ */
19
+ export declare const clearClientIdCache: () => void;
20
+ /**
21
+ * Used to store fileId to clientId mappings on paste of Editor PM Node
22
+ */
23
+ export declare const extractClientIdsFromHtml: (html: string) => void;
@@ -0,0 +1 @@
1
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml, } from './clientIdCache';
@@ -14,3 +14,4 @@ export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocument
14
14
  export type SSR = 'client' | 'server';
15
15
  export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, getRandomTelemetryId, } from './utils/helpers';
16
16
  export { useStaticCallback } from './hooks';
17
+ export { setClientIdForFile, getClientIdForFile, clearClientIdCache, extractClientIdsFromHtml, } from './copyIntent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "12.3.1",
3
+ "version": "13.0.0",
4
4
  "description": "Includes common utilities used by other media packages",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,13 +30,12 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@atlaskit/analytics-gas-types": "^5.1.0",
33
- "@atlaskit/analytics-namespaced-context": "^7.1.0",
33
+ "@atlaskit/analytics-namespaced-context": "^7.2.0",
34
34
  "@atlaskit/analytics-next": "^11.1.0",
35
- "@atlaskit/link": "^3.2.0",
36
- "@atlaskit/platform-feature-flags": "^1.1.0",
37
- "@atlaskit/section-message": "^8.7.0",
35
+ "@atlaskit/link": "^3.3.0",
36
+ "@atlaskit/section-message": "^8.12.0",
38
37
  "@babel/runtime": "^7.0.0",
39
- "immer": "^9.0.12",
38
+ "immer": "11.1.4",
40
39
  "uuid-validate": "^0.0.3"
41
40
  },
42
41
  "peerDependencies": {
@@ -54,10 +53,5 @@
54
53
  "enzyme": "^3.10.0",
55
54
  "react": "^18.2.0",
56
55
  "react-dom": "^18.2.0"
57
- },
58
- "platform-feature-flags": {
59
- "dst-a11y__replace-anchor-with-link__media-exif": {
60
- "type": "boolean"
61
- }
62
56
  }
63
57
  }