@atlaskit/editor-plugin-media 8.4.2 → 8.4.3

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,14 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 8.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`da82d015556d4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/da82d015556d4) -
8
+ Fix a bug where repeatedly cloning the media plugin state would cause severe performance
9
+ degradation over time
10
+ - Updated dependencies
11
+
3
12
  ## 8.4.2
4
13
 
5
14
  ### Patch Changes
@@ -28,6 +28,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
28
28
  var _mediaClient = require("@atlaskit/media-client");
29
29
  var _mediaCommon = require("@atlaskit/media-common");
30
30
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
31
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
31
32
  var _helpers = _interopRequireWildcard(require("../pm-plugins/commands/helpers"));
32
33
  var helpers = _helpers;
33
34
  var _mediaCommon2 = require("../pm-plugins/utils/media-common");
@@ -484,11 +485,25 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
484
485
  key: "clone",
485
486
  value: function clone() {
486
487
  var clonedAt = (performance || Date).now();
487
- return new Proxy(this, {
488
+
489
+ // Prevent double wrapping
490
+ // If clone is repeatedly called, we want to proxy the underlying MediaPluginStateImplementation target, rather than the proxy itself
491
+ // If we proxy the proxy, then calling get in future will need to recursively unwrap proxies to find the original target, which causes performance issues
492
+ // Instead, we check if there is an original target stored on "this", and if so, we use that as the proxy target instead
493
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- This is required while this is behind a feature-gate. Once the feature-gate is removed, we can inline proxyTarget as "(this as unknown as { originalTarget?: typeof proxyTarget }).originalTarget ?? this"
494
+ var proxyTarget = this;
495
+ var originalTarget = this.originalTarget;
496
+ if (originalTarget !== undefined && (0, _expValEquals.expValEquals)('platform_editor_fix_clone_nesting_exp', 'isEnabled', true)) {
497
+ proxyTarget = originalTarget;
498
+ }
499
+ return new Proxy(proxyTarget, {
488
500
  get: function get(target, prop, receiver) {
489
501
  if (prop === 'singletonCreatedAt') {
490
502
  return clonedAt;
491
503
  }
504
+ if (prop === 'originalTarget') {
505
+ return target;
506
+ }
492
507
  return Reflect.get(target, prop, receiver);
493
508
  }
494
509
  });
@@ -16,6 +16,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
16
16
  import { isFileIdentifier } from '@atlaskit/media-client';
17
17
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
18
18
  import { fg } from '@atlaskit/platform-feature-flags';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { updateMediaNodeAttrs } from '../pm-plugins/commands/helpers';
20
21
  // Ignored via go/ees005
21
22
  // eslint-disable-next-line import/no-namespace
@@ -461,11 +462,25 @@ export class MediaPluginStateImplementation {
461
462
  }
462
463
  clone() {
463
464
  const clonedAt = (performance || Date).now();
464
- return new Proxy(this, {
465
+
466
+ // Prevent double wrapping
467
+ // If clone is repeatedly called, we want to proxy the underlying MediaPluginStateImplementation target, rather than the proxy itself
468
+ // If we proxy the proxy, then calling get in future will need to recursively unwrap proxies to find the original target, which causes performance issues
469
+ // Instead, we check if there is an original target stored on "this", and if so, we use that as the proxy target instead
470
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- This is required while this is behind a feature-gate. Once the feature-gate is removed, we can inline proxyTarget as "(this as unknown as { originalTarget?: typeof proxyTarget }).originalTarget ?? this"
471
+ let proxyTarget = this;
472
+ const originalTarget = this.originalTarget;
473
+ if (originalTarget !== undefined && expValEquals('platform_editor_fix_clone_nesting_exp', 'isEnabled', true)) {
474
+ proxyTarget = originalTarget;
475
+ }
476
+ return new Proxy(proxyTarget, {
465
477
  get(target, prop, receiver) {
466
478
  if (prop === 'singletonCreatedAt') {
467
479
  return clonedAt;
468
480
  }
481
+ if (prop === 'originalTarget') {
482
+ return target;
483
+ }
469
484
  return Reflect.get(target, prop, receiver);
470
485
  }
471
486
  });
@@ -25,6 +25,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
25
25
  import { isFileIdentifier } from '@atlaskit/media-client';
26
26
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
27
27
  import { fg } from '@atlaskit/platform-feature-flags';
28
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
28
29
  import { updateMediaNodeAttrs } from '../pm-plugins/commands/helpers';
29
30
  // Ignored via go/ees005
30
31
  // eslint-disable-next-line import/no-namespace
@@ -476,11 +477,25 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
476
477
  key: "clone",
477
478
  value: function clone() {
478
479
  var clonedAt = (performance || Date).now();
479
- return new Proxy(this, {
480
+
481
+ // Prevent double wrapping
482
+ // If clone is repeatedly called, we want to proxy the underlying MediaPluginStateImplementation target, rather than the proxy itself
483
+ // If we proxy the proxy, then calling get in future will need to recursively unwrap proxies to find the original target, which causes performance issues
484
+ // Instead, we check if there is an original target stored on "this", and if so, we use that as the proxy target instead
485
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- This is required while this is behind a feature-gate. Once the feature-gate is removed, we can inline proxyTarget as "(this as unknown as { originalTarget?: typeof proxyTarget }).originalTarget ?? this"
486
+ var proxyTarget = this;
487
+ var originalTarget = this.originalTarget;
488
+ if (originalTarget !== undefined && expValEquals('platform_editor_fix_clone_nesting_exp', 'isEnabled', true)) {
489
+ proxyTarget = originalTarget;
490
+ }
491
+ return new Proxy(proxyTarget, {
480
492
  get: function get(target, prop, receiver) {
481
493
  if (prop === 'singletonCreatedAt') {
482
494
  return clonedAt;
483
495
  }
496
+ if (prop === 'originalTarget') {
497
+ return target;
498
+ }
484
499
  return Reflect.get(target, prop, receiver);
485
500
  }
486
501
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.4.2",
3
+ "version": "8.4.3",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  "@atlaskit/primitives": "^16.0.0",
67
67
  "@atlaskit/textfield": "^8.0.0",
68
68
  "@atlaskit/theme": "^21.0.0",
69
- "@atlaskit/tmp-editor-statsig": "^13.18.0",
69
+ "@atlaskit/tmp-editor-statsig": "^13.19.0",
70
70
  "@atlaskit/tokens": "^7.0.0",
71
71
  "@atlaskit/tooltip": "^20.6.0",
72
72
  "@babel/runtime": "^7.0.0",