@valbuild/tanstack 0.146.2 → 0.146.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.146.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#870](https://github.com/valbuild/val/pull/870) [`81f2e80`](https://github.com/valbuild/val/commit/81f2e803c4cefdf58bbe6856c06e98ace95a8e0b) Thanks [@freekh](https://github.com/freekh)! - The canvas works on a page behind your site's own login.
8
+
9
+ A site with its own sign-in (a dashboard, an intranet, a members' area) can be edited in the canvas. The canvas is a frame on the same origin as the Studio, so it sends your site's cookies like any other tab: if you are signed in to the site, the canvas shows the page signed in as you.
10
+
11
+ If you were not signed in, the site redirected the canvas to its login page, and the canvas then broke. That page mounted Val's whole overlay inside the canvas, a Studio inside the Studio. The canvas stayed on "Preview is not ready yet" through the sign-in and after it, until you pressed Reload. Now a page shown in the Studio's canvas counts as the canvas wherever it navigated to, so you can sign in inside the canvas and keep editing.
12
+
13
+ - Updated dependencies [[`81f2e80`](https://github.com/valbuild/val/commit/81f2e803c4cefdf58bbe6856c06e98ace95a8e0b), [`59ff6c3`](https://github.com/valbuild/val/commit/59ff6c367bc313b2bb7718b00c1641aaccab949d), [`c31f609`](https://github.com/valbuild/val/commit/c31f609fdeed79aa0e139fa4f652ba0684e96ea3)]:
14
+ - @valbuild/shared@0.146.4
15
+ - @valbuild/ui@0.146.4
16
+ - @valbuild/server@0.146.4
17
+ - @valbuild/language-server@0.146.4
18
+ - @valbuild/mcp@0.146.4
19
+ - @valbuild/react@0.146.4
20
+
21
+ ## 0.146.3
22
+
23
+ ### Patch Changes
24
+
25
+ - [#873](https://github.com/valbuild/val/pull/873) [`289b2f3`](https://github.com/valbuild/val/commit/289b2f3dc6503393697d09ba3ed802b569a914c9) Thanks [@freekh](https://github.com/freekh)! - Opening the Studio no longer flashes an empty page. The loading screen now stays
26
+ up until the Studio is ready to be seen, instead of disappearing as soon as the
27
+ page loaded and leaving a blank page while the Studio downloaded.
28
+
3
29
  ## 0.146.2
4
30
 
5
31
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-5162728d.cjs.dev.js');
5
+ var version = require('./version-1f65da50.cjs.dev.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-4497beef.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -1162,7 +1162,7 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1162
1162
  setMountOverlay(false);
1163
1163
  return;
1164
1164
  }
1165
- setIsCanvas(client.isValCanvasFrame(location.search));
1165
+ setIsCanvas(client.isValCanvasFrame(location.search, readParentPathname()));
1166
1166
  setMountOverlay(hasValEnableCookie(document.cookie));
1167
1167
  }, []);
1168
1168
  React__default["default"].useEffect(function () {
@@ -1698,6 +1698,24 @@ function isValStudioPath(pathname) {
1698
1698
  return pathname.startsWith("/val");
1699
1699
  }
1700
1700
 
1701
+ /**
1702
+ * The path of the window framing this document, or `null`.
1703
+ *
1704
+ * `null` for a top-level document, and for a parent on another origin: reading
1705
+ * a cross-origin `location` throws, and a page on another origin is not the
1706
+ * studio, whose canvas is always the same app. See `isValCanvasFrame`.
1707
+ */
1708
+ function readParentPathname() {
1709
+ try {
1710
+ if (window.parent === window) {
1711
+ return null;
1712
+ }
1713
+ return window.parent.location.pathname;
1714
+ } catch (_unused) {
1715
+ return null;
1716
+ }
1717
+ }
1718
+
1701
1719
  // function ValIcon() {
1702
1720
  // return (
1703
1721
  // <svg
@@ -2004,6 +2022,20 @@ function ValVideo(props) {
2004
2022
  }
2005
2023
 
2006
2024
  var VAL_READY_PING_MS = 100;
2025
+
2026
+ /**
2027
+ * Whether the Studio's stylesheet has loaded in this page. `val-css-loaded`
2028
+ * fires once per page, so a `ValApp` that mounts again after it -- the `/val`
2029
+ * route left and come back to -- must not wait for it a second time.
2030
+ */
2031
+ var studioStylesLoaded = false;
2032
+
2033
+ /**
2034
+ * The longest the loading screen covers the page. Past it, whatever the Studio
2035
+ * shows -- unstyled, or its own error -- is better than a spinner that never
2036
+ * ends.
2037
+ */
2038
+ var LOADING_SCREEN_MAX_MS = 15000;
2007
2039
  var ValApp = function ValApp(_ref) {
2008
2040
  var config = _ref.config,
2009
2041
  children = _ref.children;
@@ -2037,11 +2069,40 @@ var ValApp = function ValApp(_ref) {
2037
2069
  }
2038
2070
  });
2039
2071
 
2040
- // this theme is used to avoid flickering
2041
- var _useState3 = React.useState(config.defaultTheme || null),
2072
+ /*
2073
+ * Whether the loading screen still covers the page: until the Studio's
2074
+ * stylesheet has loaded, or the wait runs out. Its own state rather than
2075
+ * `loadingTheme`, which a new `config` sets again after the event has fired.
2076
+ */
2077
+ var _useState3 = React.useState(function () {
2078
+ return !studioStylesLoaded;
2079
+ }),
2042
2080
  _useState4 = createForOfIteratorHelper._slicedToArray(_useState3, 2),
2043
- loadingTheme = _useState4[0],
2044
- setLoadingTheme = _useState4[1];
2081
+ covering = _useState4[0],
2082
+ setCovering = _useState4[1];
2083
+ React.useEffect(function () {
2084
+ if (!covering) {
2085
+ return;
2086
+ }
2087
+ var onCssLoaded = function onCssLoaded() {
2088
+ studioStylesLoaded = true;
2089
+ setCovering(false);
2090
+ };
2091
+ window.addEventListener("val-css-loaded", onCssLoaded);
2092
+ var timeout = setTimeout(function () {
2093
+ return setCovering(false);
2094
+ }, LOADING_SCREEN_MAX_MS);
2095
+ return function () {
2096
+ window.removeEventListener("val-css-loaded", onCssLoaded);
2097
+ clearTimeout(timeout);
2098
+ };
2099
+ }, [covering]);
2100
+
2101
+ // this theme is used to avoid flickering
2102
+ var _useState5 = React.useState(config.defaultTheme || null),
2103
+ _useState6 = createForOfIteratorHelper._slicedToArray(_useState5, 2),
2104
+ loadingTheme = _useState6[0],
2105
+ setLoadingTheme = _useState6[1];
2045
2106
  React.useEffect(function () {
2046
2107
  var theme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
2047
2108
  if (theme === "dark") {
@@ -2082,36 +2143,49 @@ var ValApp = function ValApp(_ref) {
2082
2143
  window.removeEventListener("val-css-loaded", onCssLoaded);
2083
2144
  };
2084
2145
  }, [inMessageMode, loadingTheme]);
2085
- if (loadingTheme !== null && isClientSIde) {
2086
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2087
- style: {
2088
- color: loadingTheme === "dark" ? "white" : "black",
2089
- display: "flex",
2090
- justifyContent: "center",
2091
- alignItems: "center",
2092
- padding: "1rem",
2093
- backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2094
- minHeight: "100vh",
2095
- minWidth: "100%"
2096
- },
2097
- children: [/*#__PURE__*/jsxRuntime.jsx("style", {
2098
- children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2099
- }), /*#__PURE__*/jsxRuntime.jsx("svg", {
2100
- xmlns: "http://www.w3.org/2000/svg",
2101
- width: "24",
2102
- height: "24",
2103
- viewBox: "0 0 24 24",
2104
- fill: "none",
2105
- stroke: "currentColor",
2106
- strokeWidth: "2",
2107
- strokeLinecap: "round",
2108
- strokeLinejoin: "round",
2109
- className: cn(["animate-spin"]),
2110
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
2111
- d: "M21 12a9 9 0 1 1-6.219-8.56"
2112
- })
2113
- })]
2114
- });
2146
+
2147
+ /*
2148
+ * The loading screen stays up until the Studio's stylesheet has loaded, as
2149
+ * an overlay above the Studio mounting underneath it. It used to be rendered
2150
+ * INSTEAD of the Studio and dropped at hydration, which was before the
2151
+ * Studio's script had even been requested: the spinner went, an empty page
2152
+ * stood there while the Studio downloaded, and then the Studio appeared.
2153
+ * It is the first element both in the server render and after, so hydration
2154
+ * keeps it rather than restarting it. Only with a theme to draw it in --
2155
+ * `config.defaultTheme`, as the templates set -- as before.
2156
+ */
2157
+ var loadingScreen = !covering || loadingTheme === null || inMessageMode ? null : /*#__PURE__*/jsxRuntime.jsxs("div", {
2158
+ style: {
2159
+ color: loadingTheme === "dark" ? "white" : "black",
2160
+ display: "flex",
2161
+ justifyContent: "center",
2162
+ alignItems: "center",
2163
+ padding: "1rem",
2164
+ backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2165
+ position: "fixed",
2166
+ inset: 0,
2167
+ zIndex: 2147483647
2168
+ },
2169
+ children: [/*#__PURE__*/jsxRuntime.jsx("style", {
2170
+ children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2171
+ }), /*#__PURE__*/jsxRuntime.jsx("svg", {
2172
+ xmlns: "http://www.w3.org/2000/svg",
2173
+ width: "24",
2174
+ height: "24",
2175
+ viewBox: "0 0 24 24",
2176
+ fill: "none",
2177
+ stroke: "currentColor",
2178
+ strokeWidth: "2",
2179
+ strokeLinecap: "round",
2180
+ strokeLinejoin: "round",
2181
+ className: cn(["animate-spin"]),
2182
+ children: /*#__PURE__*/jsxRuntime.jsx("path", {
2183
+ d: "M21 12a9 9 0 1 1-6.219-8.56"
2184
+ })
2185
+ })]
2186
+ });
2187
+ if (isClientSIde && loadingScreen !== null) {
2188
+ return loadingScreen;
2115
2189
  }
2116
2190
  if (inMessageMode) {
2117
2191
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -2119,7 +2193,7 @@ var ValApp = function ValApp(_ref) {
2119
2193
  });
2120
2194
  }
