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.
Files changed (45) hide show
  1. package/build/cjs/components/components.d.ts +2 -2
  2. package/build/cjs/components/types.d.ts +2 -2
  3. package/build/cjs/components/util.d.ts +1 -1
  4. package/build/cjs/index.js +1 -1
  5. package/build/cjs/index.js.map +1 -1
  6. package/build/esm/components/components.d.ts +2 -2
  7. package/build/esm/components/types.d.ts +2 -2
  8. package/build/esm/components/util.d.ts +1 -1
  9. package/build/esm/index.js +1 -1
  10. package/build/esm/index.js.map +1 -1
  11. package/build/index.d.ts +4 -4
  12. package/package.json +12 -17
  13. package/.eslintrc.js +0 -72
  14. package/.github/renovate.json +0 -13
  15. package/.github/workflows/lint.yaml +0 -20
  16. package/.prettierrc +0 -1
  17. package/.storybook/main.js +0 -9
  18. package/.storybook/preview.js +0 -11
  19. package/LICENSE +0 -29
  20. package/README.md +0 -6
  21. package/babel.config.js +0 -3
  22. package/build/cjs/components/components.spec.d.ts +0 -1
  23. package/build/cjs/stories/utils.d.ts +0 -5
  24. package/build/esm/components/components.spec.d.ts +0 -1
  25. package/build/esm/stories/utils.d.ts +0 -5
  26. package/jest.config.js +0 -12
  27. package/rollup.config.js +0 -38
  28. package/src/components/ContainedMathbox.tsx +0 -38
  29. package/src/components/Mathbox.tsx +0 -63
  30. package/src/components/MathboxNodeContext.ts +0 -6
  31. package/src/components/components.spec.tsx +0 -311
  32. package/src/components/components.tsx +0 -443
  33. package/src/components/index.ts +0 -3
  34. package/src/components/types.ts +0 -9
  35. package/src/components/util.ts +0 -106
  36. package/src/index.ts +0 -1
  37. package/src/stories/Cartesian.stories.tsx +0 -36
  38. package/src/stories/Grid.stories.tsx +0 -38
  39. package/src/stories/Mathbox.stories.tsx +0 -16
  40. package/src/stories/Point.stories.tsx +0 -75
  41. package/src/stories/utils.tsx +0 -33
  42. package/src/testSetup.ts +0 -3
  43. package/src/testUtils.ts +0 -46
  44. package/tsconfig.base.json +0 -17
  45. 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
- declare type WithChildren<T> = {
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
- declare type ParentNodeTypes = typeof CAN_HAVE_CHILDREN[number];
9
+ type ParentNodeTypes = typeof CAN_HAVE_CHILDREN[number];
10
10
 
11
- declare type LiveProps<P> = {
11
+ type LiveProps<P> = {
12
12
  [K in keyof P]: (t: number, dt: number) => P[K];
13
13
  };
14
- declare type MathboxComponent<T extends NodeType> = React.ForwardRefExoticComponent<(T extends ParentNodeTypes ? WithChildren<Props[T]> : Props[T]) & React.RefAttributes<MathboxSelection<T>> & {
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.11-rc",
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/esm/types",
9
+ "types": "build/index.d.ts",
10
+ "files": [
11
+ "build"
12
+ ],
10
13
  "scripts": {
11
- "build": "rm -rf build && rollup -c",
12
- "build-storybook": "build-storybook",
14
+ "build": "rm -rf build && rollup --config",
15
+ "build-watch": "rollup --config --watch",
13
16
  "storybook": "start-storybook -p 6006",
14
- "lint": "eslint \"src/**/*.{ts,tsx}\" --max-warnings=0",
15
- "format": "prettier src",
16
- "autofix": "npm run format -- --write && npm run lint -- --fix",
17
- "prepack": "npm run build",
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
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": [
3
- "config:base"
4
- ],
5
- "labels": ["dependencies"],
6
- "packageRules": [
7
- {
8
- "matchDepTypes": ["devDependencies"],
9
- "automerge": true,
10
- "automergeType": "branch"
11
- }
12
- ]
13
- }
@@ -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
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
3
- addons: [
4
- "@storybook/addon-links",
5
- "@storybook/addon-essentials",
6
- "@storybook/addon-interactions",
7
- ],
8
- framework: "@storybook/react",
9
- };
@@ -1,11 +0,0 @@
1
- import "mathbox/build/mathbox.css";
2
-
3
- export const parameters = {
4
- actions: { argTypesRegex: "^on[A-Z].*" },
5
- controls: {
6
- matchers: {
7
- color: /(background|color)$/i,
8
- date: /Date$/,
9
- },
10
- },
11
- };
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
@@ -1,6 +0,0 @@
1
- To run the example, clone this repo and:
2
- ```
3
- cd example
4
- npm install
5
- npm run start
6
- ```
package/babel.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: [["@babel/preset-env", { targets: { node: "current" } }]],
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { ContainedMathbox } from "../components";
3
- declare type MathboxProps = React.ComponentProps<typeof ContainedMathbox>;
4
- export declare const CustomMathbox: (props: MathboxProps) => JSX.Element;
5
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { ContainedMathbox } from "../components";
3
- declare type MathboxProps = React.ComponentProps<typeof ContainedMathbox>;
4
- export declare const CustomMathbox: (props: MathboxProps) => JSX.Element;
5
- 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)
@@ -1,6 +0,0 @@
1
- import { createContext } from "react"
2
- import { MathboxSelection, NodeType } from "mathbox"
3
-
4
- const MathboxAPIContext = createContext<MathboxSelection<NodeType> | null>(null)
5
-
6
- export default MathboxAPIContext