@valbuild/tanstack 0.146.3 → 0.147.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 (39) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/client/dist/valbuild-tanstack-client.cjs.dev.js +6 -6
  3. package/client/dist/valbuild-tanstack-client.cjs.prod.js +6 -6
  4. package/client/dist/valbuild-tanstack-client.esm.js +4 -4
  5. package/demo/dist/valbuild-tanstack-demo.cjs.d.ts +2 -0
  6. package/demo/dist/valbuild-tanstack-demo.cjs.dev.js +105 -0
  7. package/demo/dist/valbuild-tanstack-demo.cjs.js +7 -0
  8. package/demo/dist/valbuild-tanstack-demo.cjs.prod.js +105 -0
  9. package/demo/dist/valbuild-tanstack-demo.esm.js +101 -0
  10. package/demo/package.json +4 -0
  11. package/dist/{ValOverlayContext-3f080cce.cjs.dev.js → ValOverlayContext-510328ec.cjs.dev.js} +17 -17
  12. package/dist/{ValOverlayContext-59a0b19f.esm.js → ValOverlayContext-6278320b.esm.js} +1 -1
  13. package/dist/{ValOverlayContext-3e2c48a6.cjs.prod.js → ValOverlayContext-d3acd157.cjs.prod.js} +17 -17
  14. package/dist/{version-d506fa5a.esm.js → asyncToGenerator-500f022f.esm.js} +1 -149
  15. package/dist/{version-2e1a465b.cjs.prod.js → asyncToGenerator-8e5c36c8.cjs.prod.js} +0 -151
  16. package/dist/{version-1226397e.cjs.dev.js → asyncToGenerator-c3823d62.cjs.dev.js} +0 -151
  17. package/dist/declarations/src/ValApp.d.ts +15 -1
  18. package/dist/declarations/src/ValProvider.d.ts +1 -0
  19. package/dist/declarations/src/demo/index.d.ts +7 -0
  20. package/dist/declarations/src/demo/initValDemoServer.d.ts +27 -0
  21. package/dist/demoServiceWorker-382e1b63.cjs.dev.js +60 -0
  22. package/dist/demoServiceWorker-56fd96cf.esm.js +55 -0
  23. package/dist/demoServiceWorker-994710f7.cjs.prod.js +60 -0
  24. package/dist/{routeFromVal-385ee69c.cjs.dev.js → routeFromVal-0ea4586f.cjs.dev.js} +17 -24
  25. package/dist/{routeFromVal-ffa948ef.cjs.prod.js → routeFromVal-97a52f43.cjs.prod.js} +17 -24
  26. package/dist/{routeFromVal-ae54a17e.esm.js → routeFromVal-9f1f8725.esm.js} +7 -13
  27. package/dist/{createForOfIteratorHelper-93a62170.esm.js → typeof-66e2d869.esm.js} +11 -1
  28. package/dist/{createForOfIteratorHelper-9afd7d2d.cjs.prod.js → typeof-8998e126.cjs.prod.js} +11 -0
  29. package/dist/{createForOfIteratorHelper-4497beef.cjs.dev.js → typeof-dd0246a1.cjs.dev.js} +11 -0
  30. package/dist/valbuild-tanstack.cjs.dev.js +390 -43
  31. package/dist/valbuild-tanstack.cjs.prod.js +390 -43
  32. package/dist/valbuild-tanstack.esm.js +356 -9
  33. package/dist/version-1ae7092b.esm.js +174 -0
  34. package/dist/version-83d7f4b7.cjs.prod.js +179 -0
  35. package/dist/version-a820698f.cjs.dev.js +179 -0
  36. package/package.json +16 -10
  37. package/server/dist/valbuild-tanstack-server.cjs.dev.js +60 -75
  38. package/server/dist/valbuild-tanstack-server.cjs.prod.js +60 -75
  39. package/server/dist/valbuild-tanstack-server.esm.js +4 -19
@@ -1,17 +1,19 @@
1
- import { _ as _asyncToGenerator, a as _regenerator, r as readValEnableCookie, V as VERSION$1 } from './version-d506fa5a.esm.js';
2
- import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper } from './createForOfIteratorHelper-93a62170.esm.js';
1
+ import { _ as _asyncToGenerator, a as _regenerator } from './asyncToGenerator-500f022f.esm.js';
2
+ import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper, c as _typeof } from './typeof-66e2d869.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';
5
5
  export { core as expr };
