@fluidframework/react 2.81.1 → 2.82.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,9 @@
1
1
  # @fluidframework/react
2
2
 
3
+ ## 2.82.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.81.0
4
8
 
5
9
  Dependency updates only.
@@ -1 +1 @@
1
- {"version":3,"file":"useTree.spec.js","sourceRoot":"","sources":["../../src/test/useTree.spec.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACN,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,GACpB,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACxB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QAC1B,IAAI,OAAmB,CAAC;QAExB,MAAM,CAAC,GAAG,EAAE;YACX,OAAO,GAAG,WAAW,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,EAAE;YACV,OAAO,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACvC,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,IAAK,SAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,EA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MAAM,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;oBACtD,cAAc,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;oBAC/E,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;oBACxB,cAAc,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC;oBAChD,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3B,cAAc,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;oBACpC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACvB,UAAU,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAC7C,cAAc,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC;oBAChD,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3B,cAAc,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;oBAE/C,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBACvD,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAa;IACpC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport { SchemaFactory } from \"@fluidframework/tree\";\nimport { render } from \"@testing-library/react\";\nimport globalJsdom from \"global-jsdom\";\nimport * as React from \"react\";\n\nimport { toPropTreeNode, type PropTreeNode } from \"../propNode.js\";\nimport { objectIdNumber } from \"../simpleIdentifier.js\";\nimport {\n\tusePropTreeNode,\n\twithMemoizedTreeObservations,\n\twithTreeObservations,\n} from \"../useTree.js\";\n\ndescribe(\"useTree\", () => {\n\tdescribe(\"dom tests\", () => {\n\t\tlet cleanup: () => void;\n\n\t\tbefore(() => {\n\t\t\tcleanup = globalJsdom();\n\t\t});\n\n\t\tafter(() => {\n\t\t\tcleanup();\n\t\t});\n\n\t\tit(\"withTreeObservations example\", () => {\n\t\t\tconst builder = new SchemaFactory(\"example\");\n\t\t\tclass Item extends builder.object(\"Item\", { text: SchemaFactory.string }) {}\n\t\t\tconst ItemComponentBug = ({ item }: { item: Item }): JSX.Element => (\n\t\t\t\t<span>{item.text}</span> // Reading `text`, a mutable value from a React prop, causes an invalidation bug.\n\t\t\t);\n\n\t\t\tconst ItemComponent = withTreeObservations(\n\t\t\t\t({ item }: { item: Item }): JSX.Element => <span>{item.text}</span>,\n\t\t\t);\n\n\t\t\tconst ItemParentComponent = ({ item }: { item: PropTreeNode<Item> }): JSX.Element => (\n\t\t\t\t<ItemComponent item={item} />\n\t\t\t);\n\n\t\t\tconst InvalidItemParentComponent = ({\n\t\t\t\titem,\n\t\t\t}: { item: PropTreeNode<Item> }): JSX.Element => (\n\t\t\t\t// @ts-expect-error PropTreeNode turns this invalidation bug into a compile error\n\t\t\t\t<span>{item.text}</span>\n\t\t\t);\n\t\t});\n\n\t\tfor (const reactStrictMode of [false, true]) {\n\t\t\t/**\n\t\t\t * Check then clear, the contents of `log`.\n\t\t\t *\n\t\t\t * When in StrictMode, React may double render, so that case is not checked for an exact match.\n\t\t\t */\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction checkRenderLog(log: string[], expected: readonly string[]): void {\n\t\t\t\tif (reactStrictMode) {\n\t\t\t\t\tassert.deepEqual(new Set(log), new Set(expected));\n\t\t\t\t} else {\n\t\t\t\t\tassert.deepEqual(log, expected);\n\t\t\t\t}\n\t\t\t\tlog.length = 0;\n\t\t\t}\n\n\t\t\tdescribe(`StrictMode: ${reactStrictMode}`, () => {\n\t\t\t\tit(\"usePropTreeNode\", () => {\n\t\t\t\t\tconst builder = new SchemaFactory(\"tree-react-api\");\n\n\t\t\t\t\tclass Point extends builder.object(\"Point\", {\n\t\t\t\t\t\tx: builder.number,\n\t\t\t\t\t\ty: builder.number,\n\t\t\t\t\t}) {}\n\n\t\t\t\t\tconst log: string[] = [];\n\n\t\t\t\t\tfunction PointComponent(props: { node: PropTreeNode<Point> }): JSX.Element {\n\t\t\t\t\t\tlog.push(\"render\");\n\t\t\t\t\t\tconst { x, y } = usePropTreeNode(props.node, (node) => {\n\t\t\t\t\t\t\tlog.push(`usePropTreeNode`);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tx: node.x,\n\t\t\t\t\t\t\t\ty: node.y,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn <span>{`x: ${x}, y: ${y}`}</span>;\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction ParentComponent(props: { node: PropTreeNode<Point> }): JSX.Element {\n\t\t\t\t\t\tlog.push(\"parent\");\n\t\t\t\t\t\treturn <PointComponent node={props.node} />;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst point = new Point({ x: 1, y: 1 });\n\t\t\t\t\tconst propPoint = toPropTreeNode(point);\n\n\t\t\t\t\tconst content = <ParentComponent node={propPoint} />;\n\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"x: 1, y: 1\");\n\t\t\t\t\tcheckRenderLog(log, [\"parent\", \"render\", \"usePropTreeNode\"]);\n\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tassertLogEmpty(log);\n\n\t\t\t\t\tpoint.x = 2;\n\t\t\t\t\tassertLogEmpty(log);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\t// Parent which passed node down did not rerender, but PointComponent which read from it did:\n\t\t\t\t\tcheckRenderLog(log, [\"render\", \"usePropTreeNode\"]);\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"x: 2, y: 1\");\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tdescribe(\"withTreeObservations and array\", () => {\n\t\t\t\tconst builder = new SchemaFactory(\"tree-react-api\");\n\n\t\t\t\tclass Item extends builder.object(\"Item\", {\n\t\t\t\t\tx: SchemaFactory.number,\n\t\t\t\t}) {}\n\n\t\t\t\tclass Collection extends builder.array(\"Collection\", Item) {}\n\n\t\t\t\tbeforeEach(() => {\n\t\t\t\t\t// Ensure the log starts empty for each test.\n\t\t\t\t\tlog.length = 0;\n\t\t\t\t});\n\n\t\t\t\tconst log: string[] = [];\n\n\t\t\t\tconst ItemComponent = withMemoizedTreeObservations(\n\t\t\t\t\t(props: { item: Item }): JSX.Element => {\n\t\t\t\t\t\tlog.push(`Item: ${props.item.x}`);\n\t\t\t\t\t\treturn <span>{`${props.item.x}`}</span>;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Item invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tconst CollectionComponent = withTreeObservations(\n\t\t\t\t\t(props: { collection: Collection }): JSX.Element => {\n\t\t\t\t\t\tlog.push(\"Collection\");\n\n\t\t\t\t\t\tconst items = props.collection.map((item) => (\n\t\t\t\t\t\t\t<ItemComponent key={objectIdNumber(item)} item={item} />\n\t\t\t\t\t\t));\n\n\t\t\t\t\t\treturn <div>{items}</div>;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Collection invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tconst ParentComponent = withTreeObservations(\n\t\t\t\t\t(props: { node: Collection }): JSX.Element => {\n\t\t\t\t\t\tlog.push(\"Parent\");\n\t\t\t\t\t\treturn <CollectionComponent collection={props.node} />;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Parent invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tit(\"empty\", () => {\n\t\t\t\t\tconst collection = new Collection([]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\trender(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\"]);\n\t\t\t\t});\n\n\t\t\t\t// This confirms that modifying an array does not needlessly invalid parents and reuses children (if they use memo)\n\t\t\t\tit(\"array editing: insertion\", () => {\n\t\t\t\t\tconst collection = new Collection([{ x: 1 }, { x: 2 }, { x: 3 }]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\", \"Item: 1\", \"Item: 2\", \"Item: 3\"]);\n\t\t\t\t\tcollection.insertAtEnd(new Item({ x: 4 }));\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\", \"Item: 4\"]);\n\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"1234\");\n\t\t\t\t});\n\n\t\t\t\t// This confirms the same as the above, but testes some harder cases.\n\t\t\t\t// For example this one depends on stable keys to reusing children due to indexes changing.\n\t\t\t\tit(\"array editing: general\", () => {\n\t\t\t\t\tconst collection = new Collection([{ x: 1 }, { x: 2 }, { x: 3 }]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\", \"Item: 1\", \"Item: 2\", \"Item: 3\"]);\n\t\t\t\t\tcollection.moveToEnd(0);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\"]);\n\t\t\t\t\tcollection.removeAt(1);\n\t\t\t\t\tcollection.insertAtStart(new Item({ x: 4 }));\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\", \"Item: 4\"]);\n\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"421\");\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n});\n\n/**\n * Assert that an array is empty.\n *\n * Not inlined because doing so causes TypeScript to infer the array type as never[] afterwards and breaks push.\n * Better than asserting length is 0 as this gets a better error message on failure.\n */\nfunction assertLogEmpty(log: string[]): void {\n\tassert.deepEqual(log, []);\n}\n"]}
1
+ {"version":3,"file":"useTree.spec.js","sourceRoot":"","sources":["../../src/test/useTree.spec.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACN,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,GACpB,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACxB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QAC1B,IAAI,OAAmB,CAAC;QAExB,MAAM,CAAC,GAAG,EAAE;YACX,OAAO,GAAG,WAAW,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,EAAE;YACV,OAAO,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAA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ights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"node:assert\";\n\nimport { SchemaFactory } from \"@fluidframework/tree\";\nimport { render } from \"@testing-library/react\";\nimport globalJsdom from \"global-jsdom\";\nimport * as React from \"react\";\n\nimport { toPropTreeNode, type PropTreeNode } from \"../propNode.js\";\nimport { objectIdNumber } from \"../simpleIdentifier.js\";\nimport {\n\tusePropTreeNode,\n\twithMemoizedTreeObservations,\n\twithTreeObservations,\n} from \"../useTree.js\";\n\ndescribe(\"useTree\", () => {\n\tdescribe(\"dom tests\", () => {\n\t\tlet cleanup: () => void;\n\n\t\tbefore(() => {\n\t\t\tcleanup = globalJsdom();\n\t\t});\n\n\t\tafter(() => {\n\t\t\tcleanup();\n\t\t});\n\n\t\tit(\"withTreeObservations example\", () => {\n\t\t\tconst builder = new SchemaFactory(\"example\");\n\t\t\tclass Item extends builder.object(\"Item\", { text: SchemaFactory.string }) {}\n\t\t\tconst ItemComponentBug = ({ item }: { item: Item }): JSX.Element => (\n\t\t\t\t<span>{item.text}</span> // Reading `text`, a mutable value from a React prop, causes an invalidation bug.\n\t\t\t);\n\n\t\t\tconst ItemComponent = withTreeObservations(\n\t\t\t\t({ item }: { item: Item }): JSX.Element => <span>{item.text}</span>,\n\t\t\t);\n\n\t\t\tconst ItemParentComponent = ({ item }: { item: PropTreeNode<Item> }): JSX.Element => (\n\t\t\t\t<ItemComponent item={item} />\n\t\t\t);\n\n\t\t\tconst InvalidItemParentComponent = ({\n\t\t\t\titem,\n\t\t\t}: {\n\t\t\t\titem: PropTreeNode<Item>;\n\t\t\t}): JSX.Element => (\n\t\t\t\t// @ts-expect-error PropTreeNode turns this invalidation bug into a compile error\n\t\t\t\t<span>{item.text}</span>\n\t\t\t);\n\t\t});\n\n\t\tfor (const reactStrictMode of [false, true]) {\n\t\t\t/**\n\t\t\t * Check then clear, the contents of `log`.\n\t\t\t *\n\t\t\t * When in StrictMode, React may double render, so that case is not checked for an exact match.\n\t\t\t */\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction checkRenderLog(log: string[], expected: readonly string[]): void {\n\t\t\t\tif (reactStrictMode) {\n\t\t\t\t\tassert.deepEqual(new Set(log), new Set(expected));\n\t\t\t\t} else {\n\t\t\t\t\tassert.deepEqual(log, expected);\n\t\t\t\t}\n\t\t\t\tlog.length = 0;\n\t\t\t}\n\n\t\t\tdescribe(`StrictMode: ${reactStrictMode}`, () => {\n\t\t\t\tit(\"usePropTreeNode\", () => {\n\t\t\t\t\tconst builder = new SchemaFactory(\"tree-react-api\");\n\n\t\t\t\t\tclass Point extends builder.object(\"Point\", {\n\t\t\t\t\t\tx: builder.number,\n\t\t\t\t\t\ty: builder.number,\n\t\t\t\t\t}) {}\n\n\t\t\t\t\tconst log: string[] = [];\n\n\t\t\t\t\tfunction PointComponent(props: { node: PropTreeNode<Point> }): JSX.Element {\n\t\t\t\t\t\tlog.push(\"render\");\n\t\t\t\t\t\tconst { x, y } = usePropTreeNode(props.node, (node) => {\n\t\t\t\t\t\t\tlog.push(`usePropTreeNode`);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tx: node.x,\n\t\t\t\t\t\t\t\ty: node.y,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn <span>{`x: ${x}, y: ${y}`}</span>;\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction ParentComponent(props: { node: PropTreeNode<Point> }): JSX.Element {\n\t\t\t\t\t\tlog.push(\"parent\");\n\t\t\t\t\t\treturn <PointComponent node={props.node} />;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst point = new Point({ x: 1, y: 1 });\n\t\t\t\t\tconst propPoint = toPropTreeNode(point);\n\n\t\t\t\t\tconst content = <ParentComponent node={propPoint} />;\n\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"x: 1, y: 1\");\n\t\t\t\t\tcheckRenderLog(log, [\"parent\", \"render\", \"usePropTreeNode\"]);\n\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tassertLogEmpty(log);\n\n\t\t\t\t\tpoint.x = 2;\n\t\t\t\t\tassertLogEmpty(log);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\t// Parent which passed node down did not rerender, but PointComponent which read from it did:\n\t\t\t\t\tcheckRenderLog(log, [\"render\", \"usePropTreeNode\"]);\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"x: 2, y: 1\");\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tdescribe(\"withTreeObservations and array\", () => {\n\t\t\t\tconst builder = new SchemaFactory(\"tree-react-api\");\n\n\t\t\t\tclass Item extends builder.object(\"Item\", {\n\t\t\t\t\tx: SchemaFactory.number,\n\t\t\t\t}) {}\n\n\t\t\t\tclass Collection extends builder.array(\"Collection\", Item) {}\n\n\t\t\t\tbeforeEach(() => {\n\t\t\t\t\t// Ensure the log starts empty for each test.\n\t\t\t\t\tlog.length = 0;\n\t\t\t\t});\n\n\t\t\t\tconst log: string[] = [];\n\n\t\t\t\tconst ItemComponent = withMemoizedTreeObservations(\n\t\t\t\t\t(props: { item: Item }): JSX.Element => {\n\t\t\t\t\t\tlog.push(`Item: ${props.item.x}`);\n\t\t\t\t\t\treturn <span>{`${props.item.x}`}</span>;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Item invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tconst CollectionComponent = withTreeObservations(\n\t\t\t\t\t(props: { collection: Collection }): JSX.Element => {\n\t\t\t\t\t\tlog.push(\"Collection\");\n\n\t\t\t\t\t\tconst items = props.collection.map((item) => (\n\t\t\t\t\t\t\t<ItemComponent key={objectIdNumber(item)} item={item} />\n\t\t\t\t\t\t));\n\n\t\t\t\t\t\treturn <div>{items}</div>;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Collection invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tconst ParentComponent = withTreeObservations(\n\t\t\t\t\t(props: { node: Collection }): JSX.Element => {\n\t\t\t\t\t\tlog.push(\"Parent\");\n\t\t\t\t\t\treturn <CollectionComponent collection={props.node} />;\n\t\t\t\t\t},\n\t\t\t\t\t{ onInvalidation: () => log.push(\"Parent invalidated\") },\n\t\t\t\t);\n\n\t\t\t\tit(\"empty\", () => {\n\t\t\t\t\tconst collection = new Collection([]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\trender(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\"]);\n\t\t\t\t});\n\n\t\t\t\t// This confirms that modifying an array does not needlessly invalid parents and reuses children (if they use memo)\n\t\t\t\tit(\"array editing: insertion\", () => {\n\t\t\t\t\tconst collection = new Collection([{ x: 1 }, { x: 2 }, { x: 3 }]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\", \"Item: 1\", \"Item: 2\", \"Item: 3\"]);\n\t\t\t\t\tcollection.insertAtEnd(new Item({ x: 4 }));\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\", \"Item: 4\"]);\n\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"1234\");\n\t\t\t\t});\n\n\t\t\t\t// This confirms the same as the above, but testes some harder cases.\n\t\t\t\t// For example this one depends on stable keys to reusing children due to indexes changing.\n\t\t\t\tit(\"array editing: general\", () => {\n\t\t\t\t\tconst collection = new Collection([{ x: 1 }, { x: 2 }, { x: 3 }]);\n\t\t\t\t\tconst content = <ParentComponent node={collection} />;\n\t\t\t\t\tconst rendered = render(content, { reactStrictMode });\n\t\t\t\t\tcheckRenderLog(log, [\"Parent\", \"Collection\", \"Item: 1\", \"Item: 2\", \"Item: 3\"]);\n\t\t\t\t\tcollection.moveToEnd(0);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\"]);\n\t\t\t\t\tcollection.removeAt(1);\n\t\t\t\t\tcollection.insertAtStart(new Item({ x: 4 }));\n\t\t\t\t\tcheckRenderLog(log, [\"Collection invalidated\"]);\n\t\t\t\t\trendered.rerender(content);\n\t\t\t\t\tcheckRenderLog(log, [\"Collection\", \"Item: 4\"]);\n\n\t\t\t\t\tassert.equal(rendered.baseElement.textContent, \"421\");\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n});\n\n/**\n * Assert that an array is empty.\n *\n * Not inlined because doing so causes TypeScript to infer the array type as never[] afterwards and breaks push.\n * Better than asserting length is 0 as this gets a better error message on failure.\n */\nfunction assertLogEmpty(log: string[]): void {\n\tassert.deepEqual(log, []);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/react",
3
- "version": "2.81.1",
3
+ "version": "2.82.0",
4
4
  "description": "Utilities for integrating content powered by the Fluid Framework into React applications",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -79,28 +79,28 @@
79
79
  "temp-directory": "nyc/.nyc_output"
80
80
  },
81
81
  "dependencies": {
82
- "@fluidframework/aqueduct": "~2.81.1",
83
- "@fluidframework/core-interfaces": "~2.81.1",
84
- "@fluidframework/datastore-definitions": "~2.81.1",
85
- "@fluidframework/fluid-static": "~2.81.1",
86
- "@fluidframework/runtime-definitions": "~2.81.1",
87
- "@fluidframework/shared-object-base": "~2.81.1",
88
- "@fluidframework/tree": "~2.81.1",
82
+ "@fluidframework/aqueduct": "~2.82.0",
83
+ "@fluidframework/core-interfaces": "~2.82.0",
84
+ "@fluidframework/datastore-definitions": "~2.82.0",
85
+ "@fluidframework/fluid-static": "~2.82.0",
86
+ "@fluidframework/runtime-definitions": "~2.82.0",
87
+ "@fluidframework/shared-object-base": "~2.82.0",
88
+ "@fluidframework/tree": "~2.82.0",
89
89
  "react": "^18.3.1"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@arethetypeswrong/cli": "^0.18.2",
93
93
  "@biomejs/biome": "~1.9.3",
94
- "@fluid-internal/mocha-test-setup": "~2.81.1",
94
+ "@fluid-internal/mocha-test-setup": "~2.82.0",
95
95
  "@fluid-tools/build-cli": "^0.63.0",
96
96
  "@fluidframework/build-common": "^2.0.3",
97
97
  "@fluidframework/build-tools": "^0.63.0",
98
- "@fluidframework/eslint-config-fluid": "~2.81.1",
99
- "@fluidframework/tinylicious-client": "~2.81.1",
98
+ "@fluidframework/eslint-config-fluid": "~2.82.0",
99
+ "@fluidframework/tinylicious-client": "~2.82.0",
100
100
  "@microsoft/api-extractor": "7.52.11",
101
101
  "@testing-library/react": "^16.3.0",
102
102
  "@types/mocha": "^10.0.10",
103
- "@types/node": "^18.19.0",
103
+ "@types/node": "~20.19.30",
104
104
  "@types/react": "^18.3.11",
105
105
  "c8": "^10.1.3",
106
106
  "concurrently": "^9.2.1",
Binary file
package/biome.jsonc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
- "extends": ["../../../biome.jsonc"]
4
- }