@valbuild/next 0.61.0 → 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.
Files changed (28) hide show
  1. package/client/dist/valbuild-next-client.cjs.dev.js +1 -1
  2. package/client/dist/valbuild-next-client.cjs.prod.js +1 -1
  3. package/client/dist/valbuild-next-client.esm.js +1 -1
  4. package/dist/{ValContext-a73be368.cjs.dev.js → ValContext-8eb2ec77.cjs.dev.js} +13 -13
  5. package/dist/ValContext-df4a9ae7.cjs.js +7 -0
  6. package/dist/{ValContext-37ea12ae.cjs.prod.js → ValContext-df4a9ae7.cjs.prod.js} +13 -13
  7. package/dist/{ValContext-e5293493.esm.js → ValContext-ea0b967a.esm.js} +13 -13
  8. package/dist/ValNextProvider-06d5c71e.cjs.js +7 -0
  9. package/dist/{ValNextProvider-676d6cb8.cjs.prod.js → ValNextProvider-06d5c71e.cjs.prod.js} +4 -4
  10. package/dist/{ValNextProvider-23099a43.esm.js → ValNextProvider-259bf24d.esm.js} +4 -4
  11. package/dist/{ValNextProvider-ef4fdca6.cjs.dev.js → ValNextProvider-3df6c619.cjs.dev.js} +4 -4
  12. package/dist/asyncToGenerator-0859ab5c.esm.js +334 -0
  13. package/dist/asyncToGenerator-3551d940.cjs.prod.js +337 -0
  14. package/dist/asyncToGenerator-ba66657c.cjs.dev.js +337 -0
  15. package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +3 -2
  16. package/dist/declarations/src/server/initValServer.d.ts +3 -1
  17. package/dist/valbuild-next.cjs.dev.js +1 -1
  18. package/dist/valbuild-next.cjs.prod.js +1 -1
  19. package/dist/valbuild-next.esm.js +1 -1
  20. package/package.json +5 -5
  21. package/rsc/dist/valbuild-next-rsc.cjs.dev.js +75 -76
  22. package/rsc/dist/valbuild-next-rsc.cjs.prod.js +75 -76
  23. package/rsc/dist/valbuild-next-rsc.esm.js +77 -78
  24. package/server/dist/valbuild-next-server.cjs.dev.js +8 -340
  25. package/server/dist/valbuild-next-server.cjs.prod.js +8 -340
  26. package/server/dist/valbuild-next-server.esm.js +2 -334
  27. package/dist/ValContext-37ea12ae.cjs.js +0 -7
  28. package/dist/ValNextProvider-676d6cb8.cjs.js +0 -7
@@ -1,7 +1,9 @@
1
1
  import { ValConfig, ValModules } from "@valbuild/core";
2
2
  import type { draftMode } from "next/headers";
3
3
  import { NextResponse } from "next/server";
4
- declare const initValNextAppRouter: (valModules: ValModules, config: ValConfig, nextConfig: ValServerNextConfig) => (req: Request) => Promise<NextResponse<unknown>>;
4
+ declare const initValNextAppRouter: (valModules: ValModules, config: ValConfig, nextConfig: ValServerNextConfig & {
5
+ formatter?: ((code: string, filePath: string) => string) | undefined;
6
+ }) => (req: Request) => Promise<NextResponse<unknown>>;
5
7
  type ValServerNextConfig = {
6
8
  draftMode: typeof draftMode;
7
9
  };
@@ -6,7 +6,7 @@ var objectSpread2 = require('./objectSpread2-bb9509e8.cjs.dev.js');
6
6
  var core = require('@valbuild/core');
7
7
  var stega = require('@valbuild/react/stega');
8
8
  var internal = require('@valbuild/react/internal');