6
6
  export { GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
7
7
  import { stegaEncode, stegaDecodeStrings, attrs, raw, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX } from '@valbuild/react/stega';
8
+ import { r as readValEnableCookie, _ as _toConsumableArray, V as VERSION$1 } from './version-1ae7092b.esm.js';
8
9
  export { ValRichText } from '@valbuild/react/internal';
9
10
  import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID, VAL_APP_ID } from '@valbuild/ui';
10
11
  import { useRouter, useRouterState } from '@tanstack/react-router';
11
12
  import React, { useEffect, useRef, useState } from 'react';
12
- import { V as ValExternalStore, a as ValOverlayProvider } from './ValOverlayContext-59a0b19f.esm.js';
13
+ import { V as ValExternalStore, a as ValOverlayProvider } from './ValOverlayContext-6278320b.esm.js';
13
14
  import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, isValCanvasFrame } from '@valbuild/shared/client';
14
15
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
16
+ import { D as DEMO_CLAIM_MESSAGE, a as DEMO_SERVICE_WORKER_PATH, b as DEMO_RELAY_MESSAGE } from './demoServiceWorker-56fd96cf.esm.js';
15
17
  import '@valbuild/core/patch';
16
18
 
17
19
  function getUnpatchedUnencodedVal(selector) {
@@ -1138,7 +1140,17 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1138
1140
  setMountOverlay(false);
1139
1141
  return;
1140
1142
  }
1141
- setIsCanvas(isValCanvasFrame(location.search));
1143
+ if (props.demo) {
1144
+ // Only the canvas, and always as the draft: see `demo`.
1145
+ var canvas = isValCanvasFrame(location.search, readParentPathname());
1146
+ setIsCanvas(canvas);
1147
+ setMountOverlay(canvas);
1148
+ if (canvas) {
1149
+ setDraftMode(true);
1150
+ }
1151
+ return;
1152
+ }
1153
+ setIsCanvas(isValCanvasFrame(location.search, readParentPathname()));
1142
1154
  setMountOverlay(hasValEnableCookie(document.cookie));
1143
1155
  }, []);
