Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nearly all dependencies #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions apps/docs/apiSidebars.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
const coreSidebar = require('./core-sidebar.js');
const threeSidebar = require('./three-sidebar.js');

module.exports = {
sidebar: [
{
type: 'category',
label: '@react-ecs/core',
items: coreSidebar,
},
{
type: 'category',
label: '@react-ecs/three',
items: threeSidebar,
type: 'autogenerated',
dirName: '.', // '.' means the docs folder
},
],
};
2 changes: 1 addition & 1 deletion apps/docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
plugins: ['@babel/plugin-proposal-class-properties'],
plugins: [['@babel/plugin-proposal-class-properties', { loose: true }]],
};
21 changes: 13 additions & 8 deletions apps/docs/docs/introduction.md → apps/docs/docs/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,28 @@ import { Leva } from 'leva';
import BrowserOnly from '@docusaurus/BrowserOnly';
import { Suspense } from 'react';

import { BoidExample } from '../src/scenes/BoidExample'
import { DOMParticles } from '../src/scenes/DOMParticles'
import { BoidExample } from '../src/scenes/BoidExample';
import { DOMParticles } from '../src/scenes/DOMParticles';
import { Example } from '../src/components/Example';

`react-ecs` is a declarative "Entity Component System" for React.

<Leva hidden />

<Example hideControls style={{backgroundColor: 'black', height: '250px' }}>
<BoidExample />
<Example hideControls style={{ backgroundColor: 'black', height: '250px' }}>
<BoidExample />
</Example>

<div style={{float: "right"}}>These boids are driven by react-ecs! Try dragging and zooming!</div>
<div style={{ float: 'right' }}>
These boids are driven by react-ecs! Try dragging and zooming!
</div>

## What's that?

<img style={{float: "right", maxWidth: "400px", marginLeft: "10px"}} src="https://i.imgur.com/nTfGWyF.png" />
<img
style={{ float: 'right', maxWidth: '400px', marginLeft: '10px' }}
src="https://i.imgur.com/nTfGWyF.png"
/>

An **ECS**, or _Entity Component System_ is a design pattern popular in game development. It eschews rich objects for simple **Entities** that compose data-only Components, or **Facets** as `react-ecs` calls them (to avoid confusion with React Components).

