@atlaskit/editor-extension-dropbox 10.1.23 → 10.2.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,20 @@
1
1
  # @atlaskit/editor-extension-dropbox
2
2
 
3
+ ## 10.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`85087b263ce43`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/85087b263ce43) -
8
+ Migrate react-dom render/unmountComponentAtNode to the React 18/19 createRoot API behind the
9
+ nike_r19_render_unmount feature gate. The legacy react-dom path is preserved on the gate-off
10
+ branch for rollback.
11
+
12
+ ## 10.1.24
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 10.1.23
4
19
 
5
20
  ### Patch Changes
@@ -15,7 +15,36 @@ var _builders = require("@atlaskit/adf-utils/builders");
15
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
16
  var _enableDropbox = _interopRequireDefault(require("./enable-dropbox"));
17
17
  var _constants = require("./constants");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
20
+ var reactRoots = new WeakMap();
21
+
22
+ /** Mounts `element` into `mountPoint`: uses the React 18/19 `createRoot` API when `nike_r19_render_unmount` is on, else the legacy render path. */
23
+ var renderToMountPoint = function renderToMountPoint(element, mountPoint) {
24
+ if ((0, _platformFeatureFlags.fg)('nike_r19_render_unmount')) {
25
+ var root = reactRoots.get(mountPoint);
26
+ if (!root) {
27
+ root = (0, _client.createRoot)(mountPoint);
28
+ reactRoots.set(mountPoint, root);
29
+ }
30
+ root.render(element);
31
+ } else {
32
+ _reactDom.default.render(element, mountPoint);
33
+ }
34
+ };
35
+
36
+ /** Unmounts the tree at `mountPoint`: uses `root.unmount()` when `nike_r19_render_unmount` is on, else the legacy unmount path. */
37
+ var unmountFromMountPoint = function unmountFromMountPoint(mountPoint) {
38
+ if ((0, _platformFeatureFlags.fg)('nike_r19_render_unmount')) {
39
+ var root = reactRoots.get(mountPoint);
40
+ if (root) {
41
+ root.unmount();
42
+ reactRoots.delete(mountPoint);
43
+ }
44
+ } else {
45
+ _reactDom.default.unmountComponentAtNode(mountPoint);
46
+ }
47
+ };
19
48
  function pickFromDropbox(_x, _x2) {
20
49
  return _pickFromDropbox.apply(this, arguments);
21
50
  }
@@ -60,7 +89,7 @@ function _pickFromDropbox() {
60
89
  }));
61
90
  } else {
62
91
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
63
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(Modal.default, {
92
+ renderToMountPoint( /*#__PURE__*/_react.default.createElement(Modal.default, {
64
93
  onClose: function onClose() {}
65
94
  }), popupMountPoint);
66
95
  }
@@ -87,7 +116,7 @@ function _pickFromDropbox() {
87
116
  root.unmount();
88
117
  }
89
118
  } else if (popupMountPoint) {
90
- _reactDom.default.unmountComponentAtNode(popupMountPoint);
119
+ unmountFromMountPoint(popupMountPoint);
91
120
  }
92
121
  return _context2.abrupt("return");
93
122
  case 6:
@@ -100,7 +129,7 @@ function _pickFromDropbox() {
100
129
  root.unmount();
101
130
  }
102
131
  } else if (popupMountPoint) {
103
- _reactDom.default.unmountComponentAtNode(popupMountPoint);
132
+ unmountFromMountPoint(popupMountPoint);
104
133
  }
105
134
  return _context2.abrupt("return");
106
135
  case 7:
@@ -124,7 +153,7 @@ function _pickFromDropbox() {
124
153
  root.unmount();
125
154
  }
126
155
  } else if (popupMountPoint) {
127
- _reactDom.default.unmountComponentAtNode(popupMountPoint);
156
+ unmountFromMountPoint(popupMountPoint);
128
157
  }
129
158
  return _context2.abrupt("return", node);
130
159
  case 8:
@@ -5,6 +5,35 @@ import { inlineCard } from '@atlaskit/adf-utils/builders';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  import enableDropbox from './enable-dropbox';
7
7
  import { POPUP_MOUNTPOINT, DROPBOX_IFRAME_NAME } from './constants';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
