@witchcraft/layout 0.0.5 → 0.0.7
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/module.json +1 -1
- package/dist/runtime/components/LayoutDecos.d.vue.ts +8 -0
- package/dist/runtime/components/LayoutDecos.vue.d.ts +8 -0
- package/dist/runtime/components/LayoutEdges.d.vue.ts +27 -0
- package/dist/runtime/components/LayoutEdges.vue.d.ts +27 -0
- package/dist/runtime/components/LayoutFrame.d.vue.ts +36 -0
- package/dist/runtime/components/LayoutFrame.vue.d.ts +36 -0
- package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +36 -0
- package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +36 -0
- package/dist/runtime/components/LayoutWindow.d.vue.ts +108 -0
- package/dist/runtime/components/LayoutWindow.vue.d.ts +108 -0
- package/dist/runtime/composables/useFrames.d.ts +180 -0
- package/dist/runtime/demo/App.d.vue.ts +2 -0
- package/dist/runtime/demo/App.vue.d.ts +2 -0
- package/dist/runtime/demo/DemoControls.d.vue.ts +6 -0
- package/dist/runtime/demo/DemoControls.vue.d.ts +6 -0
- package/dist/runtime/demo/main.d.ts +2 -0
- package/dist/runtime/demo/sharedLayoutInstance.d.ts +6 -0
- package/dist/runtime/demo/tailwind.css +1 -1
- package/dist/runtime/drag/CloseAction.d.ts +33 -0
- package/dist/runtime/drag/DragActionHandler.d.ts +42 -0
- package/dist/runtime/drag/DragDirectionStore.d.ts +20 -0
- package/dist/runtime/drag/SplitAction.d.ts +32 -0
- package/dist/runtime/drag/types.d.ts +92 -0
- package/dist/runtime/helpers/addPointsToIntersection.d.ts +2 -0
- package/dist/runtime/helpers/assertEdgeSorted.d.ts +2 -0
- package/dist/runtime/helpers/assertItemIn.d.ts +1 -0
- package/dist/runtime/helpers/assertItemNotIn.d.ts +1 -0
- package/dist/runtime/helpers/assertLayoutHasActiveWindow.d.ts +4 -0
- package/dist/runtime/helpers/assertValidWinAndFrame.d.ts +5 -0
- package/dist/runtime/helpers/assertValidWinAndFrameIds.d.ts +2 -0
- package/dist/runtime/helpers/assertWindowHasActiveFrame.d.ts +4 -0
- package/dist/runtime/helpers/clampNumber.d.ts +1 -0
- package/dist/runtime/helpers/cloneFrame.d.ts +2 -0
- package/dist/runtime/helpers/cloneFrames.d.ts +2 -0
- package/dist/runtime/helpers/containsEdge.d.ts +2 -0
- package/dist/runtime/helpers/convertLayoutWindowToWorkspace.d.ts +2 -0
- package/dist/runtime/helpers/copySize.d.ts +2 -0
- package/dist/runtime/helpers/createEdge.d.ts +5 -0
- package/dist/runtime/helpers/dirToOrientation.d.ts +2 -0
- package/dist/runtime/helpers/dirToSide.d.ts +2 -0
- package/dist/runtime/helpers/doEdgesOverlap.d.ts +2 -0
- package/dist/runtime/helpers/doesEdgeContinueEdge.d.ts +2 -0
- package/dist/runtime/helpers/edgeToPoints.d.ts +2 -0
- package/dist/runtime/helpers/findDraggableEdge.d.ts +4 -0
- package/dist/runtime/helpers/findFrameDraggableEdges.d.ts +7 -0
- package/dist/runtime/helpers/frameToEdges.d.ts +2 -0
- package/dist/runtime/helpers/frameToPoints.d.ts +19 -0
- package/dist/runtime/helpers/getEdgeOrientation.d.ts +2 -0
- package/dist/runtime/helpers/getEdgeSharedDirection.d.ts +2 -0
- package/dist/runtime/helpers/getEdgeSide.d.ts +2 -0
- package/dist/runtime/helpers/getFrameById.d.ts +2 -0
- package/dist/runtime/helpers/getFrameConstant.d.ts +2 -0
- package/dist/runtime/helpers/getIntersections.d.ts +2 -0
- package/dist/runtime/helpers/getIntersectionsCss.d.ts +9 -0
- package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +11 -0
- package/dist/runtime/helpers/getResizeLimit.d.ts +2 -0
- package/dist/runtime/helpers/getShapeSquareCss.d.ts +7 -0
- package/dist/runtime/helpers/getSideTouching.d.ts +2 -0
- package/dist/runtime/helpers/getVisualEdgeCss.d.ts +7 -0
- package/dist/runtime/helpers/getVisualEdges.d.ts +48 -0
- package/dist/runtime/helpers/getVisualEdgesCss.d.ts +3 -0
- package/dist/runtime/helpers/getWinAndFrameById.d.ts +10 -0
- package/dist/runtime/helpers/getWinByFrameUuid.d.ts +2 -0
- package/dist/runtime/helpers/getWinById.d.ts +2 -0
- package/dist/runtime/helpers/getWindowConstant.d.ts +2 -0
- package/dist/runtime/helpers/inRange.d.ts +1 -0
- package/dist/runtime/helpers/index.d.ts +62 -0
- package/dist/runtime/helpers/isEdgeEqual.d.ts +2 -0
- package/dist/runtime/helpers/isEdgeParallel.d.ts +2 -0
- package/dist/runtime/helpers/isPointEqual.d.ts +2 -0
- package/dist/runtime/helpers/isSizeAboveMin.d.ts +2 -0
- package/dist/runtime/helpers/isSizeEqual.d.ts +2 -0
- package/dist/runtime/helpers/isWindowEdge.d.ts +2 -0
- package/dist/runtime/helpers/isWindowEdgePoint.d.ts +2 -0
- package/dist/runtime/helpers/moveEdge.d.ts +4 -0
- package/dist/runtime/helpers/numberToScaledPercent.d.ts +13 -0
- package/dist/runtime/helpers/numberToScaledSize.d.ts +2 -0
- package/dist/runtime/helpers/oppositeSide.d.ts +2 -0
- package/dist/runtime/helpers/resizeByEdge.d.ts +2 -0
- package/dist/runtime/helpers/sideToDirection.d.ts +3 -0
- package/dist/runtime/helpers/sideToOrientation.d.ts +2 -0
- package/dist/runtime/helpers/splitEdge.d.ts +2 -0
- package/dist/runtime/helpers/toCoord.d.ts +3 -0
- package/dist/runtime/helpers/toId.d.ts +3 -0
- package/dist/runtime/helpers/toWindowCoord.d.ts +2 -0
- package/dist/runtime/helpers/unionEdges.d.ts +2 -0
- package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +2 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/layout/closeFrame.d.ts +5 -0
- package/dist/runtime/layout/closeFrames.d.ts +2 -0
- package/dist/runtime/layout/createSplitDecoEdge.d.ts +2 -0
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +2 -0
- package/dist/runtime/layout/debugFrame.d.ts +2 -0
- package/dist/runtime/layout/findFramesTouchingEdge.d.ts +49 -0
- package/dist/runtime/layout/findSafeSplitEdge.d.ts +5 -0
- package/dist/runtime/layout/findVisualEdge.d.ts +2 -0
- package/dist/runtime/layout/frameCreate.d.ts +3 -0
- package/dist/runtime/layout/frameSplit.d.ts +16 -0
- package/dist/runtime/layout/getCloseFrameInfo.d.ts +73 -0
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +6 -0
- package/dist/runtime/layout/getFrameTo.d.ts +2 -0
- package/dist/runtime/layout/index.d.ts +22 -0
- package/dist/runtime/layout/isPointInFrame.d.ts +2 -0
- package/dist/runtime/layout/layoutAddWindow.d.ts +2 -0
- package/dist/runtime/layout/layoutCreate.d.ts +3 -0
- package/dist/runtime/layout/layoutRemoveWindow.d.ts +2 -0
- package/dist/runtime/layout/resizeFrame.d.ts +6 -0
- package/dist/runtime/layout/windowAddFrame.d.ts +2 -0
- package/dist/runtime/layout/windowCreate.d.ts +4 -0
- package/dist/runtime/layout/windowRemoveFrame.d.ts +2 -0
- package/dist/runtime/layout/windowSetActiveFrame.d.ts +2 -0
- package/dist/runtime/settings.d.ts +23 -0
- package/dist/runtime/types/index.d.ts +459 -0
- package/dist/runtime/utils/KnownError.d.ts +10 -0
- package/package.json +1 -1
- package/src/runtime/demo/tailwind.css +1 -1
- package/src/runtime/layout/getFrameSplitInfo.ts +4 -1
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import type { EnumLike } from "@alanscodelog/utils";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export * from "../drag/types.js";
|
|
4
|
+
export declare const zUuid: z.ZodUUID;
|
|
5
|
+
export type AnyUuid = z.infer<typeof zUuid>;
|
|
6
|
+
export declare const zWindowIdConstants: z.ZodEnum<{
|
|
7
|
+
ACTIVE: "ACTIVE";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const zWinId: z.ZodUnion<[z.ZodUUID, z.ZodEnum<{
|
|
10
|
+
ACTIVE: "ACTIVE";
|
|
11
|
+
}>]>;
|
|
12
|
+
export type WindowId = z.infer<typeof zWinId>;
|
|
13
|
+
export declare const zFrameIdConstants: z.ZodEnum<{
|
|
14
|
+
ACTIVE: "ACTIVE";
|
|
15
|
+
}>;
|
|
16
|
+
export declare const zFrameId: z.ZodUnion<[z.ZodUUID, z.ZodEnum<{
|
|
17
|
+
ACTIVE: "ACTIVE";
|
|
18
|
+
}>]>;
|
|
19
|
+
export type FrameId = z.infer<typeof zFrameId>;
|
|
20
|
+
export declare const zScaledIntPercentage: z.ZodNumber;
|
|
21
|
+
export declare const zPos: z.ZodObject<{
|
|
22
|
+
x: z.ZodNumber;
|
|
23
|
+
y: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type Pos = z.infer<typeof zPos>;
|
|
26
|
+
export declare const zSize: z.ZodObject<{
|
|
27
|
+
width: z.ZodNumber;
|
|
28
|
+
height: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type Size = z.infer<typeof zSize>;
|
|
31
|
+
export declare const zPoint: z.ZodObject<{
|
|
32
|
+
x: z.ZodNumber;
|
|
33
|
+
y: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type Point = z.infer<typeof zPoint>;
|
|
36
|
+
export declare const zPxPos: z.ZodObject<{
|
|
37
|
+
pxX: z.ZodNumber;
|
|
38
|
+
pxY: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type PxPos = z.infer<typeof zPxPos>;
|
|
41
|
+
export declare const zPxSize: z.ZodObject<{
|
|
42
|
+
pxWidth: z.ZodNumber;
|
|
43
|
+
pxHeight: z.ZodNumber;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type PxSize = z.infer<typeof zPxSize>;
|
|
46
|
+
export declare const zEdge: z.ZodObject<{
|
|
47
|
+
startX: z.ZodNumber;
|
|
48
|
+
startY: z.ZodNumber;
|
|
49
|
+
endX: z.ZodNumber;
|
|
50
|
+
endY: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type Edge = z.infer<typeof zEdge>;
|
|
53
|
+
export declare const zDirection: z.ZodEnum<{
|
|
54
|
+
up: "up";
|
|
55
|
+
down: "down";
|
|
56
|
+
left: "left";
|
|
57
|
+
right: "right";
|
|
58
|
+
}>;
|
|
59
|
+
export declare const zExtendedDirection: z.ZodUnion<readonly [z.ZodEnum<{
|
|
60
|
+
up: "up";
|
|
61
|
+
down: "down";
|
|
62
|
+
left: "left";
|
|
63
|
+
right: "right";
|
|
64
|
+
}>, z.ZodEnum<{
|
|
65
|
+
horizontal: "horizontal";
|
|
66
|
+
vertical: "vertical";
|
|
67
|
+
}>]>;
|
|
68
|
+
export declare const zSide: z.ZodEnum<{
|
|
69
|
+
left: "left";
|
|
70
|
+
right: "right";
|
|
71
|
+
top: "top";
|
|
72
|
+
bottom: "bottom";
|
|
73
|
+
}>;
|
|
74
|
+
export declare const zOrientation: z.ZodEnum<{
|
|
75
|
+
horizontal: "horizontal";
|
|
76
|
+
vertical: "vertical";
|
|
77
|
+
}>;
|
|
78
|
+
export declare const zExtendedSide: z.ZodUnion<readonly [z.ZodEnum<{
|
|
79
|
+
left: "left";
|
|
80
|
+
right: "right";
|
|
81
|
+
top: "top";
|
|
82
|
+
bottom: "bottom";
|
|
83
|
+
}>, z.ZodEnum<{
|
|
84
|
+
horizontal: "horizontal";
|
|
85
|
+
vertical: "vertical";
|
|
86
|
+
}>]>;
|
|
87
|
+
export type Direction = z.infer<typeof zDirection>;
|
|
88
|
+
export type ExtendedDirection = z.infer<typeof zExtendedDirection>;
|
|
89
|
+
export type Orientation = z.infer<typeof zOrientation>;
|
|
90
|
+
export type EdgeSide = z.infer<typeof zSide>;
|
|
91
|
+
export type ExtendedEdgeSide = z.infer<typeof zExtendedSide>;
|
|
92
|
+
export declare const zBaseSquare: z.ZodObject<{
|
|
93
|
+
width: z.ZodNumber;
|
|
94
|
+
height: z.ZodNumber;
|
|
95
|
+
x: z.ZodNumber;
|
|
96
|
+
y: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export type BaseSquare = z.infer<typeof zBaseSquare>;
|
|
99
|
+
export type BaseSquareCss = {
|
|
100
|
+
x: string;
|
|
101
|
+
y: string;
|
|
102
|
+
width: string;
|
|
103
|
+
height: string;
|
|
104
|
+
translate?: string;
|
|
105
|
+
};
|
|
106
|
+
export type EdgeCss = BaseSquareCss & {
|
|
107
|
+
translate: string;
|
|
108
|
+
};
|
|
109
|
+
export type PointCss = BaseSquareCss & {
|
|
110
|
+
translate: string;
|
|
111
|
+
};
|
|
112
|
+
export type Intersections = Record<number, Record<number, number>>;
|
|
113
|
+
export type IntersectionEntry = {
|
|
114
|
+
point: Point;
|
|
115
|
+
count: number;
|
|
116
|
+
sharesEdge: boolean;
|
|
117
|
+
sharedEdges: {
|
|
118
|
+
horizontal: Edge[];
|
|
119
|
+
vertical: Edge[];
|
|
120
|
+
};
|
|
121
|
+
isWindowEdge: boolean;
|
|
122
|
+
};
|
|
123
|
+
export declare const zLayoutFrame: z.ZodObject<{
|
|
124
|
+
id: z.ZodUUID;
|
|
125
|
+
width: z.ZodNumber;
|
|
126
|
+
height: z.ZodNumber;
|
|
127
|
+
x: z.ZodNumber;
|
|
128
|
+
y: z.ZodNumber;
|
|
129
|
+
}, z.core.$loose>;
|
|
130
|
+
export declare const zLayoutFramePassthrough: z.ZodObject<{
|
|
131
|
+
id: z.ZodUUID;
|
|
132
|
+
width: z.ZodNumber;
|
|
133
|
+
height: z.ZodNumber;
|
|
134
|
+
x: z.ZodNumber;
|
|
135
|
+
y: z.ZodNumber;
|
|
136
|
+
}, z.core.$loose>;
|
|
137
|
+
export interface Register {
|
|
138
|
+
}
|
|
139
|
+
export type ExtendedLayoutFrame = Register extends {
|
|
140
|
+
ExtendedLayoutFrame: infer T;
|
|
141
|
+
} ? T : unknown;
|
|
142
|
+
export type ExtendedLayoutWindow = Register extends {
|
|
143
|
+
ExtendedLayoutWindow: infer T;
|
|
144
|
+
} ? T : unknown;
|
|
145
|
+
export type ExtendedLayout = Register extends {
|
|
146
|
+
ExtendedLayout: infer T;
|
|
147
|
+
} ? T : unknown;
|
|
148
|
+
export type ExtendedWorkspace = Register extends {
|
|
149
|
+
ExtendedWorkspace: infer T;
|
|
150
|
+
} ? T : unknown;
|
|
151
|
+
export type BaseLayoutFrame = Size & Pos & {
|
|
152
|
+
id: FrameId;
|
|
153
|
+
};
|
|
154
|
+
export type LayoutFrame = ExtendedLayoutFrame & BaseLayoutFrame;
|
|
155
|
+
export type LayoutFrames = Record<string, LayoutFrame>;
|
|
156
|
+
export declare const zLayoutWindow: z.ZodObject<{
|
|
157
|
+
id: z.ZodUUID;
|
|
158
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
159
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
160
|
+
id: z.ZodUUID;
|
|
161
|
+
width: z.ZodNumber;
|
|
162
|
+
height: z.ZodNumber;
|
|
163
|
+
x: z.ZodNumber;
|
|
164
|
+
y: z.ZodNumber;
|
|
165
|
+
}, z.core.$loose>>;
|
|
166
|
+
pxWidth: z.ZodNumber;
|
|
167
|
+
pxHeight: z.ZodNumber;
|
|
168
|
+
pxX: z.ZodNumber;
|
|
169
|
+
pxY: z.ZodNumber;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
export declare const zLayoutWindowPassthrough: z.ZodObject<{
|
|
172
|
+
id: z.ZodUUID;
|
|
173
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
174
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
175
|
+
id: z.ZodUUID;
|
|
176
|
+
width: z.ZodNumber;
|
|
177
|
+
height: z.ZodNumber;
|
|
178
|
+
x: z.ZodNumber;
|
|
179
|
+
y: z.ZodNumber;
|
|
180
|
+
}, z.core.$loose>>;
|
|
181
|
+
pxWidth: z.ZodNumber;
|
|
182
|
+
pxHeight: z.ZodNumber;
|
|
183
|
+
pxX: z.ZodNumber;
|
|
184
|
+
pxY: z.ZodNumber;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type BaseLayoutWindow = {
|
|
187
|
+
id: WindowId;
|
|
188
|
+
activeFrame?: string;
|
|
189
|
+
frames: LayoutFrames;
|
|
190
|
+
pxWidth: number;
|
|
191
|
+
pxHeight: number;
|
|
192
|
+
pxX: number;
|
|
193
|
+
pxY: number;
|
|
194
|
+
};
|
|
195
|
+
export type LayoutWindow = ExtendedLayoutWindow & BaseLayoutWindow;
|
|
196
|
+
export type LayoutWindows = Record<string, LayoutWindow>;
|
|
197
|
+
export declare const zWorkspace: z.ZodObject<{
|
|
198
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
199
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
200
|
+
id: z.ZodUUID;
|
|
201
|
+
width: z.ZodNumber;
|
|
202
|
+
height: z.ZodNumber;
|
|
203
|
+
x: z.ZodNumber;
|
|
204
|
+
y: z.ZodNumber;
|
|
205
|
+
}, z.core.$loose>>;
|
|
206
|
+
}, z.core.$strict>;
|
|
207
|
+
export declare const zWorkspacePassthrough: z.ZodObject<{
|
|
208
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
209
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
210
|
+
id: z.ZodUUID;
|
|
211
|
+
width: z.ZodNumber;
|
|
212
|
+
height: z.ZodNumber;
|
|
213
|
+
x: z.ZodNumber;
|
|
214
|
+
y: z.ZodNumber;
|
|
215
|
+
}, z.core.$loose>>;
|
|
216
|
+
}, z.core.$loose>;
|
|
217
|
+
export type Workspace = Pick<LayoutWindow, "activeFrame" | "frames"> & ExtendedWorkspace;
|
|
218
|
+
export declare const zLayout: z.ZodObject<{
|
|
219
|
+
activeWindow: z.ZodOptional<z.ZodString>;
|
|
220
|
+
windows: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
221
|
+
id: z.ZodUUID;
|
|
222
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
223
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
224
|
+
id: z.ZodUUID;
|
|
225
|
+
width: z.ZodNumber;
|
|
226
|
+
height: z.ZodNumber;
|
|
227
|
+
x: z.ZodNumber;
|
|
228
|
+
y: z.ZodNumber;
|
|
229
|
+
}, z.core.$loose>>;
|
|
230
|
+
pxWidth: z.ZodNumber;
|
|
231
|
+
pxHeight: z.ZodNumber;
|
|
232
|
+
pxX: z.ZodNumber;
|
|
233
|
+
pxY: z.ZodNumber;
|
|
234
|
+
}, z.core.$strict>>;
|
|
235
|
+
}, z.core.$strict>;
|
|
236
|
+
export declare const zInitializedLayout: z.ZodObject<{
|
|
237
|
+
activeWindow: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
|
|
238
|
+
windows: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
239
|
+
id: z.ZodUUID;
|
|
240
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
241
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
242
|
+
id: z.ZodUUID;
|
|
243
|
+
width: z.ZodNumber;
|
|
244
|
+
height: z.ZodNumber;
|
|
245
|
+
x: z.ZodNumber;
|
|
246
|
+
y: z.ZodNumber;
|
|
247
|
+
}, z.core.$loose>>;
|
|
248
|
+
pxWidth: z.ZodNumber;
|
|
249
|
+
pxHeight: z.ZodNumber;
|
|
250
|
+
pxX: z.ZodNumber;
|
|
251
|
+
pxY: z.ZodNumber;
|
|
252
|
+
}, z.core.$strict>>;
|
|
253
|
+
}, z.core.$strict>;
|
|
254
|
+
export type Layout = ExtendedLayout & {
|
|
255
|
+
activeWindow?: string;
|
|
256
|
+
windows: LayoutWindows;
|
|
257
|
+
};
|
|
258
|
+
export declare const zSplitDecoShapes: z.ZodObject<{
|
|
259
|
+
edge: z.ZodObject<{
|
|
260
|
+
startX: z.ZodNumber;
|
|
261
|
+
startY: z.ZodNumber;
|
|
262
|
+
endX: z.ZodNumber;
|
|
263
|
+
endY: z.ZodNumber;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
newFrame: z.ZodObject<{
|
|
266
|
+
width: z.ZodNumber;
|
|
267
|
+
height: z.ZodNumber;
|
|
268
|
+
x: z.ZodNumber;
|
|
269
|
+
y: z.ZodNumber;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
}, z.core.$strict>;
|
|
272
|
+
export type SplitDecoShapes = z.infer<typeof zSplitDecoShapes>;
|
|
273
|
+
export declare const zSplitDeco: z.ZodObject<{
|
|
274
|
+
id: z.ZodUUID;
|
|
275
|
+
type: z.ZodLiteral<"split">;
|
|
276
|
+
position: z.ZodNumber;
|
|
277
|
+
direction: z.ZodEnum<{
|
|
278
|
+
up: "up";
|
|
279
|
+
down: "down";
|
|
280
|
+
left: "left";
|
|
281
|
+
right: "right";
|
|
282
|
+
}>;
|
|
283
|
+
shapes: z.ZodObject<{
|
|
284
|
+
edge: z.ZodObject<{
|
|
285
|
+
startX: z.ZodNumber;
|
|
286
|
+
startY: z.ZodNumber;
|
|
287
|
+
endX: z.ZodNumber;
|
|
288
|
+
endY: z.ZodNumber;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
newFrame: z.ZodObject<{
|
|
291
|
+
width: z.ZodNumber;
|
|
292
|
+
height: z.ZodNumber;
|
|
293
|
+
x: z.ZodNumber;
|
|
294
|
+
y: z.ZodNumber;
|
|
295
|
+
}, z.core.$strip>;
|
|
296
|
+
}, z.core.$strict>;
|
|
297
|
+
}, z.core.$strict>;
|
|
298
|
+
export declare const zRawSplitDeco: z.ZodObject<{
|
|
299
|
+
type: z.ZodLiteral<"split">;
|
|
300
|
+
id: z.ZodUUID;
|
|
301
|
+
position: z.ZodNumber;
|
|
302
|
+
direction: z.ZodEnum<{
|
|
303
|
+
up: "up";
|
|
304
|
+
down: "down";
|
|
305
|
+
left: "left";
|
|
306
|
+
right: "right";
|
|
307
|
+
}>;
|
|
308
|
+
}, z.core.$strict>;
|
|
309
|
+
export type RawSplitDeco = z.infer<typeof zRawSplitDeco>;
|
|
310
|
+
export type SplitDeco = z.infer<typeof zSplitDeco>;
|
|
311
|
+
declare const zCloseDeco: z.ZodObject<{
|
|
312
|
+
id: z.ZodUUID;
|
|
313
|
+
type: z.ZodLiteral<"close">;
|
|
314
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
315
|
+
}, z.core.$strict>;
|
|
316
|
+
export type CloseDeco = z.infer<typeof zCloseDeco>;
|
|
317
|
+
declare const zDropDeco: z.ZodObject<{
|
|
318
|
+
id: z.ZodUUID;
|
|
319
|
+
type: z.ZodLiteral<"drop">;
|
|
320
|
+
position: z.ZodUnion<[z.ZodEnum<{
|
|
321
|
+
left: "left";
|
|
322
|
+
right: "right";
|
|
323
|
+
top: "top";
|
|
324
|
+
bottom: "bottom";
|
|
325
|
+
}>, z.ZodEnum<{
|
|
326
|
+
center: "center";
|
|
327
|
+
}>]>;
|
|
328
|
+
}, z.core.$strict>;
|
|
329
|
+
export type DropDeco = z.infer<typeof zDropDeco>;
|
|
330
|
+
export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
|
|
331
|
+
id: z.ZodUUID;
|
|
332
|
+
type: z.ZodLiteral<"split">;
|
|
333
|
+
position: z.ZodNumber;
|
|
334
|
+
direction: z.ZodEnum<{
|
|
335
|
+
up: "up";
|
|
336
|
+
down: "down";
|
|
337
|
+
left: "left";
|
|
338
|
+
right: "right";
|
|
339
|
+
}>;
|
|
340
|
+
shapes: z.ZodObject<{
|
|
341
|
+
edge: z.ZodObject<{
|
|
342
|
+
startX: z.ZodNumber;
|
|
343
|
+
startY: z.ZodNumber;
|
|
344
|
+
endX: z.ZodNumber;
|
|
345
|
+
endY: z.ZodNumber;
|
|
346
|
+
}, z.core.$strip>;
|
|
347
|
+
newFrame: z.ZodObject<{
|
|
348
|
+
width: z.ZodNumber;
|
|
349
|
+
height: z.ZodNumber;
|
|
350
|
+
x: z.ZodNumber;
|
|
351
|
+
y: z.ZodNumber;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
}, z.core.$strict>;
|
|
354
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
355
|
+
id: z.ZodUUID;
|
|
356
|
+
type: z.ZodLiteral<"close">;
|
|
357
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
358
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
359
|
+
id: z.ZodUUID;
|
|
360
|
+
type: z.ZodLiteral<"drop">;
|
|
361
|
+
position: z.ZodUnion<[z.ZodEnum<{
|
|
362
|
+
left: "left";
|
|
363
|
+
right: "right";
|
|
364
|
+
top: "top";
|
|
365
|
+
bottom: "bottom";
|
|
366
|
+
}>, z.ZodEnum<{
|
|
367
|
+
center: "center";
|
|
368
|
+
}>]>;
|
|
369
|
+
}, z.core.$strict>]>;
|
|
370
|
+
export type Deco = z.infer<typeof zDeco>;
|
|
371
|
+
export declare const LAYOUT_ERROR: {
|
|
372
|
+
INVALID_ID: "INVALID_ID";
|
|
373
|
+
ID_ALREADY_EXISTS: "ID_ALREADY_EXISTS";
|
|
374
|
+
CANT_RESIZE: "CANT_RESIZE";
|
|
375
|
+
NO_ACTIVE_WINDOW: "NO_ACTIVE_WINDOW";
|
|
376
|
+
NO_ACTIVE_FRAME: "NO_ACTIVE_FRAME";
|
|
377
|
+
CANT_CLOSE_NO_DRAG_EDGE: "CANT_CLOSE_NO_DRAG_EDGE";
|
|
378
|
+
CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL: "CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL";
|
|
379
|
+
CANT_CLOSE_SINGLE_FRAME: "CANT_CLOSE_SINGLE_FRAME";
|
|
380
|
+
CANT_SPLIT_FRAME_TOO_SMALL: "CANT_SPLIT_FRAME_TOO_SMALL";
|
|
381
|
+
CANT_CLOSE_WITHOUT_FORCE: "CANT_CLOSE_WITHOUT_FORCE";
|
|
382
|
+
};
|
|
383
|
+
export type LayoutError = EnumLike<typeof LAYOUT_ERROR>;
|
|
384
|
+
export type AllErrors = LayoutError;
|
|
385
|
+
export type ErrorInfo<T extends AllErrors> = AllErrorsInfo[T] extends undefined ? never : AllErrorsInfo[T];
|
|
386
|
+
type AllErrorsInfo = {
|
|
387
|
+
[LAYOUT_ERROR.INVALID_ID]: {
|
|
388
|
+
id: string | undefined;
|
|
389
|
+
};
|
|
390
|
+
[LAYOUT_ERROR.ID_ALREADY_EXISTS]: {
|
|
391
|
+
id: string | undefined;
|
|
392
|
+
};
|
|
393
|
+
[LAYOUT_ERROR.CANT_RESIZE]: {
|
|
394
|
+
size: Size;
|
|
395
|
+
};
|
|
396
|
+
[LAYOUT_ERROR.NO_ACTIVE_WINDOW]: Record<string, never>;
|
|
397
|
+
[LAYOUT_ERROR.NO_ACTIVE_FRAME]: Record<string, never>;
|
|
398
|
+
[LAYOUT_ERROR.CANT_CLOSE_NO_DRAG_EDGE]: {
|
|
399
|
+
frame: LayoutFrame;
|
|
400
|
+
};
|
|
401
|
+
[LAYOUT_ERROR.CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL]: {
|
|
402
|
+
frame: LayoutFrame;
|
|
403
|
+
nearbyFrames: LayoutFrame[];
|
|
404
|
+
minSize: Size;
|
|
405
|
+
};
|
|
406
|
+
[LAYOUT_ERROR.CANT_CLOSE_SINGLE_FRAME]: {
|
|
407
|
+
frame: LayoutFrame;
|
|
408
|
+
};
|
|
409
|
+
[LAYOUT_ERROR.CANT_SPLIT_FRAME_TOO_SMALL]: {
|
|
410
|
+
frame: LayoutFrame;
|
|
411
|
+
newSize: number;
|
|
412
|
+
minSize: number;
|
|
413
|
+
};
|
|
414
|
+
[LAYOUT_ERROR.CANT_CLOSE_WITHOUT_FORCE]: {
|
|
415
|
+
frame: LayoutFrame;
|
|
416
|
+
framesRequiredToBeDeleted: LayoutFrame[];
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
export type HasOpposite = Direction | EdgeSide | ExtendedDirection | ExtendedEdgeSide | keyof Point | keyof Size;
|
|
420
|
+
export declare const zWindowCreate: z.ZodObject<{
|
|
421
|
+
id: z.ZodOptional<z.ZodUUID>;
|
|
422
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
423
|
+
pxWidth: z.ZodOptional<z.ZodNumber>;
|
|
424
|
+
pxHeight: z.ZodOptional<z.ZodNumber>;
|
|
425
|
+
pxX: z.ZodOptional<z.ZodNumber>;
|
|
426
|
+
pxY: z.ZodOptional<z.ZodNumber>;
|
|
427
|
+
frames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
428
|
+
id: z.ZodUUID;
|
|
429
|
+
width: z.ZodNumber;
|
|
430
|
+
height: z.ZodNumber;
|
|
431
|
+
x: z.ZodNumber;
|
|
432
|
+
y: z.ZodNumber;
|
|
433
|
+
}, z.core.$loose>>>;
|
|
434
|
+
}, z.core.$strip>;
|
|
435
|
+
export declare const zLayoutCreate: z.ZodObject<{
|
|
436
|
+
activeWindow: z.ZodOptional<z.ZodString>;
|
|
437
|
+
windows: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
438
|
+
id: z.ZodUUID;
|
|
439
|
+
activeFrame: z.ZodOptional<z.ZodString>;
|
|
440
|
+
frames: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
441
|
+
id: z.ZodUUID;
|
|
442
|
+
width: z.ZodNumber;
|
|
443
|
+
height: z.ZodNumber;
|
|
444
|
+
x: z.ZodNumber;
|
|
445
|
+
y: z.ZodNumber;
|
|
446
|
+
}, z.core.$loose>>;
|
|
447
|
+
pxWidth: z.ZodNumber;
|
|
448
|
+
pxHeight: z.ZodNumber;
|
|
449
|
+
pxX: z.ZodNumber;
|
|
450
|
+
pxY: z.ZodNumber;
|
|
451
|
+
}, z.core.$strict>>>;
|
|
452
|
+
}, z.core.$loose>;
|
|
453
|
+
export declare const zFrameCreate: z.ZodObject<{
|
|
454
|
+
id: z.ZodOptional<z.ZodUUID>;
|
|
455
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
456
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
457
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
458
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
459
|
+
}, z.core.$loose>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AllErrors, ErrorInfo } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a known error that extends the base Error with some extra information.
|
|
4
|
+
* All the variables used to create the error message are stored in it's info property so we can easily re-craft error messages for users.
|
|
5
|
+
*/
|
|
6
|
+
export declare class KnownError<T extends AllErrors = AllErrors, TInfo extends ErrorInfo<T> = ErrorInfo<T>> extends Error {
|
|
7
|
+
code: T;
|
|
8
|
+
info: TInfo;
|
|
9
|
+
constructor(code: T, str: string, info: TInfo);
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -18,7 +18,10 @@ export function getFrameSplitInfo(
|
|
|
18
18
|
dragPointOrPosition: Point | number | "midpoint" = "midpoint",
|
|
19
19
|
minSize: Size = getMarginSize(),
|
|
20
20
|
snapAmount: Point = getSnapPoint()
|
|
21
|
-
) {
|
|
21
|
+
): {
|
|
22
|
+
splitFrame: LayoutFrame
|
|
23
|
+
newFrame: LayoutFrame
|
|
24
|
+
} | KnownError<typeof LAYOUT_ERROR.CANT_SPLIT_FRAME_TOO_SMALL> {
|
|
22
25
|
frame = cloneFrame(frame)
|
|
23
26
|
let newFrame = { ...frame }
|
|
24
27
|
const isHorz = dir === "left" || dir === "right"
|