@forge/react 12.1.0 → 12.1.1-next.0-experimental-620648d

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
  # @forge/react
2
2
 
3
+ ## 12.1.1-next.0-experimental-620648d
4
+
5
+ ### Patch Changes
6
+
7
+ - d706cd8: Normalise props when preparing update in reconciler to fix serialisation bug when running in React's development mode
8
+ - @forge/bridge@6.1.2-next.0-experimental-620648d
9
+
10
+ ## 12.1.1-next.0
11
+
12
+ ### Patch Changes
13
+
14
+ - d706cd8: Normalise props when preparing update in reconciler to fix serialisation bug when running in React's development mode
15
+ - @forge/bridge@6.1.2-next.0
16
+
3
17
  ## 12.1.0
4
18
 
5
19
  ### Minor Changes
@@ -69,7 +69,7 @@ describe('hostConfig used functions', () => {
69
69
  const newProps = {
70
70
  updated: true
71
71
  };
72
- expect(reconciler_1.hostConfig.prepareUpdate(instance, 'test', {}, newProps, emptyForgeDoc, null)).toBe(newProps);
72
+ expect(reconciler_1.hostConfig.prepareUpdate(instance, 'test', {}, newProps, emptyForgeDoc, null)).toEqual(newProps);
73
73
  expect(instance).not.toHaveProperty('oldProps');
74
74
  expect(instance).toHaveProperty('props', newProps);
75
75
  });
@@ -1 +1 @@
1
- {"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI1D,KAAK,WAAW,GAAG,MAAM,CAAC;AAC1B,KAAK,YAAY,GAAG,aAAa,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB,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GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,EAAE,aAAa,QAAQ,SAOpF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,aAAa,EAAE,UAAU,aAAa,YAerF,CAAC;AAEF,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACzC,KAAK,SAAS,GAAG,QAAQ,CAAC;AAC1B,KAAK,QAAQ,GAAG,QAAQ,CAAC;AACzB,KAAK,YAAY,GAAG,QAAQ,CAAC;AAC7B,KAAK,gBAAgB,GAAG,QAAQ,CAAC;AACjC,KAAK,kBAAkB,GAAG,QAAQ,CAAC;AACnC,KAAK,cAAc,GAAG,QAAQ,CAAC;AAE/B,KAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,KAAK,QAAQ,GAAG,GAAG,CAAC;AACpB,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AACnD,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC;AAEpB,eAAO,MAAM,UAAU,EAAE,UAAU,CACjC,cAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,aAAa,EACb,SAAS,CAgJV,CAAC;AAIF,eAAO,MAAM,eAAe;sBACR,YAAY;yBAwBT,YAAY;CAiBlC,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/out/reconciler.js CHANGED
@@ -33,6 +33,17 @@ const attachFunctionPropId = (props) => {
33
33
  }
34
34
  return props;
35
35
  };
36
+ // Normalises raw React props into the props stored on a ForgeDoc: the `children`
37
+ // prop is dropped (children are tracked separately on the ForgeDoc tree) and the
38
+ // id/function-id transforms are applied. Keeping the `children` React element out
39
+ // of the serialised props is important: in React's development build a React
40
+ // element carries an `_owner` fiber reference, which produces a circular
41
+ // structure when the reconcile payload is JSON-serialised over the bridge.
42
+ const normaliseProps = (props) => {
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ const { children, ...restProps } = props;
45
+ return newPropsWithIdPrefix(attachFunctionPropId(restProps));
46
+ };
36
47
  const handleReconcilerError = async (error) => {
37
48
  try {
38
49
  await self?.__bridge?.callBridge('onError', { error });
@@ -49,9 +60,7 @@ const callBridge = function (cmd, data) {
49
60
  };
50
61
  exports.callBridge = callBridge;
51
62
  const createElement = ({ type, props = {}, forgeReactMajorVersion }) => {
52
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
- const { children, ...restProps } = props;
54
- const newProps = newPropsWithIdPrefix(attachFunctionPropId(restProps));
63
+ const newProps = normaliseProps(props);
55
64
  const element = {
56
65
  type,
57
66
  children: [],
@@ -138,8 +147,9 @@ exports.hostConfig = {
138
147
  return false;
139
148
  },
140
149
  prepareUpdate(instance, type, oldProps, newProps) {
141
- instance.props = newProps;
142
- return newProps;
150
+ const normalisedProps = normaliseProps(newProps);
151
+ instance.props = normalisedProps;
152
+ return normalisedProps;
143
153
  },
144
154
  shouldSetTextContent() {
145
155
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/react",
3
- "version": "12.1.0",
3
+ "version": "12.1.1-next.0-experimental-620648d",
4
4
  "description": "Forge React reconciler",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/adf-schema": "^48.0.0",
37
37
  "@atlaskit/adf-utils": "^19.19.0",
38
38
  "@atlaskit/forge-react-types": "^2.3.0",
39
- "@forge/bridge": "^6.1.1",
39
+ "@forge/bridge": "^6.1.2-next.0-experimental-620648d",
40
40
  "@forge/egress": "^3.0.0",
41
41
  "@forge/i18n": "1.0.0",
42
42
  "@types/react": "^18.2.64",