diff --git a/examples/dom-cra/package.json b/examples/dom-cra/package.json
index b7ed650..f777cee 100644
--- a/examples/dom-cra/package.json
+++ b/examples/dom-cra/package.json
@@ -1,5 +1,5 @@
{
- "name": "dom-cra",
+ "name": "@examples/dom-cra",
"version": "0.1.0",
"private": true,
"installConfig": {
diff --git a/examples/r3f-cra/.env b/examples/r3f-cra/.env
new file mode 100644
index 0000000..7d910f1
--- /dev/null
+++ b/examples/r3f-cra/.env
@@ -0,0 +1 @@
+SKIP_PREFLIGHT_CHECK=true
\ No newline at end of file
diff --git a/examples/r3f-cra/.gitignore b/examples/r3f-cra/.gitignore
new file mode 100644
index 0000000..4d29575
--- /dev/null
+++ b/examples/r3f-cra/.gitignore
@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/examples/r3f-cra/README.md b/examples/r3f-cra/README.md
new file mode 100644
index 0000000..02aac3f
--- /dev/null
+++ b/examples/r3f-cra/README.md
@@ -0,0 +1,70 @@
+# Getting Started with Create React App
+
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
+
+## Available Scripts
+
+In the project directory, you can run:
+
+### `yarn start`
+
+Runs the app in the development mode.\
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
+
+The page will reload if you make edits.\
+You will also see any lint errors in the console.
+
+### `yarn test`
+
+Launches the test runner in the interactive watch mode.\
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
+
+### `yarn build`
+
+Builds the app for production to the `build` folder.\
+It correctly bundles React in production mode and optimizes the build for the best performance.
+
+The build is minified and the filenames include the hashes.\
+Your app is ready to be deployed!
+
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
+
+### `yarn eject`
+
+**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
+
+If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
+
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
+
+You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
+
+## Learn More
+
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
+
+To learn React, check out the [React documentation](https://reactjs.org/).
+
+### Code Splitting
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
+
+### Analyzing the Bundle Size
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
+
+### Making a Progressive Web App
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
+
+### Advanced Configuration
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
+
+### Deployment
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
+
+### `yarn build` fails to minify
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
diff --git a/examples/r3f-cra/package.json b/examples/r3f-cra/package.json
new file mode 100644
index 0000000..5bf1ed2
--- /dev/null
+++ b/examples/r3f-cra/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@examples/r3f-cra",
+ "version": "0.1.0",
+ "private": true,
+ "installConfig": {
+ "hoistingLimits": "dependencies"
+ },
+ "dependencies": {
+ "@react-three/drei": "^7.2.2",
+ "@react-three/fiber": "^7.0.6",
+ "@testing-library/jest-dom": "^5.11.4",
+ "@testing-library/react": "^11.1.0",
+ "@testing-library/user-event": "^12.1.10",
+ "@theatre/core": "workspace:*",
+ "@theatre/plugin-r3f": "workspace:*",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2",
+ "react-scripts": "4.0.3",
+ "three": "^0.130.1",
+ "web-vitals": "^1.0.1"
+ },
+ "devDependencies": {
+ "@theatre/studio": "workspace:*"
+ },
+ "scripts": {
+ "start": "react-scripts start",
+ "build": "react-scripts build",
+ "test": "react-scripts test",
+ "eject": "react-scripts eject"
+ },
+ "browserslist": {
+ "production": [
+ ">0.2%",
+ "not dead",
+ "not op_mini all"
+ ],
+ "development": [
+ "last 1 chrome version",
+ "last 1 firefox version",
+ "last 1 safari version"
+ ]
+ }
+}
diff --git a/examples/r3f-cra/public/favicon.ico b/examples/r3f-cra/public/favicon.ico
new file mode 100644
index 0000000..a11777c
Binary files /dev/null and b/examples/r3f-cra/public/favicon.ico differ
diff --git a/examples/r3f-cra/public/index.html b/examples/r3f-cra/public/index.html
new file mode 100644
index 0000000..aa069f2
--- /dev/null
+++ b/examples/r3f-cra/public/index.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ React App
+
+
+ You need to enable JavaScript to run this app.
+
+
+
+
diff --git a/examples/r3f-cra/public/logo192.png b/examples/r3f-cra/public/logo192.png
new file mode 100644
index 0000000..fc44b0a
Binary files /dev/null and b/examples/r3f-cra/public/logo192.png differ
diff --git a/examples/r3f-cra/public/logo512.png b/examples/r3f-cra/public/logo512.png
new file mode 100644
index 0000000..a4e47a6
Binary files /dev/null and b/examples/r3f-cra/public/logo512.png differ
diff --git a/examples/r3f-cra/public/manifest.json b/examples/r3f-cra/public/manifest.json
new file mode 100644
index 0000000..080d6c7
--- /dev/null
+++ b/examples/r3f-cra/public/manifest.json
@@ -0,0 +1,25 @@
+{
+ "short_name": "React App",
+ "name": "Create React App Sample",
+ "icons": [
+ {
+ "src": "favicon.ico",
+ "sizes": "64x64 32x32 24x24 16x16",
+ "type": "image/x-icon"
+ },
+ {
+ "src": "logo192.png",
+ "type": "image/png",
+ "sizes": "192x192"
+ },
+ {
+ "src": "logo512.png",
+ "type": "image/png",
+ "sizes": "512x512"
+ }
+ ],
+ "start_url": ".",
+ "display": "standalone",
+ "theme_color": "#000000",
+ "background_color": "#ffffff"
+}
diff --git a/examples/r3f-cra/public/robots.txt b/examples/r3f-cra/public/robots.txt
new file mode 100644
index 0000000..e9e57dc
--- /dev/null
+++ b/examples/r3f-cra/public/robots.txt
@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:
diff --git a/examples/r3f-cra/src/App.css b/examples/r3f-cra/src/App.css
new file mode 100644
index 0000000..74b5e05
--- /dev/null
+++ b/examples/r3f-cra/src/App.css
@@ -0,0 +1,38 @@
+.App {
+ text-align: center;
+}
+
+.App-logo {
+ height: 40vmin;
+ pointer-events: none;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .App-logo {
+ animation: App-logo-spin infinite 20s linear;
+ }
+}
+
+.App-header {
+ background-color: #282c34;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ font-size: calc(10px + 2vmin);
+ color: white;
+}
+
+.App-link {
+ color: #61dafb;
+}
+
+@keyframes App-logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
diff --git a/examples/r3f-cra/src/App.js b/examples/r3f-cra/src/App.js
new file mode 100644
index 0000000..e568443
--- /dev/null
+++ b/examples/r3f-cra/src/App.js
@@ -0,0 +1,142 @@
+import {getProject} from '@theatre/core'
+import * as THREE from 'three'
+import {useState, useEffect, useRef} from 'react'
+import {useFrame} from '@react-three/fiber'
+import {softShadows} from '@react-three/drei'
+
+// Soft shadows are expensive, comment and refresh when it's too slow
+softShadows()
+
+// credit: https://codesandbox.io/s/camera-pan-nsb7f
+
+function Button() {
+ const vec = new THREE.Vector3()
+ const light = useRef(undefined)
+ const [active, setActive] = useState(false)
+ const [zoom, set] = useState(true)
+ useEffect(
+ () => void (document.body.style.cursor = active ? 'pointer' : 'auto'),
+ [active],
+ )
+
+ useFrame((state) => {
+ const step = 0.1
+ const camera = state.camera
+ camera.fov = THREE.MathUtils.lerp(camera.fov, zoom ? 10 : 42, step)
+ camera.position.lerp(
+ vec.set(zoom ? 25 : 10, zoom ? 1 : 5, zoom ? 0 : 10),
+ step,
+ )
+ state.camera.lookAt(0, 0, 0)
+ state.camera.updateProjectionMatrix()
+
+ light.current.position.lerp(
+ vec.set(zoom ? 4 : 0, zoom ? 3 : 8, zoom ? 3 : 5),
+ step,
+ )
+ })
+
+ return (
+ set(!zoom)}
+ onPointerOver={() => setActive(true)}
+ onPointerOut={() => setActive(false)}
+ uniqueName="The Button"
+ >
+
+
+
+
+
+ )
+}
+
+function Plane({color, uniqueName, ...props}) {
+ return (
+
+
+
+
+ )
+}
+
+function App() {
+ return (
+
+
+ getProject('Playground - R3F').sheet('R3F-Canvas')}
+ >
+ {/* @ts-ignore */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default App
diff --git a/examples/r3f-cra/src/App.test.js b/examples/r3f-cra/src/App.test.js
new file mode 100644
index 0000000..426d4f4
--- /dev/null
+++ b/examples/r3f-cra/src/App.test.js
@@ -0,0 +1,7 @@
+import {render, screen} from '@testing-library/react'
+
+test('renders learn react link', () => {
+ render( )
+ const linkElement = screen.getByText(/learn react/i)
+ expect(linkElement).toBeInTheDocument()
+})
diff --git a/examples/r3f-cra/src/index.css b/examples/r3f-cra/src/index.css
new file mode 100644
index 0000000..ec2585e
--- /dev/null
+++ b/examples/r3f-cra/src/index.css
@@ -0,0 +1,13 @@
+body {
+ margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+ sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+ monospace;
+}
diff --git a/examples/r3f-cra/src/index.js b/examples/r3f-cra/src/index.js
new file mode 100644
index 0000000..1625c86
--- /dev/null
+++ b/examples/r3f-cra/src/index.js
@@ -0,0 +1,17 @@
+import ReactDOM from 'react-dom'
+import './index.css'
+import reportWebVitals from './reportWebVitals'
+import '@theatre/studio'
+import {getProject} from '@theatre/core'
+
+ReactDOM.render(
+
+
+ ,
+ document.getElementById('root'),
+)
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals()
diff --git a/examples/r3f-cra/src/logo.svg b/examples/r3f-cra/src/logo.svg
new file mode 100644
index 0000000..9dfc1c0
--- /dev/null
+++ b/examples/r3f-cra/src/logo.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/examples/r3f-cra/src/reportWebVitals.js b/examples/r3f-cra/src/reportWebVitals.js
new file mode 100644
index 0000000..21ea93d
--- /dev/null
+++ b/examples/r3f-cra/src/reportWebVitals.js
@@ -0,0 +1,13 @@
+const reportWebVitals = (onPerfEntry) => {
+ if (onPerfEntry && onPerfEntry instanceof Function) {
+ import('web-vitals').then(({getCLS, getFID, getFCP, getLCP, getTTFB}) => {
+ getCLS(onPerfEntry)
+ getFID(onPerfEntry)
+ getFCP(onPerfEntry)
+ getLCP(onPerfEntry)
+ getTTFB(onPerfEntry)
+ })
+ }
+}
+
+export default reportWebVitals
diff --git a/examples/r3f-cra/src/setupTests.js b/examples/r3f-cra/src/setupTests.js
new file mode 100644
index 0000000..52aaef1
--- /dev/null
+++ b/examples/r3f-cra/src/setupTests.js
@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom'
diff --git a/examples/r3f-cra/src/useDrag.js b/examples/r3f-cra/src/useDrag.js
new file mode 100644
index 0000000..65ef93b
--- /dev/null
+++ b/examples/r3f-cra/src/useDrag.js
@@ -0,0 +1,130 @@
+import {useLayoutEffect, useRef} from 'react'
+
+const noop = () => {}
+
+function createCursorLock(cursor) {
+ const el = document.createElement('div')
+ el.style.cssText = `
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 9999999;`
+
+ el.style.cursor = cursor
+ document.body.appendChild(el)
+ const relinquish = () => {
+ document.body.removeChild(el)
+ }
+
+ return relinquish
+}
+
+export default function useDrag(target, opts) {
+ const optsRef = useRef(opts)
+ optsRef.current = opts
+
+ const modeRef = useRef('notDragging')
+
+ const stateRef = useRef({dragHappened: false, startPos: {x: 0, y: 0}})
+
+ useLayoutEffect(() => {
+ if (!target) return
+
+ const getDistances = (event) => {
+ const {startPos} = stateRef.current
+ return [event.screenX - startPos.x, event.screenY - startPos.y]
+ }
+
+ let relinquishCursorLock = noop
+
+ const dragHandler = (event) => {
+ if (!stateRef.current.dragHappened && optsRef.current.lockCursorTo) {
+ relinquishCursorLock = createCursorLock(optsRef.current.lockCursorTo)
+ }
+ if (!stateRef.current.dragHappened) stateRef.current.dragHappened = true
+ modeRef.current = 'dragging'
+
+ const deltas = getDistances(event)
+ optsRef.current.onDrag(deltas[0], deltas[1], event)
+ }
+
+ const dragEndHandler = () => {
+ removeDragListeners()
+ modeRef.current = 'notDragging'
+
+ optsRef.current.onDragEnd &&
+ optsRef.current.onDragEnd(stateRef.current.dragHappened)
+ relinquishCursorLock()
+ relinquishCursorLock = noop
+ }
+
+ const addDragListeners = () => {
+ document.addEventListener('mousemove', dragHandler)
+ document.addEventListener('mouseup', dragEndHandler)
+ }
+
+ const removeDragListeners = () => {
+ document.removeEventListener('mousemove', dragHandler)
+ document.removeEventListener('mouseup', dragEndHandler)
+ }
+
+ const preventUnwantedClick = (event) => {
+ if (optsRef.current.disabled) return
+ if (stateRef.current.dragHappened) {
+ if (
+ !optsRef.current.dontBlockMouseDown &&
+ modeRef.current !== 'notDragging'
+ ) {
+ event.stopPropagation()
+ event.preventDefault()
+ }
+ stateRef.current.dragHappened = false
+ }
+ }
+
+ const dragStartHandler = (event) => {
+ const opts = optsRef.current
+ if (opts.disabled === true) return
+
+ if (event.button !== 0) return
+ const resultOfStart = opts.onDragStart && opts.onDragStart(event)
+
+ if (resultOfStart === false) return
+
+ if (!opts.dontBlockMouseDown) {
+ event.stopPropagation()
+ event.preventDefault()
+ }
+
+ modeRef.current = 'dragStartCalled'
+
+ const {screenX, screenY} = event
+ stateRef.current.startPos = {x: screenX, y: screenY}
+ stateRef.current.dragHappened = false
+
+ addDragListeners()
+ }
+
+ const onMouseDown = (e) => {
+ dragStartHandler(e)
+ }
+
+ target.addEventListener('mousedown', onMouseDown)
+ target.addEventListener('click', preventUnwantedClick)
+
+ return () => {
+ removeDragListeners()
+ target.removeEventListener('mousedown', onMouseDown)
+ target.removeEventListener('click', preventUnwantedClick)
+ relinquishCursorLock()
+
+ if (modeRef.current !== 'notDragging') {
+ optsRef.current.onDragEnd &&
+ optsRef.current.onDragEnd(modeRef.current === 'dragging')
+ }
+ modeRef.current = 'notDragging'
+ }
+ }, [target])
+}
diff --git a/package.json b/package.json
index c526724..48088a4 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
"theatre"
],
"scripts": {
+ "playground": "yarn workspace playground run serve",
"typecheck": "tsc --build ./devEnv/typecheck-all-projects/tsconfig.all.json",
"test": "jest",
"postinstall": "husky install",
diff --git a/packages/dataverse-react/package.json b/packages/dataverse-react/package.json
index fe65f78..ca455d3 100644
--- a/packages/dataverse-react/package.json
+++ b/packages/dataverse-react/package.json
@@ -14,15 +14,6 @@
},
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "require": "./dist/index.cjs",
- "import": "./dist/index.mjs",
- "default": "./dist/index.cjs",
- "node": "./dist/index.cjs"
- }
- },
"files": [
"dist/**/*"
],
diff --git a/packages/dataverse/package.json b/packages/dataverse/package.json
index a644fdf..f8d6bd4 100644
--- a/packages/dataverse/package.json
+++ b/packages/dataverse/package.json
@@ -14,15 +14,6 @@
},
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "require": "./dist/index.cjs",
- "import": "./dist/index.mjs",
- "default": "./dist/index.cjs",
- "node": "./dist/index.cjs"
- }
- },
"files": [
"dist/**/*"
],
diff --git a/packages/playground/src/r3f/App.tsx b/packages/playground/src/r3f/App.tsx
index 05eb7d1..b020777 100644
--- a/packages/playground/src/r3f/App.tsx
+++ b/packages/playground/src/r3f/App.tsx
@@ -1,5 +1,4 @@
import {editable as e, Wrapper} from '@theatre/plugin-r3f'
-import {PerspectiveCamera} from '@react-three/drei'
import {getProject} from '@theatre/core'
import * as THREE from 'three'
import React, {useState, useEffect, useRef} from 'react'
@@ -7,9 +6,6 @@ import type {Color} from '@react-three/fiber'
import {Canvas, useFrame} from '@react-three/fiber'
import {softShadows, Shadow} from '@react-three/drei'
import type {DirectionalLight} from 'three'
-import type {$FixMe} from '../../../plugin-r3f/src/types'
-
-const ECamera = e(PerspectiveCamera, 'perspectiveCamera')
// Soft shadows are expensive, comment and refresh when it's too slow
softShadows()
@@ -29,11 +25,7 @@ function Button() {
useFrame((state) => {
const step = 0.1
const camera = state.camera as THREE.PerspectiveCamera
- camera.fov = (THREE as $FixMe).MathUtils.lerp(
- camera.fov,
- zoom ? 10 : 42,
- step,
- )
+ camera.fov = (THREE as any).MathUtils.lerp(camera.fov, zoom ? 10 : 42, step)
camera.position.lerp(
vec.set(zoom ? 25 : 10, zoom ? 1 : 5, zoom ? 0 : 10),
step,
@@ -99,9 +91,10 @@ function App() {
shadowMap
>
getProject('Example project').sheet('R3F-Canvas')}
+ getSheet={() => getProject('Playground - R3F').sheet('R3F-Canvas')}
>
-
+ {/* @ts-ignore */}
+
-
+
getProject('Example project').sheet('R3F-Canvas')}
>
diff --git a/packages/plugin-r3f/devEnv/build.ts b/packages/plugin-r3f/devEnv/build.ts
new file mode 100644
index 0000000..136c217
--- /dev/null
+++ b/packages/plugin-r3f/devEnv/build.ts
@@ -0,0 +1,75 @@
+import path from 'path'
+import {build} from 'esbuild'
+import type {Plugin} from 'esbuild'
+import {writeFileSync} from 'fs'
+
+const externalPlugin = (patterns: RegExp[]): Plugin => {
+ return {
+ name: `external`,
+
+ setup(build) {
+ build.onResolve({filter: /.*/}, (args) => {
+ const external = patterns.some((p) => {
+ return p.test(args.path)
+ })
+
+ if (external) {
+ return {path: args.path, external}
+ }
+ })
+ },
+ }
+}
+
+const definedGlobals = {
+ global: 'window',
+}
+
+function createBundles(watch: boolean) {
+ const pathToPackage = path.join(__dirname, '../')
+ const esbuildConfig: Parameters[0] = {
+ entryPoints: [path.join(pathToPackage, 'src/index.tsx')],
+ bundle: true,
+ sourcemap: true,
+ define: definedGlobals,
+ watch,
+ platform: 'neutral',
+ mainFields: ['browser', 'module', 'main'],
+ target: ['firefox57', 'chrome58'],
+ conditions: ['browser', 'node'],
+ // every dependency is considered external
+ plugins: [externalPlugin([/^[\@a-zA-Z]+/])],
+ }
+
+ build({
+ ...esbuildConfig,
+ define: {...definedGlobals, 'process.env.NODE_ENV': '"production"'},
+ outfile: path.join(pathToPackage, 'dist/index.production.cjs'),
+ format: 'cjs',
+ treeShaking: true,
+ })
+
+ build({
+ ...esbuildConfig,
+ define: {...definedGlobals, 'process.env.NODE_ENV': '"development"'},
+ outfile: path.join(pathToPackage, 'dist/index.development.cjs'),
+ format: 'cjs',
+ })
+
+ writeFileSync(
+ path.join(pathToPackage, 'dist/index.cjs'),
+ `module.exports =
+ process.env.NODE_ENV === "production"
+ ? require("./index.production.cjs")
+ : require("./index.development.cjs")`,
+ {encoding: 'utf-8'},
+ )
+
+ build({
+ ...esbuildConfig,
+ outfile: path.join(pathToPackage, 'dist/index.mjs'),
+ format: 'esm',
+ })
+}
+
+createBundles(false)
diff --git a/packages/plugin-r3f/devEnv/tsconfig.json b/packages/plugin-r3f/devEnv/tsconfig.json
new file mode 100644
index 0000000..077404a
--- /dev/null
+++ b/packages/plugin-r3f/devEnv/tsconfig.json
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/packages/plugin-r3f/package.json b/packages/plugin-r3f/package.json
index 15e6b31..c6ae4ff 100644
--- a/packages/plugin-r3f/package.json
+++ b/packages/plugin-r3f/package.json
@@ -19,15 +19,18 @@
"url": "https://github.com/AriaMinaei/theatre",
"directory": "packages/plugin-r3f"
},
- "main": "dist/index.js",
+ "main": "dist/index.cjs",
"types": "dist/index.d.ts",
+ "sideEffects": false,
"files": [
"dist/**/*"
],
"scripts": {
"prepack": "yarn run build",
"typecheck": "yarn run build",
- "build": "tsc --build ./tsconfig.json",
+ "build": "run-s build:ts build:js",
+ "build:ts": "tsc --build ./tsconfig.json",
+ "build:js": "node -r esbuild-register ./devEnv/build.ts",
"prepublish": "node ../../devEnv/ensurePublishing.js"
},
"devDependencies": {
@@ -36,6 +39,7 @@
"@types/node": "^15.6.2",
"@types/react": "^17.0.9",
"@types/styled-components": "^5.1.9",
+ "npm-run-all": "^4.1.5",
"typescript": "^4.3.2"
},
"dependencies": {
diff --git a/packages/plugin-r3f/src/index.tsx b/packages/plugin-r3f/src/index.tsx
index 24f3475..22419ab 100644
--- a/packages/plugin-r3f/src/index.tsx
+++ b/packages/plugin-r3f/src/index.tsx
@@ -1,8 +1,4 @@
-import SnapshotEditor from './components/SnapshotEditor'
-import studio from '@theatre/studio'
-import Toolbar from './components/Toolbar/Toolbar'
-import {types} from '@theatre/core'
-
+import setupPlugin from './setupPlugin'
export {default as EditorHelper} from './components/EditorHelper'
export type {EditorHelperProps} from './components/EditorHelper'
export {default as editable} from './components/editable'
@@ -10,19 +6,5 @@ export type {EditableState, BindFunction} from './store'
export {default as Wrapper} from './Wrapper'
if (process.env.NODE_ENV === 'development') {
- studio.extend({
- id: '@theatre/plugin-r3f',
- globalToolbar: {
- component: Toolbar,
- },
- panes: [
- {
- class: 'snapshotEditor',
- dataType: types.compound({
- grosse: types.number(20),
- }),
- component: SnapshotEditor,
- },
- ],
- })
+ setupPlugin()
}
diff --git a/packages/plugin-r3f/src/setupPlugin.ts b/packages/plugin-r3f/src/setupPlugin.ts
new file mode 100644
index 0000000..29850b1
--- /dev/null
+++ b/packages/plugin-r3f/src/setupPlugin.ts
@@ -0,0 +1,22 @@
+import SnapshotEditor from './components/SnapshotEditor'
+import studio from '@theatre/studio'
+import Toolbar from './components/Toolbar/Toolbar'
+import {types} from '@theatre/core'
+
+export default function setupPlugin() {
+ studio.extend({
+ id: '@theatre/plugin-r3f',
+ globalToolbar: {
+ component: Toolbar,
+ },
+ panes: [
+ {
+ class: 'snapshotEditor',
+ dataType: types.compound({
+ grosse: types.number(20),
+ }),
+ component: SnapshotEditor,
+ },
+ ],
+ })
+}
diff --git a/packages/plugin-r3f/tsconfig.json b/packages/plugin-r3f/tsconfig.json
index 42750b4..3c42607 100644
--- a/packages/plugin-r3f/tsconfig.json
+++ b/packages/plugin-r3f/tsconfig.json
@@ -5,7 +5,7 @@
"lib": ["ESNext", "DOM"],
"rootDir": "src",
"types": ["jest", "node"],
- "emitDeclarationOnly": false,
+ "emitDeclarationOnly": true,
"composite": true
},
"references": [{"path": "../../theatre"}],
diff --git a/theatre/core/package.json b/theatre/core/package.json
index 833fef6..49a64e6 100644
--- a/theatre/core/package.json
+++ b/theatre/core/package.json
@@ -14,17 +14,8 @@
"url": "https://www.theatrejs.com"
},
"main": "dist/index.cjs",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "require": "./dist/index.cjs",
- "import": "./dist/index.mjs",
- "default": "./dist/index.cjs",
- "node": "./dist/index.cjs",
- "script": "./dist/index.min.js"
- }
- },
"types": "dist/index.d.ts",
+ "type": "commonjs",
"files": [
"dist/index.cjs",
"dist/index.cjs.map",
diff --git a/theatre/studio/package.json b/theatre/studio/package.json
index 948fc98..deecaea 100644
--- a/theatre/studio/package.json
+++ b/theatre/studio/package.json
@@ -14,16 +14,6 @@
"url": "https://www.theatrejs.com"
},
"main": "dist/index.cjs",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "require": "./dist/index.cjs",
- "import": "./dist/index.mjs",
- "default": "./dist/index.cjs",
- "node": "./dist/index.cjs",
- "script": "./dist/index.min.js"
- }
- },
"types": "dist/index.d.ts",
"files": [
"dist/index.cjs",
@@ -38,8 +28,11 @@
"scripts": {
"prepublish": "node ../../devEnv/ensurePublishing.js"
},
- "sideEffects": true,
+ "sideEffects": false,
"peerDependencies": {
"@theatre/core": "*"
+ },
+ "dependencies": {
+ "@theatre/dataverse": "workspace:*"
}
}
diff --git a/yarn.lock b/yarn.lock
index 39b6c87..2cd37a4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3625,6 +3625,42 @@ __metadata:
languageName: unknown
linkType: soft
+"@examples/dom-cra@workspace:examples/dom-cra":
+ version: 0.0.0-use.local
+ resolution: "@examples/dom-cra@workspace:examples/dom-cra"
+ dependencies:
+ "@testing-library/jest-dom": ^5.11.4
+ "@testing-library/react": ^11.1.0
+ "@testing-library/user-event": ^12.1.10
+ "@theatre/core": "workspace:*"
+ "@theatre/studio": "workspace:*"
+ react: ^17.0.2
+ react-dom: ^17.0.2
+ react-scripts: 4.0.3
+ web-vitals: ^1.0.1
+ languageName: unknown
+ linkType: soft
+
+"@examples/r3f-cra@workspace:examples/r3f-cra":
+ version: 0.0.0-use.local
+ resolution: "@examples/r3f-cra@workspace:examples/r3f-cra"
+ dependencies:
+ "@react-three/drei": ^7.2.2
+ "@react-three/fiber": ^7.0.6
+ "@testing-library/jest-dom": ^5.11.4
+ "@testing-library/react": ^11.1.0
+ "@testing-library/user-event": ^12.1.10
+ "@theatre/core": "workspace:*"
+ "@theatre/plugin-r3f": "workspace:*"
+ "@theatre/studio": "workspace:*"
+ react: ^17.0.2
+ react-dom: ^17.0.2
+ react-scripts: 4.0.3
+ three: ^0.130.1
+ web-vitals: ^1.0.1
+ languageName: unknown
+ linkType: soft
+
"@hapi/address@npm:2.x.x":
version: 2.1.4
resolution: "@hapi/address@npm:2.1.4"
@@ -10630,22 +10666,6 @@ __metadata:
languageName: node
linkType: hard
-"dom-cra@workspace:examples/dom-cra":
- version: 0.0.0-use.local
- resolution: "dom-cra@workspace:examples/dom-cra"
- dependencies:
- "@testing-library/jest-dom": ^5.11.4
- "@testing-library/react": ^11.1.0
- "@testing-library/user-event": ^12.1.10
- "@theatre/core": "workspace:*"
- "@theatre/studio": "workspace:*"
- react: ^17.0.2
- react-dom: ^17.0.2
- react-scripts: 4.0.3
- web-vitals: ^1.0.1
- languageName: unknown
- linkType: soft
-
"dom-serializer@npm:0":
version: 0.2.2
resolution: "dom-serializer@npm:0.2.2"