9
+ const reactRoots = new WeakMap();
10
+
11
+ /** Mounts `element` into `mountPoint`: uses the React 18/19 `createRoot` API when `nike_r19_render_unmount` is on, else the legacy render path. */
12
+ const renderToMountPoint = (element, mountPoint) => {
13
+ if (fg('nike_r19_render_unmount')) {
14
+ let root = reactRoots.get(mountPoint);
15
+ if (!root) {
16
+ root = createRoot(mountPoint);
17
+ reactRoots.set(mountPoint, root);
18
+ }
19
+ root.render(element);
20
+ } else {
21
+ ReactDOM.render(element, mountPoint);
22
+ }
23
+ };
24
+
25
+ /** Unmounts the tree at `mountPoint`: uses `root.unmount()` when `nike_r19_render_unmount` is on, else the legacy unmount path. */
26
+ const unmountFromMountPoint = mountPoint => {
27
+ if (fg('nike_r19_render_unmount')) {
28
+ const root = reactRoots.get(mountPoint);
29
+ if (root) {
30
+ root.unmount();
31
+ reactRoots.delete(mountPoint);
32
+ }
33
+ } else {
34
+ ReactDOM.unmountComponentAtNode(mountPoint);
35
+ }
36
+ };
8
37
  async function pickFromDropbox(appKey, canMountinIframe) {
9
38
  await enableDropbox(appKey);
10
39
  let popupMountPoint;
@@ -35,7 +64,7 @@ async function pickFromDropbox(appKey, canMountinIframe) {
35
64
  }));
36
65
  } else {
37
66
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
38
- ReactDOM.render( /*#__PURE__*/React.createElement(Modal.default, {
67
+ renderToMountPoint( /*#__PURE__*/React.createElement(Modal.default, {
39
68
  onClose: () => {}
40
69
  }), popupMountPoint);
41
70
  }
@@ -57,7 +86,7 @@ async function pickFromDropbox(appKey, canMountinIframe) {
57
86
  root.unmount();
58
87
  }
59
88
  } else if (popupMountPoint) {
60
- ReactDOM.unmountComponentAtNode(popupMountPoint);
89
+ unmountFromMountPoint(popupMountPoint);
61
90
  }
62
91
  return;
63
92
  }
@@ -68,7 +97,7 @@ async function pickFromDropbox(appKey, canMountinIframe) {
68
97
  root.unmount();
69
98
  }
70
99
  } else if (popupMountPoint) {
71
- ReactDOM.unmountComponentAtNode(popupMountPoint);
100
+ unmountFromMountPoint(popupMountPoint);
72
101
  }
73
102
  return;
74
103
  }
@@ -90,7 +119,7 @@ async function pickFromDropbox(appKey, canMountinIframe) {
90
119
  root.unmount();
91
120
  }
92
121
  } else if (popupMountPoint) {
93
- ReactDOM.unmountComponentAtNode(popupMountPoint);
122
+ unmountFromMountPoint(popupMountPoint);
94
123
  }
95
124
  return node;
96
125
  }
@@ -7,6 +7,35 @@ import { inlineCard } from '@atlaskit/adf-utils/builders';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
8
  import enableDropbox from './enable-dropbox';
9
9
  import { POPUP_MOUNTPOINT, DROPBOX_IFRAME_NAME } from './constants';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
+ var reactRoots = new WeakMap();
12
+
13
+ /** Mounts `element` into `mountPoint`: uses the React 18/19 `createRoot` API when `nike_r19_render_unmount` is on, else the legacy render path. */
14
+ var renderToMountPoint = function renderToMountPoint(element, mountPoint) {
15
+ if (fg('nike_r19_render_unmount')) {
16
+ var root = reactRoots.get(mountPoint);
17
+ if (!root) {
18
+ root = createRoot(mountPoint);
19
+ reactRoots.set(mountPoint, root);
20
+ }
21
+ root.render(element);
22
+ } else {
23
+ ReactDOM.render(element, mountPoint);
24
+ }
25
+ };
26
+
27
+ /** Unmounts the tree at `mountPoint`: uses `root.unmount()` when `nike_r19_render_unmount` is on, else the legacy unmount path. */
28
+ var unmountFromMountPoint = function unmountFromMountPoint(mountPoint) {
29
+ if (fg('nike_r19_render_unmount')) {
30
+ var root = reactRoots.get(mountPoint);
31
+ if (root) {
32
+ root.unmount();
33
+ reactRoots.delete(mountPoint);
34
+ }
35
+ } else {
36
+ ReactDOM.unmountComponentAtNode(mountPoint);
37
+ }
38
+ };
10
39
  function pickFromDropbox(_x, _x2) {
11
40
  return _pickFromDropbox.apply(this, arguments);
12
41
  }
