@valbuild/next 0.17.0 → 0.19.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/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 +2 -2
- package/dist/declarations/src/index.d.ts +1 -1
- package/package.json +4 -4
- package/server/dist/valbuild-next-server.cjs.dev.js +4 -4
- package/server/dist/valbuild-next-server.cjs.prod.js +4 -4
- package/server/dist/valbuild-next-server.esm.js +5 -5
- package/src/client/useVal.ts +6 -2
- package/src/index.ts +1 -9
- package/src/server/fetchVal.ts +5 -5
- package/tsconfig.json +2 -1
|
@@ -73,7 +73,7 @@ function useVal(selector) {
|
|
|
73
73
|
react$1.useEffect(function () {
|
|
74
74
|
setEnabled(document.cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true")));
|
|
75
75
|
}, []);
|
|
76
|
-
return stega.
|
|
76
|
+
return stega.stegaEncode(selector, {
|
|
77
77
|
disabled: !enabled,
|
|
78
78
|
getModule: function getModule(moduleId) {
|
|
79
79
|
if (moduleMap) {
|
|
@@ -73,7 +73,7 @@ function useVal(selector) {
|
|
|
73
73
|
react$1.useEffect(function () {
|
|
74
74
|
setEnabled(document.cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true")));
|
|
75
75
|
}, []);
|
|
76
|
-
return stega.
|
|
76
|
+
return stega.stegaEncode(selector, {
|
|
77
77
|
disabled: !enabled,
|
|
78
78
|
getModule: function getModule(moduleId) {
|
|
79
79
|
if (moduleMap) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Internal } from '@valbuild/core';
|
|
2
|
-
import { getModuleIds,
|
|
2
|
+
import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
|
|
3
3
|
import { useValStore } from '@valbuild/react';
|
|
4
4
|
import { useSyncExternalStore, useState, useEffect } from 'react';
|
|
5
5
|
|
|
@@ -69,7 +69,7 @@ function useVal(selector) {
|
|
|
69
69
|
useEffect(function () {
|
|
70
70
|
setEnabled(document.cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true")));
|
|
71
71
|
}, []);
|
|
72
|
-
return
|
|
72
|
+
return stegaEncode(selector, {
|
|
73
73
|
disabled: !enabled,
|
|
74
74
|
getModule: function getModule(moduleId) {
|
|
75
75
|
if (moduleMap) {
|
|
@@ -2,7 +2,7 @@ export { Schema, type SerializedSchema } from "@valbuild/core";
|
|
|
2
2
|
export type { SourceObject, SourcePrimitive, Source } from "@valbuild/core";
|
|
3
3
|
export type { ValModule, SerializedModule } from "@valbuild/core";
|
|
4
4
|
export type { FileSource } from "@valbuild/core";
|
|
5
|
-
export type { RichTextSource, RichText
|
|
5
|
+
export type { RichTextSource, RichText } from "@valbuild/core";
|
|
6
6
|
export { type Val, type SerializedVal, type ModuleId, type ModulePath, type SourcePath, type JsonOfSource, } from "@valbuild/core";
|
|
7
7
|
export type { Json, JsonPrimitive } from "@valbuild/core";
|
|
8
8
|
export type { ValidationErrors, ValidationError } from "@valbuild/core";
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"next",
|
|
9
9
|
"react"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.19.0",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"test": "jest"
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"exports": true
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@valbuild/core": "~0.
|
|
44
|
-
"@valbuild/react": "~0.
|
|
45
|
-
"@valbuild/server": "~0.
|
|
43
|
+
"@valbuild/core": "~0.19.0",
|
|
44
|
+
"@valbuild/react": "~0.19.0",
|
|
45
|
+
"@valbuild/server": "~0.19.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"next": ">=13.4.0",
|
|
@@ -376,7 +376,7 @@ function fetchVal(selector) {
|
|
|
376
376
|
}).then(function (res) {
|
|
377
377
|
if (fp.result.isOk(res)) {
|
|
378
378
|
var modules = res.value.modules;
|
|
379
|
-
return stega.
|
|
379
|
+
return stega.stegaEncode(selector, {
|
|
380
380
|
getModule: function getModule(moduleId) {
|
|
381
381
|
var module = modules[moduleId];
|
|
382
382
|
if (module) {
|
|
@@ -387,7 +387,7 @@ function fetchVal(selector) {
|
|
|
387
387
|
} else {
|
|
388
388
|
console.error("Val: could not fetch modules", res.error);
|
|
389
389
|
}
|
|
390
|
-
return stega.
|
|
390
|
+
return stega.stegaEncode(selector, {});
|
|
391
391
|
})["catch"](function (err) {
|
|
392
392
|
console.error("Val: failed while checking modules", err);
|
|
393
393
|
return selector;
|
|
@@ -395,7 +395,7 @@ function fetchVal(selector) {
|
|
|
395
395
|
}
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
|
-
return stega.
|
|
398
|
+
return stega.stegaEncode(selector, {
|
|
399
399
|
disabled: !enabled
|
|
400
400
|
});
|
|
401
401
|
}
|
|
@@ -470,7 +470,7 @@ function safeDraftModeEnabled() {
|
|
|
470
470
|
try {
|
|
471
471
|
return headers.draftMode().isEnabled;
|
|
472
472
|
} catch (err) {
|
|
473
|
-
console.error("Val: could read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
473
|
+
console.error("Val: could not read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
474
474
|
return false;
|
|
475
475
|
}
|
|
476
476
|
}
|
|
@@ -376,7 +376,7 @@ function fetchVal(selector) {
|
|
|
376
376
|
}).then(function (res) {
|
|
377
377
|
if (fp.result.isOk(res)) {
|
|
378
378
|
var modules = res.value.modules;
|
|
379
|
-
return stega.
|
|
379
|
+
return stega.stegaEncode(selector, {
|
|
380
380
|
getModule: function getModule(moduleId) {
|
|
381
381
|
var module = modules[moduleId];
|
|
382
382
|
if (module) {
|
|
@@ -387,7 +387,7 @@ function fetchVal(selector) {
|
|
|
387
387
|
} else {
|
|
388
388
|
console.error("Val: could not fetch modules", res.error);
|
|
389
389
|
}
|
|
390
|
-
return stega.
|
|
390
|
+
return stega.stegaEncode(selector, {});
|
|
391
391
|
})["catch"](function (err) {
|
|
392
392
|
console.error("Val: failed while checking modules", err);
|
|
393
393
|
return selector;
|
|
@@ -395,7 +395,7 @@ function fetchVal(selector) {
|
|
|
395
395
|
}
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
|
-
return stega.
|
|
398
|
+
return stega.stegaEncode(selector, {
|
|
399
399
|
disabled: !enabled
|
|
400
400
|
});
|
|
401
401
|
}
|
|
@@ -470,7 +470,7 @@ function safeDraftModeEnabled() {
|
|
|
470
470
|
try {
|
|
471
471
|
return headers.draftMode().isEnabled;
|
|
472
472
|
} catch (err) {
|
|
473
|
-
console.error("Val: could read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
473
|
+
console.error("Val: could not read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
474
474
|
return false;
|
|
475
475
|
}
|
|
476
476
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stegaEncode } from '@valbuild/react/stega';
|
|
2
2
|
import { ValApi, Internal } from '@valbuild/core';
|
|
3
3
|
import { result } from '@valbuild/core/fp';
|
|
4
4
|
import { draftMode } from 'next/headers';
|
|
@@ -354,7 +354,7 @@ function fetchVal(selector) {
|
|
|
354
354
|
}).then(function (res) {
|
|
355
355
|
if (result.isOk(res)) {
|
|
356
356
|
var modules = res.value.modules;
|
|
357
|
-
return
|
|
357
|
+
return stegaEncode(selector, {
|
|
358
358
|
getModule: function getModule(moduleId) {
|
|
359
359
|
var module = modules[moduleId];
|
|
360
360
|
if (module) {
|
|
@@ -365,7 +365,7 @@ function fetchVal(selector) {
|
|
|
365
365
|
} else {
|
|
366
366
|
console.error("Val: could not fetch modules", res.error);
|
|
367
367
|
}
|
|
368
|
-
return
|
|
368
|
+
return stegaEncode(selector, {});
|
|
369
369
|
})["catch"](function (err) {
|
|
370
370
|
console.error("Val: failed while checking modules", err);
|
|
371
371
|
return selector;
|
|
@@ -373,7 +373,7 @@ function fetchVal(selector) {
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
|
-
return
|
|
376
|
+
return stegaEncode(selector, {
|
|
377
377
|
disabled: !enabled
|
|
378
378
|
});
|
|
379
379
|
}
|
|
@@ -448,7 +448,7 @@ function safeDraftModeEnabled() {
|
|
|
448
448
|
try {
|
|
449
449
|
return draftMode().isEnabled;
|
|
450
450
|
} catch (err) {
|
|
451
|
-
console.error("Val: could read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
451
|
+
console.error("Val: could not read draft mode! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
452
452
|
return false;
|
|
453
453
|
}
|
|
454
454
|
}
|
package/src/client/useVal.ts
CHANGED
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
SelectorOf,
|
|
6
6
|
SelectorSource,
|
|
7
7
|
} from "@valbuild/core";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
StegaOfSource,
|
|
10
|
+
getModuleIds,
|
|
11
|
+
stegaEncode,
|
|
12
|
+
} from "@valbuild/react/stega";
|
|
9
13
|
import { useValStore } from "@valbuild/react";
|
|
10
14
|
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
11
15
|
|
|
@@ -25,7 +29,7 @@ export function useVal<T extends SelectorSource>(
|
|
|
25
29
|
document.cookie.includes(`${Internal.VAL_ENABLE_COOKIE_NAME}=true`)
|
|
26
30
|
);
|
|
27
31
|
}, []);
|
|
28
|
-
return
|
|
32
|
+
return stegaEncode(selector, {
|
|
29
33
|
disabled: !enabled,
|
|
30
34
|
getModule: (moduleId) => {
|
|
31
35
|
if (moduleMap) {
|
package/src/index.ts
CHANGED
|
@@ -3,15 +3,7 @@ export { Schema, type SerializedSchema } from "@valbuild/core";
|
|
|
3
3
|
export type { SourceObject, SourcePrimitive, Source } from "@valbuild/core";
|
|
4
4
|
export type { ValModule, SerializedModule } from "@valbuild/core";
|
|
5
5
|
export type { FileSource } from "@valbuild/core";
|
|
6
|
-
export type {
|
|
7
|
-
RichTextSource,
|
|
8
|
-
RichText,
|
|
9
|
-
TextNode,
|
|
10
|
-
ParagraphNode,
|
|
11
|
-
HeadingNode,
|
|
12
|
-
ListItemNode,
|
|
13
|
-
ListNode,
|
|
14
|
-
} from "@valbuild/core";
|
|
6
|
+
export type { RichTextSource, RichText } from "@valbuild/core";
|
|
15
7
|
export {
|
|
16
8
|
type Val,
|
|
17
9
|
type SerializedVal,
|
package/src/server/fetchVal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stegaEncode, type StegaOfSource } from "@valbuild/react/stega";
|
|
2
2
|
import {
|
|
3
3
|
SelectorSource,
|
|
4
4
|
SelectorOf,
|
|
@@ -34,7 +34,7 @@ export function fetchVal<T extends SelectorSource>(
|
|
|
34
34
|
.then((res) => {
|
|
35
35
|
if (result.isOk(res)) {
|
|
36
36
|
const { modules } = res.value;
|
|
37
|
-
return
|
|
37
|
+
return stegaEncode(selector, {
|
|
38
38
|
getModule: (moduleId) => {
|
|
39
39
|
const module = modules[moduleId as ModuleId];
|
|
40
40
|
if (module) {
|
|
@@ -45,7 +45,7 @@ export function fetchVal<T extends SelectorSource>(
|
|
|
45
45
|
} else {
|
|
46
46
|
console.error("Val: could not fetch modules", res.error);
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return stegaEncode(selector, {});
|
|
49
49
|
})
|
|
50
50
|
.catch((err) => {
|
|
51
51
|
console.error("Val: failed while checking modules", err);
|
|
@@ -56,7 +56,7 @@ export function fetchVal<T extends SelectorSource>(
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return stegaEncode(selector, {
|
|
60
60
|
disabled: !enabled,
|
|
61
61
|
});
|
|
62
62
|
}
|
|
@@ -115,7 +115,7 @@ function safeDraftModeEnabled() {
|
|
|
115
115
|
return draftMode().isEnabled;
|
|
116
116
|
} catch (err) {
|
|
117
117
|
console.error(
|
|
118
|
-
"Val: could read draft mode! fetchVal can only be used server-side. Use useVal on clients.",
|
|
118
|
+
"Val: could not read draft mode! fetchVal can only be used server-side. Use useVal on clients.",
|
|
119
119
|
err
|
|
120
120
|
);
|
|
121
121
|
return false;
|