@valbuild/next 0.50.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 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,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValApp-09d3eba7.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValApp-09d3eba7.cjs.dev.js");
7
+ }
@@ -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;
@@ -0,0 +1,4 @@
1
+ import { ValConfig } from "@valbuild/core";
2
+ export declare const ValApp: ({}: {
3
+ config: ValConfig;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -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
 
@@ -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
 
@@ -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,6 +7,7 @@ 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
 
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.50.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.50.0",
49
- "@valbuild/react": "~0.50.0",
50
- "@valbuild/server": "~0.50.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
  },