ranuts 0.1.0-alpha.2 → 0.1.0-alpha.20

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build/build.es.d.ts +2 -0
  3. package/dist/build/build.umd.d.ts +2 -0
  4. package/dist/build/build.umd.ml.d.ts +2 -0
  5. package/dist/build/build.umd.node.d.ts +2 -0
  6. package/dist/build/build.umd.react.d.ts +2 -0
  7. package/dist/build/build.umd.utils.d.ts +2 -0
  8. package/dist/build/build.umd.wasm.d.ts +2 -0
  9. package/dist/examples/clone-deep-example.d.ts +1 -0
  10. package/dist/examples/is-equal-example.d.ts +1 -0
  11. package/dist/index.d.ts +9 -16
  12. package/dist/index.js +147 -1116
  13. package/dist/mimeType-CrLryRe7.js +81821 -0
  14. package/dist/plugins/vite-plugins-banner.d.ts +2 -0
  15. package/dist/reactify-Z-V9Vblb.js +83 -0
  16. package/dist/src/arithmetic/index.d.ts +186 -0
  17. package/dist/src/cache/expires.d.ts +1 -0
  18. package/dist/src/ml/index.d.ts +2 -0
  19. package/dist/src/ml/index.js +1243 -0
  20. package/dist/src/ml/ocr.d.ts +11 -0
  21. package/dist/src/node/appendFile.d.ts +7 -0
  22. package/dist/src/node/body.d.ts +9 -0
  23. package/dist/src/node/color.d.ts +7 -0
  24. package/dist/src/node/command.d.ts +8 -0
  25. package/dist/src/node/ctx2req.d.ts +5 -0
  26. package/dist/src/node/fileInfo.d.ts +7 -0
  27. package/dist/src/node/fs.d.ts +7 -0
  28. package/dist/src/node/get.d.ts +10 -0
  29. package/dist/src/node/getIPAdress.d.ts +1 -0
  30. package/dist/src/node/index.d.ts +25 -0
  31. package/dist/src/node/index.js +54 -0
  32. package/dist/src/node/isColorSupported.d.ts +2 -0
  33. package/dist/src/node/paresUrl.d.ts +19 -0
  34. package/dist/src/node/readDir.d.ts +6 -0
  35. package/dist/src/node/readFile.d.ts +9 -0
  36. package/dist/src/node/router.d.ts +42 -0
  37. package/dist/src/node/send.d.ts +7 -0
  38. package/dist/src/node/server.d.ts +18 -0
  39. package/dist/src/node/startTask.d.ts +2 -0
  40. package/dist/src/node/stream.d.ts +15 -0
  41. package/dist/src/node/taskEnd.d.ts +2 -0
  42. package/dist/src/node/traverse.d.ts +17 -0
  43. package/dist/src/node/watchFile.d.ts +8 -0
  44. package/dist/src/node/websocket.d.ts +57 -0
  45. package/dist/src/node/writeFile.d.ts +8 -0
  46. package/dist/src/node/ws.d.ts +8 -0
  47. package/dist/src/optimize/index.d.ts +36 -0
  48. package/dist/src/optimize/promise.d.ts +0 -0
  49. package/dist/src/ran/commit.d.ts +0 -0
  50. package/dist/src/ran/dom.d.ts +0 -0
  51. package/dist/src/ran/hooks.d.ts +0 -0
  52. package/dist/src/ran/index.d.ts +20 -0
  53. package/dist/src/ran/min.d.ts +32 -0
  54. package/dist/src/ran/reconcile.d.ts +0 -0
  55. package/dist/src/ran/schedule.d.ts +0 -0
  56. package/dist/src/react/index.d.ts +2 -0
  57. package/dist/src/react/index.js +4 -0
  58. package/dist/src/react/reactify.d.ts +2 -0
  59. package/dist/src/sort/bubble.d.ts +7 -0
  60. package/dist/src/sort/bucket.d.ts +7 -0
  61. package/dist/src/sort/count.d.ts +7 -0
  62. package/dist/src/sort/heap.d.ts +7 -0
  63. package/dist/src/sort/index.d.ts +0 -0
  64. package/dist/src/sort/insert.d.ts +7 -0
  65. package/dist/src/sort/merge.d.ts +7 -0
  66. package/dist/src/sort/quick.d.ts +7 -0
  67. package/dist/src/sort/radix.d.ts +7 -0
  68. package/dist/src/sort/randomArray.d.ts +9 -0
  69. package/dist/src/sort/select.d.ts +7 -0
  70. package/dist/src/sort/shell.d.ts +7 -0
  71. package/dist/src/utils/audioRecorder.d.ts +16 -0
  72. package/dist/src/utils/behavior.d.ts +15 -0
  73. package/dist/src/utils/bom.d.ts +220 -0
  74. package/dist/src/utils/color.d.ts +71 -0
  75. package/dist/src/utils/compose.d.ts +10 -0
  76. package/dist/src/utils/console.d.ts +1 -0
  77. package/dist/src/utils/debounce.d.ts +7 -0
  78. package/dist/src/utils/device.d.ts +25 -0
  79. package/dist/src/utils/dom.d.ts +105 -0
  80. package/dist/src/utils/error.d.ts +1 -0
  81. package/dist/src/utils/img.d.ts +16 -0
  82. package/dist/src/utils/index.d.ts +35 -0
  83. package/dist/src/utils/index.js +4504 -0
  84. package/dist/src/utils/memoize.d.ts +7 -0
  85. package/dist/src/utils/mimeType.d.ts +3 -0
  86. package/dist/src/utils/monitor.d.ts +38 -0
  87. package/dist/src/utils/network.d.ts +39 -0
  88. package/dist/src/utils/noop.d.ts +2 -0
  89. package/dist/src/utils/number.d.ts +45 -0
  90. package/dist/src/utils/obj.d.ts +83 -0
  91. package/dist/src/utils/performance.d.ts +21 -0
  92. package/dist/src/utils/queue.d.ts +33 -0
  93. package/dist/src/utils/report.d.ts +8 -0
  94. package/dist/src/utils/request.d.ts +17 -0
  95. package/dist/src/utils/script.d.ts +7 -0
  96. package/dist/src/utils/signal.d.ts +6 -0
  97. package/dist/src/utils/storage.d.ts +2 -0
  98. package/dist/src/utils/str.d.ts +72 -0
  99. package/dist/src/utils/subscribe.d.ts +46 -0
  100. package/dist/src/utils/throttle.d.ts +15 -0
  101. package/dist/src/utils/time.d.ts +20 -0
  102. package/dist/src/utils/totp/sha/common.d.ts +151 -0
  103. package/dist/src/utils/totp/sha/converters.d.ts +88 -0
  104. package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
  105. package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
  106. package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
  107. package/dist/src/utils/totp/sha/sha.d.ts +103 -0
  108. package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
  109. package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
  110. package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
  111. package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
  112. package/dist/src/utils/totp/totp.d.ts +23 -0
  113. package/dist/src/utils/visual/application.d.ts +14 -0
  114. package/dist/src/utils/visual/demo/index.d.ts +1 -0
  115. package/dist/src/utils/visual/demo/sankey.d.ts +2 -0
  116. package/dist/src/utils/visual/enums.d.ts +27 -0
  117. package/dist/src/utils/visual/event/boundary.d.ts +22 -0
  118. package/dist/src/utils/visual/event/event.d.ts +14 -0
  119. package/dist/src/utils/visual/event/index.d.ts +6 -0
  120. package/dist/src/utils/visual/event/types.d.ts +32 -0
  121. package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
  122. package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
  123. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
  124. package/dist/src/utils/visual/graphics/index.d.ts +4 -0
  125. package/dist/src/utils/visual/index.d.ts +7 -0
  126. package/dist/src/utils/visual/math/bezier.d.ts +2 -0
  127. package/dist/src/utils/visual/math/enums.d.ts +3 -0
  128. package/dist/src/utils/visual/math/index.d.ts +5 -0
  129. package/dist/src/utils/visual/math/matrix.d.ts +113 -0
  130. package/dist/src/utils/visual/math/transform.d.ts +29 -0
  131. package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
  132. package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
  133. package/dist/src/utils/visual/render/index.d.ts +3 -0
  134. package/dist/src/utils/visual/render/render.d.ts +15 -0
  135. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  136. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  137. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  138. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  139. package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
  140. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
  141. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  142. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  143. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  144. package/dist/src/utils/visual/render/webGlRenderer.d.ts +17 -0
  145. package/dist/src/utils/visual/shape/circle.d.ts +11 -0
  146. package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
  147. package/dist/src/utils/visual/shape/index.d.ts +7 -0
  148. package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
  149. package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
  150. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  151. package/dist/src/utils/visual/shape/shape.d.ts +6 -0
  152. package/dist/src/utils/visual/style/fill.d.ts +8 -0
  153. package/dist/src/utils/visual/style/index.d.ts +3 -0
  154. package/dist/src/utils/visual/style/line.d.ts +10 -0
  155. package/dist/src/utils/visual/types.d.ts +17 -0
  156. package/dist/src/utils/visual/vertex/container.d.ts +73 -0
  157. package/dist/src/utils/visual/vertex/index.d.ts +5 -0
  158. package/dist/src/utils/visual/vertex/point.d.ts +18 -0
  159. package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
  160. package/dist/src/vnode/chainDom.d.ts +47 -0
  161. package/dist/src/vnode/h.d.ts +6 -0
  162. package/dist/src/vnode/hooks.d.ts +23 -0
  163. package/dist/src/vnode/htmlDomApi.d.ts +33 -0
  164. package/dist/src/vnode/init.d.ts +2 -0
  165. package/dist/src/vnode/is.d.ts +5 -0
  166. package/dist/src/vnode/modules/attributes.d.ts +8 -0
  167. package/dist/src/vnode/modules/class.d.ts +8 -0
  168. package/dist/src/vnode/modules/index.d.ts +3 -0
  169. package/dist/src/vnode/modules/listeners.d.ts +12 -0
  170. package/dist/src/vnode/modules/props.d.ts +8 -0
  171. package/dist/src/vnode/modules/style.d.ts +14 -0
  172. package/dist/src/vnode/vnode.d.ts +31 -0
  173. package/dist/src/wasm/index.d.ts +2 -0
  174. package/dist/src/wasm/index.js +346 -0
  175. package/dist/src/wasm/word.d.ts +17 -0
  176. package/dist/src/wicket/bridge.d.ts +4 -0
  177. package/dist/src/wicket/index.d.ts +29 -0
  178. package/dist/test/arithmetic.test.d.ts +1 -0
  179. package/dist/test/cloneDeep.test.d.ts +1 -0
  180. package/dist/test/encodeUrl.test.d.ts +1 -0
  181. package/dist/test/escapeHtml.test.d.ts +1 -0
  182. package/dist/test/is-equal.test.d.ts +1 -0
  183. package/dist/test/mimeType.test.d.ts +1 -0
  184. package/dist/test/server.test.d.ts +1 -0
  185. package/dist/test/sort.test.d.ts +1 -0
  186. package/dist/test/status.test.d.ts +1 -0
  187. package/dist/test/totp.test.d.ts +1 -0
  188. package/dist/test/utils/compose.test.d.ts +1 -0
  189. package/dist/test/utils/mergeObj.test.d.ts +1 -0
  190. package/dist/test/utils/ocr.test.d.ts +1 -0
  191. package/dist/test/visual/math.test.d.ts +1 -0
  192. package/dist/test/vnode/index.d.ts +1 -0
  193. package/dist/test/vnode/server.d.ts +2 -0
  194. package/dist/test/vnode/vnode.d.ts +1 -0
  195. package/dist/test/websocket.test.d.ts +1 -0
  196. package/dist/test/writeFile.test.d.ts +1 -0
  197. package/dist/tsconfig.json +25 -0
  198. package/dist/umd/index.umd.cjs +1 -0
  199. package/dist/umd/ml/ml.umd.cjs +1 -0
  200. package/dist/umd/node/node.umd.cjs +1 -0
  201. package/dist/umd/react/react.umd.cjs +1 -0
  202. package/dist/umd/utils/utils.umd.cjs +1 -0
  203. package/dist/umd/wasm/wasm.umd.cjs +1 -0
  204. package/dist/vite.config.d.ts +11 -0
  205. package/dist/ws-ioQsn2UB.js +703 -0
  206. package/package.json +55 -21
  207. package/readme.md +90 -0
  208. package/typings.d.ts +28 -0
  209. package/assets/img/sort/bubble.gif +0 -0
  210. package/assets/img/sort/complexity.png +0 -0
  211. package/assets/img/sort/select.gif +0 -0
  212. package/assets/img/sort/sort.png +0 -0
  213. package/assets/img/tree/balanceTree.png +0 -0
  214. package/dist/index.js.map +0 -1
  215. package/dist/index.umd.cjs +0 -2
  216. package/dist/index.umd.cjs.map +0 -1
