ranuts 0.1.0-alpha.12 → 0.1.0-alpha.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 (41) hide show
  1. package/dist/src/node/appendFile.d.ts +0 -1
  2. package/dist/src/node/body.d.ts +0 -1
  3. package/dist/src/node/command.d.ts +0 -1
  4. package/dist/src/node/ctx2req.d.ts +0 -1
  5. package/dist/src/node/fileInfo.d.ts +0 -1
  6. package/dist/src/node/fs.d.ts +0 -3
  7. package/dist/src/node/paresUrl.d.ts +0 -1
  8. package/dist/src/node/readFile.d.ts +0 -1
  9. package/dist/src/node/server.d.ts +0 -1
  10. package/dist/src/node/stream.d.ts +0 -1
  11. package/dist/src/node/traverse.d.ts +0 -1
  12. package/dist/src/node/watchFile.d.ts +0 -1
  13. package/dist/src/node/websocket.d.ts +0 -4
  14. package/dist/src/node/writeFile.d.ts +0 -1
  15. package/dist/src/node/ws.d.ts +0 -1
  16. package/dist/src/utils/visual/application.d.ts +10 -0
  17. package/dist/src/utils/visual/event/boundary.d.ts +1 -1
  18. package/dist/src/utils/visual/event/event.d.ts +1 -1
  19. package/dist/src/utils/visual/event/types.d.ts +2 -1
  20. package/dist/src/utils/visual/graphics/graphics.d.ts +7 -94
  21. package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -2
  22. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +3 -8
  23. package/dist/src/utils/visual/index.d.ts +3 -8
  24. package/dist/src/utils/visual/math/matrix.d.ts +1 -1
  25. package/dist/src/utils/visual/math/transform.d.ts +1 -1
  26. package/dist/src/utils/visual/render/canvasRenderer.d.ts +2 -2
  27. package/dist/src/utils/visual/render/index.d.ts +0 -3
  28. package/dist/src/utils/visual/render/render.d.ts +2 -2
  29. package/dist/src/utils/visual/render/webGlRenderer.d.ts +1 -1
  30. package/dist/src/utils/visual/shape/circle.d.ts +2 -2
  31. package/dist/src/utils/visual/shape/ellipse.d.ts +1 -1
  32. package/dist/src/utils/visual/shape/polygon.d.ts +4 -19
  33. package/dist/src/utils/visual/shape/rectangle.d.ts +2 -12
  34. package/dist/src/utils/visual/shape/shape.d.ts +2 -2
  35. package/dist/src/utils/visual/types.d.ts +1 -11
  36. package/dist/src/utils/visual/vertex/container.d.ts +1 -1
  37. package/dist/umd/index.umd.cjs +1 -1
  38. package/dist/umd/utils/utils.umd.cjs +1 -1
  39. package/package.json +2 -2
  40. package/readme.md +1 -1
  41. package/dist/src/cache/expires.d.ts +0 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="./typings.d.ts" />
