@atlaskit/media-common 12.3.0 → 12.4.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 +15 -2
- package/analytics/package.json +1 -1
- package/dist/cjs/copyIntent/clientIdCache.js +69 -0
- package/dist/cjs/copyIntent/index.js +30 -0
- package/dist/cjs/index.js +26 -1
- package/dist/es2019/copyIntent/clientIdCache.js +63 -0
- package/dist/es2019/copyIntent/index.js +1 -0
- package/dist/es2019/index.js +4 -1
- package/dist/esm/copyIntent/clientIdCache.js +63 -0
- package/dist/esm/copyIntent/index.js +1 -0
- package/dist/esm/index.js +4 -1
- package/dist/types/analytics/withMediaAnalyticsContext.d.ts +2 -2
- package/dist/types/copyIntent/clientIdCache.d.ts +23 -0
- package/dist/types/copyIntent/index.d.ts +1 -0
- package/dist/types/hooks/useStaticCallback.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/test-helpers/getJest.d.ts +0 -1
- package/dist/types/test-helpers/jestHelpers.d.ts +0 -1
- package/dist/types-ts4.5/analytics/withMediaAnalyticsContext.d.ts +2 -2
- package/dist/types-ts4.5/copyIntent/clientIdCache.d.ts +23 -0
- package/dist/types-ts4.5/copyIntent/index.d.ts +1 -0
- package/dist/types-ts4.5/hooks/useStaticCallback.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/test-helpers/getJest.d.ts +0 -1
- package/dist/types-ts4.5/test-helpers/jestHelpers.d.ts +0 -1
- package/downloadUrl/package.json +1 -1
- package/mediaFeatureFlags/package.json +1 -1
- package/mediaTypeUtils/package.json +1 -1
- package/package.json +6 -23
- package/test-helpers/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/media-common
|
|
2
2
|
|
|
3
|
+
## 12.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c90ccf0c600ee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c90ccf0c600ee) -
|
|
8
|
+
Enable cross product/cross client copy and paste of Media files by including clientId during Copy
|
|
9
|
+
operations.
|
|
10
|
+
|
|
11
|
+
## 12.3.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`df75f0a17ca69`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/df75f0a17ca69) -
|
|
16
|
+
Integrate web-search-ai endpoint to web search toggle
|
|
17
|
+
|
|
3
18
|
## 12.3.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -590,7 +605,6 @@
|
|
|
590
605
|
members (see below). Extra entry point `mediaTypeUtils` for all of them is added.
|
|
591
606
|
|
|
592
607
|
New members:
|
|
593
|
-
|
|
594
608
|
- getMediaTypeFromMimeType
|
|
595
609
|
- isImageMimeTypeSupportedByBrowser
|
|
596
610
|
- isDocumentMimeTypeSupportedByBrowser
|
|
@@ -821,5 +835,4 @@
|
|
|
821
835
|
|
|
822
836
|
Create @atlaskit/media-common- Updated dependencies
|
|
823
837
|
[168b5f90e5](https://bitbucket.org/atlassian/atlassian-frontend/commits/168b5f90e5):
|
|
824
|
-
|
|
825
838
|
- @atlaskit/docs@8.5.1
|
package/analytics/package.json
CHANGED
|
@@ -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';
|
package/dist/es2019/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,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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type ContextPublicAttributes } from './types';
|
|
2
|
+
import { type ContextPublicAttributes, type ContextStaticProps } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* HOC for attaching MediaAnalyticsContext to a top-level React Component.
|
|
5
5
|
*
|
|
@@ -12,4 +12,4 @@ import { type ContextPublicAttributes } from './types';
|
|
|
12
12
|
*
|
|
13
13
|
* @see packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx
|
|
14
14
|
*/
|
|
15
|
-
export declare const withMediaAnalyticsContext: (contextPublicAttributes: ContextPublicAttributes) => <Props extends
|
|
15
|
+
export declare const withMediaAnalyticsContext: (contextPublicAttributes: ContextPublicAttributes) => <Props extends ContextStaticProps, Component extends React.ComponentType<Props>>(WrappedComponent: React.JSXElementConstructor<Props> & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Props>> & React.RefAttributes<any>>;
|
|
@@ -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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => (...args: Params) => Result;
|
|
1
|
+
export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => ((...args: Params) => Result);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
export declare const asMock: (fn: Function) => jest.Mock;
|
|
3
2
|
export declare const asMockFunction: <T extends (...args: any[]) => any>(fn: T) => jest.MockedFunction<T>;
|
|
4
3
|
export declare const asMockReturnValue: <T extends (...args: any[]) => any>(fn: T, returnValue: ReturnType<T>) => jest.Mock<any, any, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type ContextPublicAttributes } from './types';
|
|
2
|
+
import { type ContextPublicAttributes, type ContextStaticProps } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* HOC for attaching MediaAnalyticsContext to a top-level React Component.
|
|
5
5
|
*
|
|
@@ -12,4 +12,4 @@ import { type ContextPublicAttributes } from './types';
|
|
|
12
12
|
*
|
|
13
13
|
* @see packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx
|
|
14
14
|
*/
|
|
15
|
-
export declare const withMediaAnalyticsContext: (contextPublicAttributes: ContextPublicAttributes) => <Props extends
|
|
15
|
+
export declare const withMediaAnalyticsContext: (contextPublicAttributes: ContextPublicAttributes) => <Props extends ContextStaticProps, Component extends React.ComponentType<Props>>(WrappedComponent: React.JSXElementConstructor<Props> & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Props>> & React.RefAttributes<any>>;
|
|
@@ -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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => (...args: Params) => Result;
|
|
1
|
+
export declare const useStaticCallback: <Params extends any[], Result>(callback: (...args: Params) => Result) => ((...args: Params) => Result);
|
|
@@ -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';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
export declare const asMock: (fn: Function) => jest.Mock;
|
|
3
2
|
export declare const asMockFunction: <T extends (...args: any[]) => any>(fn: T) => jest.MockedFunction<T>;
|
|
4
3
|
export declare const asMockReturnValue: <T extends (...args: any[]) => any>(fn: T, returnValue: ReturnType<T>) => jest.Mock<any, any, any>;
|
package/downloadUrl/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-common",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"description": "Includes common utilities used by other media packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -22,29 +22,18 @@
|
|
|
22
22
|
},
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"atlaskit:src": "src/index.ts",
|
|
25
|
-
"af:exports": {
|
|
26
|
-
"./downloadUrl": "./src/downloadUrl.ts",
|
|
27
|
-
"./mediaFeatureFlags": "./src/mediaFeatureFlags/index.ts",
|
|
28
|
-
"./analytics": "./src/analytics/index.ts",
|
|
29
|
-
"./docs": "./src/docs/index.ts",
|
|
30
|
-
"./mediaTypeUtils": "./src/mediaTypeUtils/index.ts",
|
|
31
|
-
"./test-helpers": "./src/test-helpers/index.ts",
|
|
32
|
-
".": "./src/index.ts"
|
|
33
|
-
},
|
|
34
25
|
"atlassian": {
|
|
35
26
|
"team": "Media Exif",
|
|
36
27
|
"website": {
|
|
37
28
|
"name": "Media Common"
|
|
38
|
-
}
|
|
39
|
-
"runReact18": true
|
|
29
|
+
}
|
|
40
30
|
},
|
|
41
31
|
"dependencies": {
|
|
42
32
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
43
|
-
"@atlaskit/analytics-namespaced-context": "^7.
|
|
33
|
+
"@atlaskit/analytics-namespaced-context": "^7.2.0",
|
|
44
34
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
45
|
-
"@atlaskit/link": "^3.
|
|
46
|
-
"@atlaskit/
|
|
47
|
-
"@atlaskit/section-message": "^8.2.0",
|
|
35
|
+
"@atlaskit/link": "^3.3.0",
|
|
36
|
+
"@atlaskit/section-message": "^8.12.0",
|
|
48
37
|
"@babel/runtime": "^7.0.0",
|
|
49
38
|
"immer": "^9.0.12",
|
|
50
39
|
"uuid-validate": "^0.0.3"
|
|
@@ -63,12 +52,6 @@
|
|
|
63
52
|
"@types/uuid-validate": "^0.0.2",
|
|
64
53
|
"enzyme": "^3.10.0",
|
|
65
54
|
"react": "^18.2.0",
|
|
66
|
-
"react-dom": "^18.2.0"
|
|
67
|
-
"typescript": "~5.4.2"
|
|
68
|
-
},
|
|
69
|
-
"platform-feature-flags": {
|
|
70
|
-
"dst-a11y__replace-anchor-with-link__media-exif": {
|
|
71
|
-
"type": "boolean"
|
|
72
|
-
}
|
|
55
|
+
"react-dom": "^18.2.0"
|
|
73
56
|
}
|
|
74
57
|
}
|