From ec18687a981423ad5cd44ed4efee28a29dbf4da7 Mon Sep 17 00:00:00 2001 From: Aria Date: Wed, 25 May 2022 00:37:18 +0200 Subject: [PATCH] Re-do bundling, compat tests, and extension API (#174) --- compatibility-tests/.gitignore | 5 + compatibility-tests/package.json | 6 +- compatibility-tests/scripts/clean.mjs | 3 + compatibility-tests/scripts/utils.mjs | 24 ++- .../.gitignore | 0 .../test-cra-react18/README.md | 1 + .../package.json | 3 +- .../public/index.html | 8 +- .../test-cra-react18/src/App.js | 6 + .../test-cra-react18/src/index.js | 19 +++ .../test-create-react-app/README.md | 16 -- .../test-create-react-app/public/favicon.ico | Bin 3870 -> 0 bytes .../test-create-react-app/public/logo192.png | Bin 5347 -> 0 bytes .../test-create-react-app/public/logo512.png | Bin 9664 -> 0 bytes .../public/manifest.json | 25 --- .../test-create-react-app/public/robots.txt | 3 - .../test-create-react-app/src/App.css | 38 ----- .../test-create-react-app/src/App.js | 150 ------------------ .../test-create-react-app/src/App.test.js | 7 - .../test-create-react-app/src/index.css | 13 -- .../test-create-react-app/src/index.js | 19 --- .../test-create-react-app/src/logo.svg | 1 - .../src/react-app-env.d.ts | 1 - .../src/reportWebVitals.js | 13 -- .../test-create-react-app/src/setupTests.js | 5 - .../test-create-react-app/src/useDrag.js | 130 --------------- compatibility-tests/test-next/.gitignore | 31 ++++ compatibility-tests/test-next/README.md | 1 + compatibility-tests/test-next/package.json | 15 ++ compatibility-tests/test-next/pages/index.js | 23 +++ .../test-next/public/favicon.ico | Bin 0 -> 15086 bytes .../test-parcel1-react18/.gitignore | 3 + .../test-parcel1-react18/index.html | 13 ++ .../test-parcel1-react18/package.json | 13 ++ .../test-parcel1-react18/src/App.js | 6 + .../test-parcel1-react18/src/index.js | 19 +++ .../test-parcel2-react18/.gitignore | 4 + .../test-parcel2-react18/index.html | 13 ++ .../test-parcel2-react18/package.json | 13 ++ .../test-parcel2-react18/src/App.js | 6 + .../test-parcel2-react18/src/index.js | 19 +++ .../test-vite-react18/.gitignore | 24 +++ .../test-vite-react18/index.html | 12 ++ .../test-vite-react18/package.json | 23 +++ .../test-vite-react18/src/App.tsx | 6 + .../test-vite-react18/src/main.tsx | 19 +++ .../test-vite-react18/src/vite-env.d.ts | 1 + .../test-vite-react18/tsconfig.json | 21 +++ .../test-vite-react18/tsconfig.node.json | 8 + .../test-vite-react18/vite.config.ts | 7 + packages/dataverse/devEnv/build.ts | 4 +- packages/dataverse/src/Ticker.ts | 32 ++++ .../derivations/prism/discoveryMechanism.ts | 12 +- packages/playground/devEnv/vite.config.ts | 5 +- .../ReferenceWindow/ReferenceWindow.tsx | 2 +- .../r3f/src/components/SnapshotEditor.tsx | 22 +-- .../r3f/src/components/Toolbar/Toolbar.tsx | 118 -------------- .../Toolbar/TransformControlsModeSelect.tsx | 41 ----- .../Toolbar/TransformControlsSpaceSelect.tsx | 34 ---- .../Toolbar/ViewportShadingSelect.tsx | 46 ------ packages/r3f/src/extension.ts | 142 ++++++++++++++++- theatre/core/src/coreTicker.ts | 12 +- theatre/core/src/sequences/TheatreSequence.ts | 5 + theatre/devEnv/buildUtils.ts | 15 +- theatre/studio/package.json | 5 +- theatre/studio/src/Studio.ts | 3 +- theatre/studio/src/TheatreStudio.ts | 71 ++++++--- theatre/studio/src/UI.ts | 11 ++ theatre/studio/src/UIRoot/UIRoot.tsx | 96 +++++------ theatre/studio/src/css.ts | 45 ------ theatre/studio/src/css.tsx | 146 +++++++++++++++++ theatre/studio/src/index.ts | 9 +- .../panels/BasePanel/ExtensionPaneWrapper.tsx | 26 ++- theatre/studio/src/studioTicker.ts | 11 +- .../toolbars/GlobalToolbar/GlobalToolbar.tsx | 66 +++++--- .../src/toolbars/GlobalToolbar/Toolset.tsx | 53 +++++++ .../GlobalToolbar/tools/IconButton.tsx | 28 ++++ .../toolbars/GlobalToolbar/tools/Switch.tsx | 32 ++++ theatre/studio/src/uiComponents/isSafari.ts | 6 +- .../src/utils/contextualWebComponents.tsx | 58 +++++++ theatre/studio/src/utils/isMac.ts | 3 +- .../src/utils/renderInPortalInContext.tsx | 66 ++++++++ yarn.lock | 3 - 83 files changed, 1138 insertions(+), 886 deletions(-) create mode 100644 compatibility-tests/.gitignore create mode 100644 compatibility-tests/scripts/clean.mjs rename compatibility-tests/{test-create-react-app => test-cra-react18}/.gitignore (100%) create mode 100644 compatibility-tests/test-cra-react18/README.md rename compatibility-tests/{test-create-react-app => test-cra-react18}/package.json (91%) rename compatibility-tests/{test-create-react-app => test-cra-react18}/public/index.html (77%) create mode 100644 compatibility-tests/test-cra-react18/src/App.js create mode 100644 compatibility-tests/test-cra-react18/src/index.js delete mode 100644 compatibility-tests/test-create-react-app/README.md delete mode 100644 compatibility-tests/test-create-react-app/public/favicon.ico delete mode 100644 compatibility-tests/test-create-react-app/public/logo192.png delete mode 100644 compatibility-tests/test-create-react-app/public/logo512.png delete mode 100644 compatibility-tests/test-create-react-app/public/manifest.json delete mode 100644 compatibility-tests/test-create-react-app/public/robots.txt delete mode 100644 compatibility-tests/test-create-react-app/src/App.css delete mode 100644 compatibility-tests/test-create-react-app/src/App.js delete mode 100644 compatibility-tests/test-create-react-app/src/App.test.js delete mode 100644 compatibility-tests/test-create-react-app/src/index.css delete mode 100644 compatibility-tests/test-create-react-app/src/index.js delete mode 100644 compatibility-tests/test-create-react-app/src/logo.svg delete mode 100644 compatibility-tests/test-create-react-app/src/react-app-env.d.ts delete mode 100644 compatibility-tests/test-create-react-app/src/reportWebVitals.js delete mode 100644 compatibility-tests/test-create-react-app/src/setupTests.js delete mode 100644 compatibility-tests/test-create-react-app/src/useDrag.js create mode 100644 compatibility-tests/test-next/.gitignore create mode 100644 compatibility-tests/test-next/README.md create mode 100644 compatibility-tests/test-next/package.json create mode 100644 compatibility-tests/test-next/pages/index.js create mode 100644 compatibility-tests/test-next/public/favicon.ico create mode 100644 compatibility-tests/test-parcel1-react18/.gitignore create mode 100644 compatibility-tests/test-parcel1-react18/index.html create mode 100644 compatibility-tests/test-parcel1-react18/package.json create mode 100644 compatibility-tests/test-parcel1-react18/src/App.js create mode 100644 compatibility-tests/test-parcel1-react18/src/index.js create mode 100644 compatibility-tests/test-parcel2-react18/.gitignore create mode 100644 compatibility-tests/test-parcel2-react18/index.html create mode 100644 compatibility-tests/test-parcel2-react18/package.json create mode 100644 compatibility-tests/test-parcel2-react18/src/App.js create mode 100644 compatibility-tests/test-parcel2-react18/src/index.js create mode 100644 compatibility-tests/test-vite-react18/.gitignore create mode 100644 compatibility-tests/test-vite-react18/index.html create mode 100644 compatibility-tests/test-vite-react18/package.json create mode 100644 compatibility-tests/test-vite-react18/src/App.tsx create mode 100644 compatibility-tests/test-vite-react18/src/main.tsx create mode 100644 compatibility-tests/test-vite-react18/src/vite-env.d.ts create mode 100644 compatibility-tests/test-vite-react18/tsconfig.json create mode 100644 compatibility-tests/test-vite-react18/tsconfig.node.json create mode 100644 compatibility-tests/test-vite-react18/vite.config.ts delete mode 100644 packages/r3f/src/components/Toolbar/Toolbar.tsx delete mode 100644 packages/r3f/src/components/Toolbar/TransformControlsModeSelect.tsx delete mode 100644 packages/r3f/src/components/Toolbar/TransformControlsSpaceSelect.tsx delete mode 100644 packages/r3f/src/components/Toolbar/ViewportShadingSelect.tsx delete mode 100644 theatre/studio/src/css.ts create mode 100644 theatre/studio/src/css.tsx create mode 100644 theatre/studio/src/toolbars/GlobalToolbar/Toolset.tsx create mode 100644 theatre/studio/src/toolbars/GlobalToolbar/tools/IconButton.tsx create mode 100644 theatre/studio/src/toolbars/GlobalToolbar/tools/Switch.tsx create mode 100644 theatre/studio/src/utils/contextualWebComponents.tsx create mode 100644 theatre/studio/src/utils/renderInPortalInContext.tsx diff --git a/compatibility-tests/.gitignore b/compatibility-tests/.gitignore new file mode 100644 index 0000000..6d9e0ed --- /dev/null +++ b/compatibility-tests/.gitignore @@ -0,0 +1,5 @@ +# these lock files include checksums of the @theatre/*@compat packages, which +# would change after every edit to their source, so we better not keep them +# in the repo +/*/package-lock.json +/*/yarn.lock \ No newline at end of file diff --git a/compatibility-tests/package.json b/compatibility-tests/package.json index eeb5f9b..0b9f43b 100644 --- a/compatibility-tests/package.json +++ b/compatibility-tests/package.json @@ -3,7 +3,8 @@ "private": true, "scripts": { "registry:start": "zx ./scripts/start-registry.mjs", - "test:ci": "zx ./scripts/ci.mjs" + "test:ci": "zx ./scripts/ci.mjs", + "clean": "zx ./scripts/clean.mjs" }, "dependencies": { "node-cleanup": "^2.1.2", @@ -12,5 +13,6 @@ "verdaccio-auth-memory": "^10.2.0", "verdaccio-memory": "^10.2.0", "zx": "^6.1.0" - } + }, + "version": "0.0.1-COMPAT.1" } diff --git a/compatibility-tests/scripts/clean.mjs b/compatibility-tests/scripts/clean.mjs new file mode 100644 index 0000000..0d5fa88 --- /dev/null +++ b/compatibility-tests/scripts/clean.mjs @@ -0,0 +1,3 @@ +import {clean} from './utils.mjs' + +await clean() diff --git a/compatibility-tests/scripts/utils.mjs b/compatibility-tests/scripts/utils.mjs index aa75c99..890d873 100644 --- a/compatibility-tests/scripts/utils.mjs +++ b/compatibility-tests/scripts/utils.mjs @@ -2,9 +2,8 @@ * Utility functions for the compatibility tests */ -import fs from 'fs' import path from 'path' -import {YAML} from 'zx' +import {globby, YAML} from 'zx' import onCleanup from 'node-cleanup' import * as verdaccioPackage from 'verdaccio' @@ -14,6 +13,7 @@ const startVerdaccioServer = verdaccioPackage.default.default export const VERDACCIO_PORT = 4823 export const VERDACCIO_HOST = `localhost` export const VERDACCIO_URL = `http://${VERDACCIO_HOST}:${VERDACCIO_PORT}/` +export const PATH_TO_COMPAT_TESTS_ROOT = path.join(__dirname, '..') export const MONOREPO_ROOT = path.join(__dirname, '../..') export const PATH_TO_YARNRC = path.join(MONOREPO_ROOT, '.yarnrc.yml') @@ -259,3 +259,23 @@ export function getCompatibilityTestSetups() { return setupsAbsPaths } + +/** + * Deletes ../test-*\/(node_modules|package-lock.json|yarn.lock) + */ +export async function clean() { + const toDelete = await globby( + './test-*/(node_modules|yarn.lock|package-lock.json)', + { + cwd: PATH_TO_COMPAT_TESTS_ROOT, + // node_modules et al are gitignored, but we still want to clean them + gitignore: false, + // include directories too + onlyFiles: false, + }, + ) + toDelete.forEach((fileOrDir) => { + console.log('deleting', fileOrDir) + fs.removeSync(path.join(PATH_TO_COMPAT_TESTS_ROOT, fileOrDir)) + }) +} diff --git a/compatibility-tests/test-create-react-app/.gitignore b/compatibility-tests/test-cra-react18/.gitignore similarity index 100% rename from compatibility-tests/test-create-react-app/.gitignore rename to compatibility-tests/test-cra-react18/.gitignore diff --git a/compatibility-tests/test-cra-react18/README.md b/compatibility-tests/test-cra-react18/README.md new file mode 100644 index 0000000..a7eedd2 --- /dev/null +++ b/compatibility-tests/test-cra-react18/README.md @@ -0,0 +1 @@ +Testing `@theatre/core` and `@theatre/studio` with `npm`, `create-react-app`, and `react@18` \ No newline at end of file diff --git a/compatibility-tests/test-create-react-app/package.json b/compatibility-tests/test-cra-react18/package.json similarity index 91% rename from compatibility-tests/test-create-react-app/package.json rename to compatibility-tests/test-cra-react18/package.json index eafa8be..bab4a91 100644 --- a/compatibility-tests/test-create-react-app/package.json +++ b/compatibility-tests/test-cra-react18/package.json @@ -1,5 +1,5 @@ { - "name": "@theatre-build-tests/react-app", + "name": "@compat/cra-react18", "version": "0.1.0", "private": true, "scripts": { @@ -15,7 +15,6 @@ "@testing-library/user-event": "^12.1.10", "@theatre/core": "^0.0.1-COMPAT.1", "@theatre/studio": "^0.0.1-COMPAT.1", - "@theatre/r3f": "^0.0.1-COMPAT.1", "react-scripts": "^5.0.1", "three": ">0.132.0", "web-vitals": "^1.0.1" diff --git a/compatibility-tests/test-create-react-app/public/index.html b/compatibility-tests/test-cra-react18/public/index.html similarity index 77% rename from compatibility-tests/test-create-react-app/public/index.html rename to compatibility-tests/test-cra-react18/public/index.html index aa069f2..55dcc48 100644 --- a/compatibility-tests/test-create-react-app/public/index.html +++ b/compatibility-tests/test-cra-react18/public/index.html @@ -2,19 +2,13 @@ - - - - +