2
1
  /**
3
2
  * @description: 给一个已经存在的文件追加内容
4
3
  * @param {string} path 文件路径
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { MiddlewareFunction } from '@/node/server';
3
2
  interface ServerBody {
4
3
  uploadDir: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare const runCommand: (command: string, args: string[]) => Promise<void>;
3
2
  interface PromptOption {
4
3
  message: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
2
  import type { MiddlewareFunction } from '@/node/server';
4
3
  type ConnectMiddleware = (req: IncomingMessage, res: ServerResponse, next?: Function) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="./typings.d.ts" />
2
1
  /**
3
2
  * @description: 查询一个文件的详细信息,一般用于区分文件还是目录(data.isDirectory())
4
3
  * @param {string} path 文件路径
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="./typings.d.ts" />
3
- /// <reference types="node" />
4
1
  import fs from 'node:fs';
5
2
  import type { Noop } from '@/utils/noop';
6
3
  export type FilePromiseResult = Promise<Ranuts.Identification> & {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage } from 'node:http';
3
2
  interface ParseUrl {
4
3
  search?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { FilePromiseResult } from '@/node/fs';
3
2
  /**
4
3
  * @description: 读取一个文件,读取成功返回状态码和文件内容
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
2
  import http from 'node:http';
4
3
  export type Next = () => Promise<never> | Promise<void>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ReadStream, WriteStream } from 'node:fs';
3
2
  interface ReadOption {
4
3
  path: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Stats } from 'node:fs';
3
2
  type Caller = (relPath: string, absPath: string, stats: Stats) => any;
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="./typings.d.ts" />
2
1
  /**
3
2
  * @description: 观察一个文件是否被改变,返回状态
4
3
  * @param {string} path 监听的文件路径
@@ -1,7 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
1
  import http from 'node:http';
6
2
  import type internal from 'node:stream';
7
3
  import EventEmitter from 'node:events';
@@ -1,4 +1,3 @@
1
- /// <reference types="./typings.d.ts" />
2
1
  /**
3
2
  * @description: 根据文件路径创建文件,如果文件存在会清空再写入,如果不存在会创建
4
3
  * @param {string} path 文件路径
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type http from 'node:http';
3
2
  /**
4
3
  * Create a WebSocket Server
@@ -0,0 +1,10 @@
1
+ import { Container } from '@/utils/visual/vertex/container';
2
+ import type { IApplicationOptions } from '@/utils/visual/types';
3
+ export declare class Application {
4
+ private renderer;
5
+ stage: Container;
6
+ view: HTMLCanvasElement;
7
+ constructor(options: IApplicationOptions);
8
+ private render;
9
+ private start;
10
+ }
@@ -1,4 +1,4 @@
1
- import type { Container } from '@/utils/visual/vertex';
1
+ import type { Container } from '@/utils/visual/vertex/container';
2
2
  import type { Cursor, FederatedMouseEvent } from '@/utils/visual/event/types';
3
3
  export declare class EventBoundary {
4
4
  private rootContainer;
@@ -1,4 +1,4 @@
1
- import type { Container } from '@/utils/visual/vertex';
1
+ import type { Container } from '@/utils/visual/vertex/container';
2
2
  export declare class EventSystem {
3
3
  private canvasEle;
4
4
  private eventBoundary;
@@ -1,4 +1,5 @@
1
- import { Container, Point } from '@/utils/visual/vertex';
1
+ import { Point } from '@/utils/visual/vertex/point';
2
+ import { Container } from '@/utils/visual/vertex/container';
2
3
  export declare enum EventPhase {
3
4
  NONE = 0,
4
5
  CAPTURING = 1,
@@ -1,106 +1,19 @@
1
- import { Container } from '@/utils/visual/vertex';
2
- import type { Shape } from '@/utils/visual/shape';
3
- import type { CanvasRenderer } from '@/utils/visual/render';
4
- import type { ILineStyleOptions } from '@/utils/visual/types';
5
- import type { Point } from '@/utils/visual/vertex';
1
+ import { Container } from "@/utils/visual/vertex/container";
2
+ import { Polygon } from "@/utils/visual/shape/polygon";
3
+ import type { Shape } from "@/utils/visual/shape/shape";
4
+ import type { CanvasRenderer } from '@/utils/visual/render/canvasRenderer';
6
5
  export declare class Graphics extends Container {
7
6
  private _lineStyle;
8
7
  private _fillStyle;
9
8
  private _geometry;
10
- private currentPath;
9
+ currentPath: Polygon | null;
11
10
  constructor();
12
- lineStyle(width: number, color?: string, alpha?: number): this;
13
- lineStyle(options: ILineStyleOptions): this;
14
- resetLineStyle(): void;
15
11
  protected drawShape(shape: Shape): Graphics;
16
12
  /**
17
- * 清空已有的 path,开始新的 path
18
- */
13
+ * 清空已有的 path,开始新的 path
14
+ */
19
15
  protected startPoly(): void;
20
- /**
21
- * 开始填充模式,接下来绘制的所有路径都将被填充,直到调用了 endFill
22
- * @param color 填充颜色
23
- * @param alpha 不透明度
24
- */
25
16
  beginFill(color?: string, alpha?: number): Graphics;
