@abyss-project/main 1.0.71 → 1.0.73

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.js CHANGED
@@ -96,4 +96,7 @@ AbyssCore.config = {
96
96
  baseURL: DEFAULT_BASE_URL,
97
97
  abyssUserAnonymousIdentifier: '',
98
98
  };
99
- AbyssCore.axios = axios_1.default.create({ baseURL: _a.config.baseURL });
99
+ AbyssCore.axios = axios_1.default.create({
100
+ baseURL: _a.config.baseURL,
101
+ withCredentials: true,
102
+ });
@@ -1,4 +1,4 @@
1
- import { Endpoint, ICON_LIBRARY } from '../utils';
1
+ import { Endpoint, ICON_LIBRARY, CurvePoint } from '../utils';
2
2
  export type DrawData = {
3
3
  drawId: string | null;
4
4
  shapes: DrawShapeToJsonResult[];
@@ -39,10 +39,15 @@ export interface DrawStyle {
39
39
  cornerRadius: number;
40
40
  fontSize: number;
41
41
  fontFamily: string;
42
+ fontWeight?: number;
42
43
  preserveAspectRatio: boolean;
43
44
  rotation: number;
45
+ textAlign?: 'left' | 'center' | 'right';
46
+ textVerticalPosition?: 'top' | 'center' | 'bottom';
47
+ textHorizontalPosition?: 'left' | 'center' | 'right';
44
48
  }
45
49
  export interface ShapeProperties {
50
+ id?: string;
46
51
  position: Point;
47
52
  zIndex?: number;
48
53
  size: DrawSize;
@@ -56,10 +61,11 @@ export declare enum DrawShapeType {
56
61
  ICON = "ICON",
57
62
  IMAGE = "IMAGE",
58
63
  COMMENT = "COMMENT",
59
- ARROW = "ARROW"
64
+ ARROW = "ARROW",
65
+ PENCIL = "PENCIL"
60
66
  }
61
67
  export type ResizeShape = {
62
- corner: 'se' | 'sw' | 'ne' | 'nw';
68
+ corner: 'se' | 'sw' | 'ne' | 'nw' | 'e' | 'w' | 'n' | 's';
63
69
  startPos: Point;
64
70
  originalSize: DrawSize;
65
71
  originalPosition: Point;
@@ -71,6 +77,11 @@ export type RotationData = {
71
77
  };
72
78
  export type Id = string;
73
79
  export type PortId = 'top' | 'right' | 'bottom' | 'left' | 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
80
+ export type TextAnchor = {
81
+ shapeId: string;
82
+ relativeX: number;
83
+ relativeY: number;
84
+ };
74
85
  export type DrawShapeToJsonBaseResult = {
75
86
  id: string;
76
87
  type: DrawShapeType;
@@ -84,6 +95,7 @@ export type DrawShapeArrowToJsonResult = DrawShapeToJsonBaseResult & {
84
95
  type: DrawShapeType.ARROW;
85
96
  startEndpoint: Endpoint;
86
97
  endEndpoint: Endpoint;
98
+ curvePoints?: CurvePoint[];
87
99
  };
88
100
  export type DrawShapeIconToJsonResult = DrawShapeToJsonBaseResult & {
89
101
  type: DrawShapeType.ICON;
@@ -92,6 +104,7 @@ export type DrawShapeIconToJsonResult = DrawShapeToJsonBaseResult & {
92
104
  export type DrawShapeTextToJsonResult = DrawShapeToJsonBaseResult & {
93
105
  type: DrawShapeType.TEXT;
94
106
  text: string;
107
+ anchor?: TextAnchor;
95
108
  };
96
109
  export type DrawShapeRectangleToJsonResult = {
97
110
  type: DrawShapeType.RECTANGLE;
@@ -112,4 +125,8 @@ export type DrawShapeCommentToJsonResult = DrawShapeToJsonBaseResult & {
112
125
  text: string;
113
126
  date: string;
114
127
  };
115
- export type DrawShapeToJsonResult = DrawShapeArrowToJsonResult | DrawShapeIconToJsonResult | DrawShapeTextToJsonResult | DrawShapeRectangleToJsonResult | DrawShapeDiamondToJsonResult | DrawShapeImageToJsonResult | DrawShapeCommentToJsonResult | DrawShapeEllipseToJsonResult;
128
+ export type DrawShapePencilToJsonResult = DrawShapeToJsonBaseResult & {
129
+ type: DrawShapeType.PENCIL;
130
+ points: number[];
131
+ };
132
+ export type DrawShapeToJsonResult = DrawShapeArrowToJsonResult | DrawShapeIconToJsonResult | DrawShapeTextToJsonResult | DrawShapeRectangleToJsonResult | DrawShapeDiamondToJsonResult | DrawShapeImageToJsonResult | DrawShapeCommentToJsonResult | DrawShapeEllipseToJsonResult | DrawShapePencilToJsonResult;
@@ -11,4 +11,5 @@ var DrawShapeType;
11
11
  DrawShapeType["IMAGE"] = "IMAGE";
12
12
  DrawShapeType["COMMENT"] = "COMMENT";
13
13
  DrawShapeType["ARROW"] = "ARROW";
14
+ DrawShapeType["PENCIL"] = "PENCIL";
14
15
  })(DrawShapeType || (exports.DrawShapeType = DrawShapeType = {}));
@@ -1,4 +1,4 @@
1
- import { Id, PortId, Point, DrawSize, DrawStyle, DrawShapeToJsonResult } from '../types/draw.type';
1
+ import { Id, Point, DrawSize, DrawStyle, DrawShapeToJsonResult } from '../types/draw.type';
2
2
  export type Endpoint = {
3
3
  style: DrawArrowEndpointStyle;
4
4
  } & ({
@@ -6,11 +6,15 @@ export type Endpoint = {
6
6
  x: number;
7
7
  y: number;
8
8
  } | {
9
- kind: 'port';
9
+ kind: 'anchor';
10
10
  shapeId: Id;
11
- portId: PortId;
11
+ relativeX: number;
12
+ relativeY: number;
12
13
  });
13
14
  export type DrawArrowEndpointStyle = 'arrow' | 'circle' | 'square' | 'diamond' | 'none';
15
+ export type CurvePoint = Point & {
16
+ type: 'straight' | 'curved';
17
+ };
14
18
  export declare const rectangleToSvg: (position: Point, size: DrawSize, style: DrawStyle) => string;
15
19
  export declare const diamondToSvg: (position: Point, size: DrawSize, style: DrawStyle) => string;
16
20
  export declare const ellipseToSvg: (position: Point, size: DrawSize, style: DrawStyle) => string;
@@ -46,7 +46,7 @@ const textToSvg = (position, style, text) => {
46
46
  const y = position.y;
47
47
  const fillColor = style.fillColor === 'none' ? 'none' : style.fillColor;
48
48
  const strokeColor = style.strokeColor === 'none' ? 'none' : style.strokeColor;
49
- return `<text x="${x}" y="${y}" fill="${fillColor}" stroke="${strokeColor}" stroke-width="${style.strokeWidth}" opacity="${style.opacity}" font-size="${style.fontSize}" font-family="${style.fontFamily}"
49
+ return `<text x="${x}" y="${y}" fill="${fillColor}" stroke="${strokeColor}" stroke-width="${style.strokeWidth}" opacity="${style.opacity}" font-size="${style.fontSize}" font-family="${style.fontFamily}"
50
50
  stroke-dasharray="${style.lineDash || 'none'}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${style.rotation} ${x} ${y})">${text}</text>`;
51
51
  };
52
52
  exports.textToSvg = textToSvg;
@@ -79,15 +79,15 @@ const commentToSvg = (position, size, style, id) => {
79
79
  const fontSize = size.width * 0.6;
80
80
  const textX = cx;
81
81
  const textY = cy + fontSize * 0.35;
82
- return `
83
- <g opacity="${style.opacity}" transform="rotate(${style.rotation} ${cx} ${cy})">
84
- <defs>
85
- <filter id="comment-shadow-${id}" x="-50%" y="-50%" width="200%" height="200%">
86
- <feDropShadow dx="2" dy="2" stdDeviation="5" flood-color="black" flood-opacity="0.3"/>
87
- </filter>
88
- </defs>
89
- <circle cx="${cx}" cy="${cy}" r="${radius}" fill="${fillColor}" stroke="${strokeColor}" stroke-width="${style.strokeWidth}" filter="url(#comment-shadow-${id})" />
90
- <text x="${textX}" y="${textY}" fill="white" font-size="${fontSize}" font-family="Arial" text-anchor="middle" dominant-baseline="middle" font-weight="bold">!</text>
82
+ return `
83
+ <g opacity="${style.opacity}" transform="rotate(${style.rotation} ${cx} ${cy})">
84
+ <defs>
85
+ <filter id="comment-shadow-${id}" x="-50%" y="-50%" width="200%" height="200%">
86
+ <feDropShadow dx="2" dy="2" stdDeviation="5" flood-color="black" flood-opacity="0.3"/>
87
+ </filter>
88
+ </defs>
89
+ <circle cx="${cx}" cy="${cy}" r="${radius}" fill="${fillColor}" stroke="${strokeColor}" stroke-width="${style.strokeWidth}" filter="url(#comment-shadow-${id})" />
90
+ <text x="${textX}" y="${textY}" fill="white" font-size="${fontSize}" font-family="Arial" text-anchor="middle" dominant-baseline="middle" font-weight="bold">!</text>
91
91
  </g>`;
92
92
  };
93
93
  exports.commentToSvg = commentToSvg;
@@ -146,13 +146,13 @@ const sceneToSVG = (shapes, width, height) => {
146
146
  return (0, exports.commentToSvg)(s.position, s.size, s.style, s.id);
147
147
  case draw_type_1.DrawShapeType.ARROW:
148
148
  if (s.startEndpoint && s.endEndpoint) {
149
- const fromPos = s.startEndpoint.kind === 'port'
149
+ const fromPos = s.startEndpoint.kind === 'anchor'
150
150
  ? (_a = shapes.find((shape) => { var _a; return shape.id === ((_a = s.startEndpoint) === null || _a === void 0 ? void 0 : _a.shapeId); })) === null || _a === void 0 ? void 0 : _a.position
151
151
  : {
152
152
  x: s.startEndpoint.x,
153
153
  y: s.startEndpoint.y,
154
154
  };
155
- const toPos = s.endEndpoint.kind === 'port'
155
+ const toPos = s.endEndpoint.kind === 'anchor'
156
156
  ? (_b = shapes.find((shape) => { var _a; return shape.id === ((_a = s.endEndpoint) === null || _a === void 0 ? void 0 : _a.shapeId); })) === null || _b === void 0 ? void 0 : _b.position
157
157
  : {
158
158
  x: s.endEndpoint.x,
@@ -167,15 +167,15 @@ const sceneToSVG = (shapes, width, height) => {
167
167
  return '';
168
168
  }
169
169
  });
170
- const defs = `
171
- <defs>
172
- <marker id="arrow" markerWidth="10" markerHeight="10" refX="10" refY="5" orient="auto-start-reverse">
173
- <path d="M0,0 L10,5 L0,10 z" fill="currentColor"/>
174
- </marker>
170
+ const defs = `
171
+ <defs>
172
+ <marker id="arrow" markerWidth="10" markerHeight="10" refX="10" refY="5" orient="auto-start-reverse">
173
+ <path d="M0,0 L10,5 L0,10 z" fill="currentColor"/>
174
+ </marker>
175
175
  </defs>`;
176
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">
177
- ${defs}
178
- ${shapeEls.join('\n')}
176
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">
177
+ ${defs}
178
+ ${shapeEls.join('\n')}
179
179
  </svg>`;
180
180
  };
181
181
  exports.sceneToSVG = sceneToSVG;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/main",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "Core package to interact with Abyss-Project",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",