Expand Down Expand Up @@ -197,6 +202,6 @@ export const DOMParticles = () => {
}
```

<Example hideControls style={{height: "250px"}}>
<DOMParticles />
<Example hideControls style={{ height: '250px' }}>
<DOMParticles />
</Example>
File renamed without changes.
6 changes: 3 additions & 3 deletions apps/docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
href: 'https://discord.gg/RJqjqAnmJ8',
label: 'Discord',
position: 'right',
}
},
],
},
footer: {
Expand Down Expand Up @@ -175,7 +175,7 @@ module.exports = {
allReflectionsHaveOwnDocument: true,
readme: 'none',
sidebar: {
sidebarFile: './core-sidebar.js',
categoryLabel: '@react-ecs/core',
},
watch: true,
},
Expand All @@ -193,7 +193,7 @@ module.exports = {
allReflectionsHaveOwnDocument: true,
readme: 'none',
sidebar: {
sidebarFile: './three-sidebar.js',
categoryLabel: '@react-ecs/three',
},
watch: true,
},
Expand Down
44 changes: 44 additions & 0 deletions apps/docs/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "docs",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/docs/src",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"ignorePath": "apps/docs/.eslintignore",
"eslintConfig": "apps/docs/.eslintrc.json",
"lintFilePatterns": ["apps/docs/**/*.{ts,tsx,js,jsx}"]
}
},
"fix": {
"executor": "@nrwl/linter:eslint",
"options": {
"fix": true,
"ignorePath": "apps/docs/.eslintignore",
"eslintConfig": "apps/docs/.eslintrc.json",
"lintFilePatterns": ["apps/docs/**/*.{ts,tsx,js,jsx}"]
}
},
"build": {
"executor": "@nx-plus/docusaurus:browser",
"options": {
"path": "apps/docs",
"outputPath": "dist/apps/docs"
}
},
"serve": {
"executor": "@nx-plus/docusaurus:dev-server",
"options": {
"port": 3000
}
},
"publish": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["bin/publish-site.sh"]
}
}
}
}
16 changes: 11 additions & 5 deletions apps/docs/src/scenes/DOMParticles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,17 @@ export const DOMParticles = () => {
Math.random() * s - s * 0.5;
const randomVector = (s: number) =>
new Vector2(rnd(s), rnd(s));
const rndPos = () =>
randomVector(offset).add(new Vector2(
containerRef.current.offsetWidth / 2,
containerRef.current.offsetHeight / 2,
))
const rndPos = () => {
const container = containerRef.current;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example of a bug I fixed (but there are more like it). It errors during the render function when the container unmounts. I think it would get swallowed in production, but on the dev server it shows up as an error blocking the screen that you have to X out


const containerPos =
container ? new Vector2(
container.offsetWidth / 2,
container.offsetHeight / 2,
) : new Vector2(0, 0);

randomVector(offset).add(containerPos);
};

return (
<div ref={containerRef}>
Expand Down
66 changes: 66 additions & 0 deletions libs/boids/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "boids",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/boids/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"ignorePath": "libs/boids/.eslintignore",
"eslintConfig": "libs/boids/.eslintrc.json",
"lintFilePatterns": ["libs/boids/**/*.{ts,tsx,js,jsx}"]
}
},
"fix": {
"executor": "@nrwl/linter:eslint",
"options": {
"fix": true,
"ignorePath": "libs/boids/.eslintignore",
"eslintConfig": "libs/boids/.eslintrc.json",
"lintFilePatterns": ["libs/boids/**/*.{ts,tsx,js,jsx}"]
}
},
"build": {
"executor": "@nrwl/web:package",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/boids",
"tsConfig": "libs/boids/tsconfig.lib.json",
"project": "libs/boids/package.json",
"entryFile": "libs/boids/src/index.ts",
"external": [
"react",
"react-dom",
"react/jsx-runtime",
"react/jsx-dev-runtime"
],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"assets": [
{
"glob": "README.md",
"input": ".",
"output": "."
}
]
}
},
"publish": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"npm whoami",
"npm publish dist/libs/boids --access public"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/boids"],
"options": {
"jestConfig": "libs/boids/jest.config.js",
"passWithNoTests": true
}
}
}
}
66 changes: 66 additions & 0 deletions libs/core/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "core",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/core/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"ignorePath": "libs/core/.eslintignore",
"eslintConfig": "libs/core/.eslintrc.json",
"lintFilePatterns": ["libs/core/**/*.{ts,tsx,js,jsx}"]
}
},
"fix": {
"executor": "@nrwl/linter:eslint",
"options": {
"fix": true,
"ignorePath": "libs/core/.eslintignore",
"eslintConfig": "libs/core/.eslintrc.json",
"lintFilePatterns": ["libs/core/**/*.{ts,tsx,js,jsx}"]
}
},
"build": {
"executor": "@nrwl/web:package",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/core",
"tsConfig": "libs/core/tsconfig.lib.json",
"project": "libs/core/package.json",
"entryFile": "libs/core/src/index.ts",
"external": [
"react",
"react-dom",
"react/jsx-runtime",
"react/jsx-dev-runtime"
],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"assets": [
{
"glob": "README.md",
"input": ".",
"output": "."
}
]
}
},
"publish": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"npm --userconfig /home/ldlework/.npmrc whoami",
"npm publish dist/libs/core --access public"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/core"],
"options": {
"jestConfig": "libs/core/jest.config.js",
"passWithNoTests": true
}
}
}
}
5 changes: 3 additions & 2 deletions libs/core/src/components/Entity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import { ECSContext } from "./ECS";

export type EntityProps = {
entity?: _Entity;
children: ReactNode;
};

export class Entity extends Component {
export class Entity extends Component<EntityProps> {
static contextType = ECSContext;
context!: ContextType<typeof ECSContext>;

public entity: _Entity;

constructor(props: { children: ReactNode }) {
constructor(props: EntityProps) {
super(props);
this.entity = new _Entity();
}
Expand Down
66 changes: 66 additions & 0 deletions libs/three/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "three",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/three/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"ignorePath": "libs/three/.eslintignore",
"eslintConfig": "libs/three/.eslintrc.json",
"lintFilePatterns": ["libs/three/**/*.{ts,tsx,js,jsx}"]
}
},
"fix": {
"executor": "@nrwl/linter:eslint",
"options": {
"fix": true,
"ignorePath": "libs/three/.eslintignore",
"eslintConfig": "libs/three/.eslintrc.json",
"lintFilePatterns": ["libs/three/**/*.{ts,tsx,js,jsx}"]
}
},
"build": {
"executor": "@nrwl/web:package",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/three",
"tsConfig": "libs/three/tsconfig.lib.json",
"project": "libs/three/package.json",
"entryFile": "libs/three/src/index.ts",
"external": [
"react",
"react-dom",
"react/jsx-runtime",
"react/jsx-dev-runtime"
],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"assets": [
{
"glob": "README.md",
"input": ".",
"output": "."
}
]
}
},
"publish": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"npm whoami",
"npm publish dist/libs/three --access public"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/three"],
"options": {
"jestConfig": "libs/three/jest.config.js",
"passWithNoTests": true
}
}
}
}
Loading