@valbuild/next 0.60.27 → 0.62.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 +2 -2
- package/client/dist/valbuild-next-client.cjs.prod.js +2 -2
- package/client/dist/valbuild-next-client.esm.js +2 -2
- package/dist/{ValContext-a73be368.cjs.dev.js → ValContext-8eb2ec77.cjs.dev.js} +13 -13
- package/dist/ValContext-df4a9ae7.cjs.js +7 -0
- package/dist/{ValContext-37ea12ae.cjs.prod.js → ValContext-df4a9ae7.cjs.prod.js} +13 -13
- package/dist/{ValContext-e5293493.esm.js → ValContext-ea0b967a.esm.js} +13 -13
- package/dist/ValNextProvider-06d5c71e.cjs.js +7 -0
- package/dist/{ValNextProvider-676d6cb8.cjs.prod.js → ValNextProvider-06d5c71e.cjs.prod.js} +4 -4
- package/dist/{ValNextProvider-23099a43.esm.js → ValNextProvider-259bf24d.esm.js} +4 -4
- package/dist/{ValNextProvider-ef4fdca6.cjs.dev.js → ValNextProvider-3df6c619.cjs.dev.js} +4 -4
- package/dist/asyncToGenerator-0859ab5c.esm.js +334 -0
- package/dist/asyncToGenerator-3551d940.cjs.prod.js +337 -0
- package/dist/asyncToGenerator-ba66657c.cjs.dev.js +337 -0
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +4 -2
- package/dist/declarations/src/server/initValServer.d.ts +5 -3
- package/dist/valbuild-next.cjs.dev.js +5 -1
- package/dist/valbuild-next.cjs.prod.js +5 -1
- package/dist/valbuild-next.esm.js +2 -2
- package/package.json +5 -5
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +75 -76
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +75 -76
- package/rsc/dist/valbuild-next-rsc.esm.js +77 -78
- package/server/dist/valbuild-next-server.cjs.dev.js +12 -344
- package/server/dist/valbuild-next-server.cjs.prod.js +12 -344
- package/server/dist/valbuild-next-server.esm.js +6 -338
- package/dist/ValContext-37ea12ae.cjs.js +0 -7
- package/dist/ValNextProvider-676d6cb8.cjs.js +0 -7
|
@@ -3,43 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('server-only');
|
|
6
|
+
var asyncToGenerator = require('../../dist/asyncToGenerator-3551d940.cjs.prod.js');
|
|
6
7
|
var stega = require('@valbuild/react/stega');
|
|
7
8
|
var core = require('@valbuild/core');
|
|
8
9
|
var fp = require('@valbuild/core/fp');
|
|
9
10
|
|
|
10
|
-
function optimizeTreePath(ids) {
|
|
11
|
-
return findUpperDirectory(ids);
|
|
12
|
-
}
|
|
13
|
-
function findUpperDirectory(paths) {
|
|
14
|
-
if (paths.length === 0) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
var pathSegments = paths[0].split("/");
|
|
18
|
-
for (var i = 1; i < paths.length; i++) {
|
|
19
|
-
var currentPathSegments = paths[i].split("/");
|
|
20
|
-
// Find the minimum length of the two paths
|
|
21
|
-
var minLength = Math.min(pathSegments.length, currentPathSegments.length);
|
|
22
|
-
|
|
23
|
-
// Iterate through the segments and find the common prefix
|
|
24
|
-
var commonPrefix = "";
|
|
25
|
-
for (var j = 0; j < minLength; j++) {
|
|
26
|
-
if (pathSegments[j] === currentPathSegments[j]) {
|
|
27
|
-
commonPrefix += pathSegments[j] + "/";
|
|
28
|
-
} else {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
pathSegments = commonPrefix.split("/").slice(0, -1);
|
|
33
|
-
|
|
34
|
-
// If there is no common prefix, return /
|
|
35
|
-
if (pathSegments.length <= 1) {
|
|
36
|
-
return "/";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
var upperDirectory = pathSegments.join("/");
|
|
40
|
-
return upperDirectory;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
11
|
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEnabled, getHeaders, getCookies) {
|
|
44
12
|
return function (selector) {
|
|
45
13
|
var enabled = false;
|
|
@@ -68,37 +36,58 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
|
|
|
68
36
|
}
|
|
69
37
|
var host = headers && getHost(headers);
|
|
70
38
|
if (host && cookies) {
|
|
71
|
-
var _optimizeTreePath;
|
|
72
39
|
var api = new core.ValApi("".concat(host).concat(valApiEndpoints));
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
40
|
+
return api.getPatches().then( /*#__PURE__*/function () {
|
|
41
|
+
var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator._regeneratorRuntime().mark(function _callee(patchesRes) {
|
|
42
|
+
var allPatches;
|
|
43
|
+
return asyncToGenerator._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
if (!fp.result.isErr(patchesRes)) {
|
|
47
|
+
_context.next = 3;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
console.error("Val: could not fetch patches", patchesRes.error);
|
|
51
|
+
throw Error(JSON.stringify(patchesRes.error, null, 2));
|
|
52
|
+
case 3:
|
|
53
|
+
allPatches = Object.values(patchesRes.value).flatMap(function (mp) {
|
|
54
|
+
return mp.map(function (p) {
|
|
55
|
+
return p.patch_id;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return _context.abrupt("return", api.putTree({
|
|
59
|
+
patchIds: allPatches
|
|
60
|
+
}).then(function (res) {
|
|
61
|
+
if (fp.result.isOk(res)) {
|
|
62
|
+
var modules = res.value.modules;
|
|
63
|
+
return stega.stegaEncode(selector, {
|
|
64
|
+
disabled: !enabled,
|
|
65
|
+
getModule: function getModule(path) {
|
|
66
|
+
var module = modules[path];
|
|
67
|
+
if (module) {
|
|
68
|
+
return module.source;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
if (res.error.statusCode === 401) {
|
|
74
|
+
console.warn("Val: authentication error: ", res.error.message);
|
|
75
|
+
} else {
|
|
76
|
+
console.error("Val: could not fetch modules", res.error);
|
|
77
|
+
throw Error(JSON.stringify(res.error, null, 2));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
case 5:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context.stop();
|
|
91
84
|
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
throw Error(JSON.stringify(res.error, null, 2));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
})["catch"](function (err) {
|
|
85
|
+
}, _callee);
|
|
86
|
+
}));
|
|
87
|
+
return function (_x) {
|
|
88
|
+
return _ref.apply(this, arguments);
|
|
89
|
+
};
|
|
90
|
+
}())["catch"](function (err) {
|
|
102
91
|
console.error("Val: failed while fetching modules", err);
|
|
103
92
|
return stega.stegaEncode(selector, {});
|
|
104
93
|
});
|
|
@@ -126,20 +115,30 @@ function getHost(headers) {
|
|
|
126
115
|
}
|
|
127
116
|
return null;
|
|
128
117
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
118
|
+
|
|
119
|
+
// TODO: remove
|
|
120
|
+
// function getValAuthHeaders(cookies: {
|
|
121
|
+
// get(name: string): { name: string; value: string } | undefined;
|
|
122
|
+
// }): Record<string, string> {
|
|
123
|
+
// try {
|
|
124
|
+
// const session = cookies.get(Internal.VAL_SESSION_COOKIE);
|
|
125
|
+
// if (session) {
|
|
126
|
+
// return {
|
|
127
|
+
// Cookie: `${Internal.VAL_SESSION_COOKIE}=${encodeURIComponent(
|
|
128
|
+
// session.value
|
|
129
|
+
// )}`,
|
|
130
|
+
// };
|
|
131
|
+
// }
|
|
132
|
+
// return {};
|
|
133
|
+
// } catch (err) {
|
|
134
|
+
// console.error(
|
|
135
|
+
// "Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.",
|
|
136
|
+
// err
|
|
137
|
+
// );
|
|
138
|
+
// return {};
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
141
|
+
|
|
143
142
|
var valApiEndpoints = "/api/val";
|
|
144
143
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
145
144
|
function initValRsc(config, rscNextConfig) {
|
|
@@ -1,41 +1,9 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { _ as _asyncToGenerator, a as _regeneratorRuntime } from '../../dist/asyncToGenerator-0859ab5c.esm.js';
|
|
3
|
+
import { stegaEncode } from '@valbuild/react/stega';
|
|
4
|
+
import { ValApi } from '@valbuild/core';
|
|
4
5
|
import { result } from '@valbuild/core/fp';
|
|
5
6
|
|
|
6
|
-
function optimizeTreePath(ids) {
|
|
7
|
-
return findUpperDirectory(ids);
|
|
8
|
-
}
|
|
9
|
-
function findUpperDirectory(paths) {
|
|
10
|
-
if (paths.length === 0) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
var pathSegments = paths[0].split("/");
|
|
14
|
-
for (var i = 1; i < paths.length; i++) {
|
|
15
|
-
var currentPathSegments = paths[i].split("/");
|
|
16
|
-
// Find the minimum length of the two paths
|
|
17
|
-
var minLength = Math.min(pathSegments.length, currentPathSegments.length);
|
|
18
|
-
|
|
19
|
-
// Iterate through the segments and find the common prefix
|
|
20
|
-
var commonPrefix = "";
|
|
21
|
-
for (var j = 0; j < minLength; j++) {
|
|
22
|
-
if (pathSegments[j] === currentPathSegments[j]) {
|
|
23
|
-
commonPrefix += pathSegments[j] + "/";
|
|
24
|
-
} else {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
pathSegments = commonPrefix.split("/").slice(0, -1);
|
|
29
|
-
|
|
30
|
-
// If there is no common prefix, return /
|
|
31
|
-
if (pathSegments.length <= 1) {
|
|
32
|
-
return "/";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var upperDirectory = pathSegments.join("/");
|
|
36
|
-
return upperDirectory;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
7
|
var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEnabled, getHeaders, getCookies) {
|
|
40
8
|
return function (selector) {
|
|
41
9
|
var enabled = false;
|
|
@@ -64,37 +32,58 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
|
|
|
64
32
|
}
|
|
65
33
|
var host = headers && getHost(headers);
|
|
66
34
|
if (host && cookies) {
|
|
67
|
-
var _optimizeTreePath;
|
|
68
35
|
var api = new ValApi("".concat(host).concat(valApiEndpoints));
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
36
|
+
return api.getPatches().then( /*#__PURE__*/function () {
|
|
37
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(patchesRes) {
|
|
38
|
+
var allPatches;
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
if (!result.isErr(patchesRes)) {
|
|
43
|
+
_context.next = 3;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
console.error("Val: could not fetch patches", patchesRes.error);
|
|
47
|
+
throw Error(JSON.stringify(patchesRes.error, null, 2));
|
|
48
|
+
case 3:
|
|
49
|
+
allPatches = Object.values(patchesRes.value).flatMap(function (mp) {
|
|
50
|
+
return mp.map(function (p) {
|
|
51
|
+
return p.patch_id;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return _context.abrupt("return", api.putTree({
|
|
55
|
+
patchIds: allPatches
|
|
56
|
+
}).then(function (res) {
|
|
57
|
+
if (result.isOk(res)) {
|
|
58
|
+
var modules = res.value.modules;
|
|
59
|
+
return stegaEncode(selector, {
|
|
60
|
+
disabled: !enabled,
|
|
61
|
+
getModule: function getModule(path) {
|
|
62
|
+
var module = modules[path];
|
|
63
|
+
if (module) {
|
|
64
|
+
return module.source;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
if (res.error.statusCode === 401) {
|
|
70
|
+
console.warn("Val: authentication error: ", res.error.message);
|
|
71
|
+
} else {
|
|
72
|
+
console.error("Val: could not fetch modules", res.error);
|
|
73
|
+
throw Error(JSON.stringify(res.error, null, 2));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
case 5:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context.stop();
|
|
87
80
|
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
throw Error(JSON.stringify(res.error, null, 2));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
})["catch"](function (err) {
|
|
81
|
+
}, _callee);
|
|
82
|
+
}));
|
|
83
|
+
return function (_x) {
|
|
84
|
+
return _ref.apply(this, arguments);
|
|
85
|
+
};
|
|
86
|
+
}())["catch"](function (err) {
|
|
98
87
|
console.error("Val: failed while fetching modules", err);
|
|
99
88
|
if (process.env.NODE_ENV === "development") {
|
|
100
89
|
throw Error("Val: Could not fetch data. This is likely due to a misconfiguration or a bug. Check the console for more details.");
|
|
@@ -125,20 +114,30 @@ function getHost(headers) {
|
|
|
125
114
|
}
|
|
126
115
|
return null;
|
|
127
116
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
117
|
+
|
|
118
|
+
// TODO: remove
|
|
119
|
+
// function getValAuthHeaders(cookies: {
|
|
120
|
+
// get(name: string): { name: string; value: string } | undefined;
|
|
121
|
+
// }): Record<string, string> {
|
|
122
|
+
// try {
|
|
123
|
+
// const session = cookies.get(Internal.VAL_SESSION_COOKIE);
|
|
124
|
+
// if (session) {
|
|
125
|
+
// return {
|
|
126
|
+
// Cookie: `${Internal.VAL_SESSION_COOKIE}=${encodeURIComponent(
|
|
127
|
+
// session.value
|
|
128
|
+
// )}`,
|
|
129
|
+
// };
|
|
130
|
+
// }
|
|
131
|
+
// return {};
|
|
132
|
+
// } catch (err) {
|
|
133
|
+
// console.error(
|
|
134
|
+
// "Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.",
|
|
135
|
+
// err
|
|
136
|
+
// );
|
|
137
|
+
// return {};
|
|
138
|
+
// }
|
|
139
|
+
// }
|
|
140
|
+
|
|
142
141
|
var valApiEndpoints = "/api/val";
|
|
143
142
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
143
|
function initValRsc(config, rscNextConfig) {
|