@@ -0,0 +1,22 @@
1
+ import type { Container } from '@/utils/visual/vertex/container';
2
+ import type { Cursor, FederatedMouseEvent } from '@/utils/visual/event/types';
3
+ export declare class EventBoundary {
4
+ private rootContainer;
5
+ private hasFoundTarget;
6
+ private hitTarget;
7
+ cursor: Cursor;
8
+ private eventHandlerMap;
9
+ private pressTargetsMap;
10
+ overTargets: Container[];
11
+ constructor(stage: Container);
12
+ private hitTestRecursive;
13
+ private hitTest;
14
+ fireEvent: (event: FederatedMouseEvent) => void;
15
+ private fireMouseMove;
16
+ private fireMouseDown;
17
+ private fireMouseUp;
18
+ private notifyTarget;
19
+ private propagate;
20
+ private dispatchEvent;
21
+ private composePath;
22
+ }
@@ -0,0 +1,14 @@
1
+ import type { Container } from '@/utils/visual/vertex/container';
2
+ export declare class EventSystem {
3
+ private canvasEle;
4
+ private eventBoundary;
5
+ private rootEvent;
6
+ constructor(canvasEle: HTMLCanvasElement, stage: Container);
7
+ private addEvents;
8
+ private onPointerMove;
9
+ private onPointerLeave;
10
+ private onPointerDown;
11
+ private onPointerup;
12
+ private bootstrapEvent;
13
+ private setCursor;
14
+ }
@@ -0,0 +1,6 @@
1
+ import { EventBoundary } from '@/utils/visual/event/boundary';
2
+ import { EventSystem } from '@/utils/visual/event/event';
3
+ import { EventPhase, FederatedMouseEvent } from '@/utils/visual/event/types';
4
+ import type { Cursor, FederatedEventMap } from '@/utils/visual/event/types';
5
+ export { EventBoundary, EventSystem, EventPhase, FederatedMouseEvent };
6
+ export type { FederatedEventMap, Cursor };
@@ -0,0 +1,32 @@
1
+ import { Point } from '@/utils/visual/vertex/point';
2
+ import { Container } from '@/utils/visual/vertex/container';
3
+ export declare enum EventPhase {
4
+ NONE = 0,
5
+ CAPTURING = 1,
6
+ AT_TARGET = 2,
7
+ BUBBLING = 3
8
+ }
9
+ export declare class FederatedMouseEvent {
10
+ isTrusted: boolean;
11
+ timeStamp: number;
12
+ type: keyof FederatedEventMap;
13
+ button: number;
14
+ buttons: number;
15
+ global: Point;
16
+ propagationStopped: boolean;
17
+ eventPhase: EventPhase;
18
+ target: Container;
19
+ currentTarget: Container;
20
+ stopPropagation(): void;
21
+ }
22
+ export type FederatedEventMap = {
23
+ mousedown: FederatedMouseEvent;
24
+ mouseup: FederatedMouseEvent;
25
+ click: FederatedMouseEvent;
26
+ mouseenter: FederatedMouseEvent;
27
+ mouseleave: FederatedMouseEvent;
28
+ mousemove: FederatedMouseEvent;
29
+ mouseout: FederatedMouseEvent;
30
+ mouseover: FederatedMouseEvent;
31
+ };
32
+ export type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'col-resize' | 'nwse-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing';
@@ -0,0 +1,81 @@
1
+ import { Container } from '@/utils/visual/vertex/container';
2
+ import { Polygon } from '@/utils/visual/shape/polygon';
3
+ import { GraphicsGeometry } from '@/utils/visual/graphics/graphicsGeometry';
4
+ import type { Shape } from '@/utils/visual/shape/shape';
5
+ import type { BatchRenderer } from '@/utils/visual/render/batchRenderer';
6
+ import type { ILineStyleOptions } from '@/utils/visual/types';
7
+ import type { CanvasRenderer } from '@/utils/visual/render/canvasRenderer';
8
+ import type { Point } from '@/utils/visual/vertex/point';
9
+ export declare class Graphics extends Container {
10
+ private _lineStyle;
11
+ private _fillStyle;
12
+ geometry: GraphicsGeometry;
13
+ currentPath: Polygon;
14
+ type: string;
15
+ constructor();
16
+ lineStyle(width: number, color?: string, alpha?: number): Graphics;
17
+ lineStyle(options: ILineStyleOptions): Graphics;
18
+ resetLineStyle: () => void;
19
+ protected drawShape: (shape: Shape) => Graphics;
20
+ /**
21
+ * 清空已有的 path,开始新的 path
22
+ */
23
+ protected startPoly: () => void;
24
+ beginFill: (color?: string, alpha?: number) => Graphics;
25
+ /**
26
+ * 结束填充模式
27
+ */
28
+ endFill: () => Graphics;
29
+ /**
30
+ * 画矩形
31
+ * @param x x 坐标
32
+ * @param y y 坐标
33
+ * @param width 宽度
34
+ * @param height 高度
35
+ */
36
+ drawRect: (x: number, y: number, width: number, height: number) => Graphics;
37
+ /**
38
+ * 画圆
39
+ * @param x 圆心 X 坐标
40
+ * @param y 圆心 Y 坐标
41
+ * @param radius 半径
42
+ */
43
+ drawCircle: (x: number, y: number, radius: number) => Graphics;
44
+ /**
45
+ * 画圆角矩形
46
+ * @param x x 坐标
47
+ * @param y y 坐标
48
+ * @param width 宽度
49
+ * @param height 高度
50
+ * @param radius 圆角半径
51
+ */
52
+ drawRoundedRect: (x: number, y: number, width: number, height: number, radius: number) => Graphics;
53
+ /**
54
+ * 画椭圆
55
+ * @param x 椭圆中心 x 坐标
56
+ * @param y 椭圆中心 y 坐标
57
+ * @param radiusX 椭圆 x 轴半径
58
+ * @param radiusY 椭圆 y 轴半径
59
+ */
60
+ drawEllipse: (x: number, y: number, radiusX: number, radiusY: number) => Graphics;
61
+ /**
62
+ * 画多边形
63
+ * @param points 多边形顶点坐标数组,每 2 个元素算一组 (x,y)
64
+ */
65
+ drawPolygon: (points: number[]) => Graphics;
66
+ moveTo: (x: number, y: number) => Graphics;
67
+ lineTo: (x: number, y: number) => Graphics;
68
+ closePath: () => Graphics;
69
+ containsPoint: (p: Point) => boolean;
70
+ quadraticCurveTo: (cpX: number, cpY: number, toX: number, toY: number) => Graphics;
71
+ bezierCurveTo: (cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number) => Graphics;
72
+ arc: (cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean) => Graphics;
73
+ arcTo: (x1: number, y1: number, x2: number, y2: number, radius: number) => Graphics;
74
+ clear: () => Graphics;
75
+ /**
76
+ * 调用 canvas API 绘制自身
77
+ */
78
+ protected renderCanvas: (render: CanvasRenderer) => void;
79
+ buildBatches: (batchRenderer: BatchRenderer) => void;
80
+ updateBatches: (floatView: Float32Array) => void;
81
+ }
@@ -0,0 +1,13 @@
1
+ import type { Shape } from '@/utils/visual/shape/shape';
2
+ import type { Fill } from '@/utils/visual/style/fill';
3
+ import type { Line } from '@/utils/visual/style/line';
4
+ export declare class GraphicsData {
5
+ shape: Shape;
6
+ lineStyle: Line;
7
+ fillStyle: Fill;
8
+ /**
9
+ * 顶点数组,每 2 个元素代表一个顶点
10
+ */
11
+ vertices: number[];
12
+ constructor(shape: Shape, fillStyle: Fill, lineStyle: Line);
13
+ }
@@ -0,0 +1,35 @@
1
+ import { GraphicsData } from '@/utils/visual/graphics/graphicsData';
2
+ import { CustomFloatArray, CustomIntArray } from '@/utils/visual/render/utils/float';
3
+ import type { Point } from '@/utils/visual/vertex/point';
4
+ import type { BatchPart } from '@/utils/visual/render/utils/batch';
5
+ import type { Shape } from '@/utils/visual/shape/shape';
6
+ import type { Fill } from '@/utils/visual/style/fill';
7
+ import type { Line } from '@/utils/visual/style/line';
8
+ export declare class GraphicsGeometry {
9
+ graphicsData: GraphicsData[];
10
+ private dirty;
11
+ shapeIndex: number;
12
+ /**
13
+ * 每个 batchPart 代表一个 fill 或者一个 stroke
14
+ */
15
+ batchParts: BatchPart[];
16
+ /**
17
+ * 顶点数组,每 2 个元素代表一个顶点
18
+ */
19
+ vertices: CustomFloatArray;
20
+ /**
21
+ * 顶点下标数组,每个元素代表一个顶点下标
22
+ */
23
+ indices: CustomIntArray;
24
+ drawShape(shape: Shape, fillStyle: Fill, lineStyle: Line): void;
25
+ /**
26
+ * @param p 待检测点
27
+ * @returns {boolean} 待检测点是否落在某一个子图形内
28
+ */
29
+ containsPoint(p: Point): boolean;
30
+ /**
31
+ * 将所有子图形都转化成顶点并且进行三角剖分
32
+ */
33
+ buildVerticesAndTriangulate(): void;
34
+ clear(): void;
35
+ }
@@ -0,0 +1,4 @@
1
+ import { Graphics } from '@/utils/visual/graphics/graphics';
2
+ import { GraphicsData } from '@/utils/visual/graphics/graphicsData';
3
+ import { GraphicsGeometry } from '@/utils/visual/graphics/graphicsGeometry';
4
+ export { Graphics, GraphicsData, GraphicsGeometry };
@@ -0,0 +1,7 @@
1
+ import { Application } from '@/utils/visual/application';
2
+ import { Container } from '@/utils/visual/vertex/container';
3
+ import { Graphics } from '@/utils/visual/graphics/graphics';
4
+ import { BYTES_PER_VERTEX, LINE_CAP, LINE_JOIN, MAX_VERTEX_COUNT, RENDERER_TYPE, SHAPE_TYPE } from '@/utils/visual/enums';
5
+ import type { IApplicationOptions, IFillStyleOptions, ILineStyleOptions } from '@/utils/visual/types';
6
+ export { Application, Container, Graphics, SHAPE_TYPE, LINE_CAP, LINE_JOIN, RENDERER_TYPE, MAX_VERTEX_COUNT, BYTES_PER_VERTEX, };
7
+ export type { IApplicationOptions, IFillStyleOptions, ILineStyleOptions };
@@ -0,0 +1,2 @@
1
+ export declare const getBezierLength: (P0X: number, P0Y: number, P1X: number, P1Y: number, P2X: number, P2Y: number, P3X: number, P3Y: number) => number;
2
+ export declare const getQuadraticBezierLength: (P0X: number, P0Y: number, P1X: number, P1Y: number, P2X: number, P2Y: number) => number;
@@ -0,0 +1,3 @@
1
+ export declare const DEG_TO_RAD: number;
2
+ export declare const RAD_TO_DEG: number;
3
+ export declare const PI_2: number;
@@ -0,0 +1,5 @@
1
+ import { getBezierLength, getQuadraticBezierLength } from '@/utils/visual/math/bezier';
2
+ import { DEG_TO_RAD, PI_2, RAD_TO_DEG } from '@/utils/visual/math/enums';
3
+ import { Matrix } from '@/utils/visual/math/matrix';
4
+ import { Transform } from '@/utils/visual/math/transform';
5
+ export { getBezierLength, getQuadraticBezierLength, DEG_TO_RAD, PI_2, RAD_TO_DEG, Matrix, Transform };
@@ -0,0 +1,113 @@
1
+ import { Point } from '@/utils/visual/vertex/point';
2
+ interface TransformableObject {
3
+ position: Point;
4
+ scale: Point;
5
+ pivot: Point;
6
+ skew: Point;
7
+ rotation: number;
8
+ }
9
+ export declare class Matrix {
10
+ a: number;
11
+ b: number;
12
+ c: number;
13
+ d: number;
14
+ tx: number;
15
+ ty: number;
16
+ array: Float32Array | null;
17
+ constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
18
+ set: (a: number, b: number, c: number, d: number, tx: number, ty: number) => Matrix;
19
+ /**
20
+ * 将当前矩阵右乘一个矩阵
21
+ */
22
+ append: (m: Matrix) => Matrix;
23
+ /**
24
+ * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
25
+ *
26
+ * a = array[0]
27
+ * b = array[1]
28
+ * c = array[3]
29
+ * d = array[4]
30
+ * tx = array[2]
31
+ * ty = array[5]
32
+ * @param array - The array that the matrix will be populated from.
33
+ *
34
+ * a,b,tx
35
+ * c,d,ty
36
+ */
37
+ fromArray: (array: number[]) => void;
38
+ /**
39
+ * Translates the matrix on the x and y.
40
+ * @param x - How much to translate x by
41
+ * @param y - How much to translate y by
42
+ * @returns This matrix. Good for chaining method calls.
43
+ */
44
+ translate: (x: number, y: number) => Matrix;
45
+ /**
46
+ * Applies a scale transformation to the matrix.
47
+ * @param x - The amount to scale horizontally
48
+ * @param y - The amount to scale vertically
49
+ * @returns This matrix. Good for chaining method calls.
50
+ */
51
+ scale: (x: number, y: number) => Matrix;
52
+ /**
53
+ * Sets the matrix based on all the available properties
54
+ * @param x - Position on the x axis
55
+ * @param y - Position on the y axis
56
+ * @param pivotX - Pivot on the x axis
57
+ * @param pivotY - Pivot on the y axis
58
+ * @param scaleX - Scale on the x axis
59
+ * @param scaleY - Scale on the y axis
60
+ * @param rotation - Rotation in radians
61
+ * @param skewX - Skew on the x axis
62
+ * @param skewY - Skew on the y axis
63
+ * @returns This matrix. Good for chaining method calls.
64
+ */
65
+ setTransform: (x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number) => Matrix;
66
+ /**
67
+ * Applies a rotation transformation to the matrix.
68
+ * @param angle - The angle in radians.
69
+ * @returns This matrix. Good for chaining method calls.
70
+ */
71
+ rotate: (angle: number) => Matrix;
72
+ /**
73
+ * check to see if two matrices are the same
74
+ * @param matrix - The matrix to compare to.
75
+ */
76
+ equals: (matrix: Matrix) => boolean;
77
+ /**
78
+ * Resets this Matrix to an identity (default) matrix.
79
+ * @returns This matrix. Good for chaining method calls.
80
+ */
81
+ identity: () => Matrix;
82
+ /**
83
+ * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
84
+ * @param transform - The transform to apply the properties to.
85
+ * @returns The transform with the newly applied properties
86
+ */
87
+ decompose: (transform: TransformableObject) => TransformableObject;
88
+ /**
89
+ * 对某个点应用当前的变换矩阵
90
+ * @param p 某个点
91
+ * @returns {Point} 点 p 应用当前变换矩阵后得到的一个新的点
92
+ */
93
+ apply: (p: Point) => Point;
94
+ /**
95
+ * 对某个点应用当前的变换矩阵的逆矩阵
96
+ * @param p 某个点
97
+ * @returns {Point} 点 p 应用当前变换矩阵的逆矩阵后得到的一个新的点
98
+ */
99
+ applyInverse: (p: Point) => Point;
100
+ /**
101
+ * 将当前矩阵左乘一个矩阵
102
+ */
103
+ prepend: (m: Matrix) => Matrix;
104
+ clone: () => Matrix;
105
+ /**
106
+ * Creates an array from the current Matrix object.
107
+ * @param transpose - Whether we need to transpose the matrix or not
108
+ * @param [out=new Float32Array(9)] - If provided the array will be assigned to out
109
+ * @returns The newly created array which contains the matrix
110
+ */
111
+ toArray: (transpose?: boolean, out?: Float32Array) => Float32Array;
112
+ }
113
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Matrix } from '@/utils/visual/math/matrix';
2
+ import { ObservablePoint } from '@/utils/visual/vertex/point';
3
+ export declare class Transform {
4
+ localTransform: Matrix;
5
+ worldTransform: Matrix;
6
+ position: ObservablePoint;
7
+ scale: ObservablePoint<number>;
8
+ pivot: ObservablePoint;
9
+ skew: ObservablePoint<number>;
10
+ _rotation: number;
11
+ private rotateMatrix;
12
+ private skewMatrix;
13
+ private scaleMatrix;
14
+ private localMatrix;
15
+ shouldUpdateLocalTransform: boolean;
16
+ worldId: number;
17
+ private parentId;
18
+ constructor();
19
+ get rotation(): number;
20
+ set rotation(r: number);
21
+ private onSkewChange;
22
+ private onScaleChange;
23
+ private onChange;
24
+ /**
25
+ * 更新 localTransform
26
+ */
27
+ updateLocalTransform(): void;
28
+ updateTransform(parentTransform: Transform): void;
29
+ }
@@ -0,0 +1,72 @@
1
+ import { Renderer } from '@/utils/visual/render/render';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { Batch } from '@/utils/visual/render/utils/batch';
4
+ import type { IApplicationOptions } from '@/utils/visual/types';
5
+ export declare abstract class BatchRenderer extends Renderer {
6
+ /**
7
+ * 顶点个数
8
+ */
9
+ protected vertexCount: number;
10
+ /**
11
+ * 顶点下标个数
12
+ */
13
+ protected indexCount: number;
14
+ protected batches: Array<Batch | undefined>;
15
+ protected batchesCount: number;
16
+ /**
17
+ * 顶点数组 float32 视图
18
+ */
19
+ protected vertFloatView: Float32Array;
20
+ /**
21
+ * 顶点数组 Uint32 视图
22
+ */
23
+ protected vertIntView: Uint32Array;
24
+ /**
25
+ * 顶点下标数组
26
+ */
27
+ protected indexBuffer: Uint32Array;
28
+ /**
29
+ * 当前的 webGL|webGPU vertex buffer 的长度
30
+ */
31
+ protected curVertBufferLength: number;
32
+ /**
33
+ * 当前的 webGL|webGPU index buffer 的长度
34
+ */
35
+ protected curIndexBufferLength: number;
36
+ constructor(options: IApplicationOptions);
37
+ addBatch(batch: Batch): void;
38
+ protected startBuild(): void;
39
+ protected buildEnd(): void;
40
+ /**
41
+ * 如果现有的 typed array 放不下了,则新建一个
42
+ */
43
+ protected resizeBufferIfNeeded(): void;
44
+ /**
45
+ * 将数据打包到大数组里
46
+ */
47
+ protected packData(): void;
48
+ /**
49
+ * 调用 webGL 或 webGPU 的绘制 api 将内容绘制出来
50
+ */
51
+ protected abstract draw(): void;
52
+ /**
53
+ * 更新更新 vertex buffer 和 index buffer
54
+ */
55
+ protected abstract updateBuffer(): void;
56
+ /**
57
+ * 设置投影矩阵,这是为了适配 canvas 元素的尺寸
58
+ */
59
+ protected abstract setProjectionMatrix(): void;
60
+ /**
61
+ * 更新 stage 的 transform 对应的 uniform 变量
62
+ */
63
+ protected abstract setRootTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): void;
64
+ /**
65
+ * 更新子节点的 transform
66
+ */
67
+ protected updateChildrenTransform(rootContainer: Container): void;
68
+ /**
69
+ * 更新节点的位置信息并渲染
70
+ */
71
+ render(rootContainer: Container): void;
72
+ }
@@ -0,0 +1,10 @@
1
+ import { Renderer } from '@/utils/visual/render/render';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ import type { Container } from '@/utils/visual/vertex/container';
4
+ export declare class CanvasRenderer extends Renderer {
5
+ ctx: CanvasRenderingContext2D;
6
+ private backgroundColor;
7
+ private backgroundAlpha;
8
+ constructor(options: IApplicationOptions);
9
+ render(container: Container): void;
10
+ }
@@ -0,0 +1,3 @@
1
+ import type { Renderer } from '@/utils/visual/render/render';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ export declare const getRenderer: (options: IApplicationOptions) => Renderer;
@@ -0,0 +1,15 @@
1
+ import { Rectangle } from '@/utils/visual/shape/rectangle';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { IApplicationOptions } from '@/utils/visual/types';
4
+ export declare abstract class Renderer {
5
+ /**
6
+ * 是否需要重新构建大数组
7
+ */
8
+ static needBuildArr: boolean;
9
+ canvasEle: HTMLCanvasElement;
10
+ screen: Rectangle;
11
+ constructor(options: IApplicationOptions);
12
+ resizeView(width: number, height: number): void;
13
+ abstract render(rootContainer: Container): void;
14
+ init(): Promise<any>;
15
+ }
@@ -0,0 +1,90 @@
1
+ import type { BatchRenderer } from '@/utils/visual/render/batchRenderer';
2
+ import type { Container } from '@/utils/visual/vertex/container';
3
+ import type { Fill } from '@/utils/visual/style';
4
+ import type { Graphics } from '@/utils/visual/graphics';
5
+ /**
6
+ * 构建大数组
7
+ */
8
+ export declare const buildArray: (batchRenderer: BatchRenderer, container: Container) => void;
9
+ /**
10
+ * 更新大数组
11
+ */
12
+ export declare const updateArray: (floatView: Float32Array, container: Container) => void;
13
+ export declare abstract class Batch {
14
+ /**
15
+ * 顶点个数
16
+ */
17
+ vertexCount: number;
18
+ /**
19
+ * 顶点下标个数
20
+ */
21
+ indexCount: number;
22
+ /**
23
+ * rgba 的小端序形式
24
+ */
25
+ rgba: number;
26
+ /**
27
+ * 顶点数据在大数组中的起点
28
+ */
29
+ vertexStart: number;
30
+ /**
31
+ * 顶点下标数据在大数组中的起点
32
+ */
33
+ indexStart: number;
34
+ /**
35
+ * 将顶点数据写入大数组中
36
+ */
37
+ abstract packVertices(floatView: Float32Array, intView: Uint32Array): void;
38
+ /**
39
+ * 将顶点下标数据写入大数组中
40
+ */
41
+ abstract packIndices(int32: Uint32Array): void;
42
+ /**
43
+ * 在大数组中更新顶点位置数据
44
+ */
45
+ abstract updateVertices(floatView: Float32Array): void;
46
+ }
47
+ export declare class BatchPart {
48
+ style: Fill;
49
+ vertexStart: number;
50
+ indexStart: number;
51
+ vertexCount: number;
52
+ indexCount: number;
53
+ constructor(style: Fill);
54
+ start(vertexStart: number, indexStart: number): void;
55
+ end(vertexCount: number, indexCount: number): void;
56
+ }
57
+ export declare abstract class BatchPool {
58
+ protected idx: number;
59
+ abstract getOne(): Batch;
60
+ reset(): void;
61
+ }
62
+ export declare class GraphicsBatchPool extends BatchPool {
63
+ private batches;
64
+ constructor();
65
+ getOne(): GraphicsBatch;
66
+ }
67
+ export declare class GraphicsBatch extends Batch {
68
+ /**
69
+ * 顶点部分在 geometry.vertices 中的起始下标
70
+ */
71
+ vertexOffset: number;
72
+ /**
73
+ * 顶点下标部分在 geometry.indices 中的起始下标
74
+ */
75
+ indexOffset: number;
76
+ /**
77
+ * 对应的 Graphics 实例
78
+ */
79
+ graphics: Graphics;
80
+ packVertices(floatView: Float32Array, intView: Uint32Array): void;
81
+ packIndices(int32: Uint32Array): void;
82
+ updateVertices(floatView: Float32Array): void;
83
+ }
84
+ declare class BatchPools {
85
+ private batchesMap;
86
+ get(type: string): Batch;
87
+ reset(): void;
88
+ }
89
+ export declare const batchPool: BatchPools;
90
+ export {};
@@ -0,0 +1,63 @@
1
+ export declare class CustomFloatArray {
2
+ private _oldLength;
3
+ private _length;
4
+ private curMaxLen;
5
+ private float32;
6
+ private _data;
7
+ /**
8
+ * 获取长度
9
+ */
10
+ get length(): number;
11
+ /**
12
+ * 拼接一个 number 数组
13
+ */
14
+ concat(arr: number[]): void;
15
+ /**
16
+ * 插入数据
17
+ * @param num 要插入的数
18
+ */
19
+ push(num: number): void;
20
+ /**
21
+ * 扩容
22
+ */
23
+ expandCapacity(): void;
24
+ /**
25
+ * 以从 0 到 this.length 的这段 buffer 为底层,建立 Float32Array 视图并返回
26
+ */
27
+ get data(): Float32Array;
28
+ /**
29
+ * 清空
30
+ */
31
+ clear(): void;
32
+ }
33
+ export declare class CustomIntArray {
34
+ private _oldLength;
35
+ private _length;
36
+ private curMaxLen;
37
+ private int32;
38
+ private _data;
39
+ /**
40
+ * 获取长度
41
+ */
42
+ get length(): number;
43
+ /**
44
+ * 拼接一个 number 数组
45
+ */
46
+ concat(arr: number[]): void;
47
+ /**
48
+ * 拼接一个UInt16数组
49
+ */
50
+ concatUInt16(uint16: Uint32Array): void;
51
+ /**
52
+ * 扩容
53
+ */
54
+ expandCapacity(): void;
55
+ /**
56
+ * 以从 0 到 this.length 的这段 buffer 为底层,建立 Uint32Array 视图并返回
57
+ */
58
+ get data(): Uint32Array;
59
+ /**
60
+ * 清空
61
+ */
62
+ clear(): void;
63
+ }
@@ -0,0 +1,3 @@
1
+ export declare const getRgb: (color: string) => [number, number, number];
2
+ export declare const toRgbaLittleEndian: (color: string, alpha: number) => number;
3
+ export declare const toRgbArray: (color: string) => [number, number, number];
@@ -0,0 +1,13 @@
1
+ import type { GraphicsData } from '@/utils/visual/graphics/graphicsData';
2
+ import type { GraphicsGeometry } from '@/utils/visual/graphics/graphicsGeometry';
3
+ /**
4
+ * 将一个图形顶点化
5
+ * @param data 子图形data
6
+ */
7
+ export declare const buildVertices: (data: GraphicsData) => void;
8
+ export declare const triangulateFill: (data: GraphicsData, geometry: GraphicsGeometry) => void;
9
+ export declare const getNormalVector: (x: number, y: number, lineWidth: number) => [number, number];
10
+ /**
11
+ * 构建描边的顶点 & 对其进行三角剖分
12
+ */
13
+ export declare const triangulateStroke: (data: GraphicsData, geometry: GraphicsGeometry) => void;