Skip to content

Commit 45eb2bb

Browse files
committed
main 🧊 fix registry local
1 parent 9db6e16 commit 45eb2bb

File tree

6 files changed

+90
-60
lines changed

6 files changed

+90
-60
lines changed

Diff for: ‎packages/cli/src/registry/utils/extractDependencies.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ export const extractDependencies = (content: string) => {
2525
}
2626

2727
const localMatches = Array.from(
28-
content.matchAll(/(?:import\s+type|import|export)\s*\{([^}]+)\}\s*from\s*['"]\.\/helpers/g)
28+
content.matchAll(/(?:import|export)\s*\{([^}]+)\}\s*from\s*['"]\.\/helpers/g)
2929
);
3030
for (const match of localMatches) {
31-
console.log(match);
3231
const imports = match[1].split(',').map((item) => item.trim());
3332
for (const item of imports) {
3433
if (item) locals.add(item);

Diff for: ‎packages/core/src/bundle/hooks/usePaint/helpers/Paint.js

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
import { Pointer } from './Pointer';
1+
export class Pointer {
2+
x;
3+
y;
4+
constructor(x, y) {
5+
this.x = x;
6+
this.y = y;
7+
}
8+
update(point) {
9+
this.x = point.x;
10+
this.y = point.y;
11+
}
12+
getDifferenceTo(point) {
13+
return new Pointer(this.x - point.x, this.y - point.y);
14+
}
15+
getDistanceTo(point) {
16+
const diff = this.getDifferenceTo(point);
17+
return Math.sqrt(diff.x ** 2 + diff.y ** 2);
18+
}
19+
getAngleTo(point) {
20+
const diff = this.getDifferenceTo(point);
21+
return Math.atan2(diff.y, diff.x);
22+
}
23+
equalsTo(point) {
24+
return this.x === point.x && this.y === point.y;
25+
}
26+
moveByAngle(
27+
// The angle in radians
28+
angle,
29+
// How much the point should be moved
30+
distance) {
31+
// Rotate the angle based on the browser coordinate system ([0,0] in the top left)
32+
const angleRotated = angle + Math.PI / 2;
33+
this.x += Math.sin(angleRotated) * distance;
34+
this.y -= Math.cos(angleRotated) * distance;
35+
return this;
36+
}
37+
}
238
export class Paint {
339
pointer;
440
brush;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './Paint';
2-
export * from './Pointer';

Diff for: ‎packages/core/src/hooks/usePaint/helpers/Paint.ts

+52-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
1-
import type { Point } from './Pointer';
1+
export interface Point {
2+
x: number;
3+
y: number;
4+
}
5+
6+
export class Pointer implements Point {
7+
x: number;
8+
9+
y: number;
10+
11+
constructor(x: number, y: number) {
12+
this.x = x;
13+
this.y = y;
14+
}
15+
16+
update(point: Point) {
17+
this.x = point.x;
18+
this.y = point.y;
19+
}
20+
21+
getDifferenceTo(point: Point) {
22+
return new Pointer(this.x - point.x, this.y - point.y);
23+
}
224

3-
import { Pointer } from './Pointer';
25+
getDistanceTo(point: Point) {
26+
const diff = this.getDifferenceTo(point);
27+
return Math.sqrt(diff.x ** 2 + diff.y ** 2);
28+
}
29+
30+
getAngleTo(point: Point) {
31+
const diff = this.getDifferenceTo(point);
32+
return Math.atan2(diff.y, diff.x);
33+
}
34+
35+
equalsTo(point: Point) {
36+
return this.x === point.x && this.y === point.y;
37+
}
38+
39+
moveByAngle(
40+
// The angle in radians
41+
angle: number,
42+
// How much the point should be moved
43+
distance: number
44+
) {
45+
// Rotate the angle based on the browser coordinate system ([0,0] in the top left)
46+
const angleRotated = angle + Math.PI / 2;
47+
48+
this.x += Math.sin(angleRotated) * distance;
49+
this.y -= Math.cos(angleRotated) * distance;
50+
51+
return this;
52+
}
53+
}
454

555
export class Paint {
656
pointer: Pointer;

Diff for: ‎packages/core/src/hooks/usePaint/helpers/Pointer.ts

-53
This file was deleted.
-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './Paint';
2-
export * from './Pointer';

0 commit comments

Comments
 (0)