@witchcraft/layout 0.1.0 → 0.1.1
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,8 +42,7 @@ 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/FrameLoose` to allow for extra properties.
|
|
46
|
-
|
|
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. They also use a basic `z.uuid()`, if you need something more specific you'll have to extend the type.
|
|
47
46
|
```ts
|
|
48
47
|
import { zLayoutFrameLoose, layoutCreate } from "@witchcraft/layout"
|
|
49
48
|
import { z } from "zod"
|
|
@@ -64,16 +63,18 @@ export const zAppFrame = z.discriminatedUnion("type", [
|
|
|
64
63
|
}),
|
|
65
64
|
}),
|
|
66
65
|
]).and(z.object({
|
|
67
|
-
id: z.
|
|
66
|
+
id: z.uuidv4(), // here we can specify a specific uuid type
|
|
68
67
|
}))
|
|
69
68
|
|
|
69
|
+
|
|
70
70
|
declare module "@witchcraft/layout" {
|
|
71
71
|
interface Register {
|
|
72
|
-
// Register the type
|
|
72
|
+
// Register the type, this allows importing the type from the package, while also allowing the types to be extended
|
|
73
73
|
ExtendedLayoutFrame: z.infer<typeof zAppFrame>
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
|
+
Note that `zFrameId` and `zWinId` are different as they also support constants (`zFrameIdConstants` and `zWindowIdConstants`).
|
|
77
78
|
|
|
78
79
|
## Basics
|
|
79
80
|
|
package/dist/module.json
CHANGED
|
@@ -381,9 +381,8 @@ export declare const LAYOUT_ERROR: {
|
|
|
381
381
|
CANT_CLOSE_WITHOUT_FORCE: "CANT_CLOSE_WITHOUT_FORCE";
|
|
382
382
|
};
|
|
383
383
|
export type LayoutError = EnumLike<typeof LAYOUT_ERROR>;
|
|
384
|
-
export type
|
|
385
|
-
export type
|
|
386
|
-
type AllErrorsInfo = {
|
|
384
|
+
export type LayoutErrorInfo<T extends LayoutError> = LayoutErrorsInfo[T] extends undefined ? never : LayoutErrorsInfo[T];
|
|
385
|
+
export type LayoutErrorsInfo = {
|
|
387
386
|
[LAYOUT_ERROR.INVALID_ID]: {
|
|
388
387
|
id: string | undefined;
|
|
389
388
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LayoutError, LayoutErrorInfo } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a known error that extends the base Error with some extra information.
|
|
4
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
5
|
*/
|
|
6
|
-
export declare class KnownError<T extends
|
|
6
|
+
export declare class KnownError<T extends LayoutError = LayoutError, TInfo extends LayoutErrorInfo<T> = LayoutErrorInfo<T>> extends Error {
|
|
7
7
|
code: T;
|
|
8
8
|
info: TInfo;
|
|
9
9
|
constructor(code: T, str: string, info: TInfo);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witchcraft/layout",
|
|
3
3
|
"description": "Headless layout manager.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"main": "./dist/runtime/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@witchcraft/nuxt-utils": "^0.3.6",
|
|
37
|
-
"@witchcraft/ui": "^0.3.
|
|
37
|
+
"@witchcraft/ui": "^0.3.13"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@witchcraft/ui": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
62
62
|
"@vitest/coverage-c8": "^0.33.0",
|
|
63
63
|
"@witchcraft/nuxt-utils": "^0.3.6",
|
|
64
|
-
"@witchcraft/ui": "^0.3.
|
|
64
|
+
"@witchcraft/ui": "^0.3.13",
|
|
65
65
|
"concurrently": "^9.2.1",
|
|
66
66
|
"cross-env": "^10.0.0",
|
|
67
67
|
"fast-glob": "^3.3.3",
|
|
@@ -234,11 +234,9 @@ export const LAYOUT_ERROR = enumFromArray([
|
|
|
234
234
|
|
|
235
235
|
export type LayoutError = EnumLike<typeof LAYOUT_ERROR>
|
|
236
236
|
|
|
237
|
-
export type
|
|
237
|
+
export type LayoutErrorInfo<T extends LayoutError> = LayoutErrorsInfo[T] extends undefined ? never : LayoutErrorsInfo[T]
|
|
238
238
|
|
|
239
|
-
export type
|
|
240
|
-
|
|
241
|
-
type AllErrorsInfo = {
|
|
239
|
+
export type LayoutErrorsInfo = {
|
|
242
240
|
[LAYOUT_ERROR.INVALID_ID]: {
|
|
243
241
|
id: string | undefined
|
|
244
242
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LayoutError, LayoutErrorInfo } from "../types/index.js"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a known error that extends the base Error with some extra information.
|
|
5
5
|
* 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.
|
|
6
6
|
*/
|
|
7
7
|
export class KnownError<
|
|
8
|
-
T extends
|
|
9
|
-
TInfo extends
|
|
8
|
+
T extends LayoutError = LayoutError,
|
|
9
|
+
TInfo extends LayoutErrorInfo<T> = LayoutErrorInfo<T>
|
|
10
10
|
> extends Error {
|
|
11
11
|
code: T
|
|
12
12
|
|