@witchcraft/layout 0.0.7 → 0.1.0

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/README.md CHANGED
@@ -42,22 +42,22 @@ export {}
42
42
 
43
43
  ```
44
44
 
45
- Or if using zod, you can do something like this. Note that you will need to create/extend `zLayoutWindow/Frame` or use `zLayoutWindow/FramePassthrough` to allow for extra properties. All zod types have been made `strict` where possible as it's easy to accidentally use the wrong type and loose properties silently otherwise.
45
+ Or if using zod, you can do something like this. Note that you will need to create/extend `zLayoutWindow/Frame` or use `zLayoutWindow/FrameLoose` to allow for extra properties. All zod types have been made `strict` where possible as it's easy to accidentally use the wrong type and loose properties silently otherwise.
46
46
 
47
47
  ```ts
48
- import { zLayoutFramePassthrough, layoutCreate } from "@witchcraft/layout"
48
+ import { zLayoutFrameLoose, layoutCreate } from "@witchcraft/layout"
49
49
  import { z } from "zod"
50
50
 
51
51
  // we remove the id to set the discriminated union, then add it back,
52
52
  // otherwise this doesn't work
53
53
  export const zAppFrame = z.discriminatedUnion("type", [
54
- zLayoutFramePassthrough.extend({
54
+ zLayoutFrameLoose.extend({
55
55
  type: z.literal("contentA"),
56
56
  content: z.object({
57
57
  id: z.optional(z.uuid()),
58
58
  }),
59
59
  }),
60
- zLayoutFramePassthrough.extend({
60
+ zLayoutFrameLoose.extend({
61
61
  type: z.literal("contentB"),
62
62
  content: z.object({
63
63
  someOtherKey: z.optional(z.uuid()),
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.0.7",
4
+ "version": "0.1.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, createResolver, addComponentsDir, addTemplate } from '@nuxt/kit';
2
2
  export * from '../dist/runtime/index.js';
3
3
 
4
- const module = defineNuxtModule({
4
+ const module$1 = defineNuxtModule({
5
5
  meta: {
6
6
  name: "@witchcraft/layout",
7
7
  configKey: "witchcraftLayout"
@@ -23,4 +23,4 @@ const module = defineNuxtModule({
23
23
  }
24
24
  });
25
25
 
26
- export { module as default };
26
+ export { module$1 as default };
@@ -127,7 +127,7 @@ export declare const zLayoutFrame: z.ZodObject<{
127
127
  x: z.ZodNumber;
128
128
  y: z.ZodNumber;
129
129
  }, z.core.$loose>;
130
- export declare const zLayoutFramePassthrough: z.ZodObject<{
130
+ export declare const zLayoutFrameLoose: z.ZodObject<{
131
131
  id: z.ZodUUID;
132
132
  width: z.ZodNumber;
133
133
  height: z.ZodNumber;
@@ -167,8 +167,8 @@ export declare const zLayoutWindow: z.ZodObject<{
167
167
  pxHeight: z.ZodNumber;
168
168
  pxX: z.ZodNumber;
169
169
  pxY: z.ZodNumber;
170
- }, z.core.$strict>;
171
- export declare const zLayoutWindowPassthrough: z.ZodObject<{
170
+ }, z.core.$strip>;
171
+ export declare const zLayoutWindowLoose: z.ZodObject<{
172
172
  id: z.ZodUUID;
173
173
  activeFrame: z.ZodOptional<z.ZodString>;
174
174
  frames: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -182,7 +182,7 @@ export declare const zLayoutWindowPassthrough: z.ZodObject<{
182
182
  pxHeight: z.ZodNumber;
183
183
  pxX: z.ZodNumber;
184
184
  pxY: z.ZodNumber;
185
- }, z.core.$strip>;
185
+ }, z.core.$loose>;
186
186
  export type BaseLayoutWindow = {
187
187
  id: WindowId;
188
188
  activeFrame?: string;
@@ -204,7 +204,7 @@ export declare const zWorkspace: z.ZodObject<{
204
204
  y: z.ZodNumber;
205
205
  }, z.core.$loose>>;
206
206
  }, z.core.$strict>;
207
- export declare const zWorkspacePassthrough: z.ZodObject<{
207
+ export declare const zWorkspaceLoose: z.ZodObject<{
208
208
  activeFrame: z.ZodOptional<z.ZodString>;
209
209
  frames: z.ZodRecord<z.ZodString, z.ZodObject<{
210
210
  id: z.ZodUUID;
@@ -231,8 +231,8 @@ export declare const zLayout: z.ZodObject<{
231
231
  pxHeight: z.ZodNumber;
232
232
  pxX: z.ZodNumber;
233
233
  pxY: z.ZodNumber;
234
- }, z.core.$strict>>;
235
- }, z.core.$strict>;
234
+ }, z.core.$strip>>;
235
+ }, z.core.$strip>;
236
236
  export declare const zInitializedLayout: z.ZodObject<{
237
237
  activeWindow: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
238
238
  windows: z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -249,8 +249,8 @@ export declare const zInitializedLayout: z.ZodObject<{
249
249
  pxHeight: z.ZodNumber;
250
250
  pxX: z.ZodNumber;
251
251
  pxY: z.ZodNumber;
252
- }, z.core.$strict>>;
253
- }, z.core.$strict>;
252
+ }, z.core.$strip>>;
253
+ }, z.core.$strip>;
254
254
  export type Layout = ExtendedLayout & {
255
255
  activeWindow?: string;
256
256
  windows: LayoutWindows;
@@ -431,7 +431,7 @@ export declare const zWindowCreate: z.ZodObject<{
431
431
  x: z.ZodNumber;
432
432
  y: z.ZodNumber;
433
433
  }, z.core.$loose>>>;
434
- }, z.core.$strip>;
434
+ }, z.core.$loose>;
435
435
  export declare const zLayoutCreate: z.ZodObject<{
436
436
  activeWindow: z.ZodOptional<z.ZodString>;
437
437
  windows: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -448,7 +448,7 @@ export declare const zLayoutCreate: z.ZodObject<{
448
448
  pxHeight: z.ZodNumber;
449
449
  pxX: z.ZodNumber;
450
450
  pxY: z.ZodNumber;
451
- }, z.core.$strict>>>;
451
+ }, z.core.$strip>>>;
452
452
  }, z.core.$loose>;
453
453
  export declare const zFrameCreate: z.ZodObject<{
454
454
  id: z.ZodOptional<z.ZodUUID>;
@@ -44,22 +44,22 @@ export const zBaseSquare = zSize.extend(zPos.shape);
44
44
  export const zLayoutFrame = z.looseObject({
45
45
  id: z.uuid()
46
46
  }).extend(zBaseSquare.shape);
47
- export const zLayoutFramePassthrough = zLayoutFrame.passthrough();
47
+ export const zLayoutFrameLoose = zLayoutFrame.loose();
48
48
  const baseLayoutWindow = z.object({
49
49
  id: z.uuid(),
50
50
  activeFrame: z.string().optional(),
51
51
  frames: z.record(z.string(), zLayoutFrame)
52
52
  }).extend(zPxSize.shape).extend(zPxPos.shape);
53
- export const zLayoutWindow = baseLayoutWindow.strict();
54
- export const zLayoutWindowPassthrough = baseLayoutWindow;
53
+ export const zLayoutWindow = baseLayoutWindow;
54
+ export const zLayoutWindowLoose = baseLayoutWindow.loose();
55
55
  const baseWorkspace = zLayoutWindow.pick({ activeFrame: true, frames: true });
56
56
  export const zWorkspace = baseWorkspace.strict();
57
- export const zWorkspacePassthrough = zWorkspace.passthrough();
58
- const baseLayout = z.looseObject({
57
+ export const zWorkspaceLoose = zWorkspace.loose();
58
+ const baseLayout = z.object({
59
59
  activeWindow: z.string().optional(),
60
60
  windows: z.record(z.string(), zLayoutWindow)
61
61
  });
62
- export const zLayout = baseLayout.strict();
62
+ export const zLayout = baseLayout;
63
63
  export const zInitializedLayout = zLayout.required({
64
64
  activeWindow: true
65
65
  }).refine((layout) => {
@@ -107,8 +107,8 @@ export const LAYOUT_ERROR = enumFromArray([
107
107
  "CANT_SPLIT_FRAME_TOO_SMALL",
108
108
  "CANT_CLOSE_WITHOUT_FORCE"
109
109
  ]);
110
- export const zWindowCreate = zLayoutWindowPassthrough.partial({ id: true, pxWidth: true, pxHeight: true, pxX: true, pxY: true }).extend({ frames: zLayoutWindow.shape.frames.optional() });
111
- export const zLayoutCreate = baseLayout.extend({
110
+ export const zWindowCreate = zLayoutWindowLoose.partial({ id: true, pxWidth: true, pxHeight: true, pxX: true, pxY: true }).extend({ frames: zLayoutWindow.shape.frames.optional() });
111
+ export const zLayoutCreate = baseLayout.loose().extend({
112
112
  windows: zLayout.shape.windows.optional()
113
113
  });
114
114
  export const zFrameCreate = zLayoutFrame.partial({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.0.7",
4
+ "version": "0.1.0",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -69,7 +69,7 @@
69
69
  "husky": "^9.1.7",
70
70
  "indexit": "2.1.0-beta.3",
71
71
  "madge": "^8.0.0",
72
- "nuxt": "^4.1.2",
72
+ "nuxt": "^4.2.1",
73
73
  "onchange": "^7.1.0",
74
74
  "semantic-release": "^24.2.8",
75
75
  "tailwindcss": "^4.1.12",
@@ -113,7 +113,7 @@ export const zLayoutFrame = z.looseObject({
113
113
  id: z.uuid()
114
114
  }).extend(zBaseSquare.shape)
115
115
 
116
- export const zLayoutFramePassthrough = zLayoutFrame.passthrough()
116
+ export const zLayoutFrameLoose = zLayoutFrame.loose()
117
117
 
118
118
  export interface Register {
119
119
  }
@@ -135,8 +135,8 @@ const baseLayoutWindow = z.object({
135
135
  }).extend(zPxSize.shape)
136
136
  .extend(zPxPos.shape)
137
137
 
138
- export const zLayoutWindow = baseLayoutWindow.strict()
139
- export const zLayoutWindowPassthrough = baseLayoutWindow
138
+ export const zLayoutWindow = baseLayoutWindow
139
+ export const zLayoutWindowLoose = baseLayoutWindow.loose()
140
140
  // types are re-declared so that if they are extended, the types are still correct
141
141
 
142
142
  export type BaseLayoutWindow = {
@@ -153,16 +153,16 @@ export type LayoutWindows = Record<string, LayoutWindow>
153
153
 
154
154
  const baseWorkspace = zLayoutWindow.pick({ activeFrame: true, frames: true })
155
155
  export const zWorkspace = baseWorkspace.strict()
156
- export const zWorkspacePassthrough = zWorkspace.passthrough()
156
+ export const zWorkspaceLoose = zWorkspace.loose()
157
157
 
158
158
  export type Workspace = Pick<LayoutWindow, "activeFrame" | "frames"> & ExtendedWorkspace
159
159
 
160
- const baseLayout = z.looseObject({
160
+ const baseLayout = z.object({
161
161
  activeWindow: z.string().optional(),
162
162
  windows: z.record(z.string(), zLayoutWindow)
163
163
  })
164
164
 
165
- export const zLayout = baseLayout.strict()
165
+ export const zLayout = baseLayout
166
166
 
167
167
  export const zInitializedLayout = zLayout.required({
168
168
  activeWindow: true
@@ -275,11 +275,11 @@ type AllErrorsInfo = {
275
275
  // todo rename to toOpposite
276
276
  export type HasOpposite = Direction | EdgeSide | ExtendedDirection | ExtendedEdgeSide | keyof Point | keyof Size
277
277
 
278
- export const zWindowCreate = zLayoutWindowPassthrough
278
+ export const zWindowCreate = zLayoutWindowLoose
279
279
  .partial({ id: true, pxWidth: true, pxHeight: true, pxX: true, pxY: true })
280
280
  .extend({ frames: zLayoutWindow.shape.frames.optional() })
281
281
 
282
- export const zLayoutCreate = baseLayout
282
+ export const zLayoutCreate = baseLayout.loose()
283
283
  .extend({
284
284
  windows: zLayout.shape.windows.optional()
285
285
  })