2121
2195
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2122
- children: [/*#__PURE__*/jsxRuntime.jsx(ValScript, {
2196
+ children: [loadingScreen, /*#__PURE__*/jsxRuntime.jsx(ValScript, {
2123
2197
  src: "".concat(route, "/static").concat(ui.VERSION ? "/".concat(ui.VERSION) : "").concat(ui.VAL_APP_PATH)
2124
2198
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
2125
2199
  id: ui.VAL_APP_ID,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('./version-e4ae0afe.cjs.prod.js');
5
+ var version = require('./version-2cbea560.cjs.prod.js');
6
6
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-9afd7d2d.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
@@ -1162,7 +1162,7 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1162
1162
  setMountOverlay(false);
1163
1163
  return;
1164
1164
  }
1165
- setIsCanvas(client.isValCanvasFrame(location.search));
1165
+ setIsCanvas(client.isValCanvasFrame(location.search, readParentPathname()));
1166
1166
  setMountOverlay(hasValEnableCookie(document.cookie));
1167
1167
  }, []);
1168
1168
  React__default["default"].useEffect(function () {
@@ -1698,6 +1698,24 @@ function isValStudioPath(pathname) {
1698
1698
  return pathname.startsWith("/val");
1699
1699
  }
1700
1700
 
1701
+ /**
1702
+ * The path of the window framing this document, or `null`.
1703
+ *
1704
+ * `null` for a top-level document, and for a parent on another origin: reading
1705
+ * a cross-origin `location` throws, and a page on another origin is not the
1706
+ * studio, whose canvas is always the same app. See `isValCanvasFrame`.
1707
+ */
1708
+ function readParentPathname() {
1709
+ try {
1710
+ if (window.parent === window) {
1711
+ return null;
1712
+ }
1713
+ return window.parent.location.pathname;
1714
+ } catch (_unused) {
1715
+ return null;
1716
+ }
1717
+ }
1718
+
1701
1719
  // function ValIcon() {
1702
1720
  // return (
1703
1721
  // <svg
@@ -2004,6 +2022,20 @@ function ValVideo(props) {
2004
2022
  }
2005
2023
 
2006
2024
  var VAL_READY_PING_MS = 100;
2025
+
2026
+ /**
2027
+ * Whether the Studio's stylesheet has loaded in this page. `val-css-loaded`
2028
+ * fires once per page, so a `ValApp` that mounts again after it -- the `/val`
2029
+ * route left and come back to -- must not wait for it a second time.
2030
+ */
2031
+ var studioStylesLoaded = false;
2032
+
2033
+ /**
2034
+ * The longest the loading screen covers the page. Past it, whatever the Studio
2035
+ * shows -- unstyled, or its own error -- is better than a spinner that never
2036
+ * ends.
2037
+ */
2038
+ var LOADING_SCREEN_MAX_MS = 15000;
2007
2039
  var ValApp = function ValApp(_ref) {
2008
2040
  var config = _ref.config,
2009
2041
  children = _ref.children;
@@ -2037,11 +2069,40 @@ var ValApp = function ValApp(_ref) {
2037
2069
  }
2038
2070
  });
2039
2071
 
2040
- // this theme is used to avoid flickering
2041
- var _useState3 = React.useState(config.defaultTheme || null),
2072
+ /*
2073
+ * Whether the loading screen still covers the page: until the Studio's
2074
+ * stylesheet has loaded, or the wait runs out. Its own state rather than
2075
+ * `loadingTheme`, which a new `config` sets again after the event has fired.
2076
+ */
2077
+ var _useState3 = React.useState(function () {
2078
+ return !studioStylesLoaded;
2079
+ }),
2042
2080
  _useState4 = createForOfIteratorHelper._slicedToArray(_useState3, 2),
2043
- loadingTheme = _useState4[0],
2044
- setLoadingTheme = _useState4[1];
2081
+ covering = _useState4[0],
2082
+ setCovering = _useState4[1];
2083
+ React.useEffect(function () {
2084
+ if (!covering) {
2085
+ return;
2086
+ }
2087
+ var onCssLoaded = function onCssLoaded() {
2088
+ studioStylesLoaded = true;
2089
+ setCovering(false);
2090
+ };
2091
+ window.addEventListener("val-css-loaded", onCssLoaded);
2092
+ var timeout = setTimeout(function () {
2093
+ return setCovering(false);
2094
+ }, LOADING_SCREEN_MAX_MS);
2095
+ return function () {
2096
+ window.removeEventListener("val-css-loaded", onCssLoaded);
2097
+ clearTimeout(timeout);
2098
+ };
2099
+ }, [covering]);
2100
+
2101
+ // this theme is used to avoid flickering
2102
+ var _useState5 = React.useState(config.defaultTheme || null),
2103
+ _useState6 = createForOfIteratorHelper._slicedToArray(_useState5, 2),
2104
+ loadingTheme = _useState6[0],
2105
+ setLoadingTheme = _useState6[1];
2045
2106
  React.useEffect(function () {
2046
2107
  var theme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
2047
2108
  if (theme === "dark") {
@@ -2082,36 +2143,49 @@ var ValApp = function ValApp(_ref) {
2082
2143
  window.removeEventListener("val-css-loaded", onCssLoaded);
2083
2144
  };
2084
2145
  }, [inMessageMode, loadingTheme]);
2085
- if (loadingTheme !== null && isClientSIde) {
2086
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2087
- style: {
2088
- color: loadingTheme === "dark" ? "white" : "black",
2089
- display: "flex",
2090
- justifyContent: "center",
2091
- alignItems: "center",
2092
- padding: "1rem",
2093
- backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2094
- minHeight: "100vh",
2095
- minWidth: "100%"
2096
- },
2097
- children: [/*#__PURE__*/jsxRuntime.jsx("style", {
2098
- children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2099
- }), /*#__PURE__*/jsxRuntime.jsx("svg", {
2100
- xmlns: "http://www.w3.org/2000/svg",
2101
- width: "24",
2102
- height: "24",
2103
- viewBox: "0 0 24 24",
2104
- fill: "none",
2105
- stroke: "currentColor",
2106
- strokeWidth: "2",
2107
- strokeLinecap: "round",
2108
- strokeLinejoin: "round",
2109
- className: cn(["animate-spin"]),
2110
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
2111
- d: "M21 12a9 9 0 1 1-6.219-8.56"
2112
- })
2113
- })]
2114
- });
2146
+
2147
+ /*
2148
+ * The loading screen stays up until the Studio's stylesheet has loaded, as
2149
+ * an overlay above the Studio mounting underneath it. It used to be rendered
2150
+ * INSTEAD of the Studio and dropped at hydration, which was before the
2151
+ * Studio's script had even been requested: the spinner went, an empty page
2152
+ * stood there while the Studio downloaded, and then the Studio appeared.
2153
+ * It is the first element both in the server render and after, so hydration
2154
+ * keeps it rather than restarting it. Only with a theme to draw it in --
2155
+ * `config.defaultTheme`, as the templates set -- as before.
2156
+ */
2157
+ var loadingScreen = !covering || loadingTheme === null || inMessageMode ? null : /*#__PURE__*/jsxRuntime.jsxs("div", {
2158
+ style: {
2159
+ color: loadingTheme === "dark" ? "white" : "black",
2160
+ display: "flex",
2161
+ justifyContent: "center",
2162
+ alignItems: "center",
2163
+ padding: "1rem",
2164
+ backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2165
+ position: "fixed",
2166
+ inset: 0,
2167
+ zIndex: 2147483647
2168
+ },
2169
+ children: [/*#__PURE__*/jsxRuntime.jsx("style", {
2170
+ children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2171
+ }), /*#__PURE__*/jsxRuntime.jsx("svg", {
2172
+ xmlns: "http://www.w3.org/2000/svg",
2173
+ width: "24",
2174
+ height: "24",
2175
+ viewBox: "0 0 24 24",
2176
+ fill: "none",
2177
+ stroke: "currentColor",
2178
+ strokeWidth: "2",
2179
+ strokeLinecap: "round",
2180
+ strokeLinejoin: "round",
2181
+ className: cn(["animate-spin"]),
2182
+ children: /*#__PURE__*/jsxRuntime.jsx("path", {
2183
+ d: "M21 12a9 9 0 1 1-6.219-8.56"
2184
+ })
2185
+ })]
2186
+ });
2187
+ if (isClientSIde && loadingScreen !== null) {
2188
+ return loadingScreen;
2115
2189
  }
2116
2190
  if (inMessageMode) {
2117
2191
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -2119,7 +2193,7 @@ var ValApp = function ValApp(_ref) {
2119
2193
  });
2120
2194
  }
2121
2195
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2122
- children: [/*#__PURE__*/jsxRuntime.jsx(ValScript, {
2196
+ children: [loadingScreen, /*#__PURE__*/jsxRuntime.jsx(ValScript, {
2123
2197
  src: "".concat(route, "/static").concat(ui.VERSION ? "/".concat(ui.VERSION) : "").concat(ui.VAL_APP_PATH)
2124
2198
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
2125
2199
  id: ui.VAL_APP_ID,
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-f105d9fa.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-4da65f4f.esm.js';
2
2
  import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper } from './createForOfIteratorHelper-93a62170.esm.js';
3
3
  import { Internal as Internal$1, initVal as initVal$1, DEFAULT_CONTENT_HOST } from '@valbuild/core';
4
4
  import * as core from '@valbuild/core';
@@ -1138,7 +1138,7 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1138
1138
  setMountOverlay(false);
1139
1139
  return;
1140
1140
  }
1141
- setIsCanvas(isValCanvasFrame(location.search));
1141
+ setIsCanvas(isValCanvasFrame(location.search, readParentPathname()));
1142
1142
  setMountOverlay(hasValEnableCookie(document.cookie));
1143
1143
  }, []);
1144
1144
  React.useEffect(function () {
@@ -1674,6 +1674,24 @@ function isValStudioPath(pathname) {
1674
1674
  return pathname.startsWith("/val");
1675
1675
  }
1676
1676
 
1677
+ /**
1678
+ * The path of the window framing this document, or `null`.
1679
+ *
1680
+ * `null` for a top-level document, and for a parent on another origin: reading
1681
+ * a cross-origin `location` throws, and a page on another origin is not the
1682
+ * studio, whose canvas is always the same app. See `isValCanvasFrame`.
1683
+ */
1684
+ function readParentPathname() {
1685
+ try {
1686
+ if (window.parent === window) {
1687
+ return null;
1688
+ }
1689
+ return window.parent.location.pathname;
1690
+ } catch (_unused) {
1691
+ return null;
1692
+ }
1693
+ }
1694
+
1677
1695
  // function ValIcon() {
1678
1696
  // return (
1679
1697
  // <svg
@@ -1980,6 +1998,20 @@ function ValVideo(props) {
1980
1998
  }
1981
1999
 
1982
2000
  var VAL_READY_PING_MS = 100;
2001
+
2002
+ /**
2003
+ * Whether the Studio's stylesheet has loaded in this page. `val-css-loaded`
2004
+ * fires once per page, so a `ValApp` that mounts again after it -- the `/val`
2005
+ * route left and come back to -- must not wait for it a second time.
2006
+ */
2007
+ var studioStylesLoaded = false;
2008
+
2009
+ /**
2010
+ * The longest the loading screen covers the page. Past it, whatever the Studio
2011
+ * shows -- unstyled, or its own error -- is better than a spinner that never
2012
+ * ends.
2013
+ */
2014
+ var LOADING_SCREEN_MAX_MS = 15000;
1983
2015
  var ValApp = function ValApp(_ref) {
1984
2016
  var config = _ref.config,
1985
2017
  children = _ref.children;
@@ -2013,11 +2045,40 @@ var ValApp = function ValApp(_ref) {
2013
2045
  }
2014
2046
  });
2015
2047
 
2016
- // this theme is used to avoid flickering
2017
- var _useState3 = useState(config.defaultTheme || null),
2048
+ /*
2049
+ * Whether the loading screen still covers the page: until the Studio's
2050
+ * stylesheet has loaded, or the wait runs out. Its own state rather than
2051
+ * `loadingTheme`, which a new `config` sets again after the event has fired.
2052
+ */
2053
+ var _useState3 = useState(function () {
2054
+ return !studioStylesLoaded;
2055
+ }),
2018
2056
  _useState4 = _slicedToArray(_useState3, 2),
2019
- loadingTheme = _useState4[0],
2020
- setLoadingTheme = _useState4[1];
2057
+ covering = _useState4[0],
2058
+ setCovering = _useState4[1];
2059
+ useEffect(function () {
2060
+ if (!covering) {
2061
+ return;
2062
+ }
2063
+ var onCssLoaded = function onCssLoaded() {
2064
+ studioStylesLoaded = true;
2065
+ setCovering(false);
2066
+ };
2067
+ window.addEventListener("val-css-loaded", onCssLoaded);
2068
+ var timeout = setTimeout(function () {
2069
+ return setCovering(false);
2070
+ }, LOADING_SCREEN_MAX_MS);
2071
+ return function () {
2072
+ window.removeEventListener("val-css-loaded", onCssLoaded);
2073
+ clearTimeout(timeout);
2074
+ };
2075
+ }, [covering]);
2076
+
2077
+ // this theme is used to avoid flickering
2078
+ var _useState5 = useState(config.defaultTheme || null),
2079
+ _useState6 = _slicedToArray(_useState5, 2),
2080
+ loadingTheme = _useState6[0],
2081
+ setLoadingTheme = _useState6[1];
2021
2082
  useEffect(function () {
2022
2083
  var theme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
2023
2084
  if (theme === "dark") {
@@ -2058,36 +2119,49 @@ var ValApp = function ValApp(_ref) {
2058
2119
  window.removeEventListener("val-css-loaded", onCssLoaded);
2059
2120
  };
2060
2121
  }, [inMessageMode, loadingTheme]);
2061
- if (loadingTheme !== null && isClientSIde) {
2062
- return /*#__PURE__*/jsxs("div", {
2063
- style: {
2064
- color: loadingTheme === "dark" ? "white" : "black",
2065
- display: "flex",
2066
- justifyContent: "center",
2067
- alignItems: "center",
2068
- padding: "1rem",
2069
- backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2070
- minHeight: "100vh",
2071
- minWidth: "100%"
2072
- },
2073
- children: [/*#__PURE__*/jsx("style", {
2074
- children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2075
- }), /*#__PURE__*/jsx("svg", {
2076
- xmlns: "http://www.w3.org/2000/svg",
2077
- width: "24",
2078
- height: "24",
2079
- viewBox: "0 0 24 24",
2080
- fill: "none",
2081
- stroke: "currentColor",
2082
- strokeWidth: "2",
2083
- strokeLinecap: "round",
2084
- strokeLinejoin: "round",
2085
- className: cn(["animate-spin"]),
2086
- children: /*#__PURE__*/jsx("path", {
2087
- d: "M21 12a9 9 0 1 1-6.219-8.56"
2088
- })
2089
- })]
2090
- });
2122
+
2123
+ /*
2124
+ * The loading screen stays up until the Studio's stylesheet has loaded, as
2125
+ * an overlay above the Studio mounting underneath it. It used to be rendered
2126
+ * INSTEAD of the Studio and dropped at hydration, which was before the
2127
+ * Studio's script had even been requested: the spinner went, an empty page
2128
+ * stood there while the Studio downloaded, and then the Studio appeared.
2129
+ * It is the first element both in the server render and after, so hydration
2130
+ * keeps it rather than restarting it. Only with a theme to draw it in --
2131
+ * `config.defaultTheme`, as the templates set -- as before.
2132
+ */
2133
+ var loadingScreen = !covering || loadingTheme === null || inMessageMode ? null : /*#__PURE__*/jsxs("div", {
2134
+ style: {
2135
+ color: loadingTheme === "dark" ? "white" : "black",
2136
+ display: "flex",
2137
+ justifyContent: "center",
2138
+ alignItems: "center",
2139
+ padding: "1rem",
2140
+ backgroundColor: loadingTheme === "dark" ? darkBg : lightBg,
2141
+ position: "fixed",
2142
+ inset: 0,
2143
+ zIndex: 2147483647
2144
+ },
2145
+ children: [/*#__PURE__*/jsx("style", {
2146
+ children: ".".concat(valPrefixedClass, "animate-spin {\n animation: ").concat(valPrefixedClass, "spin 2s linear infinite;\n}\n@keyframes ").concat(valPrefixedClass, "spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}")
2147
+ }), /*#__PURE__*/jsx("svg", {
2148
+ xmlns: "http://www.w3.org/2000/svg",
2149
+ width: "24",
2150
+ height: "24",
2151
+ viewBox: "0 0 24 24",
2152
+ fill: "none",
2153
+ stroke: "currentColor",
2154
+ strokeWidth: "2",
2155
+ strokeLinecap: "round",
2156
+ strokeLinejoin: "round",
2157
+ className: cn(["animate-spin"]),
2158
+ children: /*#__PURE__*/jsx("path", {
2159
+ d: "M21 12a9 9 0 1 1-6.219-8.56"
2160
+ })
2161
+ })]
2162
+ });
2163
+ if (isClientSIde && loadingScreen !== null) {
2164
+ return loadingScreen;
2091
2165
  }
2092
2166
  if (inMessageMode) {
2093
2167
  return /*#__PURE__*/jsx("div", {
@@ -2095,7 +2169,7 @@ var ValApp = function ValApp(_ref) {
2095
2169
  });
2096
2170
  }
2097
2171
  return /*#__PURE__*/jsxs(Fragment, {
2098
- children: [/*#__PURE__*/jsx(ValScript, {
2172
+ children: [loadingScreen, /*#__PURE__*/jsx(ValScript, {
2099
2173
  src: "".concat(route, "/static").concat(VERSION ? "/".concat(VERSION) : "").concat(VAL_APP_PATH)
2100
2174
  }), /*#__PURE__*/jsx("div", {
2101
2175
  id: VAL_APP_ID,
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.146.2",
215
+ version: "0.146.4",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -212,7 +212,7 @@ var packageJson = {
212
212
  "tanstack-router",
213
213
  "react"
214
214
  ],
215
- version: "0.146.2",
215
+ version: "0.146.4",
216
216
  scripts: {
217
217
  typecheck: "tsc --noEmit",
218
218
  test: "jest"
@@ -210,7 +210,7 @@ var packageJson = {
210
210
  "tanstack-router",
211
211
  "react"
212
212
  ],
213
- version: "0.146.2",
213
+ version: "0.146.4",
214
214
  scripts: {
215
215
  typecheck: "tsc --noEmit",
216
216
  test: "jest"
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "tanstack-router",
15
15
  "react"
16
16
  ],
17
- "version": "0.146.2",
17
+ "version": "0.146.4",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -43,12 +43,12 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@valbuild/core": "0.146.2",
46
- "@valbuild/language-server": "0.146.2",
47
- "@valbuild/mcp": "0.146.2",
48
- "@valbuild/react": "0.146.2",
49
- "@valbuild/server": "0.146.2",
50
- "@valbuild/shared": "0.146.2",
51
- "@valbuild/ui": "0.146.2"
46
+ "@valbuild/language-server": "0.146.4",
47
+ "@valbuild/mcp": "0.146.4",
48
+ "@valbuild/react": "0.146.4",
49
+ "@valbuild/server": "0.146.4",
50
+ "@valbuild/shared": "0.146.4",
51
+ "@valbuild/ui": "0.146.4"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@tanstack/react-router": "^1.170.41",
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-5162728d.cjs.dev.js');
5
+ var version = require('../../dist/version-1f65da50.cjs.dev.js');
6
6
  var core = require('@valbuild/core');
7
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-4497beef.cjs.dev.js');
8
8
  var server = require('@valbuild/server');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-e4ae0afe.cjs.prod.js');
5
+ var version = require('../../dist/version-2cbea560.cjs.prod.js');
6
6
  var core = require('@valbuild/core');
7
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-9afd7d2d.cjs.prod.js');
8
8
  var server = require('@valbuild/server');
@@ -1,4 +1,4 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-f105d9fa.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator, V as VERSION, s as setValEnableCookieReader } from '../../dist/version-4da65f4f.esm.js';
2
2
  import { Internal } from '@valbuild/core';
3
3
  import { _ as _objectSpread2, a as _slicedToArray, e as _arrayLikeToArray, f as _unsupportedIterableToArray, b as _createForOfIteratorHelper, d as _defineProperty } from '../../dist/createForOfIteratorHelper-93a62170.esm.js';
4
4
  import { createValApiRouter, createValServer, layeredSnapshot, proposalSnapshotForReaders, proposalSnapshot } from '@valbuild/server';