@@ -49,7 +78,7 @@ function _pickFromDropbox() {
49
78
  }));
50
79
  } else {
51
80
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
52
- ReactDOM.render( /*#__PURE__*/React.createElement(Modal.default, {
81
+ renderToMountPoint( /*#__PURE__*/React.createElement(Modal.default, {
53
82
  onClose: function onClose() {}
54
83
  }), popupMountPoint);
55
84
  }
@@ -76,7 +105,7 @@ function _pickFromDropbox() {
76
105
  root.unmount();
77
106
  }
78
107
  } else if (popupMountPoint) {
79
- ReactDOM.unmountComponentAtNode(popupMountPoint);
108
+ unmountFromMountPoint(popupMountPoint);
80
109
  }
81
110
  return _context2.abrupt("return");
82
111
  case 6:
@@ -89,7 +118,7 @@ function _pickFromDropbox() {
89
118
  root.unmount();
90
119
  }
91
120
  } else if (popupMountPoint) {
92
- ReactDOM.unmountComponentAtNode(popupMountPoint);
121
+ unmountFromMountPoint(popupMountPoint);
93
122
  }
94
123
  return _context2.abrupt("return");
95
124
  case 7:
@@ -113,7 +142,7 @@ function _pickFromDropbox() {
113
142
  root.unmount();
114
143
  }
115
144
  } else if (popupMountPoint) {
116
- ReactDOM.unmountComponentAtNode(popupMountPoint);
145
+ unmountFromMountPoint(popupMountPoint);
117
146
  }
118
147
  return _context2.abrupt("return", node);
119
148
  case 8:
@@ -1,2 +1,2 @@
1
- declare const _default: (appKey: string) => Promise<void>;
2
1
  export default _default;
2
+ declare function _default(appKey: string): Promise<void>;
@@ -1,2 +1,2 @@
1
- declare const _default: () => JSX.Element;
2
1
  export default _default;
2
+ declare function _default(): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-extension-dropbox",
3
- "version": "10.1.23",
3
+ "version": "10.2.0",
4
4
  "description": "A an atlassian editor extension to add a native dropbox picker",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,18 +33,18 @@
33
33
  "@atlaskit/adf-utils": "^20.3.0",
34
34
  "@atlaskit/button": "^24.3.0",
35
35
  "@atlaskit/heading": "^6.2.0",
36
- "@atlaskit/modal-dialog": "^16.1.0",
36
+ "@atlaskit/modal-dialog": "^16.2.0",
37
37
  "@atlaskit/platform-feature-flags": "^2.1.0",
38
38
  "@atlaskit/primitives": "^22.2.0",
39
39
  "@atlaskit/react-compiler-gating": "^0.2.0",
40
- "@atlaskit/tmp-editor-statsig": "^134.0.0",
40
+ "@atlaskit/tmp-editor-statsig": "^135.5.0",
41
41
  "@atlaskit/tokens": "^16.3.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "@compiled/react": "^1.0.0",
44
44
  "@emotion/react": "^11.7.1"
45
45
  },
46
46
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^116.40.0",
47
+ "@atlaskit/editor-common": "^116.44.0",
48
48
  "react": "^18.2.0",
49
49
  "react-dom": "^18.2.0"
50
50
  },
@@ -63,5 +63,10 @@
63
63
  "@atlassian/structured-docs-types": "workspace:^",
64
64
  "react": "^18.2.0",
65
65
  "react-dom": "^18.2.0"
66
+ },
67
+ "platform-feature-flags": {
68
+ "nike_r19_render_unmount": {
69
+ "type": "boolean"
70
+ }
66
71
  }
67
72
  }