1144
1156
  React.useEffect(function () {
@@ -1185,7 +1197,9 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1185
1197
  * there are any.
1186
1198
  */
1187
1199
  React.useEffect(function () {
1188
- if (!mountOverlay || props.disableRefresh) {
1200
+ // A demo's loaders read a server that never sees the tab's edits, so
1201
+ // re-running them would only fetch the published content again.
1202
+ if (!mountOverlay || props.disableRefresh || props.demo) {
1189
1203
  return;
1190
1204
  }
1191
1205
  var timer = null;
@@ -1275,7 +1289,7 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1275
1289
  clearInterval(safety);
1276
1290
  if (timer !== null) clearTimeout(timer);
1277
1291
  };
1278
- }, [mountOverlay, props.disableRefresh]);
1292
+ }, [mountOverlay, props.disableRefresh, props.demo]);
1279
1293
  React.useEffect(function () {
1280
1294
  if (!mountOverlay) {
1281
1295
  return;
@@ -1325,7 +1339,9 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1325
1339
 
1326
1340
  var timeout;
1327
1341
  function pollCurrentDraftMode() {
1328
- if (!mountOverlay) {
1342
+ // A demo has no server to ask: draft mode is on in its canvas, and
1343
+ // nothing is mounted anywhere else.
1344
+ if (!mountOverlay || props.demo) {
1329
1345
  return;
1330
1346
  }
1331
1347
  window.dispatchEvent(new CustomEvent("val-overlay-spa", {
@@ -1402,7 +1418,7 @@ var ValTanStackProvider = function ValTanStackProvider(props) {
1402
1418
  return function () {
1403
1419
  clearTimeout(timeout);
1404
1420
  };
1405
- }, [mountOverlay, iframeSrc]);
1421
+ }, [mountOverlay, iframeSrc, props.demo]);
1406
1422
  React.useEffect(function () {
1407
1423
  if (!mountOverlay) {
1408
1424
  return;
@@ -1674,6 +1690,24 @@ function isValStudioPath(pathname) {
1674
1690
  return pathname.startsWith("/val");
1675
1691
  }
1676
1692
 
1693
+ /**
1694
+ * The path of the window framing this document, or `null`.
1695
+ *
1696
+ * `null` for a top-level document, and for a parent on another origin: reading
1697
+ * a cross-origin `location` throws, and a page on another origin is not the
1698
+ * studio, whose canvas is always the same app. See `isValCanvasFrame`.
1699
+ */
1700
+ function readParentPathname() {
1701
+ try {
1702
+ if (window.parent === window) {
1703
+ return null;
1704
+ }
1705
+ return window.parent.location.pathname;
1706
+ } catch (_unused) {
1707
+ return null;
1708
+ }
1709
+ }
1710
+
1677
1711
  // function ValIcon() {
1678
1712
  // return (
1679
1713
  // <svg
@@ -1979,6 +2013,154 @@ function ValVideo(props) {
1979
2013
  }));
1980
2014
  }
1981
2015
 
2016
+ /** A request the demo's service worker hands this tab. */
2017
+
2018
+ function isHeaderList(value) {
2019
+ return Array.isArray(value) && value.every(function (entry) {
2020
+ return Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "string";
2021
+ });
2022
+ }
2023
+ function isRelayRequest(value) {
2024
+ return _typeof(value) === "object" && value !== null && "type" in value && value.type === DEMO_RELAY_MESSAGE && "url" in value && typeof value.url === "string" && "method" in value && typeof value.method === "string" && "headers" in value && isHeaderList(value.headers) && "body" in value && (value.body === null || value.body instanceof ArrayBuffer);
2025
+ }
2026
+
2027
+ /** Statuses a `Response` may not be given a body with. */
2028
+ var NO_BODY = new Set([101, 204, 205, 304]);
2029
+ function answer(_x, _x2) {
2030
+ return _answer.apply(this, arguments);
2031
+ }
2032
+ /**
2033
+ * Make this tab the server for the demo's uploads and unpublished files.
2034
+ *
2035
+ * Registers the demo's service worker (see `DEMO_SERVICE_WORKER_SOURCE`) and
2036
+ * answers what it relays with the same in-tab server the Studio's client
2037
+ * uses. Resolves once the worker controls this page -- the Studio must not
2038
+ * start before, or the first images it asks for go past it to a server that
2039
+ * has none of them.
2040
+ *
2041
+ * Resolves `false` where a service worker cannot run: an insecure context
2042
+ * (plain http on anything but localhost), or a browser without them. Uploads
2043
+ * are then off, and the Studio says why.
2044
+ */
2045
+ function _answer() {
2046
+ _answer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fetch, request) {
2047
+ var res, body, _t;
2048
+ return _regenerator().w(function (_context) {
2049
+ while (1) switch (_context.n) {
2050
+ case 0:
2051
+ _context.n = 1;
2052
+ return fetch(request.url, {
2053
+ method: request.method,
2054
+ headers: request.headers,
2055
+ body: request.body
2056
+ });
2057
+ case 1:
2058
+ res = _context.v;
2059
+ if (!NO_BODY.has(res.status)) {
2060
+ _context.n = 2;
2061
+ break;
2062
+ }
2063
+ _t = null;
2064
+ _context.n = 4;
2065
+ break;
2066
+ case 2:
2067
+ _context.n = 3;
2068
+ return res.arrayBuffer();
2069
+ case 3:
2070
+ _t = _context.v;
2071
+ case 4:
2072
+ body = _t;
2073
+ return _context.a(2, {
2074
+ status: res.status,
2075
+ headers: _toConsumableArray(res.headers),
2076
+ body: body
2077
+ });
2078
+ }
2079
+ }, _callee);
2080
+ }));
2081
+ return _answer.apply(this, arguments);
2082
+ }
2083
+ function startDemoRelay(_x3) {
2084
+ return _startDemoRelay.apply(this, arguments);
2085
+ }
2086
+ function _startDemoRelay() {
2087
+ _startDemoRelay = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(fetch) {
2088
+ var container, registration, _registration$active, controlled, _t2;
2089
+ return _regenerator().w(function (_context2) {
2090
+ while (1) switch (_context2.p = _context2.n) {
2091
+ case 0:
2092
+ if (!(typeof navigator === "undefined" || !("serviceWorker" in navigator) || !window.isSecureContext)) {
2093
+ _context2.n = 1;
2094
+ break;
2095
+ }
2096
+ return _context2.a(2, false);
2097
+ case 1:
2098
+ container = navigator.serviceWorker;
2099
+ container.addEventListener("message", function (event) {
2100
+ var port = event.ports[0];
2101
+ if (!isRelayRequest(event.data) || !port) return;
2102
+ answer(fetch, event.data).then(function (res) {
2103
+ return port.postMessage(res, res.body ? [res.body] : []);
2104
+ })["catch"](function (err) {
2105
+ console.error("Val: the demo could not answer a relayed request", err);
2106
+ port.postMessage({
2107
+ status: 500,
2108
+ headers: [["Content-Type", "application/json"]],
2109
+ body: new TextEncoder().encode(JSON.stringify({
2110
+ message: "The demo's server failed to answer."
2111
+ })).buffer
2112
+ });
2113
+ });
2114
+ });
2115
+ // Messages are queued until this is called, when the listener is added with
2116
+ // `addEventListener` rather than assigned to `onmessage`.
2117
+ container.startMessages();
2118
+ _context2.p = 2;
2119
+ _context2.n = 3;
2120
+ return container.register("/api/val".concat(DEMO_SERVICE_WORKER_PATH), {
2121
+ scope: "/"
2122
+ });
2123
+ case 3:
2124
+ _context2.n = 4;
2125
+ return container.ready;
2126
+ case 4:
2127
+ registration = _context2.v;
2128
+ if (container.controller) {
2129
+ _context2.n = 5;
2130
+ break;
2131
+ }
2132
+ // Not controlled yet. On a first visit the worker claims this page when
2133
+ // it activates. After a hard reload (Shift+Reload) it has activated
2134
+ // already and a browser deliberately leaves the page uncontrolled, so
2135
+ // the page asks it to claim -- or this would wait out the timeout and
2136
+ // start with uploads off.
2137
+ controlled = new Promise(function (resolve) {
2138
+ var timer = setTimeout(resolve, 10000);
2139
+ container.addEventListener("controllerchange", function () {
2140
+ clearTimeout(timer);
2141
+ resolve();
2142
+ }, {
2143
+ once: true
2144
+ });
2145
+ });
2146
+ (_registration$active = registration.active) === null || _registration$active === void 0 || _registration$active.postMessage({
2147
+ type: DEMO_CLAIM_MESSAGE
2148
+ });
2149
+ _context2.n = 5;
2150
+ return controlled;
2151
+ case 5:
2152
+ return _context2.a(2, container.controller !== null);
2153
+ case 6:
2154
+ _context2.p = 6;
2155
+ _t2 = _context2.v;
2156
+ console.error("Val: the demo's service worker did not start", _t2);
2157
+ return _context2.a(2, false);
2158
+ }
2159
+ }, _callee2, null, [[2, 6]]);
2160
+ }));
2161
+ return _startDemoRelay.apply(this, arguments);
2162
+ }
2163
+
1982
2164
  var VAL_READY_PING_MS = 100;
