@valbuild/next 0.63.5 → 0.65.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 -97
- package/client/dist/valbuild-next-client.cjs.d.ts +2 -2
- package/client/dist/valbuild-next-client.cjs.dev.js +19 -31
- package/client/dist/valbuild-next-client.cjs.prod.js +19 -31
- package/client/dist/valbuild-next-client.esm.js +19 -31
- package/dist/ValApp-50ec1e10.esm.js +53 -0
- package/dist/ValApp-9eefeefd.cjs.js +7 -0
- package/dist/ValApp-9eefeefd.cjs.prod.js +61 -0
- package/dist/ValApp-de156df4.cjs.dev.js +61 -0
- package/dist/ValNextProvider-0b711372.esm.js +430 -0
- package/dist/ValNextProvider-313af7bb.cjs.js +7 -0
- package/dist/ValNextProvider-313af7bb.cjs.prod.js +439 -0
- package/dist/ValNextProvider-abfbfdb5.cjs.dev.js +439 -0
- package/dist/{ValContext-06fe6f7e.cjs.dev.js → ValOverlayContext-55dae3ea.cjs.dev.js} +62 -71
- package/dist/ValOverlayContext-811e9be9.cjs.js +7 -0
- package/dist/{ValContext-12a3eca2.cjs.prod.js → ValOverlayContext-811e9be9.cjs.prod.js} +62 -71
- package/dist/{ValContext-8a8d9183.esm.js → ValOverlayContext-a2fdbce0.esm.js} +59 -69
- package/dist/{asyncToGenerator-0859ab5c.esm.js → asyncToGenerator-5f8c02f3.esm.js} +19 -24
- package/dist/{asyncToGenerator-ba66657c.cjs.dev.js → asyncToGenerator-67a5ff70.cjs.prod.js} +19 -24
- package/dist/{asyncToGenerator-3551d940.cjs.prod.js → asyncToGenerator-6ba61221.cjs.dev.js} +19 -24
- package/dist/declarations/src/ValApp.d.ts +1 -1
- package/dist/declarations/src/ValImage.d.ts +0 -1
- package/dist/declarations/src/ValProvider.d.ts +3 -5
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +38 -2
- package/dist/declarations/src/rsc/initValRsc.d.ts +5 -5
- package/dist/declarations/src/server/initValServer.d.ts +1 -1
- package/dist/{objectSpread2-bb9509e8.cjs.dev.js → objectSpread2-3c87fb4f.cjs.prod.js} +12 -18
- package/dist/{objectSpread2-24e737a6.cjs.prod.js → objectSpread2-792eb2c2.cjs.dev.js} +12 -18
- package/dist/{objectSpread2-439bdcdd.esm.js → objectSpread2-c1340c1c.esm.js} +12 -18
- package/dist/{slicedToArray-c03b6356.cjs.dev.js → slicedToArray-44036a76.cjs.dev.js} +5 -5
- package/dist/{slicedToArray-1ff80c5e.esm.js → slicedToArray-aa291011.esm.js} +5 -5
- package/dist/{slicedToArray-1d91551a.cjs.prod.js → slicedToArray-ce613de6.cjs.prod.js} +5 -5
- package/dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js +17 -0
- package/dist/unsupportedIterableToArray-5baabfdc.esm.js +15 -0
- package/dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js +17 -0
- package/dist/valbuild-next.cjs.d.ts +2 -2
- package/dist/valbuild-next.cjs.dev.js +23 -28
- package/dist/valbuild-next.cjs.prod.js +23 -28
- package/dist/valbuild-next.esm.js +23 -28
- package/package.json +6 -5
- package/rsc/dist/valbuild-next-rsc.cjs.d.ts +2 -2
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +131 -46
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +131 -43
- package/rsc/dist/valbuild-next-rsc.esm.js +133 -48
- package/server/dist/valbuild-next-server.cjs.d.ts +2 -2
- package/server/dist/valbuild-next-server.cjs.dev.js +8 -8
- package/server/dist/valbuild-next-server.cjs.prod.js +8 -8
- package/server/dist/valbuild-next-server.esm.js +8 -8
- package/client/dist/valbuild-next-client.cjs.d.ts.map +0 -1
- package/dist/ValApp-0ec0c7f3.cjs.js +0 -7
- package/dist/ValApp-0ec0c7f3.cjs.prod.js +0 -34
- package/dist/ValApp-61103149.esm.js +0 -26
- package/dist/ValApp-aff60572.cjs.dev.js +0 -34
- package/dist/ValContext-12a3eca2.cjs.js +0 -7
- package/dist/ValNextProvider-5226c452.cjs.js +0 -7
- package/dist/ValNextProvider-5226c452.cjs.prod.js +0 -101
- package/dist/ValNextProvider-ccbea1bd.cjs.dev.js +0 -101
- package/dist/ValNextProvider-d94cd904.esm.js +0 -92
- package/dist/unsupportedIterableToArray-51bb61c2.esm.js +0 -16
- package/dist/unsupportedIterableToArray-9e97e24a.cjs.dev.js +0 -18
- package/dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js +0 -18
- package/dist/valbuild-next.cjs.d.ts.map +0 -1
- package/rsc/dist/valbuild-next-rsc.cjs.d.ts.map +0 -1
- package/server/dist/valbuild-next-server.cjs.d.ts.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { _ as _objectSpread2 } from './objectSpread2-
|
|
1
|
+
import { _ as _objectSpread2 } from './objectSpread2-c1340c1c.esm.js';
|
|
2
2
|
import { initVal as initVal$1, Internal as Internal$1 } from '@valbuild/core';
|
|
3
3
|
import * as core from '@valbuild/core';
|
|
4
4
|
export { core as expr };
|
|
5
5
|
export { FILE_REF_PROP, GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
|
|
6
6
|
import { stegaClean, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
|
|
7
7
|
export { ValRichText } from '@valbuild/react/internal';
|
|
8
|
-
import { ValNextProvider } from './ValNextProvider-
|
|
8
|
+
import { ValNextProvider } from './ValNextProvider-0b711372.esm.js';
|
|
9
9
|
import NextImage from 'next/image';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
|
-
export { ValApp } from './ValApp-
|
|
11
|
+
export { ValApp } from './ValApp-50ec1e10.esm.js';
|
|
12
12
|
import { V as VERSION } from './version-98ec5c7a.esm.js';
|
|
13
13
|
|
|
14
14
|
function _typeof(o) {
|
|
@@ -70,38 +70,31 @@ var initVal = function initVal(config) {
|
|
|
70
70
|
|
|
71
71
|
var ValProvider = ValNextProvider;
|
|
72
72
|
|
|
73
|
-
function _objectWithoutPropertiesLoose(
|
|
74
|
-
if (
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
key = sourceKeys[i];
|
|
80
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
81
|
-
target[key] = source[key];
|
|
73
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
74
|
+
if (null == r) return {};
|
|
75
|
+
var t = {};
|
|
76
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
77
|
+
if (e.includes(n)) continue;
|
|
78
|
+
t[n] = r[n];
|
|
82
79
|
}
|
|
83
|
-
return
|
|
80
|
+
return t;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
|
-
function _objectWithoutProperties(
|
|
87
|
-
if (
|
|
88
|
-
var
|
|
89
|
-
|
|
83
|
+
function _objectWithoutProperties(e, t) {
|
|
84
|
+
if (null == e) return {};
|
|
85
|
+
var o,
|
|
86
|
+
r,
|
|
87
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
90
88
|
if (Object.getOwnPropertySymbols) {
|
|
91
|
-
var
|
|
92
|
-
for (
|
|
93
|
-
key = sourceSymbolKeys[i];
|
|
94
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
95
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
96
|
-
target[key] = source[key];
|
|
97
|
-
}
|
|
89
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
90
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
98
91
|
}
|
|
99
|
-
return
|
|
92
|
+
return i;
|
|
100
93
|
}
|
|
101
94
|
|
|
102
95
|
var _excluded = ["src", "alt", "style", "width", "disableHotspot", "height"];
|
|
103
96
|
function ValImage(props) {
|
|
104
|
-
var _src$metadata, _src$metadata2, _src$metadata3;
|
|
97
|
+
var _src$metadata, _src$metadata2, _src$metadata3, _src$metadata4;
|
|
105
98
|
var src = props.src,
|
|
106
99
|
alt = props.alt,
|
|
107
100
|
style = props.style,
|
|
@@ -120,6 +113,7 @@ function ValImage(props) {
|
|
|
120
113
|
objectPosition: "".concat(hotspot.x * 100, "% ").concat(hotspot.y * 100, "%")
|
|
121
114
|
}) : style;
|
|
122
115
|
var useMetadataDimensions = src.metadata !== undefined && !rest.fill && !width && !height;
|
|
116
|
+
var isUnoptimized = rest.unoptimized !== undefined ? rest.unoptimized : ((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.mimeType) === "image/svg+xml"; // SVGs are unoptimized by default
|
|
123
117
|
return /*#__PURE__*/jsx(NextImage, _objectSpread2(_objectSpread2({}, _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
124
118
|
layout: undefined,
|
|
125
119
|
objectFit: undefined,
|
|
@@ -134,8 +128,9 @@ function ValImage(props) {
|
|
|
134
128
|
style: imageStyle,
|
|
135
129
|
alt: raw(alt),
|
|
136
130
|
fill: rest.fill,
|
|
137
|
-
width: useMetadataDimensions ? (_src$
|
|
138
|
-
height: useMetadataDimensions ? (_src$
|
|
131
|
+
width: useMetadataDimensions ? (_src$metadata3 = src.metadata) === null || _src$metadata3 === void 0 ? void 0 : _src$metadata3.width : width,
|
|
132
|
+
height: useMetadataDimensions ? (_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.height : height,
|
|
133
|
+
unoptimized: isUnoptimized
|
|
139
134
|
}));
|
|
140
135
|
}
|
|
141
136
|
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"next",
|
|
9
9
|
"react"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.65.0",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"test": "jest"
|
|
@@ -45,10 +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/
|
|
48
|
+
"@valbuild/core": "~0.65.0",
|
|
49
|
+
"@valbuild/react": "~0.65.0",
|
|
50
|
+
"@valbuild/server": "~0.65.0",
|
|
51
|
+
"@valbuild/shared": "~0.65.0",
|
|
52
|
+
"@valbuild/ui": "~0.65.0",
|
|
52
53
|
"client-only": "^0.0.1",
|
|
53
54
|
"server-only": "^0.0.1"
|
|
54
55
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../../dist/declarations/src/rsc/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
1
|
+
export * from "../../dist/declarations/src/rsc/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsYnVpbGQtbmV4dC1yc2MuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9kaXN0L2RlY2xhcmF0aW9ucy9zcmMvcnNjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('server-only');
|
|
6
|
-
var
|
|
6
|
+
var objectSpread2 = require('../../dist/objectSpread2-792eb2c2.cjs.dev.js');
|
|
7
|
+
var asyncToGenerator = require('../../dist/asyncToGenerator-6ba61221.cjs.dev.js');
|
|
7
8
|
var stega = require('@valbuild/react/stega');
|
|
8
9
|
var core = require('@valbuild/core');
|
|
9
|
-
var
|
|
10
|
+
var internal = require('@valbuild/shared/internal');
|
|
11
|
+
var server = require('@valbuild/server');
|
|
12
|
+
var version = require('../../dist/version-82faa1d0.cjs.dev.js');
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
stega.SET_RSC(true);
|
|
15
|
+
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
12
16
|
return function (selector) {
|
|
13
17
|
var enabled = false;
|
|
14
18
|
try {
|
|
@@ -28,54 +32,84 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
|
|
|
28
32
|
console.error("Val: could not read headers! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
29
33
|
headers = null;
|
|
30
34
|
}
|
|
31
|
-
var cookies
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
var cookies = function () {
|
|
36
|
+
try {
|
|
37
|
+
return getCookies();
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error("Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}();
|
|
38
43
|
var host = headers && getHost(headers);
|
|
39
44
|
if (host && cookies) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var allPatches;
|
|
45
|
+
return valServerPromise.then(/*#__PURE__*/function () {
|
|
46
|
+
var _ref = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee(valServer) {
|
|
47
|
+
var _cookies$get, _cookies$get2;
|
|
48
|
+
var patchesRes, allPatches, treeRes, modules;
|
|
44
49
|
return asyncToGenerator._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
50
|
while (1) switch (_context.prev = _context.next) {
|
|
46
51
|
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
_context.next = 2;
|
|
53
|
+
return valServer["/patches/~"]["GET"]({
|
|
54
|
+
query: {
|
|
55
|
+
omit_patch: true,
|
|
56
|
+
author: undefined,
|
|
57
|
+
patch_id: undefined,
|
|
58
|
+
module_file_path: undefined
|
|
59
|
+
},
|
|
60
|
+
cookies: objectSpread2._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies$get = cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies$get === void 0 ? void 0 : _cookies$get.value)
|
|
61
|
+
});
|
|
62
|
+
case 2:
|
|
63
|
+
patchesRes = _context.sent;
|
|
64
|
+
if (!(patchesRes.status !== 200)) {
|
|
65
|
+
_context.next = 6;
|
|
49
66
|
break;
|
|
50
67
|
}
|
|
51
|
-
console.error("Val: could not fetch patches", patchesRes.
|
|
52
|
-
throw Error(JSON.stringify(patchesRes.
|
|
53
|
-
case
|
|
54
|
-
allPatches = Object.keys(patchesRes.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
console.error("Val: could not fetch patches", patchesRes.json);
|
|
69
|
+
throw Error(JSON.stringify(patchesRes.json, null, 2));
|
|
70
|
+
case 6:
|
|
71
|
+
allPatches = Object.keys(patchesRes.json.patches);
|
|
72
|
+
_context.next = 9;
|
|
73
|
+
return valServer["/sources"]["PUT"]({
|
|
74
|
+
path: "/",
|
|
75
|
+
query: {
|
|
76
|
+
validate_sources: true,
|
|
77
|
+
validate_all: false,
|
|
78
|
+
validate_binary_files: false
|
|
79
|
+
},
|
|
80
|
+
body: {
|
|
81
|
+
patchIds: allPatches
|
|
82
|
+
},
|
|
83
|
+
cookies: objectSpread2._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies$get2 = cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies$get2 === void 0 ? void 0 : _cookies$get2.value)
|
|
84
|
+
});
|
|
85
|
+
case 9:
|
|
86
|
+
treeRes = _context.sent;
|
|
87
|
+
if (!(treeRes.status === 200)) {
|
|
88
|
+
_context.next = 15;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
modules = treeRes.json.modules;
|
|
92
|
+
return _context.abrupt("return", stega.stegaEncode(selector, {
|
|
93
|
+
disabled: !enabled,
|
|
94
|
+
getModule: function getModule(path) {
|
|
95
|
+
var module = modules[path];
|
|
96
|
+
if (module) {
|
|
97
|
+
return module.source;
|
|
75
98
|
}
|
|
76
99
|
}
|
|
77
100
|
}));
|
|
78
|
-
case
|
|
101
|
+
case 15:
|
|
102
|
+
if (!(treeRes.status === 401)) {
|
|
103
|
+
_context.next = 19;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
console.warn("Val: authentication error: ", treeRes.json.message);
|
|
107
|
+
_context.next = 21;
|
|
108
|
+
break;
|
|
109
|
+
case 19:
|
|
110
|
+
console.error("Val: could not fetch modules", treeRes.json);
|
|
111
|
+
throw Error(JSON.stringify(treeRes.json, null, 2));
|
|
112
|
+
case 21:
|
|
79
113
|
case "end":
|
|
80
114
|
return _context.stop();
|
|
81
115
|
}
|
|
@@ -86,9 +120,6 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
|
|
|
86
120
|
};
|
|
87
121
|
}())["catch"](function (err) {
|
|
88
122
|
console.error("Val: failed while fetching modules", err);
|
|
89
|
-
if (process.env.NODE_ENV === "development") {
|
|
90
|
-
throw Error("Val: Could not fetch data. This is likely due to a misconfiguration or a bug. Check the console for more details.");
|
|
91
|
-
}
|
|
92
123
|
return stega.stegaEncode(selector, {});
|
|
93
124
|
});
|
|
94
125
|
}
|
|
@@ -141,11 +172,65 @@ function getHost(headers) {
|
|
|
141
172
|
|
|
142
173
|
var valApiEndpoints = "/api/val";
|
|
143
174
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
|
-
function initValRsc(config, rscNextConfig) {
|
|
175
|
+
function initValRsc(config, valModules, rscNextConfig) {
|
|
176
|
+
var coreVersion = core.Internal.VERSION.core;
|
|
177
|
+
if (!coreVersion) {
|
|
178
|
+
throw new Error("Could not get @valbuild/core package version");
|
|
179
|
+
}
|
|
180
|
+
var nextVersion = version.VERSION;
|
|
181
|
+
if (!nextVersion) {
|
|
182
|
+
throw new Error("Could not get @valbuild/next package version");
|
|
183
|
+
}
|
|
184
|
+
var valServerPromise = server.createValServer(valModules, "/api/val", objectSpread2._objectSpread2({
|
|
185
|
+
versions: {
|
|
186
|
+
next: nextVersion,
|
|
187
|
+
core: coreVersion
|
|
188
|
+
}
|
|
189
|
+
}, config), config, {
|
|
190
|
+
isEnabled: function isEnabled() {
|
|
191
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee2() {
|
|
192
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
193
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
194
|
+
case 0:
|
|
195
|
+
return _context2.abrupt("return", rscNextConfig.draftMode().isEnabled);
|
|
196
|
+
case 1:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context2.stop();
|
|
199
|
+
}
|
|
200
|
+
}, _callee2);
|
|
201
|
+
}))();
|
|
202
|
+
},
|
|
203
|
+
onEnable: function onEnable() {
|
|
204
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee3() {
|
|
205
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
206
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
207
|
+
case 0:
|
|
208
|
+
rscNextConfig.draftMode().enable();
|
|
209
|
+
case 1:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context3.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee3);
|
|
214
|
+
}))();
|
|
215
|
+
},
|
|
216
|
+
onDisable: function onDisable() {
|
|
217
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee4() {
|
|
218
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
219
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
rscNextConfig.draftMode().disable();
|
|
222
|
+
case 1:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context4.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee4);
|
|
227
|
+
}))();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
145
230
|
return {
|
|
146
231
|
fetchValStega: initFetchValStega(config, valApiEndpoints,
|
|
147
232
|
// TODO: get from config
|
|
148
|
-
function () {
|
|
233
|
+
valServerPromise, function () {
|
|
149
234
|
return rscNextConfig.draftMode().isEnabled;
|
|
150
235
|
}, function () {
|
|
151
236
|
return rscNextConfig.headers();
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('server-only');
|
|
6
|
-
var
|
|
6
|
+
var objectSpread2 = require('../../dist/objectSpread2-3c87fb4f.cjs.prod.js');
|
|
7
|
+
var asyncToGenerator = require('../../dist/asyncToGenerator-67a5ff70.cjs.prod.js');
|
|
7
8
|
var stega = require('@valbuild/react/stega');
|
|
8
9
|
var core = require('@valbuild/core');
|
|
9
|
-
var
|
|
10
|
+
var internal = require('@valbuild/shared/internal');
|
|
11
|
+
var server = require('@valbuild/server');
|
|
12
|
+
var version = require('../../dist/version-a9a6a619.cjs.prod.js');
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
stega.SET_RSC(true);
|
|
15
|
+
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
12
16
|
return function (selector) {
|
|
13
17
|
var enabled = false;
|
|
14
18
|
try {
|
|
@@ -28,54 +32,84 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
|
|
|
28
32
|
console.error("Val: could not read headers! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
29
33
|
headers = null;
|
|
30
34
|
}
|
|
31
|
-
var cookies
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
var cookies = function () {
|
|
36
|
+
try {
|
|
37
|
+
return getCookies();
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error("Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.", err);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}();
|
|
38
43
|
var host = headers && getHost(headers);
|
|
39
44
|
if (host && cookies) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var allPatches;
|
|
45
|
+
return valServerPromise.then(/*#__PURE__*/function () {
|
|
46
|
+
var _ref = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee(valServer) {
|
|
47
|
+
var _cookies$get, _cookies$get2;
|
|
48
|
+
var patchesRes, allPatches, treeRes, modules;
|
|
44
49
|
return asyncToGenerator._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
50
|
while (1) switch (_context.prev = _context.next) {
|
|
46
51
|
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
_context.next = 2;
|
|
53
|
+
return valServer["/patches/~"]["GET"]({
|
|
54
|
+
query: {
|
|
55
|
+
omit_patch: true,
|
|
56
|
+
author: undefined,
|
|
57
|
+
patch_id: undefined,
|
|
58
|
+
module_file_path: undefined
|
|
59
|
+
},
|
|
60
|
+
cookies: objectSpread2._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies$get = cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies$get === void 0 ? void 0 : _cookies$get.value)
|
|
61
|
+
});
|
|
62
|
+
case 2:
|
|
63
|
+
patchesRes = _context.sent;
|
|
64
|
+
if (!(patchesRes.status !== 200)) {
|
|
65
|
+
_context.next = 6;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
console.error("Val: could not fetch patches", patchesRes.json);
|
|
69
|
+
throw Error(JSON.stringify(patchesRes.json, null, 2));
|
|
70
|
+
case 6:
|
|
71
|
+
allPatches = Object.keys(patchesRes.json.patches);
|
|
72
|
+
_context.next = 9;
|
|
73
|
+
return valServer["/sources"]["PUT"]({
|
|
74
|
+
path: "/",
|
|
75
|
+
query: {
|
|
76
|
+
validate_sources: true,
|
|
77
|
+
validate_all: false,
|
|
78
|
+
validate_binary_files: false
|
|
79
|
+
},
|
|
80
|
+
body: {
|
|
81
|
+
patchIds: allPatches
|
|
82
|
+
},
|
|
83
|
+
cookies: objectSpread2._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies$get2 = cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies$get2 === void 0 ? void 0 : _cookies$get2.value)
|
|
84
|
+
});
|
|
85
|
+
case 9:
|
|
86
|
+
treeRes = _context.sent;
|
|
87
|
+
if (!(treeRes.status === 200)) {
|
|
88
|
+
_context.next = 15;
|
|
49
89
|
break;
|
|
50
90
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (fp.result.isOk(res)) {
|
|
59
|
-
var modules = res.value.modules;
|
|
60
|
-
return stega.stegaEncode(selector, {
|
|
61
|
-
disabled: !enabled,
|
|
62
|
-
getModule: function getModule(path) {
|
|
63
|
-
var module = modules[path];
|
|
64
|
-
if (module) {
|
|
65
|
-
return module.source;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
if (res.error.statusCode === 401) {
|
|
71
|
-
console.warn("Val: authentication error: ", res.error.message);
|
|
72
|
-
} else {
|
|
73
|
-
console.error("Val: could not fetch modules", res.error);
|
|
74
|
-
throw Error(JSON.stringify(res.error, null, 2));
|
|
91
|
+
modules = treeRes.json.modules;
|
|
92
|
+
return _context.abrupt("return", stega.stegaEncode(selector, {
|
|
93
|
+
disabled: !enabled,
|
|
94
|
+
getModule: function getModule(path) {
|
|
95
|
+
var module = modules[path];
|
|
96
|
+
if (module) {
|
|
97
|
+
return module.source;
|
|
75
98
|
}
|
|
76
99
|
}
|
|
77
100
|
}));
|
|
78
|
-
case
|
|
101
|
+
case 15:
|
|
102
|
+
if (!(treeRes.status === 401)) {
|
|
103
|
+
_context.next = 19;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
console.warn("Val: authentication error: ", treeRes.json.message);
|
|
107
|
+
_context.next = 21;
|
|
108
|
+
break;
|
|
109
|
+
case 19:
|
|
110
|
+
console.error("Val: could not fetch modules", treeRes.json);
|
|
111
|
+
throw Error(JSON.stringify(treeRes.json, null, 2));
|
|
112
|
+
case 21:
|
|
79
113
|
case "end":
|
|
80
114
|
return _context.stop();
|
|
81
115
|
}
|
|
@@ -138,11 +172,65 @@ function getHost(headers) {
|
|
|
138
172
|
|
|
139
173
|
var valApiEndpoints = "/api/val";
|
|
140
174
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
141
|
-
function initValRsc(config, rscNextConfig) {
|
|
175
|
+
function initValRsc(config, valModules, rscNextConfig) {
|
|
176
|
+
var coreVersion = core.Internal.VERSION.core;
|
|
177
|
+
if (!coreVersion) {
|
|
178
|
+
throw new Error("Could not get @valbuild/core package version");
|
|
179
|
+
}
|
|
180
|
+
var nextVersion = version.VERSION;
|
|
181
|
+
if (!nextVersion) {
|
|
182
|
+
throw new Error("Could not get @valbuild/next package version");
|
|
183
|
+
}
|
|
184
|
+
var valServerPromise = server.createValServer(valModules, "/api/val", objectSpread2._objectSpread2({
|
|
185
|
+
versions: {
|
|
186
|
+
next: nextVersion,
|
|
187
|
+
core: coreVersion
|
|
188
|
+
}
|
|
189
|
+
}, config), config, {
|
|
190
|
+
isEnabled: function isEnabled() {
|
|
191
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee2() {
|
|
192
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
193
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
194
|
+
case 0:
|
|
195
|
+
return _context2.abrupt("return", rscNextConfig.draftMode().isEnabled);
|
|
196
|
+
case 1:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context2.stop();
|
|
199
|
+
}
|
|
200
|
+
}, _callee2);
|
|
201
|
+
}))();
|
|
202
|
+
},
|
|
203
|
+
onEnable: function onEnable() {
|
|
204
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee3() {
|
|
205
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
206
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
207
|
+
case 0:
|
|
208
|
+
rscNextConfig.draftMode().enable();
|
|
209
|
+
case 1:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context3.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee3);
|
|
214
|
+
}))();
|
|
215
|
+
},
|
|
216
|
+
onDisable: function onDisable() {
|
|
217
|
+
return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee4() {
|
|
218
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
219
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
rscNextConfig.draftMode().disable();
|
|
222
|
+
case 1:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context4.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee4);
|
|
227
|
+
}))();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
142
230
|
return {
|
|
143
231
|
fetchValStega: initFetchValStega(config, valApiEndpoints,
|
|
144
232
|
// TODO: get from config
|
|
145
|
-
function () {
|
|
233
|
+
valServerPromise, function () {
|
|
146
234
|
return rscNextConfig.draftMode().isEnabled;
|
|
147
235
|
}, function () {
|
|
148
236
|
return rscNextConfig.headers();
|