9
- var ValNextProvider = require('./ValNextProvider-ef4fdca6.cjs.dev.js');
9
+ var ValNextProvider = require('./ValNextProvider-3df6c619.cjs.dev.js');
10
10
  var NextImage = require('next/image');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
  var ValApp = require('./ValApp-aff60572.cjs.dev.js');
@@ -6,7 +6,7 @@ var objectSpread2 = require('./objectSpread2-24e737a6.cjs.prod.js');
6
6
  var core = require('@valbuild/core');
7
7
  var stega = require('@valbuild/react/stega');
8
8
  var internal = require('@valbuild/react/internal');
9
- var ValNextProvider = require('./ValNextProvider-676d6cb8.cjs.prod.js');
9
+ var ValNextProvider = require('./ValNextProvider-06d5c71e.cjs.prod.js');
10
10
  var NextImage = require('next/image');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
  var ValApp = require('./ValApp-0ec0c7f3.cjs.prod.js');
@@ -5,7 +5,7 @@ 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-23099a43.esm.js';
8
+ import { ValNextProvider } from './ValNextProvider-259bf24d.esm.js';
9
9
  import NextImage from 'next/image';
10
10
  import { jsx } from 'react/jsx-runtime';
11
11
  export { ValApp } from './ValApp-61103149.esm.js';
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.61.0",
11
+ "version": "0.62.0",
12
12
  "scripts": {
13
13
  "typecheck": "tsc --noEmit",
14
14
  "test": "jest"
@@ -45,10 +45,10 @@
45
45
  "exports": true
46
46
  },
47
47
  "dependencies": {
48
- "@valbuild/core": "~0.61.0",
49
- "@valbuild/react": "~0.61.0",
50
- "@valbuild/server": "~0.61.0",
51
- "@valbuild/ui": "~0.61.0",
48
+ "@valbuild/core": "~0.62.0",
49
+ "@valbuild/react": "~0.62.0",
50
+ "@valbuild/server": "~0.62.0",
51
+ "@valbuild/ui": "~0.62.0",
52
52
  "client-only": "^0.0.1",
53
53
  "server-only": "^0.0.1"
54
54
  },