1983
2165
 
1984
2166
  /**
@@ -1996,8 +2178,10 @@ var studioStylesLoaded = false;
1996
2178
  var LOADING_SCREEN_MAX_MS = 15000;
1997
2179
  var ValApp = function ValApp(_ref) {
1998
2180
  var config = _ref.config,
1999
- children = _ref.children;
2181
+ children = _ref.children,
2182
+ demo = _ref.demo;
2000
2183
  var route = "/api/val"; // TODO: make configurable
2184
+ var demoStart = useDemoServer(demo === true, config);
2001
2185
  var _useState = useState(),
2002
2186
  _useState2 = _slicedToArray(_useState, 2),
2003
2187
  inMessageMode = _useState2[0],
@@ -2150,6 +2334,21 @@ var ValApp = function ValApp(_ref) {
2150
2334
  children: "Val Studio is disabled: in message mode"
2151
2335
  });
2152
2336
  }
2337
+ if (demo && demoStart.status === "failed") {
2338
+ return /*#__PURE__*/jsxs(Fragment, {
2339
+ children: [/*#__PURE__*/jsx(DemoStartFailed, {
2340
+ failure: demoStart
2341
+ }), children]
2342
+ });
2343
+ }
2344
+ if (demo && demoStart.status !== "ready") {
2345
+ // The Studio reads `window.__VAL_DEMO__` when its script starts, so the
2346
+ // server it talks to has to be there first. The modules are registered
2347
+ // by a child (`ValModulesClient`), whose effect has run by then.
2348
+ return /*#__PURE__*/jsx(Fragment, {
2349
+ children: children
2350
+ });
2351
+ }
2153
2352
  return /*#__PURE__*/jsxs(Fragment, {
2154
2353
  children: [loadingScreen, /*#__PURE__*/jsx(ValScript, {
2155
2354
  src: "".concat(route, "/static").concat(VERSION ? "/".concat(VERSION) : "").concat(VAL_APP_PATH)
@@ -2160,6 +2359,154 @@ var ValApp = function ValApp(_ref) {
2160
2359
  });
2161
2360
  };
2162
2361
 
2362
+ /**
2363
+ * Starts Val's server in this tab, and hands it to the Studio.
2364
+ *
2365
+ * Loaded on demand: `@valbuild/server/browser` is the whole request-handling
2366
+ * half of the server, and only a demo should download it.
2367
+ */
2368
+
2369
+ function useDemoServer(demo, config) {
2370
+ var _useState7 = useState({
2371
+ status: "starting"
2372
+ }),
2373
+ _useState8 = _slicedToArray(_useState7, 2),
2374
+ start = _useState8[0],
2375
+ setStart = _useState8[1];
2376
+ useEffect(function () {
2377
+ if (!demo) return;
2378
+ var cancelled = false;
2379
+ var run = /*#__PURE__*/function () {
2380
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2381
+ var _yield$import, createInTabValFetch, modules, fetch, uploads, runtime;
2382
+ return _regenerator().w(function (_context) {
2383
+ while (1) switch (_context.n) {
2384
+ case 0:
2385
+ _context.n = 1;
2386
+ return import('@valbuild/server/browser');
2387
+ case 1:
2388
+ _yield$import = _context.v;
2389
+ createInTabValFetch = _yield$import.createInTabValFetch;
2390
+ modules = window.__VAL_MODULES__;
2391
+ if (modules) {
2392
+ _context.n = 2;
2393
+ break;
2394
+ }
2395
+ return _context.a(2, {
2396
+ status: "failed",
2397
+ message: "This demo was built without its content. Render <ValModulesClient modules={valModules} /> inside <ValApp demo>.",
2398
+ details: null,
2399
+ retryable: false
2400
+ });
2401
+ case 2:
2402
+ fetch = createInTabValFetch(modules, {
2403
+ config: config
2404
+ });
2405
+ _context.n = 3;
2406
+ return startDemoRelay(fetch);
2407
+ case 3:
2408
+ uploads = _context.v;
2409
+ runtime = {
2410
+ fetch: fetch,
2411
+ uploads: uploads
2412
+ };
2413
+ window.__VAL_DEMO__ = runtime;
2414
+ return _context.a(2, {
2415
+ status: "ready"
2416
+ });
2417
+ }
2418
+ }, _callee);
2419
+ }));
2420
+ return function run() {
2421
+ return _ref2.apply(this, arguments);
2422
+ };
2423
+ }();
2424
+ run()["catch"](function (err) {
2425
+ console.error("Val: the demo could not start", err);
2426
+ return {
2427
+ status: "failed",
2428
+ // Most often the server's code did not download: the page is fine,
2429
+ // and loading it again fetches it again.
2430
+ message: "The demo could not start: part of it did not load.",
2431
+ details: err instanceof Error ? err.message : String(err),
2432
+ retryable: true
2433
+ };
2434
+ }).then(function (result) {
2435
+ if (!cancelled) setStart(result);
2436
+ });
2437
+ return function () {
2438
+ cancelled = true;
2439
+ };
2440
+ }, [demo, config]);
2441
+ return start;
2442
+ }
2443
+
2444
+ /**
2445
+ * Said on the page, not only in the console: without it a demo that failed
2446
+ * to start is a site with no Studio and no reason given. Plain styles, since
2447
+ * the Studio's stylesheet is exactly what has not loaded.
2448
+ */
2449
+ function DemoStartFailed(_ref3) {
2450
+ var failure = _ref3.failure;
2451
+ return /*#__PURE__*/jsxs("div", {
2452
+ role: "alert",
2453
+ style: {
2454
+ position: "fixed",
2455
+ left: "1rem",
2456
+ right: "1rem",
2457
+ bottom: "1rem",
2458
+ maxWidth: "28rem",
2459
+ margin: "0 auto",
2460
+ padding: "1rem",
2461
+ borderRadius: "0.75rem",
2462
+ background: "white",
2463
+ color: "black",
2464
+ boxShadow: "0 8px 30px rgba(0, 0, 0, 0.2)",
2465
+ fontFamily: "system-ui, sans-serif",
2466
+ fontSize: "0.875rem",
2467
+ lineHeight: 1.4,
2468
+ zIndex: 2147483647
2469
+ },
2470
+ children: [/*#__PURE__*/jsx("p", {
2471
+ style: {
2472
+ margin: 0
2473
+ },
2474
+ children: failure.message
2475
+ }), failure.retryable && /*#__PURE__*/jsx("button", {
2476
+ type: "button",
2477
+ onClick: function onClick() {
2478
+ return window.location.reload();
2479
+ },
2480
+ style: {
2481
+ marginTop: "0.75rem",
2482
+ padding: "0.375rem 0.75rem",
2483
+ borderRadius: "0.375rem",
2484
+ border: "1px solid #ccc",
2485
+ background: "#f4f4f4",
2486
+ font: "inherit",
2487
+ cursor: "pointer"
2488
+ },
2489
+ children: "Try again"
2490
+ }), failure.details !== null && /*#__PURE__*/jsxs("details", {
2491
+ style: {
2492
+ marginTop: "0.75rem",
2493
+ color: "#555"
2494
+ },
2495
+ children: [/*#__PURE__*/jsx("summary", {
2496
+ style: {
2497
+ cursor: "pointer"
2498
+ },
2499
+ children: "Details"
2500
+ }), /*#__PURE__*/jsx("code", {
2501
+ style: {
2502
+ wordBreak: "break-word"
2503
+ },
2504
+ children: failure.details
2505
+ })]
2506
+ })]
2507
+ });
2508
+ }
2509
+
2163
2510
  // Keep in sync with VAL_MODULES_UPDATED_EVENT in @valbuild/ui (useValModules.ts).
