mathbox-react 0.0.11-rc → 0.0.13
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/build/cjs/components/components.d.ts +2 -2
- package/build/cjs/components/types.d.ts +2 -2
- package/build/cjs/components/util.d.ts +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/index.js.map +1 -1
- package/build/esm/components/components.d.ts +2 -2
- package/build/esm/components/types.d.ts +2 -2
- package/build/esm/components/util.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/package.json +12 -17
- package/.eslintrc.js +0 -72
- package/.github/renovate.json +0 -13
- package/.github/workflows/lint.yaml +0 -20
- package/.prettierrc +0 -1
- package/.storybook/main.js +0 -9
- package/.storybook/preview.js +0 -11
- package/LICENSE +0 -29
- package/README.md +0 -6
- package/babel.config.js +0 -3
- package/build/cjs/components/components.spec.d.ts +0 -1
- package/build/cjs/stories/utils.d.ts +0 -5
- package/build/esm/components/components.spec.d.ts +0 -1
- package/build/esm/stories/utils.d.ts +0 -5
- package/jest.config.js +0 -12
- package/rollup.config.js +0 -38
- package/src/components/ContainedMathbox.tsx +0 -38
- package/src/components/Mathbox.tsx +0 -63
- package/src/components/MathboxNodeContext.ts +0 -6
- package/src/components/components.spec.tsx +0 -311
- package/src/components/components.tsx +0 -443
- package/src/components/index.ts +0 -3
- package/src/components/types.ts +0 -9
- package/src/components/util.ts +0 -106
- package/src/index.ts +0 -1
- package/src/stories/Cartesian.stories.tsx +0 -36
- package/src/stories/Grid.stories.tsx +0 -38
- package/src/stories/Mathbox.stories.tsx +0 -16
- package/src/stories/Point.stories.tsx +0 -75
- package/src/stories/utils.tsx +0 -33
- package/src/testSetup.ts +0 -3
- package/src/testUtils.ts +0 -46
- package/tsconfig.base.json +0 -17
- package/tsconfig.json +0 -5
package/build/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NodeType, Props, MathboxSelection, RootProps } from 'mathbox';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type WithChildren<T> = {
|
|
5
5
|
children?: ReactNode | ReactNode[];
|
|
6
6
|
} & T;
|
|
7
7
|
|
|
8
8
|
declare const CAN_HAVE_CHILDREN: readonly ["view", "cartesian", "cartesian4", "polar", "spherical", "stereographic", "stereographic4", "transform", "transform4", "vertex", "fragment", "layer", "mask", "group", "inherit", "root", "unit", "rtt", "clock", "now", "move", "present", "reveal", "slide"];
|
|
9
|
-
|
|
9
|
+
type ParentNodeTypes = typeof CAN_HAVE_CHILDREN[number];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type LiveProps<P> = {
|
|
12
12
|
[K in keyof P]: (t: number, dt: number) => P[K];
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type MathboxComponent<T extends NodeType> = React.ForwardRefExoticComponent<(T extends ParentNodeTypes ? WithChildren<Props[T]> : Props[T]) & React.RefAttributes<MathboxSelection<T>> & {
|
|
15
15
|
liveProps?: LiveProps<Props[T]>;
|
|
16
16
|
}>;
|
|
17
17
|
/**
|
package/package.json
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mathbox-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "React wrapper for Mathbox",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Chris Chudzicki",
|
|
7
7
|
"main": "build/cjs/index.js",
|
|
8
8
|
"module": "build/esm/index.js",
|
|
9
|
-
"types": "build/
|
|
9
|
+
"types": "build/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"build"
|
|
12
|
+
],
|
|
10
13
|
"scripts": {
|
|
11
|
-
"build": "rm -rf build && rollup
|
|
12
|
-
"build-
|
|
14
|
+
"build": "rm -rf build && rollup --config",
|
|
15
|
+
"build-watch": "rollup --config --watch",
|
|
13
16
|
"storybook": "start-storybook -p 6006",
|
|
14
|
-
"lint": "
|
|
15
|
-
"format": "
|
|
16
|
-
"autofix": "
|
|
17
|
-
"prepack": "
|
|
17
|
+
"lint": "yarn global:lint",
|
|
18
|
+
"format": "yarn global:format",
|
|
19
|
+
"autofix": "yarn global:autofix",
|
|
20
|
+
"prepack": "yarn build",
|
|
18
21
|
"test": "jest"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
@@ -36,15 +39,8 @@
|
|
|
36
39
|
"@types/three": "0.140.0",
|
|
37
40
|
"babel-jest": "27.5.1",
|
|
38
41
|
"babel-loader": "8.2.5",
|
|
39
|
-
"eslint-config-airbnb": "19.0.4",
|
|
40
|
-
"eslint-config-airbnb-typescript": "17.0.0",
|
|
41
|
-
"eslint-config-prettier": "8.5.0",
|
|
42
|
-
"eslint-config-react-app": "7.0.1",
|
|
43
|
-
"eslint-import-resolver-typescript": "3.5.1",
|
|
44
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
45
42
|
"jest": "27.5.1",
|
|
46
43
|
"mathbox": "2.2.1",
|
|
47
|
-
"prettier": "2.7.1",
|
|
48
44
|
"react": "17.0.2",
|
|
49
45
|
"react-dom": "17.0.2",
|
|
50
46
|
"rollup": "2.79.1",
|
|
@@ -52,8 +48,7 @@
|
|
|
52
48
|
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
53
49
|
"rollup-plugin-terser": "7.0.2",
|
|
54
50
|
"three": "0.140.0",
|
|
55
|
-
"ts-jest": "27.1.5"
|
|
56
|
-
"typescript": "4.8.4"
|
|
51
|
+
"ts-jest": "27.1.5"
|
|
57
52
|
},
|
|
58
53
|
"peerDependencies": {
|
|
59
54
|
"mathbox": "^2.2.1",
|
package/.eslintrc.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
"react-app",
|
|
4
|
-
"react-app/jest",
|
|
5
|
-
"airbnb",
|
|
6
|
-
"airbnb-typescript",
|
|
7
|
-
"prettier",
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:react/recommended",
|
|
10
|
-
"plugin:@typescript-eslint/recommended",
|
|
11
|
-
"plugin:react-hooks/recommended",
|
|
12
|
-
],
|
|
13
|
-
plugins: ["react", "@typescript-eslint", "prettier"],
|
|
14
|
-
rules: {
|
|
15
|
-
"import/no-extraneous-dependencies": [
|
|
16
|
-
"error",
|
|
17
|
-
{
|
|
18
|
-
devDependencies: ["**/*.stories.*", "**/*.spec.*"],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
"import/prefer-default-export": "off",
|
|
22
|
-
"max-classes-per-file": "off",
|
|
23
|
-
"react/destructuring-assignment": "off",
|
|
24
|
-
"react/function-component-definition": [
|
|
25
|
-
"error",
|
|
26
|
-
{
|
|
27
|
-
namedComponents: "arrow-function",
|
|
28
|
-
unnamedComponents: "arrow-function",
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
"@typescript-eslint/no-unused-vars": [
|
|
32
|
-
"warn",
|
|
33
|
-
{
|
|
34
|
-
ignoreRestSiblings: true,
|
|
35
|
-
argsIgnorePattern: "^_",
|
|
36
|
-
varsIgnorePattern: "^_",
|
|
37
|
-
caughtErrorsIgnorePattern: "^_",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
"@typescript-eslint/naming-convention": [
|
|
41
|
-
"error",
|
|
42
|
-
{
|
|
43
|
-
selector: "variable",
|
|
44
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
45
|
-
filter: {
|
|
46
|
-
regex: "^_",
|
|
47
|
-
match: false,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
settings: {},
|
|
53
|
-
overrides: [
|
|
54
|
-
{
|
|
55
|
-
files: ["**/*.ts?(x)"],
|
|
56
|
-
rules: {
|
|
57
|
-
"react/prop-types": "off",
|
|
58
|
-
"react/require-default-props": "off",
|
|
59
|
-
"react/jsx-props-no-spreading": "off",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
files: ["**/*.stories.*"],
|
|
64
|
-
rules: {
|
|
65
|
-
"import/no-anonymous-default-export": "off",
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
parserOptions: {
|
|
70
|
-
project: "./tsconfig.base.json",
|
|
71
|
-
},
|
|
72
|
-
}
|
package/.github/renovate.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
linting_and_tests:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v3
|
|
12
|
-
- uses: actions/setup-node@v3
|
|
13
|
-
with:
|
|
14
|
-
node-version: "16"
|
|
15
|
-
cache: "npm"
|
|
16
|
-
cache-dependency-path: package-lock.json
|
|
17
|
-
- run: npm ci
|
|
18
|
-
- run: npm run format
|
|
19
|
-
- run: npm run lint
|
|
20
|
-
- run: npm run test
|
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
semi: false
|
package/.storybook/main.js
DELETED
package/.storybook/preview.js
DELETED
package/LICENSE
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022, Chris Chudzicki
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
DELETED
package/babel.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/jest.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: "ts-jest",
|
|
3
|
-
transform: {
|
|
4
|
-
"^.+\\.(ts|tsx)?$": "ts-jest",
|
|
5
|
-
"^.+\\.(js|jsx)$": "babel-jest",
|
|
6
|
-
},
|
|
7
|
-
transformIgnorePatterns: [
|
|
8
|
-
"node_modules/(?!(mathbox|threestrap|three|shadergraph)/)",
|
|
9
|
-
],
|
|
10
|
-
testEnvironment: "jsdom",
|
|
11
|
-
setupFiles: ["./src/testSetup.ts"],
|
|
12
|
-
}
|
package/rollup.config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
2
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
3
|
-
import typescript from "@rollup/plugin-typescript";
|
|
4
|
-
import dts from "rollup-plugin-dts";
|
|
5
|
-
import { terser } from "rollup-plugin-terser";
|
|
6
|
-
import peerDepsExternal from "rollup-plugin-peer-deps-external";
|
|
7
|
-
import packageJson from "./package.json";
|
|
8
|
-
|
|
9
|
-
export default [
|
|
10
|
-
{
|
|
11
|
-
input: "src/index.ts",
|
|
12
|
-
output: [
|
|
13
|
-
{
|
|
14
|
-
file: packageJson.main,
|
|
15
|
-
format: "cjs",
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
file: packageJson.module,
|
|
20
|
-
format: "esm",
|
|
21
|
-
sourcemap: true,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
plugins: [
|
|
25
|
-
peerDepsExternal(),
|
|
26
|
-
resolve(),
|
|
27
|
-
commonjs(),
|
|
28
|
-
typescript({ tsconfig: "./tsconfig.json" }),
|
|
29
|
-
terser(),
|
|
30
|
-
],
|
|
31
|
-
external: ["react", "react-dom", "styled-components"],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
input: "build/esm/index.d.ts",
|
|
35
|
-
output: [{ file: "build/index.d.ts", format: "esm" }],
|
|
36
|
-
plugins: [dts()],
|
|
37
|
-
},
|
|
38
|
-
];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useState, forwardRef } from "react"
|
|
2
|
-
import { RootProps, MathBoxOptions, MathboxSelection } from "mathbox"
|
|
3
|
-
import Mathbox from "./Mathbox"
|
|
4
|
-
import { WithChildren } from "./types"
|
|
5
|
-
|
|
6
|
-
type Props = WithChildren<
|
|
7
|
-
{
|
|
8
|
-
containerId?: string
|
|
9
|
-
containerClass?: string
|
|
10
|
-
containerStyle?: React.CSSProperties
|
|
11
|
-
options?: MathBoxOptions
|
|
12
|
-
} & RootProps
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
const ContainedMathbox = (
|
|
16
|
-
props: Props,
|
|
17
|
-
ref: React.Ref<MathboxSelection<"root">>
|
|
18
|
-
) => {
|
|
19
|
-
const { children, containerId, containerClass, containerStyle, ...others } =
|
|
20
|
-
props
|
|
21
|
-
const [container, setContainer] = useState<HTMLDivElement | null>(null)
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
ref={setContainer}
|
|
25
|
-
id={containerId}
|
|
26
|
-
className={containerClass}
|
|
27
|
-
style={containerStyle}
|
|
28
|
-
>
|
|
29
|
-
{container && (
|
|
30
|
-
<Mathbox ref={ref} container={container} {...others}>
|
|
31
|
-
{children}
|
|
32
|
-
</Mathbox>
|
|
33
|
-
)}
|
|
34
|
-
</div>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default forwardRef(ContainedMathbox)
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useState,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
} from "react"
|
|
7
|
-
import { Color } from "three"
|
|
8
|
-
import { mathBox, RootProps, MathboxSelection, MathBoxOptions } from "mathbox"
|
|
9
|
-
import MathboxAPIContext from "./MathboxNodeContext"
|
|
10
|
-
import { WithChildren } from "./types"
|
|
11
|
-
import { useDeepCompareMemo } from "./util"
|
|
12
|
-
|
|
13
|
-
type Props = WithChildren<
|
|
14
|
-
{
|
|
15
|
-
container: HTMLElement
|
|
16
|
-
options?: MathBoxOptions
|
|
17
|
-
} & RootProps
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
const Mathbox = (
|
|
21
|
-
props: Props,
|
|
22
|
-
ref: React.Ref<MathboxSelection<"root"> | null>
|
|
23
|
-
) => {
|
|
24
|
-
const { container, children, options, ...rootProps } = props
|
|
25
|
-
const mathboxOptions = useDeepCompareMemo(options ?? {}, {})
|
|
26
|
-
const [selection, setSelection] = useState<MathboxSelection<"root"> | null>(
|
|
27
|
-
null
|
|
28
|
-
)
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!container) return () => {}
|
|
31
|
-
|
|
32
|
-
const mathbox = mathBox({
|
|
33
|
-
...mathboxOptions,
|
|
34
|
-
element: container,
|
|
35
|
-
})
|
|
36
|
-
setSelection(mathbox)
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* TODO: Should Mathbox component allow setting these more easily?
|
|
40
|
-
*/
|
|
41
|
-
mathbox.three.renderer.setClearColor(new Color(0xffffff), 1.0)
|
|
42
|
-
mathbox.three.camera.position.set(1, 1, 2)
|
|
43
|
-
return () => {
|
|
44
|
-
mathbox.select("*").remove()
|
|
45
|
-
mathbox.three.destroy()
|
|
46
|
-
setSelection(null)
|
|
47
|
-
}
|
|
48
|
-
}, [container, mathboxOptions])
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!selection) return
|
|
52
|
-
selection.set(rootProps)
|
|
53
|
-
}, [selection, rootProps])
|
|
54
|
-
|
|
55
|
-
useImperativeHandle(ref, () => selection, [selection])
|
|
56
|
-
return (
|
|
57
|
-
<MathboxAPIContext.Provider value={selection}>
|
|
58
|
-
{children}
|
|
59
|
-
</MathboxAPIContext.Provider>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default forwardRef(Mathbox)
|