@valbuild/next 0.67.1 → 0.68.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 +24 -24
- package/dist/declarations/src/ValImage.d.ts +1 -0
- package/dist/declarations/src/ValProvider.d.ts +3 -2
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +1 -24
- package/dist/declarations/src/rsc/initValRsc.d.ts +1 -1
- package/dist/declarations/src/server/initValServer.d.ts +1 -1
- package/package.json +6 -6
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +2 -2
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +2 -2
- package/rsc/dist/valbuild-next-rsc.esm.js +2 -2
package/README.md
CHANGED
|
@@ -73,8 +73,6 @@ npm install @valbuild/core@latest @valbuild/next@latest @valbuild/eslint-plugin@
|
|
|
73
73
|
npx @valbuild/init@latest
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
**NOTE** if your Next.js project is using
|
|
77
|
-
|
|
78
76
|
## Getting started
|
|
79
77
|
|
|
80
78
|
### Create your first Val content file
|
|
@@ -83,31 +81,17 @@ Content in Val is always defined in `.val.ts` (or `.js`) files.
|
|
|
83
81
|
|
|
84
82
|
**NOTE**: the init script will generate an example Val content file (unless you opt out of it).
|
|
85
83
|
|
|
86
|
-
Val content files are _evaluated_ by Val, therefore they
|
|
87
|
-
|
|
88
|
-
- they must export a default content definition (`c.define`) where the first argument equals the path of the file relative to the `val.config.ts` file; and
|
|
89
|
-
- they must have a default export that is `c.define; and
|
|
90
|
-
- they can only import Val related files and / or types
|
|
91
|
-
|
|
92
|
-
If you use the eslint plugins these requirements will be enforced. You can also validate val files using the @valbuild/cli: `npx -p @valbuild/cli val validate --fix`
|
|
93
|
-
|
|
94
|
-
### Adding Val content file to val.modules
|
|
84
|
+
Val content files are _evaluated_ by Val, therefore they need to abide a set of requirements.
|
|
85
|
+
If you use the eslint plugins these requirements will be enforced. You can also validate val files using the @valbuild/cli: `npx -p @valbuild/cli val validate`.
|
|
95
86
|
|
|
96
|
-
|
|
87
|
+
For reference these requirements are:
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
import {
|
|
102
|
-
import { config } from "./val.config";
|
|
103
|
-
|
|
104
|
-
export default modules(config, [
|
|
105
|
-
// Add your modules here
|
|
106
|
-
{ def: () => import("./examples/val/example.val") },
|
|
107
|
-
]);
|
|
108
|
-
```
|
|
89
|
+
- they must export a default content definition (`c.define`) where the first argument equals the path of the file relative to the `val.config` file; and
|
|
90
|
+
- they must be declared in the `val.modules` file; and
|
|
91
|
+
- they must have a default export that is `c.define`; and
|
|
92
|
+
- they can only import Val related files or types (using `import type { MyType } from "./otherModule.ts"`)
|
|
109
93
|
|
|
110
|
-
###
|
|
94
|
+
### Val content file example
|
|
111
95
|
|
|
112
96
|
```ts
|
|
113
97
|
// ./examples/val/example.val.ts
|
|
@@ -133,6 +117,22 @@ export default c.define("/examples/val/example.val.ts", schema, {
|
|
|
133
117
|
});
|
|
134
118
|
```
|
|
135
119
|
|
|
120
|
+
### The `val.modules` file
|
|
121
|
+
|
|
122
|
+
Once you have created your Val content file, it must be declared in the `val.modules.ts` (or `.js`) file in the project root folder.
|
|
123
|
+
|
|
124
|
+
Example:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { modules } from "@valbuild/next";
|
|
128
|
+
import { config } from "./val.config";
|
|
129
|
+
|
|
130
|
+
export default modules(config, [
|
|
131
|
+
// Add your modules here
|
|
132
|
+
{ def: () => import("./examples/val/example.val") },
|
|
133
|
+
]);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
136
|
### Using Val in Client Components
|
|
137
137
|
|
|
138
138
|
In client components you can access your content with the `useVal` hook:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import NextImage from "next/image";
|
|
2
3
|
import { Image } from "@valbuild/react/stega";
|
|
3
4
|
export type ValImageProps = Omit<React.ComponentProps<typeof NextImage>, "src" | "alt" | "srcset" | "layout" | "objectFit" | "objectPosition" | "lazyBoundary" | "lazyRoot"> & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const ValProvider: (props: {
|
|
2
|
-
children:
|
|
3
|
+
children: import("react").ReactNode | import("react").ReactNode[];
|
|
3
4
|
config: import("@valbuild/core").ValConfig;
|
|
4
|
-
disableRefresh?: boolean;
|
|
5
|
+
disableRefresh?: boolean | undefined;
|
|
5
6
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -44,30 +44,7 @@ export declare const Internal: {
|
|
|
44
44
|
[k: string]: string;
|
|
45
45
|
};
|
|
46
46
|
ModuleFilePathSep: string;
|
|
47
|
-
notFileOp: (op: import("@valbuild/core/patch").Operation) =>
|
|
48
|
-
op: "add";
|
|
49
|
-
path: string[];
|
|
50
|
-
value: import("@valbuild/core/dist/declarations/src/patch").JSONValue;
|
|
51
|
-
} | {
|
|
52
|
-
op: "remove";
|
|
53
|
-
path: import("@valbuild/core/dist/declarations/src/fp/array").NonEmptyArray<string>;
|
|
54
|
-
} | {
|
|
55
|
-
op: "replace";
|
|
56
|
-
path: string[];
|
|
57
|
-
value: import("@valbuild/core/dist/declarations/src/patch").JSONValue;
|
|
58
|
-
} | {
|
|
59
|
-
op: "move";
|
|
60
|
-
from: import("@valbuild/core/dist/declarations/src/fp/array").NonEmptyArray<string>;
|
|
61
|
-
path: string[];
|
|
62
|
-
} | {
|
|
63
|
-
op: "copy";
|
|
64
|
-
from: string[];
|
|
65
|
-
path: string[];
|
|
66
|
-
} | {
|
|
67
|
-
op: "test";
|
|
68
|
-
path: string[];
|
|
69
|
-
value: import("@valbuild/core/dist/declarations/src/patch").JSONValue;
|
|
70
|
-
};
|
|
47
|
+
notFileOp: (op: import("@valbuild/core/patch").Operation) => boolean;
|
|
71
48
|
isFileOp: (op: import("@valbuild/core/patch").Operation) => op is {
|
|
72
49
|
op: "file";
|
|
73
50
|
path: string[];
|
|
@@ -9,7 +9,7 @@ declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, va
|
|
|
9
9
|
name: string;
|
|
10
10
|
value: string;
|
|
11
11
|
} | undefined;
|
|
12
|
-
}>) => <T extends SelectorSource>(selector: T) => Promise<SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never>;
|
|
12
|
+
}>) => <T extends SelectorSource>(selector: T) => Promise<SelectorOf<T> extends GenericSelector<infer S extends import("@valbuild/core").Source, undefined> ? StegaOfSource<S> : never>;
|
|
13
13
|
type ValNextRscConfig = {
|
|
14
14
|
draftMode: typeof draftMode;
|
|
15
15
|
headers: typeof headers;
|
|
@@ -2,7 +2,7 @@ import { ValConfig, ValModules } from "@valbuild/core";
|
|
|
2
2
|
import type { draftMode } from "next/headers";
|
|
3
3
|
import { NextResponse } from "next/server";
|
|
4
4
|
declare const initValNextAppRouter: (valModules: ValModules, config: ValConfig, nextConfig: ValServerNextConfig & {
|
|
5
|
-
formatter?: (code: string, filePath: string) => Promise<string> | string;
|
|
5
|
+
formatter?: ((code: string, filePath: string) => Promise<string> | string) | undefined;
|
|
6
6
|
}) => (req: Request) => Promise<NextResponse<unknown>>;
|
|
7
7
|
type ValServerNextConfig = {
|
|
8
8
|
draftMode: typeof draftMode;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"next",
|
|
9
9
|
"react"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.68.0",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"test": "jest"
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"exports": true
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@valbuild/core": "~0.
|
|
49
|
-
"@valbuild/react": "~0.
|
|
50
|
-
"@valbuild/server": "~0.
|
|
51
|
-
"@valbuild/shared": "~0.
|
|
52
|
-
"@valbuild/ui": "~0.
|
|
48
|
+
"@valbuild/core": "~0.68.0",
|
|
49
|
+
"@valbuild/react": "~0.68.0",
|
|
50
|
+
"@valbuild/server": "~0.68.0",
|
|
51
|
+
"@valbuild/shared": "~0.68.0",
|
|
52
|
+
"@valbuild/ui": "~0.68.0",
|
|
53
53
|
"client-only": "^0.0.1",
|
|
54
54
|
"server-only": "^0.0.1"
|
|
55
55
|
},
|
|
@@ -80,7 +80,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
80
80
|
case 38:
|
|
81
81
|
valServer = _context.sent;
|
|
82
82
|
_context.next = 41;
|
|
83
|
-
return valServer["/patches
|
|
83
|
+
return valServer["/patches"]["GET"]({
|
|
84
84
|
query: {
|
|
85
85
|
omit_patch: true,
|
|
86
86
|
author: undefined,
|
|
@@ -99,7 +99,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
99
99
|
case 44:
|
|
100
100
|
allPatches = Object.keys(patchesRes.json.patches);
|
|
101
101
|
_context.next = 47;
|
|
102
|
-
return valServer["/sources"]["PUT"]({
|
|
102
|
+
return valServer["/sources/~"]["PUT"]({
|
|
103
103
|
path: "/",
|
|
104
104
|
query: {
|
|
105
105
|
validate_sources: true,
|
|
@@ -80,7 +80,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
80
80
|
case 38:
|
|
81
81
|
valServer = _context.sent;
|
|
82
82
|
_context.next = 41;
|
|
83
|
-
return valServer["/patches
|
|
83
|
+
return valServer["/patches"]["GET"]({
|
|
84
84
|
query: {
|
|
85
85
|
omit_patch: true,
|
|
86
86
|
author: undefined,
|
|
@@ -99,7 +99,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
99
99
|
case 44:
|
|
100
100
|
allPatches = Object.keys(patchesRes.json.patches);
|
|
101
101
|
_context.next = 47;
|
|
102
|
-
return valServer["/sources"]["PUT"]({
|
|
102
|
+
return valServer["/sources/~"]["PUT"]({
|
|
103
103
|
path: "/",
|
|
104
104
|
query: {
|
|
105
105
|
validate_sources: true,
|
|
@@ -76,7 +76,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
76
76
|
case 38:
|
|
77
77
|
valServer = _context.sent;
|
|
78
78
|
_context.next = 41;
|
|
79
|
-
return valServer["/patches
|
|
79
|
+
return valServer["/patches"]["GET"]({
|
|
80
80
|
query: {
|
|
81
81
|
omit_patch: true,
|
|
82
82
|
author: undefined,
|
|
@@ -95,7 +95,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
|
|
|
95
95
|
case 44:
|
|
96
96
|
allPatches = Object.keys(patchesRes.json.patches);
|
|
97
97
|
_context.next = 47;
|
|
98
|
-
return valServer["/sources"]["PUT"]({
|
|
98
|
+
return valServer["/sources/~"]["PUT"]({
|
|
99
99
|
path: "/",
|
|
100
100
|
query: {
|
|
101
101
|
validate_sources: true,
|