@@ -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-ba66657c.cjs.dev.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
- var valModuleIds = stega.getModuleIds(selector);
74
- return api.getTree({
75
- // TODO: get tree should probably have a list of ids instead
76
- treePath: (_optimizeTreePath = optimizeTreePath(valModuleIds)) !== null && _optimizeTreePath !== void 0 ? _optimizeTreePath : undefined,
77
- patch: true,
78
- includeSource: true,
79
- includeSchema: true,
80
- headers: getValAuthHeaders(cookies)
81
- }).then(function (res) {
82
- if (fp.result.isOk(res)) {
83
- var modules = res.value.modules;
84
- return stega.stegaEncode(selector, {
85
- disabled: !enabled,
86
- getModule: function getModule(moduleId) {
87
- var module = modules[moduleId];
88
- if (module) {
89
- return module.source;
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
- } else {
94
- if (res.error.statusCode === 401) {
95
- console.warn("Val: authentication error: ", res.error.message);
96
- } else {
97
- console.error("Val: could not fetch modules", res.error);
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
  if (process.env.NODE_ENV === "development") {
104
93
  throw Error("Val: Could not fetch data. This is likely due to a misconfiguration or a bug. Check the console for more details.");
@@ -129,20 +118,30 @@ function getHost(headers) {
129
118
  }
130
119
  return null;
131
120
  }
132
- function getValAuthHeaders(cookies) {
133
- try {
134
- var session = cookies.get(core.Internal.VAL_SESSION_COOKIE);
135
- if (session) {
136
- return {
137
- Cookie: "".concat(core.Internal.VAL_SESSION_COOKIE, "=").concat(encodeURIComponent(session.value))
138
- };
139
- }
140
- return {};
141
- } catch (err) {
142
- console.error("Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.", err);
143
- return {};
144
- }
145
- }
121
+
122
+ // TODO: remove
123
+ // function getValAuthHeaders(cookies: {
124
+ // get(name: string): { name: string; value: string } | undefined;
125
+ // }): Record<string, string> {
126
+ // try {
127
+ // const session = cookies.get(Internal.VAL_SESSION_COOKIE);
128
+ // if (session) {
129
+ // return {
130
+ // Cookie: `${Internal.VAL_SESSION_COOKIE}=${encodeURIComponent(
131
+ // session.value
132
+ // )}`,
133
+ // };
134
+ // }
135
+ // return {};
136
+ // } catch (err) {
137
+ // console.error(
138
+ // "Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.",
139
+ // err
140
+ // );
141
+ // return {};
142
+ // }
143
+ // }
144
+
146
145
  var valApiEndpoints = "/api/val";
147
146
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
147
  function initValRsc(config, rscNextConfig) {
@@ -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
- var valModuleIds = stega.getModuleIds(selector);
74
- return api.getTree({
75
- // TODO: get tree should probably have a list of ids instead
76
- treePath: (_optimizeTreePath = optimizeTreePath(valModuleIds)) !== null && _optimizeTreePath !== void 0 ? _optimizeTreePath : undefined,
77
- patch: true,
78
- includeSource: true,
79
- includeSchema: true,
80
- headers: getValAuthHeaders(cookies)
81
- }).then(function (res) {
82
- if (fp.result.isOk(res)) {
83
- var modules = res.value.modules;
84
- return stega.stegaEncode(selector, {
85
- disabled: !enabled,
86
- getModule: function getModule(moduleId) {
87
- var module = modules[moduleId];
88
- if (module) {
89
- return module.source;
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
- } else {
94
- if (res.error.statusCode === 401) {
95
- console.warn("Val: authentication error: ", res.error.message);
96
- } else {
97
- console.error("Val: could not fetch modules", res.error);
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
- function getValAuthHeaders(cookies) {
130
- try {
131
- var session = cookies.get(core.Internal.VAL_SESSION_COOKIE);
132
- if (session) {
133
- return {
134
- Cookie: "".concat(core.Internal.VAL_SESSION_COOKIE, "=").concat(encodeURIComponent(session.value))
135
- };
136
- }
137
- return {};
138
- } catch (err) {
139
- console.error("Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.", err);
140
- return {};
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 { getModuleIds, stegaEncode } from '@valbuild/react/stega';
3
- import { ValApi, Internal } from '@valbuild/core';
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
- var valModuleIds = getModuleIds(selector);
70
- return api.getTree({
71
- // TODO: get tree should probably have a list of ids instead
72
- treePath: (_optimizeTreePath = optimizeTreePath(valModuleIds)) !== null && _optimizeTreePath !== void 0 ? _optimizeTreePath : undefined,
73
- patch: true,
74
- includeSource: true,
75
- includeSchema: true,
76
- headers: getValAuthHeaders(cookies)
77
- }).then(function (res) {
78
- if (result.isOk(res)) {
79
- var modules = res.value.modules;
80
- return stegaEncode(selector, {
81
- disabled: !enabled,
82
- getModule: function getModule(moduleId) {
83
- var module = modules[moduleId];
84
- if (module) {
85
- return module.source;
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
- } else {
90
- if (res.error.statusCode === 401) {
91
- console.warn("Val: authentication error: ", res.error.message);
92
- } else {
93
- console.error("Val: could not fetch modules", res.error);
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
- function getValAuthHeaders(cookies) {
129
- try {
130
- var session = cookies.get(Internal.VAL_SESSION_COOKIE);
131
- if (session) {
132
- return {
133
- Cookie: "".concat(Internal.VAL_SESSION_COOKIE, "=").concat(encodeURIComponent(session.value))
134
- };
135
- }
136
- return {};
137
- } catch (err) {
138
- console.error("Val: could not read cookies! fetchVal can only be used server-side. Use useVal on clients.", err);
139
- return {};
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) {