@reactunity/renderer 0.23.2 → 0.25.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/README.md +34 -0
- package/css/preflight.css +54 -0
- package/css/tailwind.css +21 -0
- package/css/theme.css +17 -0
- package/dist/{base-BT2GMEbv.d.ts → base-3-s8tzdC.d.ts} +2827 -1173
- package/dist/{components-Cbty8Ffc.d.ts → components-CHc816Qv.d.ts} +4 -4
- package/dist/editor/index.d.ts +3 -3
- package/dist/editor/jsx-dev-runtime.d.ts +1 -1
- package/dist/editor/jsx-runtime.d.ts +1 -1
- package/dist/{editor-Ds4U7pg6.d.ts → editor-DwsHqUiS.d.ts} +2708 -2168
- package/dist/index-DVMJGbQf.d.ts +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/{jsx-9V8cIFit.d.ts → jsx-5DJ6sjv6.d.ts} +4 -4
- package/dist/{jsx-DXzVL17E.d.ts → jsx-DEILne0Q.d.ts} +4 -3
- package/dist/{jsx-BZUfiU1y.d.ts → jsx-DJhfjIPV.d.ts} +3 -3
- package/dist/{tests-DbTTvHZm.d.ts → tests-ByeoZtD1.d.ts} +2 -24
- package/dist/tests.d.ts +2 -2
- package/dist/ugui/index.d.ts +2 -2
- package/dist/ugui/jsx-dev-runtime.d.ts +1 -1
- package/dist/ugui/jsx-runtime.d.ts +1 -1
- package/dist/uitoolkit/index.d.ts +2 -2
- package/dist/uitoolkit/jsx-dev-runtime.d.ts +1 -1
- package/dist/uitoolkit/jsx-runtime.d.ts +1 -1
- package/dist/{unity-BQNCBoTP.d.ts → unity-CqyiwXyf.d.ts} +8125 -5457
- package/dist/vite.d.mts +44 -0
- package/dist/vite.mjs +239 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +32 -7
- package/dist/index-CBMYN8iy.d.ts +0 -1
package/README.md
CHANGED
|
@@ -10,3 +10,37 @@ See [main repo](https://github.com/ReactUnity/core) for further info.
|
|
|
10
10
|
```
|
|
11
11
|
npm i @reactunity/renderer
|
|
12
12
|
```
|
|
13
|
+
|
|
14
|
+
## Vite plugin
|
|
15
|
+
|
|
16
|
+
`@reactunity/renderer/vite` is a preset that configures Vite for a ReactUnity app:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// vite.config.mts
|
|
20
|
+
import reactUnity from '@reactunity/renderer/vite';
|
|
21
|
+
import { defineConfig } from 'vite';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({ plugins: [reactUnity()] });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
It adds [`@vitejs/plugin-react`](https://www.npmjs.com/package/@vitejs/plugin-react), finds the Unity
|
|
27
|
+
project above the app and builds into its `Assets/Resources/react`, and empties that folder before
|
|
28
|
+
each build while keeping Unity's `.meta` files — so the GUIDs your scenes reference survive a
|
|
29
|
+
rebuild. Filenames carry no content hash for the same reason, emitted assets keep their extension
|
|
30
|
+
twice over (`index.css.css`) so Unity's extensionless resource lookup cannot confuse two of them,
|
|
31
|
+
assets are never inlined as `data:` URIs, and CSS is lowered for an old browser so ReactUnity's
|
|
32
|
+
parser can read it. It also turns off the
|
|
33
|
+
Vite devtools and the HMR error overlay, neither of which Unity can display.
|
|
34
|
+
|
|
35
|
+
Every part of that is an option:
|
|
36
|
+
|
|
37
|
+
| Option | Default | |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `unityProject` | discovered | The Unity project to build into, absolute or relative to the Vite root. |
|
|
40
|
+
| `assetPath` | `Assets/Resources/react` | Output folder inside the Unity project. |
|
|
41
|
+
| `clean` | `true` | Empty the output directory before each build, keeping its `.meta` files. |
|
|
42
|
+
| `preserve` | `[]` | Paths inside the output directory that the clean never deletes. |
|
|
43
|
+
| `hashFileNames` | `false` | Put content hashes in output filenames. |
|
|
44
|
+
| `react` | `{}` | Options for `@vitejs/plugin-react`, or `false` to add the React plugin yourself. |
|
|
45
|
+
|
|
46
|
+
Anything set in the Vite config itself wins: the preset only fills in what you left out.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Tailwind's Preflight, for ReactUnity.
|
|
3
|
+
|
|
4
|
+
Tailwind's own resets what a browser does to a document. There is no browser here, so this resets
|
|
5
|
+
what ReactUnity does -- the padding and the paint its user-agent stylesheet gives its controls --
|
|
6
|
+
and leaves out everything about elements ReactUnity has not got, which is most of the original.
|
|
7
|
+
|
|
8
|
+
Belongs in the `base` layer, or it would win over the utilities:
|
|
9
|
+
@import "@reactunity/renderer/tailwind/preflight.css" layer(base);
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Remove the padding ReactUnity gives a button, an input and a toggle, and the margin around a
|
|
14
|
+
toggle, so a `p-*` or `m-*` utility is the only thing that decides. There are no borders to reset:
|
|
15
|
+
a border here is 0 wide and already solid.
|
|
16
|
+
*/
|
|
17
|
+
*,
|
|
18
|
+
:before,
|
|
19
|
+
:after {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
1. Tailwind's default line height. ReactUnity's is whatever the font says, and a `text-*` utility
|
|
26
|
+
replaces this with the type scale's own value anyway.
|
|
27
|
+
2. `sans-serif` and `monospace` are the two families ReactUnity ships, and what the theme values
|
|
28
|
+
in `@reactunity/renderer/tailwind/theme.css` name. A stack of web font names resolves to none.
|
|
29
|
+
*/
|
|
30
|
+
:root {
|
|
31
|
+
line-height: 1.5; /* 1 */
|
|
32
|
+
font-family: --theme(--default-font-family, sans-serif); /* 2 */
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
Unpaint the controls. ReactUnity gives them a grey fill and rounded corners, which is opt-out here
|
|
37
|
+
the same way a browser's button styling is under Preflight. `appearance` is left alone -- it is
|
|
38
|
+
what makes them behave as controls, not what makes them look styled.
|
|
39
|
+
*/
|
|
40
|
+
button,
|
|
41
|
+
input,
|
|
42
|
+
toggle {
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
border-radius: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
Half of whatever colour the placeholder is given, in place of the opacity ReactUnity dims it with
|
|
49
|
+
-- which no colour utility can undo. This is Tailwind's own rule for it.
|
|
50
|
+
*/
|
|
51
|
+
input::placeholder {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
color: color-mix(in oklab, currentcolor 50%, transparent);
|
|
54
|
+
}
|
package/css/tailwind.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Tailwind, for ReactUnity: everything `@import "tailwindcss"` brings, except that the Preflight is
|
|
3
|
+
one written for what ReactUnity renders rather than the one that resets a document, and the theme
|
|
4
|
+
values whose defaults name web fonts are replaced.
|
|
5
|
+
|
|
6
|
+
`@reactunity/renderer/vite` points a bare `@import "tailwindcss"` at this file, so an app writes
|
|
7
|
+
that line and nothing else. Without the plugin, or with its `tailwind` option off, import it by
|
|
8
|
+
name instead:
|
|
9
|
+
|
|
10
|
+
@import "@reactunity/renderer/tailwind.css";
|
|
11
|
+
|
|
12
|
+
Either half can also be taken on its own, from `@reactunity/renderer/tailwind/preflight.css`
|
|
13
|
+
(into `layer(base)`, since an unlayered rule beats every utility) and
|
|
14
|
+
`@reactunity/renderer/tailwind/theme.css`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
@layer theme, base, components, utilities;
|
|
18
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
19
|
+
@import "./preflight.css" layer(base);
|
|
20
|
+
@import "tailwindcss/utilities.css" layer(utilities);
|
|
21
|
+
@import "./theme.css";
|
package/css/theme.css
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The theme values whose defaults mean nothing outside a browser.
|
|
3
|
+
|
|
4
|
+
ReactUnity ships two font families, `sans-serif` and `monospace`, as @font-face aliases for the
|
|
5
|
+
fonts in its resources. Tailwind's defaults are stacks of web font names, so `font-sans`,
|
|
6
|
+
`font-mono` and the `--default-font-family` Preflight reads would all resolve to nothing. Every
|
|
7
|
+
other default carries over: the spacing scale, the type scale and the colours are `rem`, `oklch`
|
|
8
|
+
and unitless line heights, all of which ReactUnity reads.
|
|
9
|
+
|
|
10
|
+
`--font-serif` is left as it is. ReactUnity ships no serif font, and naming one it has not got
|
|
11
|
+
would be worse than a `font-serif` utility that does nothing.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
@theme {
|
|
15
|
+
--font-sans: sans-serif;
|
|
16
|
+
--font-mono: monospace;
|
|
17
|
+
}
|