26
- /**
27
- * 结束填充模式
28
- */
29
- endFill(): Graphics;
30
- /**
31
- * 画矩形
32
- * @param x x 坐标
33
- * @param y y 坐标
34
- * @param width 宽度
35
- * @param height 高度
36
- */
37
17
  drawRect(x: number, y: number, width: number, height: number): Graphics;
38
- /**
39
- * 画圆
40
- * @param x 圆心 X 坐标
41
- * @param y 圆心 Y 坐标
42
- * @param radius 半径
43
- */
44
- drawCircle(x: number, y: number, radius: number): Graphics;
45
- /**
46
- * 画圆角矩形
47
- * @param x x 坐标
48
- * @param y y 坐标
49
- * @param width 宽度
50
- * @param height 高度
51
- * @param radius 圆角半径
52
- */
53
- drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Graphics;
54
- drawEllipse(x: number, y: number, radiusX: number, radiusY: number): Graphics;
55
- /**
56
- * 画多边形
57
- * @param points 多边形顶点坐标数组,每 2 个元素算一组 (x,y)
58
- */
59
- drawPolygon(points: number[]): Graphics;
60
- moveTo(x: number, y: number): Graphics;
61
- lineTo(x: number, y: number): Graphics;
62
- closePath(): Graphics;
63
- /**
64
- * 画二阶贝塞尔曲线
65
- * @param cpX 控制点的 X 坐标
66
- * @param cpY 控制点的 Y 坐标
67
- * @param toX 终点的 X 坐标
68
- * @param toY 终点的 Y 坐标
69
- */
70
- quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): Graphics;
71
- /**
72
- * 画三阶贝塞尔曲线
73
- * @param cpX 控制点1的X坐标
74
- * @param cpY 控制点1的Y坐标
75
- * @param cpX2 控制点2的X坐标
76
- * @param cpY2 控制点2的Y坐标
77
- * @param toX 终点的X坐标
78
- * @param toY 终点的Y坐标
79
- */
80
- bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Graphics;
81
- /**
82
- * 画圆弧
83
- * @param cx 圆弧对应的圆的中心点的x坐标
84
- * @param cy 圆弧对应的圆的中心点的y坐标
85
- * @param radius 半径
86
- * @param startAngle 开始角度
87
- * @param endAngle 结束角度
88
- * @param anticlockwise 是否逆时针
89
- */
90
- arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): Graphics;
91
- /**
92
- * 画圆弧
93
- * @param x1 控制点1的x坐标
94
- * @param y1 控制点1的y坐标
95
- * @param x2 控制点2的x坐标
96
- * @param y2 控制点2的y坐标
97
- * @param radius 半径
98
- */
99
- arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics;
100
- clear(): Graphics;
101
- /**
102
- * 调用 canvas API 绘制自身
103
- */
104
18
  protected renderCanvas(render: CanvasRenderer): void;
105
- containsPoint(p: Point): boolean;
106
19
  }
