@valbuild/next 0.49.0 → 0.51.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 +42 -2
- package/dist/ValApp-09d3eba7.cjs.js +7 -0
- package/dist/ValApp-09d3eba7.cjs.prod.js +37 -0
- package/dist/ValApp-6827827a.esm.js +29 -0
- package/dist/ValApp-cbf9b1c3.cjs.dev.js +37 -0
- package/dist/declarations/src/ValApp.d.ts +4 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/valbuild-next.cjs.dev.js +16 -11
- package/dist/valbuild-next.cjs.prod.js +16 -11
- package/dist/valbuild-next.esm.js +12 -11
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -159,9 +159,9 @@ npm install @valbuild/next@latest
|
|
|
159
159
|
|
|
160
160
|
import { initVal } from "@valbuild/next";
|
|
161
161
|
|
|
162
|
-
const { s, val } = initVal();
|
|
162
|
+
const { s, val, config } = initVal();
|
|
163
163
|
|
|
164
|
-
export { s, val };
|
|
164
|
+
export { s, val, config };
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
- Create the endpoints file:
|
|
@@ -501,6 +501,46 @@ const image = useVal(imageVal);
|
|
|
501
501
|
return <img src={image.url} />;
|
|
502
502
|
```
|
|
503
503
|
|
|
504
|
+
## Union
|
|
505
|
+
|
|
506
|
+
The union schema can be used to create either "tagged unions" or a union of string literals.
|
|
507
|
+
|
|
508
|
+
### Union Schema tagged unions
|
|
509
|
+
|
|
510
|
+
A tagged union is a union of objects which all have the same field (of the same type). This field can be used to determine (or "discriminate") the exact type of one of the types of the union.
|
|
511
|
+
|
|
512
|
+
It is useful when editors should be able to chose from a set of objects that are different.
|
|
513
|
+
|
|
514
|
+
Example: let us say you have a page that can be one of the following: blog (page) or product (page). In this case your schema could look like this:
|
|
515
|
+
|
|
516
|
+
```ts
|
|
517
|
+
s.union(
|
|
518
|
+
"type", // the key of the "discriminator"
|
|
519
|
+
s.object({
|
|
520
|
+
type: s.literal("blogPage"), // <- each type must have a UNIQUE value
|
|
521
|
+
author: s.string(),
|
|
522
|
+
// ...
|
|
523
|
+
}),
|
|
524
|
+
s.object({
|
|
525
|
+
type: s.literal("productPage"),
|
|
526
|
+
sku: s.number(),
|
|
527
|
+
// ...
|
|
528
|
+
})
|
|
529
|
+
); // <- Schema<{ type: "blogPage", author: string } | { type: "productPage", sku: number }>
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## Union Schema: union of string literals
|
|
533
|
+
|
|
534
|
+
You can also use a union to create a union of string literals. This is useful if you want a type-safe way to describe a set of valid strings that can be chosen by an editor.
|
|
535
|
+
|
|
536
|
+
```ts
|
|
537
|
+
s.union(
|
|
538
|
+
s.literal("one"),
|
|
539
|
+
s.literal("two")
|
|
540
|
+
//...
|
|
541
|
+
); // <- Schema<"one" | "two">
|
|
542
|
+
```
|
|
543
|
+
|
|
504
544
|
## KeyOf
|
|
505
545
|
|
|
506
546
|
If you need to reference content in another `.val` file you can use the `keyOf` schema.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var ui = require('@valbuild/ui');
|
|
7
|
+
var Script = require('next/script');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var Script__default = /*#__PURE__*/_interopDefault(Script);
|
|
13
|
+
|
|
14
|
+
function _objectDestructuringEmpty(obj) {
|
|
15
|
+
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var ValApp = function ValApp(_ref) {
|
|
19
|
+
_objectDestructuringEmpty(_ref);
|
|
20
|
+
var route = "/api/val";
|
|
21
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
22
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("link", {
|
|
23
|
+
rel: "stylesheet",
|
|
24
|
+
href: "".concat(route , "/static").concat(ui.VAL_CSS_PATH)
|
|
25
|
+
}), ui.IS_DEV && /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
26
|
+
type: "module",
|
|
27
|
+
children: "import RefreshRuntime from \"".concat(route, "/static/@react-refresh\"\nif (RefreshRuntime.injectIntoGlobalHook) {\n RefreshRuntime.injectIntoGlobalHook(window)\n window.$RefreshReg$ = () => {}\n window.$RefreshSig$ = () => (type) => type\n window.__vite_plugin_react_preamble_installed__ = true\n}")
|
|
28
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
29
|
+
type: "module",
|
|
30
|
+
src: "".concat(route, "/static").concat(ui.VAL_APP_PATH)
|
|
31
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
32
|
+
id: ui.VAL_APP_ID
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.ValApp = ValApp;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { VAL_CSS_PATH, IS_DEV, VAL_APP_PATH, VAL_APP_ID } from '@valbuild/ui';
|
|
3
|
+
import Script from 'next/script';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function _objectDestructuringEmpty(obj) {
|
|
7
|
+
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var ValApp = function ValApp(_ref) {
|
|
11
|
+
_objectDestructuringEmpty(_ref);
|
|
12
|
+
var route = "/api/val";
|
|
13
|
+
return /*#__PURE__*/jsxs("div", {
|
|
14
|
+
children: [/*#__PURE__*/jsx("link", {
|
|
15
|
+
rel: "stylesheet",
|
|
16
|
+
href: "".concat(route , "/static").concat(VAL_CSS_PATH)
|
|
17
|
+
}), IS_DEV && /*#__PURE__*/jsx(Script, {
|
|
18
|
+
type: "module",
|
|
19
|
+
children: "import RefreshRuntime from \"".concat(route, "/static/@react-refresh\"\nif (RefreshRuntime.injectIntoGlobalHook) {\n RefreshRuntime.injectIntoGlobalHook(window)\n window.$RefreshReg$ = () => {}\n window.$RefreshSig$ = () => (type) => type\n window.__vite_plugin_react_preamble_installed__ = true\n}")
|
|
20
|
+
}), /*#__PURE__*/jsx(Script, {
|
|
21
|
+
type: "module",
|
|
22
|
+
src: "".concat(route, "/static").concat(VAL_APP_PATH)
|
|
23
|
+
}), /*#__PURE__*/jsx("div", {
|
|
24
|
+
id: VAL_APP_ID
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { ValApp };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var ui = require('@valbuild/ui');
|
|
7
|
+
var Script = require('next/script');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var Script__default = /*#__PURE__*/_interopDefault(Script);
|
|
13
|
+
|
|
14
|
+
function _objectDestructuringEmpty(obj) {
|
|
15
|
+
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var ValApp = function ValApp(_ref) {
|
|
19
|
+
_objectDestructuringEmpty(_ref);
|
|
20
|
+
var route = "/api/val";
|
|
21
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
22
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("link", {
|
|
23
|
+
rel: "stylesheet",
|
|
24
|
+
href: "".concat(route , "/static").concat(ui.VAL_CSS_PATH)
|
|
25
|
+
}), ui.IS_DEV && /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
26
|
+
type: "module",
|
|
27
|
+
children: "import RefreshRuntime from \"".concat(route, "/static/@react-refresh\"\nif (RefreshRuntime.injectIntoGlobalHook) {\n RefreshRuntime.injectIntoGlobalHook(window)\n window.$RefreshReg$ = () => {}\n window.$RefreshSig$ = () => (type) => type\n window.__vite_plugin_react_preamble_installed__ = true\n}")
|
|
28
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
29
|
+
type: "module",
|
|
30
|
+
src: "".concat(route, "/static").concat(ui.VAL_APP_PATH)
|
|
31
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
32
|
+
id: ui.VAL_APP_ID
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.ValApp = ValApp;
|
|
@@ -16,6 +16,7 @@ export { ValRichText } from "@valbuild/react/internal";
|
|
|
16
16
|
export { type ValEncodedString, type Image } from "@valbuild/react/stega";
|
|
17
17
|
export { ValProvider } from "./ValProvider.js";
|
|
18
18
|
export { ValImage, type ValImageProps } from "./ValImage.js";
|
|
19
|
+
export { ValApp } from "./ValApp.js";
|
|
19
20
|
export { initVal } from "./initVal.js";
|
|
20
21
|
import type { UseValType } from "./client/initValClient.js";
|
|
21
22
|
import { Schema, SelectorSource } from "@valbuild/core";
|
|
@@ -8,6 +8,7 @@ var ValNextProvider = require('./ValNextProvider-49d2bec1.cjs.dev.js');
|
|
|
8
8
|
var NextImage = require('next/image');
|
|
9
9
|
var stega = require('@valbuild/react/stega');
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
var ValApp = require('./ValApp-cbf9b1c3.cjs.dev.js');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -34,24 +35,24 @@ var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
|
|
|
34
35
|
|
|
35
36
|
var ValProvider = ValNextProvider.ValNextProvider;
|
|
36
37
|
|
|
37
|
-
function
|
|
38
|
-
if (
|
|
39
|
-
var
|
|
40
|
-
if (
|
|
41
|
-
var
|
|
42
|
-
if (
|
|
38
|
+
function toPrimitive(t, r) {
|
|
39
|
+
if ("object" != typeof t || !t) return t;
|
|
40
|
+
var e = t[Symbol.toPrimitive];
|
|
41
|
+
if (void 0 !== e) {
|
|
42
|
+
var i = e.call(t, r || "default");
|
|
43
|
+
if ("object" != typeof i) return i;
|
|
43
44
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
44
45
|
}
|
|
45
|
-
return (
|
|
46
|
+
return ("string" === r ? String : Number)(t);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function
|
|
49
|
-
var
|
|
50
|
-
return
|
|
49
|
+
function toPropertyKey(t) {
|
|
50
|
+
var i = toPrimitive(t, "string");
|
|
51
|
+
return "symbol" == typeof i ? i : String(i);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
function _defineProperty(obj, key, value) {
|
|
54
|
-
key =
|
|
55
|
+
key = toPropertyKey(key);
|
|
55
56
|
if (key in obj) {
|
|
56
57
|
Object.defineProperty(obj, key, {
|
|
57
58
|
value: value,
|
|
@@ -214,6 +215,10 @@ Object.defineProperty(exports, 'ValRichText', {
|
|
|
214
215
|
enumerable: true,
|
|
215
216
|
get: function () { return internal.ValRichText; }
|
|
216
217
|
});
|
|
218
|
+
Object.defineProperty(exports, 'ValApp', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () { return ValApp.ValApp; }
|
|
221
|
+
});
|
|
217
222
|
exports.ValImage = ValImage;
|
|
218
223
|
exports.ValProvider = ValProvider;
|
|
219
224
|
exports.initVal = initVal;
|
|
@@ -8,6 +8,7 @@ var ValNextProvider = require('./ValNextProvider-7750e412.cjs.prod.js');
|
|
|
8
8
|
var NextImage = require('next/image');
|
|
9
9
|
var stega = require('@valbuild/react/stega');
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
var ValApp = require('./ValApp-09d3eba7.cjs.prod.js');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -34,24 +35,24 @@ var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
|
|
|
34
35
|
|
|
35
36
|
var ValProvider = ValNextProvider.ValNextProvider;
|
|
36
37
|
|
|
37
|
-
function
|
|
38
|
-
if (
|
|
39
|
-
var
|
|
40
|
-
if (
|
|
41
|
-
var
|
|
42
|
-
if (
|
|
38
|
+
function toPrimitive(t, r) {
|
|
39
|
+
if ("object" != typeof t || !t) return t;
|
|
40
|
+
var e = t[Symbol.toPrimitive];
|
|
41
|
+
if (void 0 !== e) {
|
|
42
|
+
var i = e.call(t, r || "default");
|
|
43
|
+
if ("object" != typeof i) return i;
|
|
43
44
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
44
45
|
}
|
|
45
|
-
return (
|
|
46
|
+
return ("string" === r ? String : Number)(t);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function
|
|
49
|
-
var
|
|
50
|
-
return
|
|
49
|
+
function toPropertyKey(t) {
|
|
50
|
+
var i = toPrimitive(t, "string");
|
|
51
|
+
return "symbol" == typeof i ? i : String(i);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
function _defineProperty(obj, key, value) {
|
|
54
|
-
key =
|
|
55
|
+
key = toPropertyKey(key);
|
|
55
56
|
if (key in obj) {
|
|
56
57
|
Object.defineProperty(obj, key, {
|
|
57
58
|
value: value,
|
|
@@ -214,6 +215,10 @@ Object.defineProperty(exports, 'ValRichText', {
|
|
|
214
215
|
enumerable: true,
|
|
215
216
|
get: function () { return internal.ValRichText; }
|
|
216
217
|
});
|
|
218
|
+
Object.defineProperty(exports, 'ValApp', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () { return ValApp.ValApp; }
|
|
221
|
+
});
|
|
217
222
|
exports.ValImage = ValImage;
|
|
218
223
|
exports.ValProvider = ValProvider;
|
|
219
224
|
exports.initVal = initVal;
|
|
@@ -7,27 +7,28 @@ import { ValNextProvider } from './ValNextProvider-c5c9fcb0.esm.js';
|
|
|
7
7
|
import NextImage from 'next/image';
|
|
8
8
|
import { stegaClean, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
export { ValApp } from './ValApp-6827827a.esm.js';
|
|
10
11
|
|
|
11
12
|
var ValProvider = ValNextProvider;
|
|
12
13
|
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
15
|
-
var
|
|
16
|
-
if (
|
|
17
|
-
var
|
|
18
|
-
if (
|
|
14
|
+
function toPrimitive(t, r) {
|
|
15
|
+
if ("object" != typeof t || !t) return t;
|
|
16
|
+
var e = t[Symbol.toPrimitive];
|
|
17
|
+
if (void 0 !== e) {
|
|
18
|
+
var i = e.call(t, r || "default");
|
|
19
|
+
if ("object" != typeof i) return i;
|
|
19
20
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
20
21
|
}
|
|
21
|
-
return (
|
|
22
|
+
return ("string" === r ? String : Number)(t);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
function
|
|
25
|
-
var
|
|
26
|
-
return
|
|
25
|
+
function toPropertyKey(t) {
|
|
26
|
+
var i = toPrimitive(t, "string");
|
|
27
|
+
return "symbol" == typeof i ? i : String(i);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function _defineProperty(obj, key, value) {
|
|
30
|
-
key =
|
|
31
|
+
key = toPropertyKey(key);
|
|
31
32
|
if (key in obj) {
|
|
32
33
|
Object.defineProperty(obj, key, {
|
|
33
34
|
value: value,
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"next",
|
|
9
9
|
"react"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.51.0",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"test": "jest"
|
|
@@ -45,9 +45,10 @@
|
|
|
45
45
|
"exports": true
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@valbuild/core": "~0.
|
|
49
|
-
"@valbuild/react": "~0.
|
|
50
|
-
"@valbuild/server": "~0.
|
|
48
|
+
"@valbuild/core": "~0.51.0",
|
|
49
|
+
"@valbuild/react": "~0.51.0",
|
|
50
|
+
"@valbuild/server": "~0.51.0",
|
|
51
|
+
"@valbuild/ui": "~0.51.0",
|
|
51
52
|
"client-only": "^0.0.1",
|
|
52
53
|
"server-only": "^0.0.1"
|
|
53
54
|
},
|