@valbuild/next 0.101.1 → 0.103.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 (35) hide show
  1. package/README.md +50 -1
  2. package/client/dist/valbuild-next-client.cjs.dev.js +25 -2
  3. package/client/dist/valbuild-next-client.cjs.prod.js +25 -2
  4. package/client/dist/valbuild-next-client.esm.js +25 -2
  5. package/dist/ValApp-90c4171d.cjs.js +7 -0
  6. package/dist/{ValApp-bb207e96.cjs.prod.js → ValApp-90c4171d.cjs.prod.js} +8 -6
  7. package/dist/{ValApp-1992d8b3.cjs.dev.js → ValApp-c1c3ef55.cjs.dev.js} +8 -6
  8. package/dist/{ValApp-8912fc8b.esm.js → ValApp-e17eb734.esm.js} +5 -3
  9. package/dist/ValCanvasBridge-96f67a41.cjs.dev.js +395 -0
  10. package/dist/ValCanvasBridge-d8713d9d.esm.js +387 -0
  11. package/dist/ValCanvasBridge-f75509c6.cjs.js +7 -0
  12. package/dist/ValCanvasBridge-f75509c6.cjs.prod.js +395 -0
  13. package/dist/{ValNextProvider-7302b8af.esm.js → ValNextProvider-3209948c.esm.js} +282 -43
  14. package/dist/{ValNextProvider-03a9f8fd.cjs.dev.js → ValNextProvider-3d8ebfec.cjs.dev.js} +297 -58
  15. package/dist/ValNextProvider-3fdf8756.cjs.js +7 -0
  16. package/dist/{ValNextProvider-6103cb74.cjs.prod.js → ValNextProvider-3fdf8756.cjs.prod.js} +297 -58
  17. package/dist/ValOverlayContext-1d019b95.cjs.js +7 -0
  18. package/dist/{ValOverlayContext-f7f45bc7.cjs.prod.js → ValOverlayContext-1d019b95.cjs.prod.js} +8 -2
  19. package/dist/{ValOverlayContext-c6f27a6d.cjs.dev.js → ValOverlayContext-ca3b6ebd.cjs.dev.js} +8 -2
  20. package/dist/{ValOverlayContext-3c37e5a7.esm.js → ValOverlayContext-f63e0fc9.esm.js} +8 -2
  21. package/dist/declarations/src/ValApp.d.ts +1 -1
  22. package/dist/declarations/src/ValImage.d.ts +1 -1
  23. package/dist/declarations/src/ValProvider.d.ts +1 -1
  24. package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +7 -5
  25. package/dist/fallbackColors-5ead2c26.esm.js +58 -0
  26. package/dist/{cssUtils-9c11102f.cjs.dev.js → fallbackColors-9a2ac53a.cjs.dev.js} +30 -0
  27. package/dist/{cssUtils-d97a757c.cjs.prod.js → fallbackColors-d4a5b0da.cjs.prod.js} +30 -0
  28. package/dist/valbuild-next.cjs.dev.js +8 -13
  29. package/dist/valbuild-next.cjs.prod.js +8 -13
  30. package/dist/valbuild-next.esm.js +9 -10
  31. package/package.json +13 -13
  32. package/dist/ValApp-bb207e96.cjs.js +0 -7
  33. package/dist/ValNextProvider-6103cb74.cjs.js +0 -7
  34. package/dist/ValOverlayContext-f7f45bc7.cjs.js +0 -7
  35. package/dist/cssUtils-b5651c03.esm.js +0 -32
@@ -10,11 +10,12 @@ var ui = require('@valbuild/ui');
10
10
  var navigation = require('next/navigation');
11
11
  var Script = require('next/script');
12
12
  var React = require('react');
13
- var ValOverlayContext = require('./ValOverlayContext-c6f27a6d.cjs.dev.js');
13
+ var ValOverlayContext = require('./ValOverlayContext-ca3b6ebd.cjs.dev.js');
14
14
  var stega = require('@valbuild/react/stega');
