@jiujue/react-canvas-fiber 1.1.3 → 1.1.5
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/dist/index.cjs +43 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ReactDOM = require('react-dom');
|
|
4
5
|
var load = require('yoga-layout/load');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
28
|
+
|
|
29
|
+
var require$1 = (name) => {
|
|
30
|
+
if (name === 'react') return (React__namespace.default || React__namespace);
|
|
31
|
+
if (name === 'react-dom') return (ReactDOM__namespace.default || ReactDOM__namespace);
|
|
32
|
+
throw new Error('Dynamic require of "' + name + '" is not supported');
|
|
33
|
+
};
|
|
7
34
|
var __create = Object.create;
|
|
8
35
|
var __defProp = Object.defineProperty;
|
|
9
36
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
37
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
38
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
39
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
14
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
40
|
+
var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
41
|
+
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
15
42
|
}) : x)(function(x) {
|
|
16
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
43
|
+
if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
|
|
17
44
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
18
45
|
});
|
|
19
46
|
var __commonJS = (cb, mod) => function __require2() {
|
|
@@ -21948,10 +21975,10 @@ function createCanvasRoot(canvas, options) {
|
|
|
21948
21975
|
};
|
|
21949
21976
|
}
|
|
21950
21977
|
function Canvas(props) {
|
|
21951
|
-
const canvasRef =
|
|
21952
|
-
const rootRef =
|
|
21978
|
+
const canvasRef = React.useRef(null);
|
|
21979
|
+
const rootRef = React.useRef(null);
|
|
21953
21980
|
const dpr = props.dpr ?? 1;
|
|
21954
|
-
const canvasStyle =
|
|
21981
|
+
const canvasStyle = React.useMemo(
|
|
21955
21982
|
() => ({
|
|
21956
21983
|
width: props.width,
|
|
21957
21984
|
height: props.height,
|
|
@@ -21961,7 +21988,7 @@ function Canvas(props) {
|
|
|
21961
21988
|
}),
|
|
21962
21989
|
[props.width, props.height, props.style]
|
|
21963
21990
|
);
|
|
21964
|
-
const dispatchPointer =
|
|
21991
|
+
const dispatchPointer = React.useCallback(
|
|
21965
21992
|
(type, e) => {
|
|
21966
21993
|
const canvas = canvasRef.current;
|
|
21967
21994
|
const root = rootRef.current;
|
|
@@ -21988,7 +22015,7 @@ function Canvas(props) {
|
|
|
21988
22015
|
},
|
|
21989
22016
|
[props.width, props.height]
|
|
21990
22017
|
);
|
|
21991
|
-
const handleWheel =
|
|
22018
|
+
const handleWheel = React.useCallback(
|
|
21992
22019
|
(e) => {
|
|
21993
22020
|
const canvas = canvasRef.current;
|
|
21994
22021
|
const root = rootRef.current;
|
|
@@ -22024,7 +22051,7 @@ function Canvas(props) {
|
|
|
22024
22051
|
},
|
|
22025
22052
|
[props.width, props.height]
|
|
22026
22053
|
);
|
|
22027
|
-
const handlePointerDown =
|
|
22054
|
+
const handlePointerDown = React.useCallback(
|
|
22028
22055
|
(e) => {
|
|
22029
22056
|
const canvas = canvasRef.current;
|
|
22030
22057
|
if (canvas && typeof canvas.setPointerCapture === "function") {
|
|
@@ -22037,7 +22064,7 @@ function Canvas(props) {
|
|
|
22037
22064
|
},
|
|
22038
22065
|
[dispatchPointer]
|
|
22039
22066
|
);
|
|
22040
|
-
|
|
22067
|
+
React.useLayoutEffect(() => {
|
|
22041
22068
|
const canvas = canvasRef.current;
|
|
22042
22069
|
if (!canvas) return;
|
|
22043
22070
|
const listener = (e) => {
|
|
@@ -22048,7 +22075,7 @@ function Canvas(props) {
|
|
|
22048
22075
|
canvas.removeEventListener("wheel", listener);
|
|
22049
22076
|
};
|
|
22050
22077
|
}, [handleWheel]);
|
|
22051
|
-
|
|
22078
|
+
React.useLayoutEffect(() => {
|
|
22052
22079
|
const canvas = canvasRef.current;
|
|
22053
22080
|
if (!canvas) return;
|
|
22054
22081
|
rootRef.current = createCanvasRoot(canvas, {
|
|
@@ -22075,7 +22102,7 @@ function Canvas(props) {
|
|
|
22075
22102
|
props.lineHeight,
|
|
22076
22103
|
dpr
|
|
22077
22104
|
]);
|
|
22078
|
-
|
|
22105
|
+
React.useLayoutEffect(() => {
|
|
22079
22106
|
rootRef.current?.render(props.children ?? null);
|
|
22080
22107
|
}, [props.children]);
|
|
22081
22108
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -22093,13 +22120,13 @@ function Canvas(props) {
|
|
|
22093
22120
|
);
|
|
22094
22121
|
}
|
|
22095
22122
|
function View(props) {
|
|
22096
|
-
return
|
|
22123
|
+
return React.createElement("View", props);
|
|
22097
22124
|
}
|
|
22098
22125
|
function Rect(props) {
|
|
22099
|
-
return
|
|
22126
|
+
return React.createElement("Rect", props);
|
|
22100
22127
|
}
|
|
22101
22128
|
function Text(props) {
|
|
22102
|
-
return
|
|
22129
|
+
return React.createElement("Text", props);
|
|
22103
22130
|
}
|
|
22104
22131
|
/*! Bundled license information:
|
|
22105
22132
|
|