@valbuild/next 0.125.0 → 0.127.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/CHANGELOG.md +158 -0
- package/README.md +50 -16
- package/client/dist/valbuild-next-client.cjs.dev.js +1 -1
- package/client/dist/valbuild-next-client.cjs.prod.js +1 -1
- package/client/dist/valbuild-next-client.esm.js +1 -1
- package/dist/ValNextProvider-062a8dc9.cjs.dev.js +1 -1
- package/dist/ValNextProvider-3d2cd7e4.esm.js +1 -1
- package/dist/ValNextProvider-da189afe.cjs.prod.js +1 -1
- package/dist/{ValOverlayContext-e42a2e14.esm.js → ValOverlayContext-398baef3.esm.js} +13 -11
- package/dist/{ValOverlayContext-5bd7628b.cjs.dev.js → ValOverlayContext-98d33d86.cjs.dev.js} +13 -11
- package/dist/ValOverlayContext-9c4ae06d.cjs.js +7 -0
- package/dist/{ValOverlayContext-d690744f.cjs.prod.js → ValOverlayContext-9c4ae06d.cjs.prod.js} +13 -11
- package/dist/declarations/src/initVal.d.ts +53 -4
- package/dist/valbuild-next.cjs.dev.js +1 -1
- package/dist/valbuild-next.cjs.prod.js +1 -1
- package/dist/valbuild-next.esm.js +1 -1
- package/dist/{version-4302babf.cjs.dev.js → version-15707a75.cjs.dev.js} +1 -1
- package/dist/{version-eb9498d9.cjs.prod.js → version-9b3eb9b7.cjs.prod.js} +1 -1
- package/dist/{version-8ab79315.esm.js → version-dc02550b.esm.js} +1 -1
- package/package.json +8 -8
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +1 -1
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +1 -1
- package/rsc/dist/valbuild-next-rsc.esm.js +1 -1
- package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-next-server.esm.js +1 -1
- package/dist/ValOverlayContext-d690744f.cjs.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,163 @@
|
|
|
1
1
|
# @valbuild/next
|
|
2
2
|
|
|
3
|
+
## 0.127.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#665](https://github.com/valbuild/val/pull/665) [`7072e07`](https://github.com/valbuild/val/commit/7072e07623c953a09ac14388ae22dada0b431ce3) Thanks [@freekh](https://github.com/freekh)! - `.nullable()` no longer drops the field's `.validate(...)` functions.
|
|
8
|
+
|
|
9
|
+
`.nullable()` returns a copy of the schema, and most of the schema classes built
|
|
10
|
+
that copy with an empty list of custom validators — so a validator declared
|
|
11
|
+
before the `.nullable()` was silently thrown away:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
s.number()
|
|
15
|
+
.validate((n) => (n > 100 ? "Too big" : false))
|
|
16
|
+
.nullable(); // the validator never ran
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`array`, `object`, `discriminatedUnion`, `enum`, `number`, `boolean`, `literal`,
|
|
20
|
+
`keyOf`, `date`, `dateTime`, `code`, `color` and `richtext` were affected;
|
|
21
|
+
`string`, `record`, `route`, `file` and `image` already carried them over, which
|
|
22
|
+
is why the bug was easy to miss. Validators now survive `.nullable()` on every
|
|
23
|
+
schema, in either order.
|
|
24
|
+
|
|
25
|
+
A validator on a nullable schema is called with `null` when the value is unset,
|
|
26
|
+
rather than being skipped — the same thing the schemas that never dropped them
|
|
27
|
+
have always done. If yours was written before the `.nullable()`, its argument is
|
|
28
|
+
typed as non-null even though `null` can reach it, so guard for it.
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`7fa8699`](https://github.com/valbuild/val/commit/7fa869974bc895af992a7d5c18b76253636d7d65), [`600308d`](https://github.com/valbuild/val/commit/600308d0174990ad9f5c417147d160273489c65a), [`5b7fe05`](https://github.com/valbuild/val/commit/5b7fe05cec6365f9cd1de9ba31e65ed4a87edb63), [`88262ac`](https://github.com/valbuild/val/commit/88262ac8db068650a664981ef73556457d87741a), [`7072e07`](https://github.com/valbuild/val/commit/7072e07623c953a09ac14388ae22dada0b431ce3), [`29811c3`](https://github.com/valbuild/val/commit/29811c3f8c7e001a950e6f4833af6888e6a4efea), [`9983116`](https://github.com/valbuild/val/commit/99831164c5151aad7ca69de79e1d0d59878be251)]:
|
|
31
|
+
- @valbuild/core@0.127.0
|
|
32
|
+
- @valbuild/shared@0.127.0
|
|
33
|
+
- @valbuild/ui@0.127.0
|
|
34
|
+
- @valbuild/server@0.127.0
|
|
35
|
+
- @valbuild/react@0.127.0
|
|
36
|
+
- @valbuild/language-server@0.127.0
|
|
37
|
+
- @valbuild/mcp@0.127.0
|
|
38
|
+
|
|
39
|
+
## 0.126.0
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#652](https://github.com/valbuild/val/pull/652) [`f2fe70d`](https://github.com/valbuild/val/commit/f2fe70dab2b65000dfaf289f09c70b4a8291467a) Thanks [@freekh](https://github.com/freekh)! - `s.union` is now `s.discriminatedUnion` and `s.enum`.
|
|
44
|
+
|
|
45
|
+
`s.union` did two unrelated jobs and worked out which one you meant from its
|
|
46
|
+
first argument: a string key meant a tagged union of objects, literal schemas
|
|
47
|
+
meant a set of allowed strings. Those are now two schemas with two names.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// A fixed set of strings — presents as a dropdown
|
|
51
|
+
s.enum("primary", "secondary", "ghost"); // Schema<"primary" | "secondary" | "ghost">
|
|
52
|
+
|
|
53
|
+
// One of several object shapes, told apart by a tag field
|
|
54
|
+
s.discriminatedUnion(
|
|
55
|
+
"type",
|
|
56
|
+
s.object({ type: s.literal("hero"), heading: s.string() }),
|
|
57
|
+
s.object({ type: s.literal("quote"), text: s.string() }),
|
|
58
|
+
);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`s.enum` takes the strings directly, so the `s.literal(...)` wrapper is gone.
|
|
62
|
+
|
|
63
|
+
**`s.union` still works** — it is deprecated, and it builds exactly the schema
|
|
64
|
+
above, so nothing has to change today:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
s.union(s.literal("one"), s.literal("two")); // → s.enum("one", "two")
|
|
68
|
+
s.union("type", pageA, pageB); // → s.discriminatedUnion("type", pageA, pageB)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The two are different kinds of node, and that is the reason for the split. A
|
|
72
|
+
discriminated union is a container: the selected variant's fields are the fields
|
|
73
|
+
being edited, and everything that walks a schema descends through it. An enum is
|
|
74
|
+
a leaf — a string with a closed domain — so nothing recurses into it. Told apart
|
|
75
|
+
only by the shape of `key`, every consumer had to re-derive which one it was
|
|
76
|
+
holding; each now has its own serialized type (`"discriminated-union"` and
|
|
77
|
+
`"enum"`) and Val Studio has a field per kind rather than one field that
|
|
78
|
+
branches.
|
|
79
|
+
|
|
80
|
+
Two behaviour changes fall out of the split, both of them fixes:
|
|
81
|
+
|
|
82
|
+
- A value that is not a string at all now fails an enum's validation with a
|
|
83
|
+
type error. `s.union` of literals only ever checked the value against its
|
|
84
|
+
literals when the value WAS a string, so a number or an object where an enum
|
|
85
|
+
was declared validated clean.
|
|
86
|
+
- An enum field now shows its validation errors in Val Studio where the field
|
|
87
|
+
is opened on its own — the module editor and the canvas's fields column — and
|
|
88
|
+
gets the compact error layout inside an inline list row. It is a leaf now, so
|
|
89
|
+
it goes through the same error rendering as every other leaf field; the string
|
|
90
|
+
union bypassed it and showed nothing in those places.
|
|
91
|
+
|
|
92
|
+
Several latent crashes in the old `s.union` are fixed on the way past, all of
|
|
93
|
+
them cases where it threw a `TypeError` instead of reporting:
|
|
94
|
+
|
|
95
|
+
- A required discriminated union holding `null` now reports a type error rather
|
|
96
|
+
than throwing, and resolving a path underneath a nullable one that is `null`
|
|
97
|
+
gives the error the API promises instead of a crash.
|
|
98
|
+
- `s.literal("")` is a legal discriminator tag, and `s.enum("")` a legal value.
|
|
99
|
+
Both used to be treated as absent by a truthiness check — in path resolution,
|
|
100
|
+
in stega encoding, and in the message that lists a union's valid tags. The
|
|
101
|
+
editor's dropdowns handle them too: an empty value is reserved by the select
|
|
102
|
+
component and had to be mapped around.
|
|
103
|
+
- A variant that omits the discriminator entirely is now reported as the schema
|
|
104
|
+
error it is, instead of throwing while the check looked for it.
|
|
105
|
+
- An enum's value is now indexed for search, like every other string leaf. The
|
|
106
|
+
old string union was never indexed at all, so searching for one of its values
|
|
107
|
+
could not find the field.
|
|
108
|
+
- A nullable discriminated union set to `null` no longer renders a spinner that
|
|
109
|
+
never resolves.
|
|
110
|
+
|
|
111
|
+
`s.discriminatedUnion` also requires at least one variant, as `s.enum` requires
|
|
112
|
+
at least one value: a union with nothing to select is not a thing to write, and
|
|
113
|
+
everything downstream reads the first variant where it needs any.
|
|
114
|
+
|
|
115
|
+
If you read serialized schemas yourself, that is the breaking part: `type` is no
|
|
116
|
+
longer `"union"`, an enum carries `values: string[]` instead of a `key` plus
|
|
117
|
+
`items` of literal schemas, and `UnionSchema` is no longer a class.
|
|
118
|
+
`SerializedUnionSchema`, `SerializedStringUnionSchema`,
|
|
119
|
+
`SerializedObjectUnionSchema` and `UnionSchema` remain as deprecated type
|
|
120
|
+
aliases.
|
|
121
|
+
|
|
122
|
+
- [#661](https://github.com/valbuild/val/pull/661) [`171208a`](https://github.com/valbuild/val/commit/171208a20177e68ed5a8b1a6fdaabfe893a6aa5f) Thanks [@freekh](https://github.com/freekh)! - Every schema method now has a worked `@example` in its JSDoc, so hovering it in
|
|
123
|
+
your editor shows what to write.
|
|
124
|
+
|
|
125
|
+
That covers the whole builder surface — `.describe()`, `.validate()`,
|
|
126
|
+
`.nullable()`, `.readonly()`, `.hidden()`, `.preview()`, `.render()`, and the
|
|
127
|
+
per-type methods such as `.minLength()`, `.regexp()`, `.raw()`, `.multiline()`,
|
|
128
|
+
`.from()` / `.to()`, `.remote()`, `.jsonValues()` and `.external()` — as well as
|
|
129
|
+
`c.define()`, `c.json()`, `c.external()` and the `val` helpers (`val.attrs`,
|
|
130
|
+
`val.raw`, `val.unstable_getPath` and friends).
|
|
131
|
+
|
|
132
|
+
One of the examples corrected a real trap: a custom validator returns
|
|
133
|
+
`false | string`, so the natural-looking
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
s.string().validate((val) => val.trim() === val || "No surrounding spaces");
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
does not type check — `||` yields `true`, and `true` is not one of the two
|
|
140
|
+
answers. Write it as a ternary instead:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
s.string().validate((val) =>
|
|
144
|
+
val.trim() === val ? false : "No surrounding spaces",
|
|
145
|
+
);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The examples are checked in CI, not just written: one test asks the TypeScript
|
|
149
|
+
checker for the doc each method actually resolves to and fails if it has no
|
|
150
|
+
`@example`, and another compiles every example it finds.
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [[`719ad6b`](https://github.com/valbuild/val/commit/719ad6b607bcf136d0dbde9e90bf4b8a843561a4), [`9830277`](https://github.com/valbuild/val/commit/9830277e9aaca8da3030f629c2656ec58da47e45), [`64bfd0a`](https://github.com/valbuild/val/commit/64bfd0a6c85832ea5169b53e47087f22e193df36), [`7782979`](https://github.com/valbuild/val/commit/7782979e9b52f2015a6e72dc981e630d4f8c78e2), [`5bfd630`](https://github.com/valbuild/val/commit/5bfd630b63dee2189e238f20fe72ecc5537160f7), [`ccbcda6`](https://github.com/valbuild/val/commit/ccbcda60b3e3c465071229ae1ba28ac735483e63), [`f2fe70d`](https://github.com/valbuild/val/commit/f2fe70dab2b65000dfaf289f09c70b4a8291467a), [`5c18c99`](https://github.com/valbuild/val/commit/5c18c99ecc84651f82123481fc042063db953833), [`755e1a3`](https://github.com/valbuild/val/commit/755e1a3953775cb8d2c2dce87d6810d3dc329640), [`c6b1ec8`](https://github.com/valbuild/val/commit/c6b1ec84f1883750a4cfe5f70470b177621e971f), [`656f680`](https://github.com/valbuild/val/commit/656f680043c640f678625a64e690389ab23a0a69), [`610a041`](https://github.com/valbuild/val/commit/610a0414b120b521f38a2eb1182b3778bf778b2b), [`171208a`](https://github.com/valbuild/val/commit/171208a20177e68ed5a8b1a6fdaabfe893a6aa5f)]:
|
|
153
|
+
- @valbuild/ui@0.126.0
|
|
154
|
+
- @valbuild/shared@0.126.0
|
|
155
|
+
- @valbuild/server@0.126.0
|
|
156
|
+
- @valbuild/core@0.126.0
|
|
157
|
+
- @valbuild/react@0.126.0
|
|
158
|
+
- @valbuild/language-server@0.126.0
|
|
159
|
+
- @valbuild/mcp@0.126.0
|
|
160
|
+
|
|
3
161
|
## 0.125.0
|
|
4
162
|
|
|
5
163
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -385,6 +385,16 @@ import { s } from "./val.config";
|
|
|
385
385
|
s.string().nullable(); // <- Schema<string | null>
|
|
386
386
|
```
|
|
387
387
|
|
|
388
|
+
`.nullable()` can go before or after `.validate(...)` — a validator declared on
|
|
389
|
+
either side of it is kept, and runs on `null` too, so the validator decides for
|
|
390
|
+
itself what an unset value means:
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
s.string()
|
|
394
|
+
.nullable()
|
|
395
|
+
.validate((val) => (val === null ? "Please fill this in" : false));
|
|
396
|
+
```
|
|
397
|
+
|
|
388
398
|
## Read-only and hidden fields
|
|
389
399
|
|
|
390
400
|
`.readonly()` renders a field disabled in the Val editor, and `.hidden()` leaves
|
|
@@ -571,7 +581,7 @@ const sectionsSchema = s.array(
|
|
|
571
581
|
);
|
|
572
582
|
```
|
|
573
583
|
|
|
574
|
-
A
|
|
584
|
+
A discriminated union with no preview of its own previews as the VARIANT the value
|
|
575
585
|
takes, so a page-builder list previews each block by its own block type.
|
|
576
586
|
|
|
577
587
|
Your function is run on demand, for the rows actually on screen, so it is fine
|
|
@@ -909,20 +919,16 @@ const image = useVal(imageVal);
|
|
|
909
919
|
return <img src={image.url} />;
|
|
910
920
|
```
|
|
911
921
|
|
|
912
|
-
## Union
|
|
913
|
-
|
|
914
|
-
The union schema can be used to create either "tagged unions" or a union of string literals.
|
|
922
|
+
## Discriminated Union
|
|
915
923
|
|
|
916
|
-
|
|
924
|
+
A discriminated union is a union of objects which all have the same field (of the same type). This field determines (or "discriminates") which of the union's types a value is.
|
|
917
925
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
It is useful when editors should be able to chose from a set of objects that are different.
|
|
926
|
+
It is useful when editors should be able to choose from a set of objects that are different.
|
|
921
927
|
|
|
922
928
|
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:
|
|
923
929
|
|
|
924
930
|
```ts
|
|
925
|
-
s.
|
|
931
|
+
s.discriminatedUnion(
|
|
926
932
|
"type", // the key of the "discriminator"
|
|
927
933
|
s.object({
|
|
928
934
|
type: s.literal("blogPage"), // <- each type must have a UNIQUE value
|
|
@@ -937,16 +943,23 @@ s.union(
|
|
|
937
943
|
); // <- Schema<{ type: "blogPage", author: string } | { type: "productPage", sku: number }>
|
|
938
944
|
```
|
|
939
945
|
|
|
940
|
-
##
|
|
946
|
+
## Enum
|
|
941
947
|
|
|
942
|
-
|
|
948
|
+
Use `s.enum` for a fixed set of strings. It gives you a type-safe way to describe the valid values an editor can choose from, and it presents as a dropdown in Val Studio.
|
|
943
949
|
|
|
944
950
|
```ts
|
|
945
|
-
s.
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
951
|
+
s.enum("one", "two"); // <- Schema<"one" | "two">
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
### `s.union` is deprecated
|
|
955
|
+
|
|
956
|
+
`s.union` did both of these jobs, deciding which one you meant from its first
|
|
957
|
+
argument. It still works, and produces exactly the schemas above, but name the
|
|
958
|
+
one you mean instead:
|
|
959
|
+
|
|
960
|
+
```ts
|
|
961
|
+
s.union(s.literal("one"), s.literal("two")); // -> s.enum("one", "two")
|
|
962
|
+
s.union("type", pageA, pageB); // -> s.discriminatedUnion("type", pageA, pageB)
|
|
950
963
|
```
|
|
951
964
|
|
|
952
965
|
## KeyOf
|
|
@@ -1325,6 +1338,27 @@ s.string().validate((val) => {
|
|
|
1325
1338
|
});
|
|
1326
1339
|
```
|
|
1327
1340
|
|
|
1341
|
+
`.validate(...)` and `.nullable()` can be written in either order: the validator
|
|
1342
|
+
is carried through the copy `.nullable()` makes. On a nullable schema the value
|
|
1343
|
+
reaching the validator can be `null`, and it is handed over rather than skipped —
|
|
1344
|
+
so a validator declared **before** the `.nullable()` has to guard for it, since
|
|
1345
|
+
its argument is still typed as non-null there:
|
|
1346
|
+
|
|
1347
|
+
```ts
|
|
1348
|
+
s.string()
|
|
1349
|
+
.validate((val) => (val !== null && val.length > 80 ? "Too long" : false))
|
|
1350
|
+
.nullable();
|
|
1351
|
+
|
|
1352
|
+
// Declared after, and the argument is typed `string | null`:
|
|
1353
|
+
s.string()
|
|
1354
|
+
.nullable()
|
|
1355
|
+
.validate((val) => (val !== null && val.length > 80 ? "Too long" : false));
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
Not every modifier is order-free, though: a record's `.jsonValues()` changes the
|
|
1359
|
+
source shape, so it must come **before** `.validate(...)` and `.preview(...)`,
|
|
1360
|
+
and throws with that message if it does not.
|
|
1361
|
+
|
|
1328
1362
|
## Get in touch
|
|
1329
1363
|
|
|
1330
1364
|
Join us on [discord](https://discord.gg/cZzqPvaX8k) to get help or give us feedback.
|
|
@@ -7,7 +7,7 @@ var routeFromVal = require('../../dist/routeFromVal-d53d5ffb.cjs.dev.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var ValOverlayContext = require('../../dist/ValOverlayContext-
|
|
10
|
+
var ValOverlayContext = require('../../dist/ValOverlayContext-98d33d86.cjs.dev.js');
|
|
11
11
|
require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
12
12
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
13
13
|
require('../../dist/objectSpread2-58024783.cjs.dev.js');
|
|
@@ -7,7 +7,7 @@ var routeFromVal = require('../../dist/routeFromVal-e0995830.cjs.prod.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var ValOverlayContext = require('../../dist/ValOverlayContext-
|
|
10
|
+
var ValOverlayContext = require('../../dist/ValOverlayContext-9c4ae06d.cjs.prod.js');
|
|
11
11
|
require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
12
12
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
13
13
|
require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
|
|
@@ -3,7 +3,7 @@ import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema
|
|
|
3
3
|
import { Internal } from '@valbuild/core';
|
|
4
4
|
import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { useValOverlayContext } from '../../dist/ValOverlayContext-
|
|
6
|
+
import { useValOverlayContext } from '../../dist/ValOverlayContext-398baef3.esm.js';
|
|
7
7
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
8
8
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
9
9
|
import '../../dist/objectSpread2-60d1bd93.esm.js';
|
|
@@ -11,7 +11,7 @@ var ui = require('@valbuild/ui');
|
|
|
11
11
|
var navigation = require('next/navigation');
|
|
12
12
|
var Script = require('next/script');
|
|
13
13
|
var React = require('react');
|
|
14
|
-
var ValOverlayContext = require('./ValOverlayContext-
|
|
14
|
+
var ValOverlayContext = require('./ValOverlayContext-98d33d86.cjs.dev.js');
|
|
15
15
|
var stega = require('@valbuild/react/stega');
|
|
16
16
|
var fallbackColors = require('./fallbackColors-080c1bbc.cjs.dev.js');
|
|
17
17
|
var client = require('@valbuild/shared/client');
|
|
@@ -7,7 +7,7 @@ import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID } from '@valbuild/ui';
|
|
|
7
7
|
import { useRouter, usePathname } from 'next/navigation';
|
|
8
8
|
import Script from 'next/script';
|
|
9
9
|
import React, { useEffect } from 'react';
|
|
10
|
-
import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-
|
|
10
|
+
import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-398baef3.esm.js';
|
|
11
11
|
import { SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
|
|
12
12
|
import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-149dfbc9.esm.js';
|
|
13
13
|
import { VAL_THEME_SESSION_STORAGE_KEY, isValCanvasFrame } from '@valbuild/shared/client';
|
|
@@ -11,7 +11,7 @@ var ui = require('@valbuild/ui');
|
|
|
11
11
|
var navigation = require('next/navigation');
|
|
12
12
|
var Script = require('next/script');
|
|
13
13
|
var React = require('react');
|
|
14
|
-
var ValOverlayContext = require('./ValOverlayContext-
|
|
14
|
+
var ValOverlayContext = require('./ValOverlayContext-9c4ae06d.cjs.prod.js');
|
|
15
15
|
var stega = require('@valbuild/react/stega');
|
|
16
16
|
var fallbackColors = require('./fallbackColors-e1d73b36.cjs.prod.js');
|
|
17
17
|
var client = require('@valbuild/shared/client');
|
|
@@ -24,20 +24,22 @@ function _createClass(e, r, t) {
|
|
|
24
24
|
|
|
25
25
|
var LOAD_TIMEOUT_MS = 10000;
|
|
26
26
|
var ValExternalStore = /*#__PURE__*/function () {
|
|
27
|
-
// Path-keyed cache of every source seen via update(). The single source of
|
|
28
|
-
// truth: load state and snapshots are both derived from this, so data can be
|
|
29
|
-
// queried for any combination of paths even before a subscriber registers.
|
|
30
|
-
|
|
31
|
-
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
32
|
-
// Built lazily from loadedSources in get() and invalidated in update().
|
|
33
|
-
|
|
34
|
-
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
35
|
-
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
36
|
-
// leak) a subscriberId.
|
|
37
|
-
|
|
38
27
|
function ValExternalStore() {
|
|
39
28
|
var _this = this;
|
|
40
29
|
_classCallCheck(this, ValExternalStore);
|
|
30
|
+
_defineProperty(this, "listeners", void 0);
|
|
31
|
+
_defineProperty(this, "loadPromises", void 0);
|
|
32
|
+
// Path-keyed cache of every source seen via update(). The single source of
|
|
33
|
+
// truth: load state and snapshots are both derived from this, so data can be
|
|
34
|
+
// queried for any combination of paths even before a subscriber registers.
|
|
35
|
+
_defineProperty(this, "loadedSources", void 0);
|
|
36
|
+
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
37
|
+
// Built lazily from loadedSources in get() and invalidated in update().
|
|
38
|
+
_defineProperty(this, "snapshots", void 0);
|
|
39
|
+
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
40
|
+
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
41
|
+
// leak) a subscriberId.
|
|
42
|
+
_defineProperty(this, "loadListeners", void 0);
|
|
41
43
|
_defineProperty(this, "subscribe", function (paths) {
|
|
42
44
|
return function (listener) {
|
|
43
45
|
var subscriberId = createSubscriberId(paths);
|
package/dist/{ValOverlayContext-5bd7628b.cjs.dev.js → ValOverlayContext-98d33d86.cjs.dev.js}
RENAMED
|
@@ -32,20 +32,22 @@ function _createClass(e, r, t) {
|
|
|
32
32
|
|
|
33
33
|
var LOAD_TIMEOUT_MS = 10000;
|
|
34
34
|
var ValExternalStore = /*#__PURE__*/function () {
|
|
35
|
-
// Path-keyed cache of every source seen via update(). The single source of
|
|
36
|
-
// truth: load state and snapshots are both derived from this, so data can be
|
|
37
|
-
// queried for any combination of paths even before a subscriber registers.
|
|
38
|
-
|
|
39
|
-
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
40
|
-
// Built lazily from loadedSources in get() and invalidated in update().
|
|
41
|
-
|
|
42
|
-
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
43
|
-
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
44
|
-
// leak) a subscriberId.
|
|
45
|
-
|
|
46
35
|
function ValExternalStore() {
|
|
47
36
|
var _this = this;
|
|
48
37
|
_classCallCheck(this, ValExternalStore);
|
|
38
|
+
defineProperty._defineProperty(this, "listeners", void 0);
|
|
39
|
+
defineProperty._defineProperty(this, "loadPromises", void 0);
|
|
40
|
+
// Path-keyed cache of every source seen via update(). The single source of
|
|
41
|
+
// truth: load state and snapshots are both derived from this, so data can be
|
|
42
|
+
// queried for any combination of paths even before a subscriber registers.
|
|
43
|
+
defineProperty._defineProperty(this, "loadedSources", void 0);
|
|
44
|
+
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
45
|
+
// Built lazily from loadedSources in get() and invalidated in update().
|
|
46
|
+
defineProperty._defineProperty(this, "snapshots", void 0);
|
|
47
|
+
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
48
|
+
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
49
|
+
// leak) a subscriberId.
|
|
50
|
+
defineProperty._defineProperty(this, "loadListeners", void 0);
|
|
49
51
|
defineProperty._defineProperty(this, "subscribe", function (paths) {
|
|
50
52
|
return function (listener) {
|
|
51
53
|
var subscriberId = createSubscriberId(paths);
|
package/dist/{ValOverlayContext-d690744f.cjs.prod.js → ValOverlayContext-9c4ae06d.cjs.prod.js}
RENAMED
|
@@ -32,20 +32,22 @@ function _createClass(e, r, t) {
|
|
|
32
32
|
|
|
33
33
|
var LOAD_TIMEOUT_MS = 10000;
|
|
34
34
|
var ValExternalStore = /*#__PURE__*/function () {
|
|
35
|
-
// Path-keyed cache of every source seen via update(). The single source of
|
|
36
|
-
// truth: load state and snapshots are both derived from this, so data can be
|
|
37
|
-
// queried for any combination of paths even before a subscriber registers.
|
|
38
|
-
|
|
39
|
-
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
40
|
-
// Built lazily from loadedSources in get() and invalidated in update().
|
|
41
|
-
|
|
42
|
-
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
43
|
-
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
44
|
-
// leak) a subscriberId.
|
|
45
|
-
|
|
46
35
|
function ValExternalStore() {
|
|
47
36
|
var _this = this;
|
|
48
37
|
_classCallCheck(this, ValExternalStore);
|
|
38
|
+
defineProperty._defineProperty(this, "listeners", void 0);
|
|
39
|
+
defineProperty._defineProperty(this, "loadPromises", void 0);
|
|
40
|
+
// Path-keyed cache of every source seen via update(). The single source of
|
|
41
|
+
// truth: load state and snapshots are both derived from this, so data can be
|
|
42
|
+
// queried for any combination of paths even before a subscriber registers.
|
|
43
|
+
defineProperty._defineProperty(this, "loadedSources", void 0);
|
|
44
|
+
// Reference-stable per-subscriberId snapshot cache for useSyncExternalStore.
|
|
45
|
+
// Built lazily from loadedSources in get() and invalidated in update().
|
|
46
|
+
defineProperty._defineProperty(this, "snapshots", void 0);
|
|
47
|
+
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
48
|
+
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
49
|
+
// leak) a subscriberId.
|
|
50
|
+
defineProperty._defineProperty(this, "loadListeners", void 0);
|
|
49
51
|
defineProperty._defineProperty(this, "subscribe", function (paths) {
|
|
50
52
|
return function (listener) {
|
|
51
53
|
var subscriberId = createSubscriberId(paths);
|
|
@@ -26,6 +26,10 @@ export declare const initVal: (config?: ValConfig) => InitVal & {
|
|
|
26
26
|
* cache for every route it covers, for all visitors. It is NOT needed for
|
|
27
27
|
* the `suspend` prop on ValProvider (which detects the cookie client-side)
|
|
28
28
|
* — reserve it for advanced server-side conditionals.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // In a Server Component, a Server Action or a Route Handler:
|
|
32
|
+
* const enabled = await isValEnabled();
|
|
29
33
|
*/
|
|
30
34
|
isValEnabled: typeof isValEnabled;
|
|
31
35
|
val: ValConstructor & {
|
|
@@ -40,10 +44,22 @@ export declare const initVal: (config?: ValConfig) => InitVal & {
|
|
|
40
44
|
*
|
|
41
45
|
* This method is primarily intended for tooling and other advanced use cases
|
|
42
46
|
* outside of the actual application.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import pageVal from "./page.val";
|
|
50
|
+
* const page = val.unstable_getUnpatchedUnencodedVal(pageVal);
|
|
43
51
|
*/
|
|
44
52
|
unstable_getUnpatchedUnencodedVal: typeof getUnpatchedUnencodedVal;
|
|
45
53
|
/**
|
|
46
54
|
* Convert any object that is encoded with Val stega encoding back to the original values
|
|
55
|
+
*
|
|
56
|
+
* Use it wherever an encoded string would break something: a `key`, a
|
|
57
|
+
* comparison, a URL, anything sent to an API.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* import pageVal from "./page.val";
|
|
61
|
+
* const page = useVal(pageVal);
|
|
62
|
+
* const slug = val.raw(page.slug);
|
|
47
63
|
*/
|
|
48
64
|
raw: typeof raw;
|
|
49
65
|
/**
|
|
@@ -52,12 +68,30 @@ export declare const initVal: (config?: ValConfig) => InitVal & {
|
|
|
52
68
|
* This is typically used to manually set the data-val-path attribute for visual editing on any element.
|
|
53
69
|
*
|
|
54
70
|
* @example
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
71
|
+
* import pageVal from "./page.val";
|
|
72
|
+
* function PageLink() {
|
|
73
|
+
* const page = useVal(pageVal);
|
|
74
|
+
* return (
|
|
75
|
+
* <a href={page.url.href} {...val.attrs(page)}>
|
|
76
|
+
* {page.url.label}
|
|
77
|
+
* </a>
|
|
78
|
+
* );
|
|
79
|
+
* }
|
|
59
80
|
*/
|
|
60
81
|
attrs: typeof attrs;
|
|
82
|
+
/**
|
|
83
|
+
* The Val paths encoded into a single stega encoded string, or `undefined`
|
|
84
|
+
* when there are none.
|
|
85
|
+
*
|
|
86
|
+
* `val.attrs` is what an element usually wants; this is the lower-level
|
|
87
|
+
* read, for when you need the paths themselves. Unstable: the shape of a
|
|
88
|
+
* path is not part of the public API yet.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* import pageVal from "./page.val";
|
|
92
|
+
* const page = useVal(pageVal);
|
|
93
|
+
* const paths = val.unstable_decodeValPathsOfString(page.title);
|
|
94
|
+
*/
|
|
61
95
|
unstable_decodeValPathsOfString: typeof decodeValPathsOfString;
|
|
62
96
|
};
|
|
63
97
|
/**
|
|
@@ -73,6 +107,21 @@ export declare const initVal: (config?: ValConfig) => InitVal & {
|
|
|
73
107
|
* });
|
|
74
108
|
*/
|
|
75
109
|
nextAppRouter: ValRouter;
|
|
110
|
+
/**
|
|
111
|
+
* A router for pages that are NOT in this application: the keys of the record
|
|
112
|
+
* are whole URLs, not route paths of your site.
|
|
113
|
+
*
|
|
114
|
+
* It is what `s.route()` links to when the destination is somewhere else -
|
|
115
|
+
* a campaign site, a docs host, a social profile.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const links = s.record(s.object({ title: s.string() }));
|
|
119
|
+
* export default c.define(
|
|
120
|
+
* "/content/external.val.ts",
|
|
121
|
+
* links.router(externalPageRouter),
|
|
122
|
+
* { "https://val.build": { title: "Val" } },
|
|
123
|
+
* );
|
|
124
|
+
*/
|
|
76
125
|
externalPageRouter: ValRouter;
|
|
77
126
|
};
|
|
78
127
|
export {};
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-294e5b53.cjs.dev.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-15707a75.cjs.dev.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
17
17
|
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
18
18
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
@@ -12,7 +12,7 @@ var NextImage = require('next/image');
|
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-ab8a96fd.cjs.prod.js');
|
|
14
14
|
var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
|
|
15
|
-
var version = require('./version-
|
|
15
|
+
var version = require('./version-9b3eb9b7.cjs.prod.js');
|
|
16
16
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
17
17
|
require('./defineProperty-8951f469.cjs.prod.js');
|
|
18
18
|
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
@@ -11,7 +11,7 @@ import NextImage from 'next/image';
|
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
export { ValApp } from './ValApp-3a70afe1.esm.js';
|
|
13
13
|
export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
|
|
14
|
-
import { V as VERSION } from './version-
|
|
14
|
+
import { V as VERSION } from './version-dc02550b.esm.js';
|
|
15
15
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
|
|
16
16
|
import './defineProperty-cca5affa.esm.js';
|
|
17
17
|
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.127.0",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
|
-
"@valbuild/core": "0.
|
|
51
|
-
"@valbuild/mcp": "0.
|
|
52
|
-
"@valbuild/
|
|
53
|
-
"@valbuild/
|
|
54
|
-
"@valbuild/server": "0.
|
|
55
|
-
"@valbuild/
|
|
56
|
-
"@valbuild/
|
|
50
|
+
"@valbuild/core": "0.127.0",
|
|
51
|
+
"@valbuild/mcp": "0.127.0",
|
|
52
|
+
"@valbuild/react": "0.127.0",
|
|
53
|
+
"@valbuild/language-server": "0.127.0",
|
|
54
|
+
"@valbuild/server": "0.127.0",
|
|
55
|
+
"@valbuild/ui": "0.127.0",
|
|
56
|
+
"@valbuild/shared": "0.127.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/react": "^16.3.3",
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-15707a75.cjs.dev.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
17
17
|
require('../../dist/slicedToArray-44036a76.cjs.dev.js');
|
|
@@ -11,7 +11,7 @@ var stega = require('@valbuild/react/stega');
|
|
|
11
11
|
var core = require('@valbuild/core');
|
|
12
12
|
var internal = require('@valbuild/shared/internal');
|
|
13
13
|
var server = require('@valbuild/server');
|
|
14
|
-
var version = require('../../dist/version-
|
|
14
|
+
var version = require('../../dist/version-9b3eb9b7.cjs.prod.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
17
17
|
require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
|
|
@@ -7,7 +7,7 @@ import { SET_RSC, stegaEncode, SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/
|
|
|
7
7
|
import { Internal } from '@valbuild/core';
|
|
8
8
|
import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
9
9
|
import { createValServer } from '@valbuild/server';
|
|
10
|
-
import { V as VERSION } from '../../dist/version-
|
|
10
|
+
import { V as VERSION } from '../../dist/version-dc02550b.esm.js';
|
|
11
11
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
12
12
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
13
13
|
import '../../dist/slicedToArray-aa291011.esm.js';
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-58024783.cjs.dev.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-15707a75.cjs.dev.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
15
15
|
require('../../dist/defineProperty-f90345d7.cjs.dev.js');
|
|
@@ -9,7 +9,7 @@ var objectSpread2 = require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
|
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var server = require('@valbuild/server');
|
|
11
11
|
var server$1 = require('next/server');
|
|
12
|
-
var version = require('../../dist/version-
|
|
12
|
+
var version = require('../../dist/version-9b3eb9b7.cjs.prod.js');
|
|
13
13
|
var mcp = require('@valbuild/mcp');
|
|
14
14
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
15
15
|
require('../../dist/defineProperty-8951f469.cjs.prod.js');
|
|
@@ -5,7 +5,7 @@ import { _ as _objectSpread2 } from '../../dist/objectSpread2-60d1bd93.esm.js';
|
|
|
5
5
|
import { Internal } from '@valbuild/core';
|
|
6
6
|
import { createValApiRouter, createValServer } from '@valbuild/server';
|
|
7
7
|
import { NextResponse } from 'next/server';
|
|
8
|
-
import { V as VERSION } from '../../dist/version-
|
|
8
|
+
import { V as VERSION } from '../../dist/version-dc02550b.esm.js';
|
|
9
9
|
import { initValMcp as initValMcp$1 } from '@valbuild/mcp';
|
|
10
10
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
11
11
|
import '../../dist/defineProperty-cca5affa.esm.js';
|