15
15
  var internal = require('@valbuild/shared/internal');
16
- var cssUtils = require('./cssUtils-9c11102f.cjs.dev.js');
16
+ var fallbackColors = require('./fallbackColors-9a2ac53a.cjs.dev.js');
17
17
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
18
+ var ValCanvasBridge = require('./ValCanvasBridge-96f67a41.cjs.dev.js');
18
19
  var jsxRuntime = require('react/jsx-runtime');
19
20
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
20
21
  require('./defineProperty-f90345d7.cjs.dev.js');
@@ -76,7 +77,77 @@ function hasValEnableCookie(cookieString) {
76
77
  return false;
77
78
  }
78
79
 
80
+ /**
81
+ * Whether the page should re-read the server on its own, right now.
82
+ *
83
+ * The page cannot know when its own edit has been persisted. An edit is applied
84
+ * to the client store immediately and written to the server asynchronously, so
85
+ * a `router.refresh()` fired on the edit can reach a server that has not saved
86
+ * the patch yet: the payload comes back with the old content, and nothing
87
+ * schedules another look. What an editor sees is a canvas that flickered and did
88
+ * not change — which is indistinguishable from an edit that did not work.
89
+ *
90
+ * So the page asks again a little later. This is the "should I bother" half of
91
+ * that, kept out of the effect and pure so the reasons NOT to are checkable:
92
+ * every one of them is a whole-route request avoided, and in development Next
93
+ * re-renders (and sometimes recompiles) the page for each one.
94
+ */
95
+ function shouldSafetyRefresh(state) {
96
+ // Never edited: a preview someone is only looking at has nothing to catch up
97
+ // on, and polling it would cost a route render per tick for nothing.
98
+ if (state.lastEditAt === 0) return false;
99
+ // The editing stopped long enough ago that anything in flight has landed.
100
+ if (state.now - state.lastEditAt > state.windowMs) return false;
101
+ // Nobody is looking. The caller refreshes once on the way back instead.
102
+ if (state.hidden) return false;
103
+ // Already on its way. Stacking whole-route requests makes the slowness this
104
+ // exists to paper over worse, not better.
105
+ if (state.isRefreshing) return false;
106
+ // One just went out — usually the edit-driven refresh, a moment ago.
107
+ if (state.now - state.lastRefreshAt < state.minIntervalMs) return false;
108
+ return true;
109
+ }
110
+
111
+ var REFRESH_INTERVAL_MS = 500;
112
+
113
+ /**
114
+ * How often the page re-reads the server on its own, without being told to.
115
+ *
116
+ * A safety net for a race no amount of care on this side can close. An edit is
117
+ * applied to the client store immediately and saved to the server
118
+ * asynchronously, so `router.refresh()` fired on the edit can reach a server
119
+ * that has not written the patch yet: the RSC payload comes back with the old
120
+ * content, the counter has already been cleared, and nothing schedules another
121
+ * look. What you see is a canvas that flickered and did not change — which is
122
+ * indistinguishable from an edit that did not work.
123
+ *
124
+ * The honest fix would be for the page to know when its patch has been
125
+ * persisted, and it has no way to ask. So it asks again a little later instead.
126
+ */
127
+ var SAFETY_REFRESH_MS = 10000;
128
+
129
+ /**
130
+ * How long after an edit the safety net keeps looking.
131
+ *
132
+ * The reason to stop is that this is a whole-route request: in development Next
133
+ * re-renders (and sometimes recompiles) the page for every one, and a preview
134
+ * nobody is editing has nothing to catch up on. So the net is armed by editing
135
+ * and disarms itself when the editing stops — long enough after the last
136
+ * keystroke that any write still in flight has certainly landed.
137
+ */
138
+ var SAFETY_REFRESH_WINDOW_MS = 30000;
139
+
140
+ /**
141
+ * Fired on this window when an edit has been applied to the client store.
142
+ *
143
+ * The refresh loop listens for it so it can start the round trip immediately
144
+ * rather than on its next tick. A DOM event rather than state, because the
145
+ * counter it accompanies is a ref and the loop lives in an effect that must not
146
+ * be torn down and rebuilt per keystroke.
147
+ */
148
+ var VAL_EDIT_LANDED = "val-edit-landed";
79
149
  var ValNextProvider = function ValNextProvider(props) {
150
+ var _draftModeReady$curre2;
80
151
  // TODO: use config:
81
152
  var route = "/api/val";
82
153
  var client = React__default["default"].useMemo(function () {
@@ -102,28 +173,102 @@ var ValNextProvider = function ValNextProvider(props) {
102
173
  _React$useState2 = slicedToArray._slicedToArray(_React$useState, 2),
103
174
  suspendActive = _React$useState2[0],
104
175
  setSuspendActive = _React$useState2[1];
105
- var _React$useState3 = React__default["default"].useState(),
176
+ /**
177
+ * Whether the studio has said it sent everything it holds.
178
+ *
179
+ * Until then, a module missing from the store might still be on its way. After
180
+ * it, a missing module simply has no draft — see `sourcesSynced` in the canvas
181
+ * protocol. Without this the page could only wait out `waitForLoad`'s timeout,
182
+ * ten seconds per module nobody had edited.
183
+ */
184
+ var _React$useState3 = React__default["default"].useState(false),
106
185
  _React$useState4 = slicedToArray._slicedToArray(_React$useState3, 2),
107
- mountOverlay = _React$useState4[0],
108
- setMountOverlay = _React$useState4[1];
109
- var _React$useState5 = React__default["default"].useState(null),
186
+ draftSourcesSynced = _React$useState4[0],
187
+ setDraftSourcesSynced = _React$useState4[1];
188
+ var _React$useState5 = React__default["default"].useState(),
110
189
  _React$useState6 = slicedToArray._slicedToArray(_React$useState5, 2),
111
- draftMode = _React$useState6[0],
112
- setDraftMode = _React$useState6[1];
190
+ mountOverlay = _React$useState6[0],
191
+ setMountOverlay = _React$useState6[1];
192
+ /**
193
+ * Whether this document is the studio's canvas frame.
194
+ *
195
+ * The canvas needs everything `mountOverlay` turns on — draft content,
196
+ * `data-val-path` on every tracked element, the refresh loop that brings an
197
+ * edit across — and none of what it *shows*, because the studio around the
198
+ * frame is already that UI. So it is a second flag rather than a different
199
+ * value of the first one: two overlays on one screen, one of them inside the
200
+ * other, is the thing to avoid.
201
+ *
202
+ * Read once, in the same effect as `mountOverlay`: it is a property of how
203
+ * the document was loaded, and it cannot change without a navigation.
204
+ */
113
205
  var _React$useState7 = React__default["default"].useState(false),
114
206
  _React$useState8 = slicedToArray._slicedToArray(_React$useState7, 2),
115
- spaReady = _React$useState8[0],
116
- setSpaReady = _React$useState8[1]; // TODO: consider removing spaReady - it is not used? If we remove, clean up the custom events that send the message too...
207
+ isCanvas = _React$useState8[0],
208
+ setIsCanvas = _React$useState8[1];
209
+ var _React$useState9 = React__default["default"].useState(null),
210
+ _React$useState0 = slicedToArray._slicedToArray(_React$useState9, 2),
211
+ draftMode = _React$useState0[0],
212
+ setDraftMode = _React$useState0[1];
213
+ /**
214
+ * Resolves when `draftMode` stops being unknown.
215
+ *
216
+ * `null` is the state before `/draft/stat` has answered, and it is NOT a
217
+ * synonym for "off": the reader that turns a selector into content treats it
218
+ * as off, so a render that happens while draft mode is still unknown resolves
219
+ * against committed source. For a route that only exists in an uncommitted
220
+ * patch that means `notFound()` — terminal, before the answer even arrives.
221
+ *
222
+ * So a page that is going to suspend waits for the answer first. A promise
223
+ * rather than a re-render, because the thing that has to wait is a render.
224
+ */
225
+ var draftModeReady = React__default["default"].useRef(null);
226
+ // Only for a page that opted in. A visitor with Val off never reads it, and
227
+ // an object created per mount for nobody is the kind of cost that is invisible
228
+ // until it is in every page of every app.
229
+ if (props.suspend && draftModeReady.current === null) {
230
+ var resolve = function resolve() {
231
+ return undefined;
232
+ };
233
+ var promise = new Promise(function (r) {
234
+ resolve = r;
235
+ });
236
+ draftModeReady.current = {
237
+ promise: promise,
238
+ resolve: resolve
239
+ };
240
+ }
241
+ React__default["default"].useEffect(function () {
242
+ if (draftMode !== null) {
243
+ var _draftModeReady$curre;
244
+ (_draftModeReady$curre = draftModeReady.current) === null || _draftModeReady$curre === void 0 || _draftModeReady$curre.resolve();
245
+ }
246
+ }, [draftMode]);
247
+ var _React$useState1 = React__default["default"].useState(false),
248
+ _React$useState10 = slicedToArray._slicedToArray(_React$useState1, 2),
249
+ spaReady = _React$useState10[0],
250
+ setSpaReady = _React$useState10[1]; // TODO: consider removing spaReady - it is not used? If we remove, clean up the custom events that send the message too...
117
251
  var router = navigation.useRouter();
118
252
  var _React$useTransition = React__default["default"].useTransition(),
119
253
  _React$useTransition2 = slicedToArray._slicedToArray(_React$useTransition, 2),
254
+ isRefreshing = _React$useTransition2[0],
120
255
  startTransition = _React$useTransition2[1];
256
+ /**
257
+ * The same answer as `isRefreshing`, readable from the refresh effect.
258
+ *
259
+ * The effect must not be rebuilt every time a refresh starts and ends — it
260
+ * owns the timers and the "when did we last edit" bookkeeping, and tearing
261
+ * that down mid-flurry loses it. A ref updated on render is the value without
262
+ * the dependency.
263
+ */
264
+ var isRefreshingRef = React__default["default"].useRef(false);
121
265
  var rerenderCounterRef = React__default["default"].useRef(0);
122
- var _React$useState9 = React__default["default"].useState(null),
123
- _React$useState0 = slicedToArray._slicedToArray(_React$useState9, 2),
124
- iframeSrc = _React$useState0[0],
125
- setIframeSrc = _React$useState0[1];
266
+ var _React$useState11 = React__default["default"].useState(null),
267
+ _React$useState12 = slicedToArray._slicedToArray(_React$useState11, 2),
268
+ iframeSrc = _React$useState12[0],
269
+ setIframeSrc = _React$useState12[1];
126
270
  var pathname = navigation.usePathname();
271
+ isRefreshingRef.current = isRefreshing;
127
272
  React.useEffect(function () {
128
273
  window.dispatchEvent(new CustomEvent("val-provider:pathname", {
129
274
  detail: pathname
@@ -139,6 +284,7 @@ var ValNextProvider = function ValNextProvider(props) {
139
284
  setMountOverlay(false);
140
285
  return;
141
286
  }
287
+ setIsCanvas(internal.isValCanvasFrame(location.search));
142
288
  setMountOverlay(hasValEnableCookie(document.cookie));
143
289
  }, []);
144
290
  React__default["default"].useEffect(function () {
@@ -154,22 +300,101 @@ var ValNextProvider = function ValNextProvider(props) {
154
300
  });
155
301
  }
156
302
  }, [props.suspend]);
303
+
304
+ /**
305
+ * Re-render the server tree when an edit lands, then at most every 500ms.
306
+ *
307
+ * Leading edge, which is the whole point. This polled every 500ms and only
308
+ * refreshed on the tick, so a keystroke waited up to half a second before the
309
+ * round trip even began — pure dead time on top of a request that is already
310
+ * the slow part in development. Refreshing on arrival and *then* enforcing the
311
+ * gap keeps the same ceiling on requests while removing the wait.
312
+ *
313
+ * Still a counter rather than a boolean: edits that arrive during the gap have
314
+ * to be picked up by the next refresh, and the count is what says whether
315
+ * there are any.
316
+ */
157
317
  React__default["default"].useEffect(function () {
158
- if (!mountOverlay) {
318
+ if (!mountOverlay || props.disableRefresh) {
159
319
  return;
160
320
  }
161
- var interval = setInterval(function () {
162
- if (rerenderCounterRef.current > 0) {
163
- if (!props.disableRefresh) {
164
- rerenderCounterRef.current = 0;
165
- startTransition(function () {
166
- router.refresh();
167
- });
168
- }
321
+ var timer = null;
322
+ var lastRefreshAt = 0;
323
+ /** When an edit last landed here. 0 means this page has never been edited. */
324
+ var lastEditAt = 0;
325
+ /** Whether a safety tick was skipped because nobody was looking. */
326
+ var missedWhileHidden = false;
327
+ var refresh = function refresh() {
328
+ rerenderCounterRef.current = 0;
329
+ lastRefreshAt = Date.now();
330
+ startTransition(function () {
331
+ router.refresh();
332
+ });
333
+ };
334
+ var _tick = function tick() {
335
+ timer = null;
336
+ if (rerenderCounterRef.current === 0) return;
337
+ var since = Date.now() - lastRefreshAt;
338
+ if (since >= REFRESH_INTERVAL_MS) {
339
+ refresh();
340
+ } else {
341
+ timer = setTimeout(_tick, REFRESH_INTERVAL_MS - since);
169
342
  }
170
- }, 500);
343
+ };
344
+ var onEdit = function onEdit() {
345
+ lastEditAt = Date.now();
346
+ if (timer !== null) return;
347
+ timer = setTimeout(_tick, 0);
348
+ };
349
+ window.addEventListener(VAL_EDIT_LANDED, onEdit);
350
+ // A backstop for the counter being bumped without the event — the two are
351
+ // incremented in the same places today, but the poll is what made this
352
+ // correct regardless of who bumped it.
353
+ var interval = setInterval(_tick, REFRESH_INTERVAL_MS);
354
+
355
+ /**
356
+ * The safety net: look again, whether or not anything told us to.
357
+ *
358
+ * The reasons not to are in `shouldSafetyRefresh`, where they can be tested.
359
+ * `hidden` is the one this side has to remember something about: a skipped
360
+ * tick is worth one look when the tab comes back.
361
+ */
362
+ var safetyTick = function safetyTick() {
363
+ if (document.hidden) {
364
+ missedWhileHidden = true;
365
+ return;
366
+ }
367
+ var go = shouldSafetyRefresh({
368
+ now: Date.now(),
369
+ lastEditAt: lastEditAt,
370
+ lastRefreshAt: lastRefreshAt,
371
+ hidden: false,
372
+ isRefreshing: isRefreshingRef.current,
373
+ windowMs: SAFETY_REFRESH_WINDOW_MS,
374
+ minIntervalMs: REFRESH_INTERVAL_MS
375
+ });
376
+ if (go) refresh();
377
+ };
378
+ var safety = setInterval(safetyTick, SAFETY_REFRESH_MS);
379
+ /**
380
+ * Coming back to the tab is worth one look.
381
+ *
382
+ * Otherwise a background tab skips its ticks and then has to wait out a
383
+ * whole interval on return — which is exactly the moment someone is looking
384
+ * at the page to see whether their edit took.
385
+ */
386
+ var onVisibilityChange = function onVisibilityChange() {
387
+ if (document.hidden || !missedWhileHidden) return;
388
+ missedWhileHidden = false;
389
+ safetyTick();
390
+ };
391
+ document.addEventListener("visibilitychange", onVisibilityChange);
171
392
  return function () {
393
+ window.removeEventListener(VAL_EDIT_LANDED, onEdit);
394
+ document.removeEventListener("visibilitychange", onVisibilityChange);
172
395
  clearInterval(interval);
396
+ clearInterval(safety);
397
+ if (timer !== null) clearTimeout(timer);
173
398
  };
174
399
  }, [mountOverlay, props.disableRefresh]);
175
400
  React__default["default"].useEffect(function () {
@@ -254,6 +479,7 @@ var ValNextProvider = function ValNextProvider(props) {
254
479
  setDraftMode(function (prev) {
255
480
  if (prev !== res.json.draftMode) {
256
481
  rerenderCounterRef.current++;
482
+ window.dispatchEvent(new Event(VAL_EDIT_LANDED));
257
483
  return res.json.draftMode;
258
484
  }
259
485
  return prev;
@@ -292,15 +518,20 @@ var ValNextProvider = function ValNextProvider(props) {
292
518
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
293
519
  var reactServerComponentRefreshListener = function reactServerComponentRefreshListener(event) {
294
520
  if (event instanceof CustomEvent) {
295
- var _event$detail;
296
- if (((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.type) === "source-update") {
297
- var _event$detail2, _event$detail3;
298
- var moduleFilePath = (_event$detail2 = event.detail) === null || _event$detail2 === void 0 ? void 0 : _event$detail2.moduleFilePath;
299
- var source = (_event$detail3 = event.detail) === null || _event$detail3 === void 0 ? void 0 : _event$detail3.source;
521
+ var _event$detail, _event$detail2;
522
+ if (((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.type) === "sources-synced") {
523
+ setDraftSourcesSynced(true);
524
+ return;
525
+ }
526
+ if (((_event$detail2 = event.detail) === null || _event$detail2 === void 0 ? void 0 : _event$detail2.type) === "source-update") {
527
+ var _event$detail3, _event$detail4;
528
+ var moduleFilePath = (_event$detail3 = event.detail) === null || _event$detail3 === void 0 ? void 0 : _event$detail3.moduleFilePath;
529
+ var source = (_event$detail4 = event.detail) === null || _event$detail4 === void 0 ? void 0 : _event$detail4.source;
300
530
  if (typeof moduleFilePath === "string" && source !== undefined) {
301
531
  valStore.update(moduleFilePath, source);
302
532
  if (!props.disableRefresh) {
303
533
  rerenderCounterRef.current++;
534
+ window.dispatchEvent(new Event(VAL_EDIT_LANDED));
304
535
  }
305
536
  } else {
306
537
  console.error("Val: invalid event detail", event.detail);
@@ -340,10 +571,10 @@ var ValNextProvider = function ValNextProvider(props) {
340
571
  window.dispatchEvent(new CustomEvent("val-append-overlay"));
341
572
  }
342
573
  });
343
- var _React$useState1 = React__default["default"].useState(null),
344
- _React$useState10 = slicedToArray._slicedToArray(_React$useState1, 2),
345
- dropZone = _React$useState10[0],
346
- setDropZone = _React$useState10[1];
574
+ var _React$useState13 = React__default["default"].useState(null),
575
+ _React$useState14 = slicedToArray._slicedToArray(_React$useState13, 2),
576
+ dropZone = _React$useState14[0],
577
+ setDropZone = _React$useState14[1];
347
578
  React__default["default"].useEffect(function () {
348
579
  var storedDropZone = localStorage.getItem("val-menu-drop-zone-default");
349
580
  if (storedDropZone) {
@@ -352,14 +583,14 @@ var ValNextProvider = function ValNextProvider(props) {
352
583
  setDropZone("val-menu-right-center");
353
584
  }
354
585
  }, []);
355
- cssUtils.useConfigStorageSave(props.config);
586
+ fallbackColors.useConfigStorageSave(props.config);
356
587
  var initTheme = React__default["default"].useMemo(function () {
357
588
  return initSessionTheme(props.config);
358
589
  }, [props.config]);
359
- var _React$useState11 = React__default["default"].useState(false),
360
- _React$useState12 = slicedToArray._slicedToArray(_React$useState11, 2),
361
- spaLoaded = _React$useState12[0],
362
- setSpaLoaded = _React$useState12[1];
590
+ var _React$useState15 = React__default["default"].useState(false),
591
+ _React$useState16 = slicedToArray._slicedToArray(_React$useState15, 2),
592
+ spaLoaded = _React$useState16[0],
593
+ setSpaLoaded = _React$useState16[1];
363
594
  React__default["default"].useEffect(function () {
364
595
  var listener = function listener() {
365
596
  setSpaLoaded(true);
@@ -369,12 +600,13 @@ var ValNextProvider = function ValNextProvider(props) {
369
600
  window.removeEventListener("val-ui-created", listener);
370
601
  };
371
602
  }, []);
603
+ // The pill is Val's chrome floating over the customer's page, so it takes
604
+ // the float background rather than the studio's canvas.
372
605
  var _React$useMemo = React__default["default"].useMemo(function () {
373
606
  if (initTheme !== "light") {
374
- return ["#0c111d", "white"];
375
- } else {
376
- return ["white", "black"];
607
+ return [fallbackColors.floatDarkBg, "white"];
377
608
  }
609
+ return [fallbackColors.floatLightBg, "black"];
378
610
  }, [initTheme]),
379
611
  _React$useMemo2 = slicedToArray._slicedToArray(_React$useMemo, 2),
380
612
  backgroundColor = _React$useMemo2[0],
@@ -396,18 +628,22 @@ var ValNextProvider = function ValNextProvider(props) {
396
628
  "items-center": "align-items: center;",
397
629
  "justify-center": "justify-content: center;"
398
630
  };
399
- }, [cssUtils.valPrefixedClass]);
631
+ }, [fallbackColors.valPrefixedClass]);
400
632
  return /*#__PURE__*/jsxRuntime.jsxs(ValOverlayContext.ValOverlayProvider, {
401
633
  draftMode: draftMode,
634
+ draftModeReady: (_draftModeReady$curre2 = draftModeReady.current) === null || _draftModeReady$curre2 === void 0 ? void 0 : _draftModeReady$curre2.promise,
635
+ draftSourcesSynced: draftSourcesSynced,
402
636
  suspend: suspendActive,
403
637
  store: valStore,
404
- children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && initTheme !== null && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
638
+ children: [props.children, dropZone !== null && !spaLoaded && mountOverlay &&
639
+ // The canvas frame loads no SPA, so its pill would spin for ever.
640
+ !isCanvas && initTheme !== null && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
405
641
  children: [/*#__PURE__*/jsxRuntime.jsx("style", {
406
- children: "\n".concat(positionStyles, "\n").concat(cssUtils.prefixStyles(commonStyles), "\n@keyframes rotate-clock {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n")
642
+ children: "\n".concat(positionStyles, "\n").concat(fallbackColors.prefixStyles(commonStyles), "\n@keyframes rotate-clock {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n")
407
643
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
408
- className: "".concat(getPositionClassName(dropZone), " ").concat(cssUtils.cn(["p-4"])),
644
+ className: "".concat(getPositionClassName(dropZone), " ").concat(fallbackColors.cn(["p-4"])),
409
645
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
410
- className: "".concat(cssUtils.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cssUtils.cn(["text-text-primary", "bg-bg-primary", "rounded", "backdrop-blur"])),
646
+ className: "".concat(fallbackColors.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(fallbackColors.cn(["text-text-primary", "bg-bg-primary", "rounded", "backdrop-blur"])),
411
647
  children: /*#__PURE__*/jsxRuntime.jsxs("svg", {
412
648
  xmlns: "http://www.w3.org/2000/svg",
413
649
  width: "16",
@@ -444,7 +680,7 @@ var ValNextProvider = function ValNextProvider(props) {
444
680
  })
445
681
  })
446
682
  })]
447
- }), mountOverlay && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
683
+ }), mountOverlay && !isCanvas && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
448
684
  children: [/*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
449
685
  type: "module",
450
686
  src: "".concat(route, "/static").concat(ui.VERSION ? "/".concat(ui.VERSION) : "").concat(ui.VAL_APP_PATH),
@@ -453,6 +689,9 @@ var ValNextProvider = function ValNextProvider(props) {
453
689
  id: ui.VAL_OVERLAY_ID,
454
690
  ref: container
455
691
  })]
692
+ }), mountOverlay && isCanvas && /*#__PURE__*/jsxRuntime.jsx(ValCanvasBridge.ValCanvasBridge, {
693
+ draftMode: draftMode === true,
694
+ isRefreshing: isRefreshing
456
695
  }), mountOverlay && iframeSrc && /*#__PURE__*/jsxRuntime.jsx("iframe", {
457
696
  loading: "eager",
458
697
  style: {
@@ -474,7 +713,7 @@ function useConsoleLogEnableVal(showOverlay) {
474
713
  }
475
714
  }, [showOverlay]);
476
715
  }
477
- var positionStyles = cssUtils.prefixStyles({
716
+ var positionStyles = fallbackColors.prefixStyles({
478
717
  "left-0": "left: 0;",
479
718
  "top-0": "top: 0;",
480
719
  "left-1/2": "left: 50%;",
@@ -487,25 +726,25 @@ var positionStyles = cssUtils.prefixStyles({
487
726
 
488
727
  // This is a copy of the function from the ValMenu component.
489
728
  function getPositionClassName(dropZone) {
490
- var className = cssUtils.cn(["fixed", "transform"]);
729
+ var className = fallbackColors.cn(["fixed", "transform"]);
491
730
  if (dropZone === "val-menu-left-top") {
492
- className += " ".concat(cssUtils.cn(["left-0", "top-0"]));
731
+ className += " ".concat(fallbackColors.cn(["left-0", "top-0"]));
493
732
  } else if (dropZone === "val-menu-left-center") {
494
- className += " ".concat(cssUtils.cn(["left-0", "top-1/2", "-translate-y-1/2"]));
733
+ className += " ".concat(fallbackColors.cn(["left-0", "top-1/2", "-translate-y-1/2"]));
495
734
  } else if (dropZone === "val-menu-left-bottom") {
496
- className += " ".concat(cssUtils.cn(["left-0", "bottom-0"]));
735
+ className += " ".concat(fallbackColors.cn(["left-0", "bottom-0"]));
497
736
  } else if (dropZone === "val-menu-center-top") {
498
- className += " ".concat(cssUtils.cn(["left-1/2", "-translate-x-1/2", "top-0"]));
737
+ className += " ".concat(fallbackColors.cn(["left-1/2", "-translate-x-1/2", "top-0"]));
499
738
  } else if (dropZone === "val-menu-center-bottom") {
500
- className += " ".concat(cssUtils.cn(["left-1/2", "-translate-x-1/2", "bottom-0"]));
739
+ className += " ".concat(fallbackColors.cn(["left-1/2", "-translate-x-1/2", "bottom-0"]));
501
740
  } else if (dropZone === "val-menu-right-top") {
502
- className += " ".concat(cssUtils.cn(["right-0", "top-0"]));
741
+ className += " ".concat(fallbackColors.cn(["right-0", "top-0"]));
503
742
  } else if (dropZone === "val-menu-right-center") {
504
- className += " ".concat(cssUtils.cn(["right-0", "top-1/2", "-translate-y-1/2"]));
743
+ className += " ".concat(fallbackColors.cn(["right-0", "top-1/2", "-translate-y-1/2"]));
505
744
  } else if (dropZone === "val-menu-right-bottom") {
506
- className += " ".concat(cssUtils.cn(["right-0", "bottom-0"]));
745
+ className += " ".concat(fallbackColors.cn(["right-0", "bottom-0"]));
507
746
  } else {
508
- className += " ".concat(cssUtils.cn(["right-0", "bottom-0"]));
747
+ className += " ".concat(fallbackColors.cn(["right-0", "bottom-0"]));
509
748
  }
510
749
  return className;
511
750
  }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValNextProvider-3fdf8756.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValNextProvider-3fdf8756.cjs.dev.js");
7
+ }