@atlaskit/media-file-preview 0.11.0 → 0.11.2

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,19 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 0.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#133477](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/133477)
14
+ [`7e502ba2970b9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7e502ba2970b9) -
15
+ Remove media script added during SSR to prevent hydrateRoot mismatch
16
+
3
17
  ## 0.11.0
4
18
 
5
19
  ### Minor Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.printScript = exports.printFunctionCall = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var printParam = function printParam(param) {
10
11
  if (typeof param === 'string') {
11
12
  return "'".concat(param, "'");
@@ -27,6 +28,10 @@ var printFunctionCall = exports.printFunctionCall = function printFunctionCall(f
27
28
  }
28
29
  return "(".concat(fn.toString(), ")(").concat(printParams(args), ");");
29
30
  };
31
+
32
+ // Removing the script tag after execution to prevent hydration
33
+ // mismatch issues after SSR. We don't want to render different
34
+ // HTML on the client and server https://react.dev/reference/react-dom/client/hydrateRoot
30
35
  var printScript = exports.printScript = function printScript(statements) {
31
- return "(function(){\n ".concat(statements.join(';'), "\n})();\n");
36
+ return (0, _platformFeatureFlags.fg)('platform_remove_media_script_after_execution') ? "(function(){\n \t\t\t ".concat(statements.join(';'), "\n \t\t\tdocument.currentScript.remove();\n\t\t})();\n\t\t") : "(function(){\n \t\t\t".concat(statements.join(';'), "\n \t\t})();");
32
37
  };
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  const printParam = param => {
2
3
  if (typeof param === 'string') {
3
4
  return `'${param}'`;
@@ -10,7 +11,14 @@ const printParam = param => {
10
11
  };
11
12
  const printParams = args => args.map(arg => printParam(arg)).join(',');
12
13
  export const printFunctionCall = (fn, ...args) => `(${fn.toString()})(${printParams(args)});`;
13
- export const printScript = statements => `(function(){
14
- ${statements.join(';')}
15
- })();
16
- `;
14
+
15
+ // Removing the script tag after execution to prevent hydration
16
+ // mismatch issues after SSR. We don't want to render different
17
+ // HTML on the client and server https://react.dev/reference/react-dom/client/hydrateRoot
18
+ export const printScript = statements => fg('platform_remove_media_script_after_execution') ? `(function(){
19
+ ${statements.join(';')}
20
+ document.currentScript.remove();
21
+ })();
22
+ ` : `(function(){
23
+ ${statements.join(';')}
24
+ })();`;
@@ -1,4 +1,5 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  var printParam = function printParam(param) {
3
4
  if (typeof param === 'string') {
4
5
  return "'".concat(param, "'");
@@ -20,6 +21,10 @@ export var printFunctionCall = function printFunctionCall(fn) {
20
21
  }
21
22
  return "(".concat(fn.toString(), ")(").concat(printParams(args), ");");
22
23
  };
24
+
25
+ // Removing the script tag after execution to prevent hydration
26
+ // mismatch issues after SSR. We don't want to render different
27
+ // HTML on the client and server https://react.dev/reference/react-dom/client/hydrateRoot
23
28
  export var printScript = function printScript(statements) {
24
- return "(function(){\n ".concat(statements.join(';'), "\n})();\n");
29
+ return fg('platform_remove_media_script_after_execution') ? "(function(){\n \t\t\t ".concat(statements.join(';'), "\n \t\t\tdocument.currentScript.remove();\n\t\t})();\n\t\t") : "(function(){\n \t\t\t".concat(statements.join(';'), "\n \t\t})();");
25
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "A React Hook to fetch and render file previews. It's overloaded with fancy features like SSR, lazy loading, memory cache and local preview.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,10 @@
34
34
  ".": "./src/index.ts"
35
35
  },
36
36
  "dependencies": {
37
- "@atlaskit/media-client": "^32.0.0",
37
+ "@atlaskit/media-client": "^33.0.0",
38
38
  "@atlaskit/media-client-react": "^4.0.0",
39
39
  "@atlaskit/media-common": "^12.0.0",
40
- "@atlaskit/media-ui": "^28.0.0",
40
+ "@atlaskit/media-ui": "^28.1.0",
41
41
  "@atlaskit/platform-feature-flags": "^1.1.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "eventemitter2": "^4.1.0",
@@ -48,13 +48,13 @@
48
48
  "react-dom": "^18.2.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@af/integration-testing": "*",
52
- "@af/visual-regression": "*",
51
+ "@af/integration-testing": "workspace:^",
52
+ "@af/visual-regression": "workspace:^",
53
53
  "@atlaskit/media-state": "^1.5.0",
54
54
  "@atlaskit/media-test-data": "^3.0.0",
55
- "@atlaskit/section-message": "^8.0.0",
56
- "@atlaskit/ssr": "*",
57
- "@atlaskit/visual-regression": "*",
55
+ "@atlaskit/section-message": "^8.2.0",
56
+ "@atlaskit/ssr": "workspace:^",
57
+ "@atlaskit/visual-regression": "workspace:^",
58
58
  "@testing-library/react": "^13.4.0",
59
59
  "@testing-library/react-hooks": "^8.0.1",
60
60
  "react-dom": "^18.2.0",
@@ -96,5 +96,9 @@
96
96
  ]
97
97
  }
98
98
  },
99
- "platform-feature-flags": {}
99
+ "platform-feature-flags": {
100
+ "platform_remove_media_script_after_execution": {
101
+ "type": "boolean"
102
+ }
103
+ }
100
104
  }