@@ -1,5 +1,6 @@
1
- import type { Shape } from '@/utils/visual/shape';
2
- import type { Fill, Line } from '@/utils/visual/style';
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";
3
4
  export declare class GraphicsData {
4
5
  shape: Shape;
5
6
  lineStyle: Line;
@@ -1,15 +1,10 @@
1
- import type { Shape } from '@/utils/visual/shape';
2
- import type { Fill, Line } from '@/utils/visual/style';
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";
3
4
  import { GraphicsData } from '@/utils/visual/graphics/graphicsData';
4
- import type { Point } from '@/utils/visual/vertex';
5
5
  export declare class GraphicsGeometry {
6
6
  graphicsData: GraphicsData[];
7
7
  constructor();
8
8
  drawShape(shape: Shape, fillStyle: Fill, lineStyle: Line): void;
9
- /**
10
- * @param p 待检测点
11
- * @returns {boolean} 待检测点是否落在某一个子图形内
12
- */
13
- containsPoint(p: Point): boolean;
14
9
  clear(): void;
15
10
  }
@@ -1,9 +1,4 @@
1
- export * from '@/utils/visual/vertex';
2
- export * from '@/utils/visual/graphics';
1
+ export * from '@/utils/visual/application';
2
+ export * from '@/utils/visual/vertex/container';
3
+ export * from '@/utils/visual/graphics/graphics';
3
4
  export * from '@/utils/visual/enums';
4
- export * from '@/utils/visual/event';
5
- export * from '@/utils/visual/math';
6
- export * from '@/utils/visual/render';
7
- export * from '@/utils/visual/shape';
8
- export * from '@/utils/visual/style';
9
- export * from '@/utils/visual/types';
@@ -1,4 +1,4 @@
1
- import { Point } from '@/utils/visual/vertex';
1
+ import { Point } from '@/utils/visual/vertex/point';
2
2
  export declare class Matrix {
3
3
  a: number;
4
4
  b: number;
@@ -1,5 +1,5 @@
1
1
  import { Matrix } from '@/utils/visual/math/matrix';
2
- import { ObservablePoint } from '@/utils/visual/vertex';
2
+ import { ObservablePoint } from '@/utils/visual/vertex/point';
3
3
  export declare class Transform {
4
4
  localTransform: Matrix;
5
5
  worldTransform: Matrix;
@@ -1,9 +1,9 @@
1
1
  import { Renderer } from '@/utils/visual/render/render';
2
2
  import type { IApplicationOptions } from '@/utils/visual/types';
3
- import type { Container } from '@/utils/visual/vertex';
3
+ import type { Container } from '@/utils/visual/vertex/container';
4
4
  export declare class CanvasRenderer extends Renderer {
5
5
  ctx: CanvasRenderingContext2D;
6
6
  private background;
7
7
  constructor(options: IApplicationOptions);
8
- render: (container: Container) => void;
8
+ render(container: Container): void;
9
9
  }
@@ -1,6 +1,3 @@
1
1
  import type { Renderer } from '@/utils/visual/render/render';
2
2
  import type { IApplicationOptions } from '@/utils/visual/types';
3
3
  export declare const getRenderer: (options: IApplicationOptions) => Renderer;
4
- export * from '@/utils/visual/render/canvasRenderer';
5
- export * from '@/utils/visual/render/render';
6
- export * from '@/utils/visual/render/webGlRenderer';
@@ -1,5 +1,5 @@
1
- import type { Container } from '@/utils/visual/vertex';
2
- import { Rectangle } from '@/utils/visual/shape';
1
+ import type { Container } from '@/utils/visual/vertex/container';
2
+ import { Rectangle } from '@/utils/visual/shape/rectangle';
3
3
  import type { IApplicationOptions } from '@/utils/visual/types';
4
4
  export declare class Renderer {
5
5
  canvasEle: HTMLCanvasElement;
@@ -1,6 +1,6 @@
1
1
  import { Renderer } from '@/utils/visual/render/render';
2
2
  import type { IApplicationOptions } from '@/utils/visual/types';
3
- import type { Container } from '@/utils/visual/vertex';
3
+ import type { Container } from '@/utils/visual/vertex/container';
4
4
  export declare class WebGlRenderer extends Renderer {
5
5
  constructor(options: IApplicationOptions);
6
6
  render(container: Container): void;
@@ -1,11 +1,11 @@
1
1
  import { Shape } from '@/utils/visual/shape/shape';
2
2
  import { ShapeType } from '@/utils/visual/enums';
3
- import type { Point } from '@/utils/visual/vertex';
3
+ import type { Point } from '@/utils/visual/vertex/point';
4
4
  export declare class Circle extends Shape {
5
5
  x: number;
6
6
  y: number;
7
7
  radius: number;
8
8
  readonly type = ShapeType.Circle;
9
9
  constructor(x?: number, y?: number, radius?: number);
10
- contains(p: Point): boolean;
10
+ contains(point: Point): boolean;
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import { Shape } from '@/utils/visual/shape/shape';
2
2
  import { ShapeType } from '@/utils/visual/enums';
3
- import type { Point } from '@/utils/visual/vertex';
3
+ import type { Point } from '@/utils/visual/vertex/point';
4
4
  export declare class Ellipse extends Shape {
5
5
  x: number;
6
6
  y: number;
@@ -1,25 +1,10 @@
1
1
  import { Shape } from '@/utils/visual/shape/shape';
2
2
  import { ShapeType } from '@/utils/visual/enums';
3
- import type { Point } from '@/utils/visual/vertex';
3
+ import type { Point } from '@/utils/visual/vertex/point';
4
4
  export declare class Polygon extends Shape {
5
5
  points: number[];
6
6
  closeStroke: boolean;
7
- readonly type = ShapeType.Polygon;
8
- constructor(points?: number[]);
9
- /**
10
- *
11
- * @param px 待检测点的 x 坐标
12
- * @param py 待检测点的 y 坐标
13
- * @param p1x 线段的其中一个端点的 x 坐标
14
- * @param p1y 线段的其中一个端点的 y 坐标
15
- * @param p2x 线段的另一个端点的 x 坐标
16
- * @param p2y 线段的另一个端点的 y 坐标
17
- * @returns {boolean} 从待检测点发出的射线是否与线段相交
18
- */
19
- private isIntersect;
20
- /**
21
- * @param p 待检测点
22
- * @returns {boolean} 待检测点是否在多边形内部
23
- */
24
- contains(p: Point): boolean;
7
+ type: ShapeType;
8
+ constructor();
9
+ contains(point: Point): boolean;
25
10
  }
@@ -1,6 +1,6 @@
1
1
  import { Shape } from '@/utils/visual/shape/shape';
2
2
  import { ShapeType } from '@/utils/visual/enums';
3
- import type { Point } from '@/utils/visual/vertex';
3
+ import type { Point } from '@/utils/visual/vertex/point';
4
4
  export declare class Rectangle extends Shape {
5
5
  x: number;
6
6
  y: number;
@@ -8,15 +8,5 @@ export declare class Rectangle extends Shape {
8
8
  height: number;
9
9
  type: ShapeType;
10
10
  constructor(x?: number, y?: number, width?: number, height?: number);
11
- contains(p: Point): boolean;
12
- }
13
- export declare class RoundedRectangle extends Shape {
14
- x: number;
15
- y: number;
16
- width: number;
17
- height: number;
18
- radius: number;
19
- readonly type = ShapeType.RoundedRectangle;
20
- constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
21
- contains(p: Point): boolean;
11
+ contains(point: Point): boolean;
22
12
  }
@@ -1,5 +1,5 @@
1
- import type { ShapeType } from '@/utils/visual/enums';
2
- import type { Point } from '@/utils/visual/vertex';
1
+ import type { ShapeType } from "@/utils/visual/enums";
2
+ import type { Point } from "@/utils/visual/vertex/point";
3
3
  export declare abstract class Shape {
4
4
  abstract type: ShapeType;
5
5
  constructor();
@@ -1,16 +1,6 @@
1
- import type { LineCap, LineJoin, RendererType } from '@/utils/visual/enums';
1
+ import type { RendererType } from '@/utils/visual/enums';
2
2
  export interface IApplicationOptions {
3
3
  rendererType?: RendererType;
4
4
  view: HTMLCanvasElement;
5
5
  backgroundColor?: string;
6
6
  }
7
- export interface IFillStyleOptions {
8
- color?: string;
9
- alpha?: number;
10
- visible?: boolean;
11
- }
12
- export interface ILineStyleOptions extends IFillStyleOptions {
13
- width?: number;
14
- cap?: LineCap;
15
- join?: LineJoin;
16
- }
@@ -1,5 +1,5 @@
1
1
  import { Vertex } from '@/utils/visual/vertex/vertex';
2
- import type { CanvasRenderer } from '@/utils/visual/render';
2
+ import type { CanvasRenderer } from '@/utils/visual/render/canvasRenderer';
3
3
  import type { Point } from '@/utils/visual/vertex/point';
4
4
  export declare class Container extends Vertex {
5
5
  readonly children: Container[];