From a5ea5e1acdc9bfd0f2f870b41ed79126813d0c12 Mon Sep 17 00:00:00 2001 From: ja-ni Date: Mon, 8 Apr 2024 15:13:21 +0200 Subject: [PATCH 1/6] reverts package json changes --- packages/@react-facet/deferred-mount/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@react-facet/deferred-mount/package.json b/packages/@react-facet/deferred-mount/package.json index ba93be5..010e8b5 100644 --- a/packages/@react-facet/deferred-mount/package.json +++ b/packages/@react-facet/deferred-mount/package.json @@ -30,7 +30,7 @@ "bugs": "https://github.com/Mojang/ore-ui/issues", "license": "MIT", "version": "0.5.4", - "main": "dist/index.js", + "main": "dist/index.tsx", "publishConfig": { "main": "dist/index.js", "types": "dist/index.d.ts" From 1c41accbca4a6a7d57087af32a0df58a681a5099 Mon Sep 17 00:00:00 2001 From: ja-ni Date: Mon, 8 Apr 2024 15:14:14 +0200 Subject: [PATCH 2/6] reverts package json changes again... --- packages/@react-facet/deferred-mount/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@react-facet/deferred-mount/package.json b/packages/@react-facet/deferred-mount/package.json index 010e8b5..ab496fe 100644 --- a/packages/@react-facet/deferred-mount/package.json +++ b/packages/@react-facet/deferred-mount/package.json @@ -30,7 +30,7 @@ "bugs": "https://github.com/Mojang/ore-ui/issues", "license": "MIT", "version": "0.5.4", - "main": "dist/index.tsx", + "main": "src/index.tsx", "publishConfig": { "main": "dist/index.js", "types": "dist/index.d.ts" From b15d3e219a6a44090fb1d1cc2682466295509795 Mon Sep 17 00:00:00 2001 From: Marlon Huber-Smith Date: Tue, 30 Apr 2024 11:47:39 +0200 Subject: [PATCH 3/6] Add unit test for unsubscribing from insertBefore/fast-* component. --- .../dom-fiber/src/setupHostConfig.spec.tsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx index 3ae5a67..44612d6 100644 --- a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx +++ b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx @@ -2041,6 +2041,39 @@ describe('umnount', () => { expect(unsubscribe).toHaveBeenCalledTimes(1) }) + it('unsubscribes from a facet (via a fast-* component) inserted using insertBefore, when the parent is unmounted', () => { + it.only('unsubscribes from all facets when a elements are swapped', () => { + const unsubscribe = jest.fn() + + const facet: Facet = { + get: () => 'abc', + observe: jest.fn().mockReturnValue(unsubscribe), + } + + const TestComponent = ({ show, facet }: { facet: Facet; show?: boolean }) => ( +
+ {show ? : null} +
+
+ ) + + render() + + expect(facet.observe).toHaveBeenCalledTimes(0) + expect(unsubscribe).toHaveBeenCalledTimes(0) + + render() + + expect(facet.observe).toHaveBeenCalledTimes(1) + expect(unsubscribe).toHaveBeenCalledTimes(0) + + render(<>) + + expect(facet.observe).toHaveBeenCalledTimes(1) + expect(unsubscribe).toHaveBeenCalledTimes(1) + }) + }) + it('keeps the subscription of facets when moving in a keyed list', () => { const unsubscribeA = jest.fn() From f70df9c56aadda19311d01c6bfaae9650f3d6e20 Mon Sep 17 00:00:00 2001 From: ja-ni Date: Tue, 7 May 2024 10:43:05 +0200 Subject: [PATCH 4/6] updates performance benchmark, formats code --- .eslintrc.js | 2 +- .github/workflows/benchmarking.yml | 2 +- CONTRIBUTING.md | 4 ++-- tsconfig.json | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2bcd49e..9e9704d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,7 +28,7 @@ module.exports = { 'import/no-cycle': 'error', 'no-unreachable': 'error', 'no-undef': 'error', - 'eqeqeq': 'error', + eqeqeq: 'error', 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'error', 'react/jsx-uses-react': 'error', diff --git a/.github/workflows/benchmarking.yml b/.github/workflows/benchmarking.yml index 3ffab68..0cab045 100644 --- a/.github/workflows/benchmarking.yml +++ b/.github/workflows/benchmarking.yml @@ -36,7 +36,7 @@ jobs: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install --immutable - - run: cd examples/benchmarking && yarn build && yarn compare mountFacetDomFiber mountReactDom 90 + - run: cd examples/benchmarking && yarn build && yarn compare mountFacetDomFiber mountReactDom 91 overhead: runs-on: ubuntu-latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a70bf6..191cae8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Currently the process of updating the version of the packages is mostly manual. Before you start, first you need to make sure you have the permissions to publish the packages. -- If there is a release branch (see __Release candidate__ below) that hasn't been merged to `main` yet now is the time to do so. +- If there is a release branch (see **Release candidate** below) that hasn't been merged to `main` yet now is the time to do so. - Make sure that you are logged in into your `npm` account. Use the command `yarn npm login` on the project folder to do this. - While on the `main` branch. - Perform a search an replace on all "package.json" files from the old version to the new. (ex `0.1.4` to `0.2.0`). @@ -25,4 +25,4 @@ Currently the process of updating the version of the packages is mostly manual. - Create an annotated git tag by running `git tag -a v0.4.0-rc.0` (replace with the version). The tag message can be the version again. - Push commit and the tag `git push --follow-tags`. - Publish the packages by running `yarn publish --tag rc` (it will also build the packages). -- We are currently not doing release notes for release candidates so you are all done! 🎉 \ No newline at end of file +- We are currently not doing release notes for release candidates so you are all done! 🎉 diff --git a/tsconfig.json b/tsconfig.json index a711293..d4840c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,11 @@ { "compilerOptions": { "baseUrl": ".", - "paths": { - "@react-facet/core": ["packages/@react-facet/core/*"], - "@react-facet/dom-fiber": ["packages/@react-facet/dom-fiber/*"], - "@react-facet/dom-fiber-testing-library": ["packages/@react-facet/dom-fiber-testing-library/*"] - }, + "paths": { + "@react-facet/core": ["packages/@react-facet/core/*"], + "@react-facet/dom-fiber": ["packages/@react-facet/dom-fiber/*"], + "@react-facet/dom-fiber-testing-library": ["packages/@react-facet/dom-fiber-testing-library/*"] + }, "outDir": "dist", "target": "es6", "moduleResolution": "node", From 70a7fd7c51b60f24fbb2f585a9ff5a584f932cc6 Mon Sep 17 00:00:00 2001 From: ja-ni Date: Tue, 7 May 2024 11:41:21 +0200 Subject: [PATCH 5/6] removes only test and deferred mount override --- packages/@react-facet/deferred-mount/package.json | 2 +- packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@react-facet/deferred-mount/package.json b/packages/@react-facet/deferred-mount/package.json index ab496fe..ba93be5 100644 --- a/packages/@react-facet/deferred-mount/package.json +++ b/packages/@react-facet/deferred-mount/package.json @@ -30,7 +30,7 @@ "bugs": "https://github.com/Mojang/ore-ui/issues", "license": "MIT", "version": "0.5.4", - "main": "src/index.tsx", + "main": "dist/index.js", "publishConfig": { "main": "dist/index.js", "types": "dist/index.d.ts" diff --git a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx index 44612d6..86a8850 100644 --- a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx +++ b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx @@ -2042,7 +2042,7 @@ describe('umnount', () => { }) it('unsubscribes from a facet (via a fast-* component) inserted using insertBefore, when the parent is unmounted', () => { - it.only('unsubscribes from all facets when a elements are swapped', () => { + it('unsubscribes from all facets when a elements are swapped', () => { const unsubscribe = jest.fn() const facet: Facet = { From 0c93b521bfe1d65225e158f17d4a59c33457c94b Mon Sep 17 00:00:00 2001 From: ja-ni Date: Tue, 7 May 2024 11:54:24 +0200 Subject: [PATCH 6/6] updates broken test file --- .../dom-fiber/src/setupHostConfig.spec.tsx | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx index 86a8850..78b32a9 100644 --- a/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx +++ b/packages/@react-facet/dom-fiber/src/setupHostConfig.spec.tsx @@ -2042,36 +2042,34 @@ describe('umnount', () => { }) it('unsubscribes from a facet (via a fast-* component) inserted using insertBefore, when the parent is unmounted', () => { - it('unsubscribes from all facets when a elements are swapped', () => { - const unsubscribe = jest.fn() + const unsubscribe = jest.fn() - const facet: Facet = { - get: () => 'abc', - observe: jest.fn().mockReturnValue(unsubscribe), - } + const facet: Facet = { + get: () => 'abc', + observe: jest.fn().mockReturnValue(unsubscribe), + } - const TestComponent = ({ show, facet }: { facet: Facet; show?: boolean }) => ( -
- {show ? : null} -
-
- ) + const TestComponent = ({ show, facet }: { facet: Facet; show?: boolean }) => ( +
+ {show ? : null} +
+
+ ) - render() + render() - expect(facet.observe).toHaveBeenCalledTimes(0) - expect(unsubscribe).toHaveBeenCalledTimes(0) + expect(facet.observe).toHaveBeenCalledTimes(0) + expect(unsubscribe).toHaveBeenCalledTimes(0) - render() + render() - expect(facet.observe).toHaveBeenCalledTimes(1) - expect(unsubscribe).toHaveBeenCalledTimes(0) + expect(facet.observe).toHaveBeenCalledTimes(1) + expect(unsubscribe).toHaveBeenCalledTimes(0) - render(<>) + render(<>) - expect(facet.observe).toHaveBeenCalledTimes(1) - expect(unsubscribe).toHaveBeenCalledTimes(1) - }) + expect(facet.observe).toHaveBeenCalledTimes(1) + expect(unsubscribe).toHaveBeenCalledTimes(1) }) it('keeps the subscription of facets when moving in a keyed list', () => {