2164
2511
  var VAL_MODULES_UPDATED_EVENT = "val-modules-updated";
2165
2512
 
@@ -0,0 +1,174 @@
1
+ import { _ as _asyncToGenerator, a as _regenerator } from './asyncToGenerator-500f022f.esm.js';
2
+ import { d as _arrayLikeToArray, e as _unsupportedIterableToArray } from './typeof-66e2d869.esm.js';
3
+
4
+ /**
5
+ * How `initVal().isValEnabled()` reaches the server without importing it.
6
+ *
7
+ * EXPERIMENTAL — see VAL_PROMPT.md.
8
+ *
9
+ * The cookie can only be read through `@tanstack/react-start/server`, and that
10
+ * module is reachable from this package's ROOT entry, which every client
11
+ * component imports. `initVal.ts` used `await import()` for exactly that reason,
12
+ * and under Vite the dynamic form does keep it out of the client bundle.
13
+ *
14
+ * It does not everywhere. A host that bundles this package ahead of time and
15
+ * audits what each chunk imports sees a dynamically imported chunk as a chunk
16
+ * like any other, and this one reaches TanStack's SSR path and lands on
17
+ * `node:stream/web`. That is why `@valbuild/tanstack` could not be built for a
18
+ * Cloudflare Worker at all.
19
+ *
20
+ * So the edge is inverted. The root entry holds a slot; `@valbuild/tanstack/server`
21
+ * fills it on import with the implementation that was already there,
22
+ * `hasValEnableCookieOnServer`. Nothing about the behaviour changes for an app
23
+ * that imports `/server` — which every app with a Val API does — and the root
24
+ * entry no longer names TanStack's server module at all.
25
+ *
26
+ * Ordering: the slot is filled when `/server` is first imported. An
27
+ * `isValEnabled()` call that somehow happens before that returns false, which
28
+ * is what the old implementation's `catch` returned in the same situation.
29
+ */
30
+
31
+ var reader = null;
32
+ function setValEnableCookieReader(read) {
33
+ reader = read;
34
+ }
35
+ function readValEnableCookie() {
36
+ return _readValEnableCookie.apply(this, arguments);
37
+ }
38
+ function _readValEnableCookie() {
39
+ _readValEnableCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
40
+ return _regenerator().w(function (_context) {
41
+ while (1) switch (_context.p = _context.n) {
42
+ case 0:
43
+ if (reader) {
44
+ _context.n = 1;
45
+ break;
46
+ }
47
+ return _context.a(2, false);
48
+ case 1:
49
+ _context.p = 1;
50
+ _context.n = 2;
51
+ return reader();
52
+ case 2:
53
+ return _context.a(2, _context.v);
54
+ case 3:
55
+ _context.p = 3;
56
+ _context.v;
57
+ return _context.a(2, false);
58
+ }
59
+ }, _callee, null, [[1, 3]]);
60
+ }));
61
+ return _readValEnableCookie.apply(this, arguments);
62
+ }
63
+
64
+ function _arrayWithoutHoles(r) {
65
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
66
+ }
67
+
68
+ function _iterableToArray(r) {
69
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
70
+ }
71
+
72
+ function _nonIterableSpread() {
73
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
74
+ }
75
+
76
+ function _toConsumableArray(r) {
77
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
78
+ }
79
+
80
+ var packageJson = {
81
+ name: "@valbuild/tanstack",
82
+ description: "Val for TanStack Start: hard-coded content - super-charged",
83
+ "private": false,
84
+ repository: {
85
+ type: "git",
86
+ url: "git+https://github.com/valbuild/val.git"
87
+ },
88
+ sideEffects: true,
89
+ keywords: [
90
+ "CMS",
91
+ "tanstack",
92
+ "tanstack-start",
93
+ "tanstack-router",
94
+ "react"
95
+ ],
96
+ version: "0.147.0",
97
+ scripts: {
98
+ typecheck: "tsc --noEmit",
99
+ test: "jest"
100
+ },
101
+ main: "dist/valbuild-tanstack.cjs.js",
102
+ module: "dist/valbuild-tanstack.esm.js",
103
+ exports: {
104
+ ".": {
105
+ module: "./dist/valbuild-tanstack.esm.js",
106
+ "default": "./dist/valbuild-tanstack.cjs.js"
107
+ },
108
+ "./demo": {
109
+ module: "./demo/dist/valbuild-tanstack-demo.esm.js",
110
+ "default": "./demo/dist/valbuild-tanstack-demo.cjs.js"
111
+ },
112
+ "./client": {
113
+ module: "./client/dist/valbuild-tanstack-client.esm.js",
114
+ "default": "./client/dist/valbuild-tanstack-client.cjs.js"
115
+ },
116
+ "./server": {
117
+ module: "./server/dist/valbuild-tanstack-server.esm.js",
118
+ "default": "./server/dist/valbuild-tanstack-server.cjs.js"
119
+ },
120
+ "./package.json": "./package.json"
121
+ },
122
+ types: "dist/valbuild-tanstack.cjs.d.ts",
123
+ preconstruct: {
124
+ entrypoints: [
125
+ "./index.ts",
126
+ "./server/index.ts",
127
+ "./client/index.ts",
128
+ "./demo/index.ts"
129
+ ],
130
+ exports: true
131
+ },
132
+ dependencies: {
133
+ "@valbuild/core": "workspace:*",
134
+ "@valbuild/language-server": "workspace:*",
135
+ "@valbuild/mcp": "workspace:*",
136
+ "@valbuild/react": "workspace:*",
137
+ "@valbuild/server": "workspace:*",
138
+ "@valbuild/shared": "workspace:*",
139
+ "@valbuild/ui": "workspace:*"
140
+ },
141
+ devDependencies: {
142
+ "@tanstack/react-router": "^1.170.41",
143
+ "@tanstack/react-start": "^1.168.60",
144
+ "@testing-library/react": "^16.3.3",
145
+ "@types/react": "^19.2.18",
146
+ "@types/react-dom": "^19.2.5",
147
+ "jest-environment-jsdom": "^30.5.0",
148
+ react: "^19.2.8",
149
+ "react-dom": "^19.2.8",
150
+ typescript: "^6.0.3"
151
+ },
152
+ peerDependencies: {
153
+ "@tanstack/react-router": ">=1.130.0",
154
+ "@tanstack/react-start": ">=1.130.0",
155
+ react: ">=19.0.0",
156
+ "react-dom": ">=19.0.0"
157
+ },
158
+ externals: [
159
+ "@tanstack/react-router",
160
+ "@tanstack/react-start"
161
+ ],
162
+ files: [
163
+ "CHANGELOG.md",
164
+ "dist",
165
+ "client",
166
+ "server",
167
+ "demo"
168
+ ]
169
+ };
170
+
171
+ var _packageJson$version;
172
+ var VERSION = (_packageJson$version = packageJson.version) !== null && _packageJson$version !== void 0 ? _packageJson$version : null;
173
+
174
+ export { VERSION as V, _toConsumableArray as _, readValEnableCookie as r, setValEnableCookieReader as s };