@valbuild/next 0.58.0 → 0.59.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.
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValNextProvider-3931035e.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValNextProvider-3931035e.cjs.dev.js");
7
+ }
@@ -11,9 +11,13 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
 
12
12
  var ValNextProvider = function ValNextProvider(props) {
13
13
  var router = navigation.useRouter();
14
+ var pathname = navigation.usePathname();
14
15
  var _useTransition = react.useTransition(),
15
16
  _useTransition2 = slicedToArray._slicedToArray(_useTransition, 2),
16
17
  startTransition = _useTransition2[1];
18
+ if (pathname.startsWith("/val")) {
19
+ return props.children;
20
+ }
17
21
  return /*#__PURE__*/jsxRuntime.jsx(internal.ValProvider, {
18
22
  onSubmit: function onSubmit(refreshRequired) {
19
23
  if (refreshRequired && !props.disableRefresh) {
@@ -11,9 +11,13 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
 
12
12
  var ValNextProvider = function ValNextProvider(props) {
13
13
  var router = navigation.useRouter();
14
+ var pathname = navigation.usePathname();
14
15
  var _useTransition = react.useTransition(),
15
16
  _useTransition2 = slicedToArray._slicedToArray(_useTransition, 2),
16
17
  startTransition = _useTransition2[1];
18
+ if (pathname.startsWith("/val")) {
19
+ return props.children;
20
+ }
17
21
  return /*#__PURE__*/jsxRuntime.jsx(internal.ValProvider, {
18
22
  onSubmit: function onSubmit(refreshRequired) {
19
23
  if (refreshRequired && !props.disableRefresh) {
@@ -1,15 +1,19 @@
1
1
  'use client';
2
2
  import { _ as _slicedToArray } from './slicedToArray-62cd636a.esm.js';
3
3
  import { ValProvider } from '@valbuild/react/internal';
4
- import { useRouter } from 'next/navigation';
4
+ import { useRouter, usePathname } from 'next/navigation';
5
5
  import { useTransition } from 'react';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
8
  var ValNextProvider = function ValNextProvider(props) {
9
9
  var router = useRouter();
10
+ var pathname = usePathname();
10
11
  var _useTransition = useTransition(),
11
12
  _useTransition2 = _slicedToArray(_useTransition, 2),
12
13
  startTransition = _useTransition2[1];
14
+ if (pathname.startsWith("/val")) {
15
+ return props.children;
16
+ }
13
17
  return /*#__PURE__*/jsx(ValProvider, {
14
18
  onSubmit: function onSubmit(refreshRequired) {
15
19
  if (refreshRequired && !props.disableRefresh) {
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
+ /// <reference types="react/experimental" />
2
3
  export declare const ValProvider: (props: {
3
4
  children: import("react").ReactNode | import("react").ReactNode[];
4
5
  config: import("@valbuild/core").ValConfig;
5
6
  disableRefresh?: boolean | undefined;
6
- }) => import("react/jsx-runtime").JSX.Element;
7
+ }) => string | number | boolean | Iterable<import("react").ReactNode> | import("react").PromiseLikeOfReactNode | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var core = require('@valbuild/core');
6
6
  var stega = require('@valbuild/react/stega');
7
7
  var internal = require('@valbuild/react/internal');
8
- var ValNextProvider = require('./ValNextProvider-49d2bec1.cjs.dev.js');
8
+ var ValNextProvider = require('./ValNextProvider-48de1a1b.cjs.dev.js');
9
9
  var NextImage = require('next/image');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
  var ValApp = require('./ValApp-cbf9b1c3.cjs.dev.js');
@@ -105,14 +105,12 @@ function decodeValPathOfString(encodedString) {
105
105
  }
106
106
 
107
107
  var initVal = function initVal(config) {
108
- var _createValSystem = core.initVal(),
108
+ var _createValSystem = core.initVal(config),
109
109
  s = _createValSystem.s,
110
110
  c = _createValSystem.c,
111
111
  val = _createValSystem.val,
112
112
  systemConfig = _createValSystem.config;
113
- var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
114
- valConfigPath: (config === null || config === void 0 ? void 0 : config.valConfigPath) || "./val.config"
115
- });
113
+ var currentConfig = _objectSpread2(_objectSpread2({}, systemConfig), config);
116
114
  return {
117
115
  s: s,
118
116
  c: c,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var core = require('@valbuild/core');
6
6
  var stega = require('@valbuild/react/stega');
7
7
  var internal = require('@valbuild/react/internal');
8
- var ValNextProvider = require('./ValNextProvider-7750e412.cjs.prod.js');
8
+ var ValNextProvider = require('./ValNextProvider-3931035e.cjs.prod.js');
9
9
  var NextImage = require('next/image');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
  var ValApp = require('./ValApp-09d3eba7.cjs.prod.js');
@@ -105,14 +105,12 @@ function decodeValPathOfString(encodedString) {
105
105
  }
106
106
 
107
107
  var initVal = function initVal(config) {
108
- var _createValSystem = core.initVal(),
108
+ var _createValSystem = core.initVal(config),
109
109
  s = _createValSystem.s,
110
110
  c = _createValSystem.c,
111
111
  val = _createValSystem.val,
112
112
  systemConfig = _createValSystem.config;
113
- var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
114
- valConfigPath: (config === null || config === void 0 ? void 0 : config.valConfigPath) || "./val.config"
115
- });
113
+ var currentConfig = _objectSpread2(_objectSpread2({}, systemConfig), config);
116
114
  return {
117
115
  s: s,
118
116
  c: c,
@@ -4,7 +4,7 @@ export { core as expr };
4
4
  export { FILE_REF_PROP, GenericSelector, Schema, VAL_EXTENSION, derefPatch } from '@valbuild/core';
5
5
  import { stegaClean, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
6
6
  export { ValRichText } from '@valbuild/react/internal';
7
- import { ValNextProvider } from './ValNextProvider-c5c9fcb0.esm.js';
7
+ import { ValNextProvider } from './ValNextProvider-b4aaca09.esm.js';
8
8
  import NextImage from 'next/image';
9
9
  import { jsx } from 'react/jsx-runtime';
10
10
  export { ValApp } from './ValApp-6827827a.esm.js';
@@ -81,14 +81,12 @@ function decodeValPathOfString(encodedString) {
81
81
  }
82
82
 
83
83
  var initVal = function initVal(config) {
84
- var _createValSystem = initVal$1(),
84
+ var _createValSystem = initVal$1(config),
85
85
  s = _createValSystem.s,
86
86
  c = _createValSystem.c,
87
87
  val = _createValSystem.val,
88
88
  systemConfig = _createValSystem.config;
89
- var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
90
- valConfigPath: (config === null || config === void 0 ? void 0 : config.valConfigPath) || "./val.config"
91
- });
89
+ var currentConfig = _objectSpread2(_objectSpread2({}, systemConfig), config);
92
90
  return {
93
91
  s: s,
94
92
  c: c,
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.58.0",
11
+ "version": "0.59.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.58.0",
49
- "@valbuild/react": "~0.58.0",
50
- "@valbuild/server": "~0.58.0",
51
- "@valbuild/ui": "~0.58.0",
48
+ "@valbuild/core": "~0.59.0",
49
+ "@valbuild/react": "~0.59.0",
50
+ "@valbuild/server": "~0.59.0",
51
+ "@valbuild/ui": "~0.59.0",
52
52
  "client-only": "^0.0.1",
53
53
  "server-only": "^0.0.1"
54
54
  },
@@ -67,7 +67,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
67
67
  cookies = null;
68
68
  }
69
69
  var host = headers && getHost(headers);
70
- if (host && cookies && isProxyMode(config)) {
70
+ if (host && cookies) {
71
71
  var _optimizeTreePath;
72
72
  var api = new core.ValApi("".concat(host).concat(valApiEndpoints));
73
73
  var valModuleIds = stega.getModuleIds(selector);
@@ -100,7 +100,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
100
100
  })["catch"](function (err) {
101
101
  console.error("Val: failed while fetching modules", err);
102
102
  if (process.env.NODE_ENV === "development") {
103
- throw Error('You are running in "proxy" mode in development and Val could not fetch remote / proxy data. This is likely due to a misconfiguration. Check the console for more details.');
103
+ throw Error("Val: Could not fetch data. This is likely due to a misconfiguration or a bug. Check the console for more details.");
104
104
  }
105
105
  return stega.stegaEncode(selector, {});
106
106
  });
@@ -128,12 +128,6 @@ function getHost(headers) {
128
128
  }
129
129
  return null;
130
130
  }
131
- function isProxyMode(opts) {
132
- var maybeApiKey = opts.apiKey || process.env.VAL_API_KEY;
133
- var maybeValSecret = opts.valSecret || process.env.VAL_SECRET;
134
- var isProxyMode = opts.mode === "proxy" || opts.mode === undefined && (maybeApiKey || maybeValSecret);
135
- return !!isProxyMode;
136
- }
137
131
  function getValAuthHeaders(cookies) {
138
132
  try {
139
133
  var session = cookies.get(core.Internal.VAL_SESSION_COOKIE);
@@ -67,7 +67,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
67
67
  cookies = null;
68
68
  }
69
69
  var host = headers && getHost(headers);
70
- if (host && cookies && isProxyMode(config)) {
70
+ if (host && cookies) {
71
71
  var _optimizeTreePath;
72
72
  var api = new core.ValApi("".concat(host).concat(valApiEndpoints));
73
73
  var valModuleIds = stega.getModuleIds(selector);
@@ -125,12 +125,6 @@ function getHost(headers) {
125
125
  }
126
126
  return null;
127
127
  }
128
- function isProxyMode(opts) {
129
- var maybeApiKey = opts.apiKey || process.env.VAL_API_KEY;
130
- var maybeValSecret = opts.valSecret || process.env.VAL_SECRET;
131
- var isProxyMode = opts.mode === "proxy" || opts.mode === undefined && (maybeApiKey || maybeValSecret);
132
- return !!isProxyMode;
133
- }
134
128
  function getValAuthHeaders(cookies) {
135
129
  try {
136
130
  var session = cookies.get(core.Internal.VAL_SESSION_COOKIE);
@@ -63,7 +63,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
63
63
  cookies = null;
64
64
  }
65
65
  var host = headers && getHost(headers);
66
- if (host && cookies && isProxyMode(config)) {
66
+ if (host && cookies) {
67
67
  var _optimizeTreePath;
68
68
  var api = new ValApi("".concat(host).concat(valApiEndpoints));
69
69
  var valModuleIds = getModuleIds(selector);
@@ -96,7 +96,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, isEn
96
96
  })["catch"](function (err) {
97
97
  console.error("Val: failed while fetching modules", err);
98
98
  if (process.env.NODE_ENV === "development") {
99
- throw Error('You are running in "proxy" mode in development and Val could not fetch remote / proxy data. This is likely due to a misconfiguration. Check the console for more details.');
99
+ throw Error("Val: Could not fetch data. This is likely due to a misconfiguration or a bug. Check the console for more details.");
100
100
  }
101
101
  return stegaEncode(selector, {});
102
102
  });
@@ -124,12 +124,6 @@ function getHost(headers) {
124
124
  }
125
125
  return null;
126
126
  }
127
- function isProxyMode(opts) {
128
- var maybeApiKey = opts.apiKey || process.env.VAL_API_KEY;
129
- var maybeValSecret = opts.valSecret || process.env.VAL_SECRET;
130
- var isProxyMode = opts.mode === "proxy" || opts.mode === undefined && (maybeApiKey || maybeValSecret);
131
- return !!isProxyMode;
132
- }
133
127
  function getValAuthHeaders(cookies) {
134
128
  try {
135
129
  var session = cookies.get(Internal.VAL_SESSION_COOKIE);
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValNextProvider-7750e412.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValNextProvider-7750e412.cjs.dev.js");
7
- }