@atlaskit/renderer 130.6.4 → 131.1.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,23 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 131.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3e32ed83c03e3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3e32ed83c03e3) -
8
+ DITOR-679 improve media provider
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 131.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - [`479eca77367d5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/479eca77367d5) -
19
+ Update imports of renderer to remove file barrelling
20
+
3
21
  ## 130.6.4
4
22
 
5
23
  ### Patch Changes
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer/actions",
3
- "main": "../dist/cjs/actions.js",
4
- "module": "../dist/esm/actions.js",
5
- "module:es2019": "../dist/es2019/actions.js",
3
+ "main": "../dist/cjs/actions/index.js",
4
+ "module": "../dist/esm/actions/index.js",
5
+ "module:es2019": "../dist/es2019/actions/index.js",
6
6
  "sideEffects": [
7
7
  "*.compiled.css"
8
8
  ],
9
- "types": "../dist/types/actions.d.ts",
9
+ "types": "../dist/types/actions/index.d.ts",
10
10
  "typesVersions": {
11
11
  ">=4.5 <5.9": {
12
12
  "*": [
13
- "../dist/types-ts4.5/actions.d.ts"
13
+ "../dist/types-ts4.5/actions/index.d.ts"
14
14
  ]
15
15
  }
16
16
  }
@@ -15,7 +15,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
15
15
  var EditorMediaClientProvider = exports.EditorMediaClientProvider = function EditorMediaClientProvider(_ref) {
16
16
  var children = _ref.children,
17
17
  ssr = _ref.ssr;
18
- var _useState = (0, _react.useState)(),
18
+ var _useState = (0, _react.useState)(function () {
19
+ return (0, _expValEquals.expValEquals)('platform_editor_media_reliability_enhancements', 'isEnabled', true) ? ssr === null || ssr === void 0 ? void 0 : ssr.config : undefined;
20
+ }),
19
21
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
20
22
  mediaClientConfig = _useState2[0],
21
23
  setMediaClientConfig = _useState2[1];
@@ -51,7 +53,46 @@ var EditorMediaClientProvider = exports.EditorMediaClientProvider = function Edi
51
53
  // and provide a top level mediaClient context
52
54
  // This is useful for testing and creating examples.
53
55
 
56
+ // When the experiment is enabled, use useEffect instead of useLayoutEffect because:
57
+ // - For the ssr.config branch: useState is already initialised with ssr.config, so this
58
+ // effect is a no-op on first render — the "before paint" guarantee is irrelevant.
59
+ // - For the mediaProvider branch: the actual work happens inside a Promise callback which
60
+ // resolves asynchronously, so it can never run before paint regardless of which hook
61
+ // schedules it — useLayoutEffect's guarantee is equally irrelevant here.
62
+ // The legacy path keeps useLayoutEffect to preserve existing behaviour when the experiment is off.
63
+ //
64
+ // The two hooks below are mutually exclusive — only one runs per render — so there is no
65
+ // actual chaining of state updates at runtime. The lint rule cannot statically prove this.
66
+ (0, _react.useEffect)(function () {
67
+ if (!(0, _expValEquals.expValEquals)('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
68
+ return;
69
+ }
70
+ if (ssr !== null && ssr !== void 0 && ssr.config) {
71
+ // eslint-disable-next-line @atlassian/perf-linting/no-chain-state-updates
72
+ setMediaClientConfig(ssr.config);
73
+ } else if (mediaProvider) {
74
+ var cancelled = false;
75
+ // Cancellation flag prevents setMediaClientConfig from being called after
76
+ // unmount or when mediaProvider changes mid-flight (stale promise fix).
77
+ // No .catch() is needed — the media provider is not expected to reject,
78
+ // and a catch handler would be a no-op anyway.
79
+ mediaProvider.then(function (provider) {
80
+ if (!cancelled) {
81
+ setMediaClientConfig(provider.viewMediaClientConfig);
82
+ }
83
+ });
84
+ return function () {
85
+ cancelled = true;
86
+ };
87
+ }
88
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
89
+
90
+ // Legacy path (experiment off): keep useLayoutEffect to preserve existing behaviour.
91
+ // remove this when clean up platform_editor_media_reliability_enhancements
54
92
  (0, _react.useLayoutEffect)(function () {
93
+ if ((0, _expValEquals.expValEquals)('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
94
+ return;
95
+ }
55
96
  if (ssr !== null && ssr !== void 0 && ssr.config) {
56
97
  setMediaClientConfig(ssr.config);
57
98
  } else if (mediaProvider) {
@@ -59,7 +100,7 @@ var EditorMediaClientProvider = exports.EditorMediaClientProvider = function Edi
59
100
  setMediaClientConfig(provider.viewMediaClientConfig);
60
101
  });
61
102
  }
62
- }, [mediaProvider, ssr]);
103
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
63
104
  return /*#__PURE__*/_react.default.createElement(_mediaClientReact.MediaClientContext.Provider, {
64
105
  value: shouldSkipContext ? mediaClient : contextMediaClient
65
106
  }, children);
@@ -1,4 +1,4 @@
1
- import React, { useContext, useLayoutEffect, useMemo, useState } from 'react';
1
+ import React, { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react';
2
2
  import { MediaClientContext, getMediaClient } from '@atlaskit/media-client-react';
3
3
  import { useProviderFactory, useProviderLayout } from '@atlaskit/editor-common/provider-factory';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
@@ -6,7 +6,7 @@ export const EditorMediaClientProvider = ({
6
6
  children,
7
7
  ssr
8
8
  }) => {
9
- const [mediaClientConfig, setMediaClientConfig] = useState();
9
+ const [mediaClientConfig, setMediaClientConfig] = useState(() => expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true) ? ssr === null || ssr === void 0 ? void 0 : ssr.config : undefined);
10
10
  const providerFactory = useProviderFactory();
11
11
  const mediaProvider = useProviderLayout('mediaProvider');
12
12
 
@@ -37,7 +37,46 @@ export const EditorMediaClientProvider = ({
37
37
  // and provide a top level mediaClient context
38
38
  // This is useful for testing and creating examples.
39
39
 
40
+ // When the experiment is enabled, use useEffect instead of useLayoutEffect because:
41
+ // - For the ssr.config branch: useState is already initialised with ssr.config, so this
42
+ // effect is a no-op on first render — the "before paint" guarantee is irrelevant.
43
+ // - For the mediaProvider branch: the actual work happens inside a Promise callback which
44
+ // resolves asynchronously, so it can never run before paint regardless of which hook
45
+ // schedules it — useLayoutEffect's guarantee is equally irrelevant here.
46
+ // The legacy path keeps useLayoutEffect to preserve existing behaviour when the experiment is off.
47
+ //
48
+ // The two hooks below are mutually exclusive — only one runs per render — so there is no
49
+ // actual chaining of state updates at runtime. The lint rule cannot statically prove this.
50
+ useEffect(() => {
51
+ if (!expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
52
+ return;
53
+ }
54
+ if (ssr !== null && ssr !== void 0 && ssr.config) {
55
+ // eslint-disable-next-line @atlassian/perf-linting/no-chain-state-updates
56
+ setMediaClientConfig(ssr.config);
57
+ } else if (mediaProvider) {
58
+ let cancelled = false;
59
+ // Cancellation flag prevents setMediaClientConfig from being called after
60
+ // unmount or when mediaProvider changes mid-flight (stale promise fix).
61
+ // No .catch() is needed — the media provider is not expected to reject,
62
+ // and a catch handler would be a no-op anyway.
63
+ mediaProvider.then(provider => {
64
+ if (!cancelled) {
65
+ setMediaClientConfig(provider.viewMediaClientConfig);
66
+ }
67
+ });
68
+ return () => {
69
+ cancelled = true;
70
+ };
71
+ }
72
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
73
+
74
+ // Legacy path (experiment off): keep useLayoutEffect to preserve existing behaviour.
75
+ // remove this when clean up platform_editor_media_reliability_enhancements
40
76
  useLayoutEffect(() => {
77
+ if (expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
78
+ return;
79
+ }
41
80
  if (ssr !== null && ssr !== void 0 && ssr.config) {
42
81
  setMediaClientConfig(ssr.config);
43
82
  } else if (mediaProvider) {
@@ -45,7 +84,7 @@ export const EditorMediaClientProvider = ({
45
84
  setMediaClientConfig(provider.viewMediaClientConfig);
46
85
  });
47
86
  }
48
- }, [mediaProvider, ssr]);
87
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
49
88
  return /*#__PURE__*/React.createElement(MediaClientContext.Provider, {
50
89
  value: shouldSkipContext ? mediaClient : contextMediaClient
51
90
  }, children);
@@ -1,12 +1,14 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useContext, useLayoutEffect, useMemo, useState } from 'react';
2
+ import React, { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react';
3
3
  import { MediaClientContext, getMediaClient } from '@atlaskit/media-client-react';
4
4
  import { useProviderFactory, useProviderLayout } from '@atlaskit/editor-common/provider-factory';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  export var EditorMediaClientProvider = function EditorMediaClientProvider(_ref) {
7
7
  var children = _ref.children,
8
8
  ssr = _ref.ssr;
9
- var _useState = useState(),
9
+ var _useState = useState(function () {
10
+ return expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true) ? ssr === null || ssr === void 0 ? void 0 : ssr.config : undefined;
11
+ }),
10
12
  _useState2 = _slicedToArray(_useState, 2),
11
13
  mediaClientConfig = _useState2[0],
12
14
  setMediaClientConfig = _useState2[1];
@@ -42,7 +44,46 @@ export var EditorMediaClientProvider = function EditorMediaClientProvider(_ref)
42
44
  // and provide a top level mediaClient context
43
45
  // This is useful for testing and creating examples.
44
46
 
47
+ // When the experiment is enabled, use useEffect instead of useLayoutEffect because:
48
+ // - For the ssr.config branch: useState is already initialised with ssr.config, so this
49
+ // effect is a no-op on first render — the "before paint" guarantee is irrelevant.
50
+ // - For the mediaProvider branch: the actual work happens inside a Promise callback which
51
+ // resolves asynchronously, so it can never run before paint regardless of which hook
52
+ // schedules it — useLayoutEffect's guarantee is equally irrelevant here.
53
+ // The legacy path keeps useLayoutEffect to preserve existing behaviour when the experiment is off.
54
+ //
55
+ // The two hooks below are mutually exclusive — only one runs per render — so there is no
56
+ // actual chaining of state updates at runtime. The lint rule cannot statically prove this.
57
+ useEffect(function () {
58
+ if (!expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
59
+ return;
60
+ }
61
+ if (ssr !== null && ssr !== void 0 && ssr.config) {
62
+ // eslint-disable-next-line @atlassian/perf-linting/no-chain-state-updates
63
+ setMediaClientConfig(ssr.config);
64
+ } else if (mediaProvider) {
65
+ var cancelled = false;
66
+ // Cancellation flag prevents setMediaClientConfig from being called after
67
+ // unmount or when mediaProvider changes mid-flight (stale promise fix).
68
+ // No .catch() is needed — the media provider is not expected to reject,
69
+ // and a catch handler would be a no-op anyway.
70
+ mediaProvider.then(function (provider) {
71
+ if (!cancelled) {
72
+ setMediaClientConfig(provider.viewMediaClientConfig);
73
+ }
74
+ });
75
+ return function () {
76
+ cancelled = true;
77
+ };
78
+ }
79
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
80
+
81
+ // Legacy path (experiment off): keep useLayoutEffect to preserve existing behaviour.
82
+ // remove this when clean up platform_editor_media_reliability_enhancements
45
83
  useLayoutEffect(function () {
84
+ if (expValEquals('platform_editor_media_reliability_enhancements', 'isEnabled', true)) {
85
+ return;
86
+ }
46
87
  if (ssr !== null && ssr !== void 0 && ssr.config) {
47
88
  setMediaClientConfig(ssr.config);
48
89
  } else if (mediaProvider) {
@@ -50,7 +91,7 @@ export var EditorMediaClientProvider = function EditorMediaClientProvider(_ref)
50
91
  setMediaClientConfig(provider.viewMediaClientConfig);
51
92
  });
52
93
  }
53
- }, [mediaProvider, ssr]);
94
+ }, [mediaProvider, ssr === null || ssr === void 0 ? void 0 : ssr.config]);
54
95
  return /*#__PURE__*/React.createElement(MediaClientContext.Provider, {
55
96
  value: shouldSkipContext ? mediaClient : contextMediaClient
56
97
  }, children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "130.6.4",
3
+ "version": "131.1.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,13 +30,13 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@atlaskit/adf-schema": "^52.11.0",
34
- "@atlaskit/adf-utils": "^19.29.0",
33
+ "@atlaskit/adf-schema": "^52.12.0",
34
+ "@atlaskit/adf-utils": "^19.30.0",
35
35
  "@atlaskit/afm-i18n-platform-editor-renderer": "2.10.0",
36
36
  "@atlaskit/analytics-listeners": "^10.1.0",
37
37
  "@atlaskit/analytics-namespaced-context": "^7.3.0",
38
38
  "@atlaskit/analytics-next": "^11.2.0",
39
- "@atlaskit/browser-apis": "^0.0.1",
39
+ "@atlaskit/browser-apis": "^0.0.2",
40
40
  "@atlaskit/button": "^23.11.0",
41
41
  "@atlaskit/code": "^17.5.0",
42
42
  "@atlaskit/editor-json-transformer": "^8.32.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/feature-gate-js-client": "^5.7.0",
49
49
  "@atlaskit/icon": "^35.0.0",
50
50
  "@atlaskit/link": "^3.4.0",
51
- "@atlaskit/link-datasource": "^5.2.0",
51
+ "@atlaskit/link-datasource": "^5.3.0",
52
52
  "@atlaskit/link-extractors": "^2.6.0",
53
53
  "@atlaskit/linking-common": "^9.11.0",
54
54
  "@atlaskit/media-card": "^80.5.0",
@@ -66,7 +66,7 @@
66
66
  "@atlaskit/status": "^4.1.0",
67
67
  "@atlaskit/task-decision": "^20.1.0",
68
68
  "@atlaskit/theme": "^23.2.0",
69
- "@atlaskit/tmp-editor-statsig": "^81.1.0",
69
+ "@atlaskit/tmp-editor-statsig": "^81.3.0",
70
70
  "@atlaskit/tokens": "^13.0.0",
71
71
  "@atlaskit/tooltip": "^22.2.0",
72
72
  "@atlaskit/visually-hidden": "^3.1.0",
@@ -80,7 +80,7 @@
80
80
  "uuid": "^3.1.0"
81
81
  },
82
82
  "peerDependencies": {
83
- "@atlaskit/editor-common": "^114.35.0",
83
+ "@atlaskit/editor-common": "^114.36.0",
84
84
  "@atlaskit/link-provider": "^4.4.0",
85
85
  "@atlaskit/media-core": "^37.1.0",
86
86
  "react": "^18.2.0",
@@ -98,7 +98,7 @@
98
98
  "@atlaskit/media-integration-test-helpers": "workspace:^",
99
99
  "@atlaskit/media-test-helpers": "^41.1.0",
100
100
  "@atlaskit/mention": "^26.0.0",
101
- "@atlaskit/modal-dialog": "^15.0.0",
101
+ "@atlaskit/modal-dialog": "^15.1.0",
102
102
  "@atlaskit/navigation-system": "^9.4.0",
103
103
  "@atlaskit/profilecard": "^25.7.0",
104
104
  "@atlaskit/side-nav-items": "^1.13.0",
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RendererActionsContext", {
7
- enumerable: true,
8
- get: function get() {
9
- return _RendererActionsContext.RendererActionsContext;
10
- }
11
- });
12
- Object.defineProperty(exports, "RendererActionsContextConsumer", {
13
- enumerable: true,
14
- get: function get() {
15
- return _RendererActionsContext.RendererActionsContextConsumer;
16
- }
17
- });
18
- Object.defineProperty(exports, "WithRendererActions", {
19
- enumerable: true,
20
- get: function get() {
21
- return _WithRendererActions.WithRendererActions;
22
- }
23
- });
24
- var _RendererActionsContext = require("./ui/RendererActionsContext");
25
- var _WithRendererActions = require("./ui/RendererActionsContext/WithRendererActions");
@@ -1,7 +0,0 @@
1
- /* eslint-disable @atlaskit/editor/no-re-export */
2
- // Entry file in package.json
3
-
4
- import { RendererActionsContext, RendererActionsContextConsumer } from './ui/RendererActionsContext';
5
- import { WithRendererActions } from './ui/RendererActionsContext/WithRendererActions';
6
- // This file exists purely as an entry point, until they are configurable.
7
- export { RendererActionsContext, RendererActionsContextConsumer, WithRendererActions };
@@ -1,7 +0,0 @@
1
- /* eslint-disable @atlaskit/editor/no-re-export */
2
- // Entry file in package.json
3
-
4
- import { RendererActionsContext, RendererActionsContextConsumer } from './ui/RendererActionsContext';
5
- import { WithRendererActions } from './ui/RendererActionsContext/WithRendererActions';
6
- // This file exists purely as an entry point, until they are configurable.
7
- export { RendererActionsContext, RendererActionsContextConsumer, WithRendererActions };
@@ -1,4 +0,0 @@
1
- import { RendererActionsContext, RendererActionsContextConsumer } from './ui/RendererActionsContext';
2
- import { WithRendererActions } from './ui/RendererActionsContext/WithRendererActions';
3
- export type { default as RendererActions } from './actions/';
4
- export { RendererActionsContext, RendererActionsContextConsumer, WithRendererActions };
@@ -1,4 +0,0 @@
1
- import { RendererActionsContext, RendererActionsContextConsumer } from './ui/RendererActionsContext';
2
- import { WithRendererActions } from './ui/RendererActionsContext/WithRendererActions';
3
- export type { default as RendererActions } from './actions/';
4
- export { RendererActionsContext, RendererActionsContextConsumer, WithRendererActions };