@valbuild/next 0.108.2 → 0.108.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/client/dist/valbuild-next-client.cjs.dev.js +1 -1
- package/client/dist/valbuild-next-client.cjs.prod.js +1 -1
- package/client/dist/valbuild-next-client.esm.js +1 -1
- package/dist/{ValCanvasBridge-cb2d9112.cjs.dev.js → ValCanvasBridge-9d148bdd.cjs.dev.js} +73 -4
- package/dist/{ValCanvasBridge-1310aaeb.esm.js → ValCanvasBridge-d9948526.esm.js} +73 -4
- package/dist/ValCanvasBridge-e62125f8.cjs.js +7 -0
- package/dist/{ValCanvasBridge-32299c6e.cjs.prod.js → ValCanvasBridge-e62125f8.cjs.prod.js} +73 -4
- package/dist/{ValNextProvider-3209948c.esm.js → ValNextProvider-588f2ff0.esm.js} +75 -5
- package/dist/ValNextProvider-bd3f89d3.cjs.js +7 -0
- package/dist/{ValNextProvider-3fdf8756.cjs.prod.js → ValNextProvider-bd3f89d3.cjs.prod.js} +75 -5
- package/dist/{ValNextProvider-3d8ebfec.cjs.dev.js → ValNextProvider-f206d2ea.cjs.dev.js} +75 -5
- package/dist/{ValOverlayContext-ca3b6ebd.cjs.dev.js → ValOverlayContext-5bd7628b.cjs.dev.js} +31 -1
- package/dist/ValOverlayContext-d690744f.cjs.js +7 -0
- package/dist/{ValOverlayContext-1d019b95.cjs.prod.js → ValOverlayContext-d690744f.cjs.prod.js} +31 -1
- package/dist/{ValOverlayContext-f63e0fc9.esm.js → ValOverlayContext-e42a2e14.esm.js} +31 -1
- package/dist/valbuild-next.cjs.dev.js +1 -1
- package/dist/valbuild-next.cjs.prod.js +1 -1
- package/dist/valbuild-next.esm.js +1 -1
- package/package.json +5 -5
- package/dist/ValCanvasBridge-32299c6e.cjs.js +0 -7
- package/dist/ValNextProvider-3fdf8756.cjs.js +0 -7
- package/dist/ValOverlayContext-1d019b95.cjs.js +0 -7
|
@@ -7,7 +7,7 @@ var routeFromVal = require('../../dist/routeFromVal-b48a454a.cjs.dev.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var ValOverlayContext = require('../../dist/ValOverlayContext-
|
|
10
|
+
var ValOverlayContext = require('../../dist/ValOverlayContext-5bd7628b.cjs.dev.js');
|
|
11
11
|
require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
12
12
|
require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
13
13
|
require('../../dist/objectSpread2-58024783.cjs.dev.js');
|
|
@@ -7,7 +7,7 @@ var routeFromVal = require('../../dist/routeFromVal-8ac2f984.cjs.prod.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var ValOverlayContext = require('../../dist/ValOverlayContext-
|
|
10
|
+
var ValOverlayContext = require('../../dist/ValOverlayContext-d690744f.cjs.prod.js');
|
|
11
11
|
require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
12
12
|
require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
13
13
|
require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
|
|
@@ -3,7 +3,7 @@ import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema
|
|
|
3
3
|
import { Internal } from '@valbuild/core';
|
|
4
4
|
import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { useValOverlayContext } from '../../dist/ValOverlayContext-
|
|
6
|
+
import { useValOverlayContext } from '../../dist/ValOverlayContext-e42a2e14.esm.js';
|
|
7
7
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
8
8
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
9
9
|
import '../../dist/objectSpread2-60d1bd93.esm.js';
|
|
@@ -289,10 +289,8 @@ function ValCanvasBridge(_ref) {
|
|
|
289
289
|
setHighlighted(message.path);
|
|
290
290
|
if (message.path !== null && message.scrollIntoView) {
|
|
291
291
|
var target = findByPath(message.path);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
behavior: "smooth"
|
|
295
|
-
});
|
|
292
|
+
// NOT `scrollIntoView` — see `scrollWithinPage`.
|
|
293
|
+
if (target !== null) scrollWithinPage(target);
|
|
296
294
|
}
|
|
297
295
|
};
|
|
298
296
|
window.addEventListener("message", listener);
|
|
@@ -499,6 +497,77 @@ function highlightRule(path) {
|
|
|
499
497
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
500
498
|
return "".concat(selectors, " { outline: 2px solid ").concat(SELECTION, "; outline-offset: 1px; }");
|
|
501
499
|
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Bring an element into view WITHOUT scrolling anything outside this page.
|
|
503
|
+
*
|
|
504
|
+
* `Element.scrollIntoView` would be the obvious thing, and it is the thing that
|
|
505
|
+
* broke the studio. It scrolls every scroll container between the element and
|
|
506
|
+
* the viewport, and for a same-origin frame that chain does not stop at the
|
|
507
|
+
* frame: it continues into the embedder and scrolls the studio's own containers
|
|
508
|
+
* too. Measured in Chromium — with the studio's phone panes placed on the
|
|
509
|
+
* editor, a single `scrollIntoView` in here pulls them back onto the canvas, and
|
|
510
|
+
* because it reveals the element rather than the frame it can leave them
|
|
511
|
+
* anywhere in between, showing half of each.
|
|
512
|
+
*
|
|
513
|
+
* That is not a thing the page has any business doing. It was asked to show one
|
|
514
|
+
* of its own elements; where the studio is looking is the studio's affair. So
|
|
515
|
+
* the scrolling is done by hand, one scrollport at a time, and the walk stops at
|
|
516
|
+
* this document.
|
|
517
|
+
*
|
|
518
|
+
* Only the document centres the target vertically — it is being pointed out,
|
|
519
|
+
* and something flush against the top edge of the fold does not read as pointed
|
|
520
|
+
* out. Every scrollport inside the page is moved as little as it takes to bring
|
|
521
|
+
* the target inside it: a carousel, a sticky sidebar or a sideways-scrolling
|
|
522
|
+
* table is showing what it is showing on purpose, and re-centring one that did
|
|
523
|
+
* not need moving is the page rearranging itself around a highlight.
|
|
524
|
+
*/
|
|
525
|
+
function scrollWithinPage(target) {
|
|
526
|
+
var node = target.parentElement;
|
|
527
|
+
while (node !== null) {
|
|
528
|
+
var isRoot = node === document.body || node === document.documentElement;
|
|
529
|
+
if (isRoot) break;
|
|
530
|
+
if (isScrollable(node)) {
|
|
531
|
+
var port = node.getBoundingClientRect();
|
|
532
|
+
var _box = target.getBoundingClientRect();
|
|
533
|
+
node.scrollTop += delta(_box.top - port.top, _box.height, node.clientHeight, false);
|
|
534
|
+
node.scrollLeft += delta(_box.left - port.left, _box.width, node.clientWidth, false);
|
|
535
|
+
}
|
|
536
|
+
node = node.parentElement;
|
|
537
|
+
}
|
|
538
|
+
// And this document, which is the last scrollport there is as far as the page
|
|
539
|
+
// is concerned. `window`, not `documentElement.scrollIntoView`-by-another-name:
|
|
540
|
+
// this cannot reach past the frame.
|
|
541
|
+
var box = target.getBoundingClientRect();
|
|
542
|
+
window.scrollTo({
|
|
543
|
+
top: Math.max(0, window.scrollY + delta(box.top, box.height, window.innerHeight, true)),
|
|
544
|
+
left: Math.max(0, window.scrollX + delta(box.left, box.width, window.innerWidth, false)),
|
|
545
|
+
behavior: "smooth"
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* How far a scrollport has to move for `size` at `offset` to be shown.
|
|
551
|
+
*
|
|
552
|
+
* `center` asks for the middle of the port; without it the answer is zero
|
|
553
|
+
* whenever the thing is already inside, which is what keeps a scrollport that
|
|
554
|
+
* did not need moving from being disturbed.
|
|
555
|
+
*/
|
|
556
|
+
function delta(offset, size, port, center) {
|
|
557
|
+
if (center) return offset - (port - size) / 2;
|
|
558
|
+
if (offset < 0) return offset;
|
|
559
|
+
if (offset + size > port) return Math.min(offset, offset + size - port);
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** Whether this element scrolls its own content, rather than growing with it. */
|
|
564
|
+
function isScrollable(el) {
|
|
565
|
+
var style = getComputedStyle(el);
|
|
566
|
+
var scrolls = function scrolls(value) {
|
|
567
|
+
return value === "auto" || value === "scroll" || value === "overlay";
|
|
568
|
+
};
|
|
569
|
+
return scrolls(style.overflowY) && el.scrollHeight > el.clientHeight || scrolls(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
570
|
+
}
|
|
502
571
|
function findByPath(path) {
|
|
503
572
|
var elements = document.querySelectorAll("[data-val-path]");
|
|
504
573
|
for (var _i = 0, _Array$from = Array.from(elements); _i < _Array$from.length; _i++) {
|
|
@@ -281,10 +281,8 @@ function ValCanvasBridge(_ref) {
|
|
|
281
281
|
setHighlighted(message.path);
|
|
282
282
|
if (message.path !== null && message.scrollIntoView) {
|
|
283
283
|
var target = findByPath(message.path);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
behavior: "smooth"
|
|
287
|
-
});
|
|
284
|
+
// NOT `scrollIntoView` — see `scrollWithinPage`.
|
|
285
|
+
if (target !== null) scrollWithinPage(target);
|
|
288
286
|
}
|
|
289
287
|
};
|
|
290
288
|
window.addEventListener("message", listener);
|
|
@@ -491,6 +489,77 @@ function highlightRule(path) {
|
|
|
491
489
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
492
490
|
return "".concat(selectors, " { outline: 2px solid ").concat(SELECTION, "; outline-offset: 1px; }");
|
|
493
491
|
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Bring an element into view WITHOUT scrolling anything outside this page.
|
|
495
|
+
*
|
|
496
|
+
* `Element.scrollIntoView` would be the obvious thing, and it is the thing that
|
|
497
|
+
* broke the studio. It scrolls every scroll container between the element and
|
|
498
|
+
* the viewport, and for a same-origin frame that chain does not stop at the
|
|
499
|
+
* frame: it continues into the embedder and scrolls the studio's own containers
|
|
500
|
+
* too. Measured in Chromium — with the studio's phone panes placed on the
|
|
501
|
+
* editor, a single `scrollIntoView` in here pulls them back onto the canvas, and
|
|
502
|
+
* because it reveals the element rather than the frame it can leave them
|
|
503
|
+
* anywhere in between, showing half of each.
|
|
504
|
+
*
|
|
505
|
+
* That is not a thing the page has any business doing. It was asked to show one
|
|
506
|
+
* of its own elements; where the studio is looking is the studio's affair. So
|
|
507
|
+
* the scrolling is done by hand, one scrollport at a time, and the walk stops at
|
|
508
|
+
* this document.
|
|
509
|
+
*
|
|
510
|
+
* Only the document centres the target vertically — it is being pointed out,
|
|
511
|
+
* and something flush against the top edge of the fold does not read as pointed
|
|
512
|
+
* out. Every scrollport inside the page is moved as little as it takes to bring
|
|
513
|
+
* the target inside it: a carousel, a sticky sidebar or a sideways-scrolling
|
|
514
|
+
* table is showing what it is showing on purpose, and re-centring one that did
|
|
515
|
+
* not need moving is the page rearranging itself around a highlight.
|
|
516
|
+
*/
|
|
517
|
+
function scrollWithinPage(target) {
|
|
518
|
+
var node = target.parentElement;
|
|
519
|
+
while (node !== null) {
|
|
520
|
+
var isRoot = node === document.body || node === document.documentElement;
|
|
521
|
+
if (isRoot) break;
|
|
522
|
+
if (isScrollable(node)) {
|
|
523
|
+
var port = node.getBoundingClientRect();
|
|
524
|
+
var _box = target.getBoundingClientRect();
|
|
525
|
+
node.scrollTop += delta(_box.top - port.top, _box.height, node.clientHeight, false);
|
|
526
|
+
node.scrollLeft += delta(_box.left - port.left, _box.width, node.clientWidth, false);
|
|
527
|
+
}
|
|
528
|
+
node = node.parentElement;
|
|
529
|
+
}
|
|
530
|
+
// And this document, which is the last scrollport there is as far as the page
|
|
531
|
+
// is concerned. `window`, not `documentElement.scrollIntoView`-by-another-name:
|
|
532
|
+
// this cannot reach past the frame.
|
|
533
|
+
var box = target.getBoundingClientRect();
|
|
534
|
+
window.scrollTo({
|
|
535
|
+
top: Math.max(0, window.scrollY + delta(box.top, box.height, window.innerHeight, true)),
|
|
536
|
+
left: Math.max(0, window.scrollX + delta(box.left, box.width, window.innerWidth, false)),
|
|
537
|
+
behavior: "smooth"
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* How far a scrollport has to move for `size` at `offset` to be shown.
|
|
543
|
+
*
|
|
544
|
+
* `center` asks for the middle of the port; without it the answer is zero
|
|
545
|
+
* whenever the thing is already inside, which is what keeps a scrollport that
|
|
546
|
+
* did not need moving from being disturbed.
|
|
547
|
+
*/
|
|
548
|
+
function delta(offset, size, port, center) {
|
|
549
|
+
if (center) return offset - (port - size) / 2;
|
|
550
|
+
if (offset < 0) return offset;
|
|
551
|
+
if (offset + size > port) return Math.min(offset, offset + size - port);
|
|
552
|
+
return 0;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Whether this element scrolls its own content, rather than growing with it. */
|
|
556
|
+
function isScrollable(el) {
|
|
557
|
+
var style = getComputedStyle(el);
|
|
558
|
+
var scrolls = function scrolls(value) {
|
|
559
|
+
return value === "auto" || value === "scroll" || value === "overlay";
|
|
560
|
+
};
|
|
561
|
+
return scrolls(style.overflowY) && el.scrollHeight > el.clientHeight || scrolls(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
562
|
+
}
|
|
494
563
|
function findByPath(path) {
|
|
495
564
|
var elements = document.querySelectorAll("[data-val-path]");
|
|
496
565
|
for (var _i = 0, _Array$from = Array.from(elements); _i < _Array$from.length; _i++) {
|
|
@@ -289,10 +289,8 @@ function ValCanvasBridge(_ref) {
|
|
|
289
289
|
setHighlighted(message.path);
|
|
290
290
|
if (message.path !== null && message.scrollIntoView) {
|
|
291
291
|
var target = findByPath(message.path);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
behavior: "smooth"
|
|
295
|
-
});
|
|
292
|
+
// NOT `scrollIntoView` — see `scrollWithinPage`.
|
|
293
|
+
if (target !== null) scrollWithinPage(target);
|
|
296
294
|
}
|
|
297
295
|
};
|
|
298
296
|
window.addEventListener("message", listener);
|
|
@@ -499,6 +497,77 @@ function highlightRule(path) {
|
|
|
499
497
|
var selectors = ["[data-val-path=".concat(value, "]"), "[data-val-path^=".concat(first, "]"), "[data-val-path$=".concat(last, "]"), "[data-val-path*=".concat(inner, "]")].join(",\n");
|
|
500
498
|
return "".concat(selectors, " { outline: 2px solid ").concat(SELECTION, "; outline-offset: 1px; }");
|
|
501
499
|
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Bring an element into view WITHOUT scrolling anything outside this page.
|
|
503
|
+
*
|
|
504
|
+
* `Element.scrollIntoView` would be the obvious thing, and it is the thing that
|
|
505
|
+
* broke the studio. It scrolls every scroll container between the element and
|
|
506
|
+
* the viewport, and for a same-origin frame that chain does not stop at the
|
|
507
|
+
* frame: it continues into the embedder and scrolls the studio's own containers
|
|
508
|
+
* too. Measured in Chromium — with the studio's phone panes placed on the
|
|
509
|
+
* editor, a single `scrollIntoView` in here pulls them back onto the canvas, and
|
|
510
|
+
* because it reveals the element rather than the frame it can leave them
|
|
511
|
+
* anywhere in between, showing half of each.
|
|
512
|
+
*
|
|
513
|
+
* That is not a thing the page has any business doing. It was asked to show one
|
|
514
|
+
* of its own elements; where the studio is looking is the studio's affair. So
|
|
515
|
+
* the scrolling is done by hand, one scrollport at a time, and the walk stops at
|
|
516
|
+
* this document.
|
|
517
|
+
*
|
|
518
|
+
* Only the document centres the target vertically — it is being pointed out,
|
|
519
|
+
* and something flush against the top edge of the fold does not read as pointed
|
|
520
|
+
* out. Every scrollport inside the page is moved as little as it takes to bring
|
|
521
|
+
* the target inside it: a carousel, a sticky sidebar or a sideways-scrolling
|
|
522
|
+
* table is showing what it is showing on purpose, and re-centring one that did
|
|
523
|
+
* not need moving is the page rearranging itself around a highlight.
|
|
524
|
+
*/
|
|
525
|
+
function scrollWithinPage(target) {
|
|
526
|
+
var node = target.parentElement;
|
|
527
|
+
while (node !== null) {
|
|
528
|
+
var isRoot = node === document.body || node === document.documentElement;
|
|
529
|
+
if (isRoot) break;
|
|
530
|
+
if (isScrollable(node)) {
|
|
531
|
+
var port = node.getBoundingClientRect();
|
|
532
|
+
var _box = target.getBoundingClientRect();
|
|
533
|
+
node.scrollTop += delta(_box.top - port.top, _box.height, node.clientHeight, false);
|
|
534
|
+
node.scrollLeft += delta(_box.left - port.left, _box.width, node.clientWidth, false);
|
|
535
|
+
}
|
|
536
|
+
node = node.parentElement;
|
|
537
|
+
}
|
|
538
|
+
// And this document, which is the last scrollport there is as far as the page
|
|
539
|
+
// is concerned. `window`, not `documentElement.scrollIntoView`-by-another-name:
|
|
540
|
+
// this cannot reach past the frame.
|
|
541
|
+
var box = target.getBoundingClientRect();
|
|
542
|
+
window.scrollTo({
|
|
543
|
+
top: Math.max(0, window.scrollY + delta(box.top, box.height, window.innerHeight, true)),
|
|
544
|
+
left: Math.max(0, window.scrollX + delta(box.left, box.width, window.innerWidth, false)),
|
|
545
|
+
behavior: "smooth"
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* How far a scrollport has to move for `size` at `offset` to be shown.
|
|
551
|
+
*
|
|
552
|
+
* `center` asks for the middle of the port; without it the answer is zero
|
|
553
|
+
* whenever the thing is already inside, which is what keeps a scrollport that
|
|
554
|
+
* did not need moving from being disturbed.
|
|
555
|
+
*/
|
|
556
|
+
function delta(offset, size, port, center) {
|
|
557
|
+
if (center) return offset - (port - size) / 2;
|
|
558
|
+
if (offset < 0) return offset;
|
|
559
|
+
if (offset + size > port) return Math.min(offset, offset + size - port);
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** Whether this element scrolls its own content, rather than growing with it. */
|
|
564
|
+
function isScrollable(el) {
|
|
565
|
+
var style = getComputedStyle(el);
|
|
566
|
+
var scrolls = function scrolls(value) {
|
|
567
|
+
return value === "auto" || value === "scroll" || value === "overlay";
|
|
568
|
+
};
|
|
569
|
+
return scrolls(style.overflowY) && el.scrollHeight > el.clientHeight || scrolls(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
570
|
+
}
|
|
502
571
|
function findByPath(path) {
|
|
503
572
|
var elements = document.querySelectorAll("[data-val-path]");
|
|
504
573
|
for (var _i = 0, _Array$from = Array.from(elements); _i < _Array$from.length; _i++) {
|
|
@@ -6,12 +6,12 @@ import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID } from '@valbuild/ui';
|
|
|
6
6
|
import { useRouter, usePathname } from 'next/navigation';
|
|
7
7
|
import Script from 'next/script';
|
|
8
8
|
import React, { useEffect } from 'react';
|
|
9
|
-
import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-
|
|
9
|
+
import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-e42a2e14.esm.js';
|
|
10
10
|
import { SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
|
|
11
11
|
import { VAL_THEME_SESSION_STORAGE_KEY, createValClient, isValCanvasFrame } from '@valbuild/shared/internal';
|
|
12
12
|
import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-5ead2c26.esm.js';
|
|
13
13
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
|
|
14
|
-
import { ValCanvasBridge } from './ValCanvasBridge-
|
|
14
|
+
import { ValCanvasBridge } from './ValCanvasBridge-d9948526.esm.js';
|
|
15
15
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
16
|
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
|
17
17
|
import './defineProperty-cca5affa.esm.js';
|
|
@@ -137,6 +137,38 @@ var SAFETY_REFRESH_WINDOW_MS = 30000;
|
|
|
137
137
|
* be torn down and rebuilt per keystroke.
|
|
138
138
|
*/
|
|
139
139
|
var VAL_EDIT_LANDED = "val-edit-landed";
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* How often `/draft/stat` is asked when nothing is in progress.
|
|
143
|
+
*
|
|
144
|
+
* Draft mode changes when someone toggles it, which the handshake below already
|
|
145
|
+
* covers — so this is only there to notice it being changed somewhere else.
|
|
146
|
+
*/
|
|
147
|
+
var DRAFT_IDLE_POLL_MS = 20000;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* And how often while the enable/disable handshake is in flight.
|
|
151
|
+
*
|
|
152
|
+
* Fast on purpose: the hidden iframe redirects through `/draft/enable`, and the
|
|
153
|
+
* page cannot do anything useful until that has landed.
|
|
154
|
+
*/
|
|
155
|
+
var DRAFT_HANDSHAKE_POLL_MS = 100;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* How long that fast phase may last before it gives up.
|
|
159
|
+
*
|
|
160
|
+
* Without a deadline it does not end: the only thing that clears `iframeSrc` is
|
|
161
|
+
* a `val-ready` message posted by the redirect target, so a frame that fails to
|
|
162
|
+
* load — a 500, an auth redirect, a dev server still compiling — left the page
|
|
163
|
+
* asking ten times a second, forever. A browser runs about six connections per
|
|
164
|
+
* origin, so that is enough to push `/stat`, `/patches` and the canvas document
|
|
165
|
+
* itself into the browser's own queue, where they are indistinguishable from a
|
|
166
|
+
* slow server.
|
|
167
|
+
*
|
|
168
|
+
* Generous enough for a first compile in `next dev`, which is the slowest case
|
|
169
|
+
* that is not a fault.
|
|
170
|
+
*/
|
|
171
|
+
var DRAFT_HANDSHAKE_TIMEOUT_MS = 10000;
|
|
140
172
|
var ValNextProvider = function ValNextProvider(props) {
|
|
141
173
|
var _draftModeReady$curre2;
|
|
142
174
|
// TODO: use config:
|
|
@@ -482,9 +514,32 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
482
514
|
return;
|
|
483
515
|
}
|
|
484
516
|
pollDraftStatIdRef.current--;
|
|
485
|
-
|
|
517
|
+
var handshaking = iframeSrc !== null;
|
|
518
|
+
if (handshaking && Date.now() - startedAt > DRAFT_HANDSHAKE_TIMEOUT_MS) {
|
|
519
|
+
/**
|
|
520
|
+
* The handshake did not complete, so stop hammering.
|
|
521
|
+
*
|
|
522
|
+
* Clearing `iframeSrc` unmounts the hidden frame and takes the poll
|
|
523
|
+
* back to its idle interval — which is the honest state: nothing is
|
|
524
|
+
* in progress any more. Leaving it set is what made this
|
|
525
|
+
* unrecoverable, because the ONLY other thing that clears it is the
|
|
526
|
+
* `val-ready` message the frame never sent.
|
|
527
|
+
*/
|
|
528
|
+
console.warn("Val: draft mode did not confirm in time. Falling back to the " + "idle poll — try toggling preview again.");
|
|
529
|
+
setIframeSrc(null);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
timeout = setTimeout(pollCurrentDraftMode, handshaking ? DRAFT_HANDSHAKE_POLL_MS : DRAFT_IDLE_POLL_MS);
|
|
486
533
|
});
|
|
487
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* When this spell of polling began.
|
|
537
|
+
*
|
|
538
|
+
* The effect re-runs when `iframeSrc` changes, so for the fast phase this is
|
|
539
|
+
* the moment the handshake started — which is what the deadline below is
|
|
540
|
+
* measured from.
|
|
541
|
+
*/
|
|
542
|
+
var startedAt = Date.now();
|
|
488
543
|
pollCurrentDraftMode();
|
|
489
544
|
return function () {
|
|
490
545
|
clearTimeout(timeout);
|
|
@@ -519,8 +574,23 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
519
574
|
var moduleFilePath = (_event$detail3 = event.detail) === null || _event$detail3 === void 0 ? void 0 : _event$detail3.moduleFilePath;
|
|
520
575
|
var source = (_event$detail4 = event.detail) === null || _event$detail4 === void 0 ? void 0 : _event$detail4.source;
|
|
521
576
|
if (typeof moduleFilePath === "string" && source !== undefined) {
|
|
522
|
-
valStore.update(moduleFilePath, source);
|
|
523
|
-
|
|
577
|
+
var changed = valStore.update(moduleFilePath, source);
|
|
578
|
+
/**
|
|
579
|
+
* Armed by a CHANGE, not by a message.
|
|
580
|
+
*
|
|
581
|
+
* The editor re-sends everything it holds whenever this page
|
|
582
|
+
* becomes a new document — a reload, or the one `next dev` does
|
|
583
|
+
* when a publish rewrites the `.val.ts` files — and most of that
|
|
584
|
+
* snapshot is content this page already has. Counting those
|
|
585
|
+
* bought a whole-route request per publish whether or not the
|
|
586
|
+
* page was out of date, which with auto-save on is one per pause
|
|
587
|
+
* in typing.
|
|
588
|
+
*
|
|
589
|
+
* The catch-up that MATTERS still refreshes: a page whose server
|
|
590
|
+
* render predates the write has no value for that module, so the
|
|
591
|
+
* first arrival counts as a change.
|
|
592
|
+
*/
|
|
593
|
+
if (changed && !props.disableRefresh) {
|
|
524
594
|
rerenderCounterRef.current++;
|
|
525
595
|
window.dispatchEvent(new Event(VAL_EDIT_LANDED));
|
|
526
596
|
}
|
|
@@ -10,12 +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-
|
|
13
|
+
var ValOverlayContext = require('./ValOverlayContext-d690744f.cjs.prod.js');
|
|
14
14
|
var stega = require('@valbuild/react/stega');
|
|
15
15
|
var internal = require('@valbuild/shared/internal');
|
|
16
16
|
var fallbackColors = require('./fallbackColors-d4a5b0da.cjs.prod.js');
|
|
17
17
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
18
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
18
|
+
var ValCanvasBridge = require('./ValCanvasBridge-e62125f8.cjs.prod.js');
|
|
19
19
|
var jsxRuntime = require('react/jsx-runtime');
|
|
20
20
|
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
21
21
|
require('./defineProperty-8951f469.cjs.prod.js');
|
|
@@ -146,6 +146,38 @@ var SAFETY_REFRESH_WINDOW_MS = 30000;
|
|
|
146
146
|
* be torn down and rebuilt per keystroke.
|
|
147
147
|
*/
|
|
148
148
|
var VAL_EDIT_LANDED = "val-edit-landed";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* How often `/draft/stat` is asked when nothing is in progress.
|
|
152
|
+
*
|
|
153
|
+
* Draft mode changes when someone toggles it, which the handshake below already
|
|
154
|
+
* covers — so this is only there to notice it being changed somewhere else.
|
|
155
|
+
*/
|
|
156
|
+
var DRAFT_IDLE_POLL_MS = 20000;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* And how often while the enable/disable handshake is in flight.
|
|
160
|
+
*
|
|
161
|
+
* Fast on purpose: the hidden iframe redirects through `/draft/enable`, and the
|
|
162
|
+
* page cannot do anything useful until that has landed.
|
|
163
|
+
*/
|
|
164
|
+
var DRAFT_HANDSHAKE_POLL_MS = 100;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* How long that fast phase may last before it gives up.
|
|
168
|
+
*
|
|
169
|
+
* Without a deadline it does not end: the only thing that clears `iframeSrc` is
|
|
170
|
+
* a `val-ready` message posted by the redirect target, so a frame that fails to
|
|
171
|
+
* load — a 500, an auth redirect, a dev server still compiling — left the page
|
|
172
|
+
* asking ten times a second, forever. A browser runs about six connections per
|
|
173
|
+
* origin, so that is enough to push `/stat`, `/patches` and the canvas document
|
|
174
|
+
* itself into the browser's own queue, where they are indistinguishable from a
|
|
175
|
+
* slow server.
|
|
176
|
+
*
|
|
177
|
+
* Generous enough for a first compile in `next dev`, which is the slowest case
|
|
178
|
+
* that is not a fault.
|
|
179
|
+
*/
|
|
180
|
+
var DRAFT_HANDSHAKE_TIMEOUT_MS = 10000;
|
|
149
181
|
var ValNextProvider = function ValNextProvider(props) {
|
|
150
182
|
var _draftModeReady$curre2;
|
|
151
183
|
// TODO: use config:
|
|
@@ -491,9 +523,32 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
491
523
|
return;
|
|
492
524
|
}
|
|
493
525
|
pollDraftStatIdRef.current--;
|
|
494
|
-
|
|
526
|
+
var handshaking = iframeSrc !== null;
|
|
527
|
+
if (handshaking && Date.now() - startedAt > DRAFT_HANDSHAKE_TIMEOUT_MS) {
|
|
528
|
+
/**
|
|
529
|
+
* The handshake did not complete, so stop hammering.
|
|
530
|
+
*
|
|
531
|
+
* Clearing `iframeSrc` unmounts the hidden frame and takes the poll
|
|
532
|
+
* back to its idle interval — which is the honest state: nothing is
|
|
533
|
+
* in progress any more. Leaving it set is what made this
|
|
534
|
+
* unrecoverable, because the ONLY other thing that clears it is the
|
|
535
|
+
* `val-ready` message the frame never sent.
|
|
536
|
+
*/
|
|
537
|
+
console.warn("Val: draft mode did not confirm in time. Falling back to the " + "idle poll — try toggling preview again.");
|
|
538
|
+
setIframeSrc(null);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
timeout = setTimeout(pollCurrentDraftMode, handshaking ? DRAFT_HANDSHAKE_POLL_MS : DRAFT_IDLE_POLL_MS);
|
|
495
542
|
});
|
|
496
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* When this spell of polling began.
|
|
546
|
+
*
|
|
547
|
+
* The effect re-runs when `iframeSrc` changes, so for the fast phase this is
|
|
548
|
+
* the moment the handshake started — which is what the deadline below is
|
|
549
|
+
* measured from.
|
|
550
|
+
*/
|
|
551
|
+
var startedAt = Date.now();
|
|
497
552
|
pollCurrentDraftMode();
|
|
498
553
|
return function () {
|
|
499
554
|
clearTimeout(timeout);
|
|
@@ -528,8 +583,23 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
528
583
|
var moduleFilePath = (_event$detail3 = event.detail) === null || _event$detail3 === void 0 ? void 0 : _event$detail3.moduleFilePath;
|
|
529
584
|
var source = (_event$detail4 = event.detail) === null || _event$detail4 === void 0 ? void 0 : _event$detail4.source;
|
|
530
585
|
if (typeof moduleFilePath === "string" && source !== undefined) {
|
|
531
|
-
valStore.update(moduleFilePath, source);
|
|
532
|
-
|
|
586
|
+
var changed = valStore.update(moduleFilePath, source);
|
|
587
|
+
/**
|
|
588
|
+
* Armed by a CHANGE, not by a message.
|
|
589
|
+
*
|
|
590
|
+
* The editor re-sends everything it holds whenever this page
|
|
591
|
+
* becomes a new document — a reload, or the one `next dev` does
|
|
592
|
+
* when a publish rewrites the `.val.ts` files — and most of that
|
|
593
|
+
* snapshot is content this page already has. Counting those
|
|
594
|
+
* bought a whole-route request per publish whether or not the
|
|
595
|
+
* page was out of date, which with auto-save on is one per pause
|
|
596
|
+
* in typing.
|
|
597
|
+
*
|
|
598
|
+
* The catch-up that MATTERS still refreshes: a page whose server
|
|
599
|
+
* render predates the write has no value for that module, so the
|
|
600
|
+
* first arrival counts as a change.
|
|
601
|
+
*/
|
|
602
|
+
if (changed && !props.disableRefresh) {
|
|
533
603
|
rerenderCounterRef.current++;
|
|
534
604
|
window.dispatchEvent(new Event(VAL_EDIT_LANDED));
|
|
535
605
|
}
|
|
@@ -10,12 +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-
|
|
13
|
+
var ValOverlayContext = require('./ValOverlayContext-5bd7628b.cjs.dev.js');
|
|
14
14
|
var stega = require('@valbuild/react/stega');
|
|
15
15
|
var internal = require('@valbuild/shared/internal');
|
|
16
16
|
var fallbackColors = require('./fallbackColors-9a2ac53a.cjs.dev.js');
|
|
17
17
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
18
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
18
|
+
var ValCanvasBridge = require('./ValCanvasBridge-9d148bdd.cjs.dev.js');
|
|
19
19
|
var jsxRuntime = require('react/jsx-runtime');
|
|
20
20
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
21
21
|
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
@@ -146,6 +146,38 @@ var SAFETY_REFRESH_WINDOW_MS = 30000;
|
|
|
146
146
|
* be torn down and rebuilt per keystroke.
|
|
147
147
|
*/
|
|
148
148
|
var VAL_EDIT_LANDED = "val-edit-landed";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* How often `/draft/stat` is asked when nothing is in progress.
|
|
152
|
+
*
|
|
153
|
+
* Draft mode changes when someone toggles it, which the handshake below already
|
|
154
|
+
* covers — so this is only there to notice it being changed somewhere else.
|
|
155
|
+
*/
|
|
156
|
+
var DRAFT_IDLE_POLL_MS = 20000;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* And how often while the enable/disable handshake is in flight.
|
|
160
|
+
*
|
|
161
|
+
* Fast on purpose: the hidden iframe redirects through `/draft/enable`, and the
|
|
162
|
+
* page cannot do anything useful until that has landed.
|
|
163
|
+
*/
|
|
164
|
+
var DRAFT_HANDSHAKE_POLL_MS = 100;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* How long that fast phase may last before it gives up.
|
|
168
|
+
*
|
|
169
|
+
* Without a deadline it does not end: the only thing that clears `iframeSrc` is
|
|
170
|
+
* a `val-ready` message posted by the redirect target, so a frame that fails to
|
|
171
|
+
* load — a 500, an auth redirect, a dev server still compiling — left the page
|
|
172
|
+
* asking ten times a second, forever. A browser runs about six connections per
|
|
173
|
+
* origin, so that is enough to push `/stat`, `/patches` and the canvas document
|
|
174
|
+
* itself into the browser's own queue, where they are indistinguishable from a
|
|
175
|
+
* slow server.
|
|
176
|
+
*
|
|
177
|
+
* Generous enough for a first compile in `next dev`, which is the slowest case
|
|
178
|
+
* that is not a fault.
|
|
179
|
+
*/
|
|
180
|
+
var DRAFT_HANDSHAKE_TIMEOUT_MS = 10000;
|
|
149
181
|
var ValNextProvider = function ValNextProvider(props) {
|
|
150
182
|
var _draftModeReady$curre2;
|
|
151
183
|
// TODO: use config:
|
|
@@ -491,9 +523,32 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
491
523
|
return;
|
|
492
524
|
}
|
|
493
525
|
pollDraftStatIdRef.current--;
|
|
494
|
-
|
|
526
|
+
var handshaking = iframeSrc !== null;
|
|
527
|
+
if (handshaking && Date.now() - startedAt > DRAFT_HANDSHAKE_TIMEOUT_MS) {
|
|
528
|
+
/**
|
|
529
|
+
* The handshake did not complete, so stop hammering.
|
|
530
|
+
*
|
|
531
|
+
* Clearing `iframeSrc` unmounts the hidden frame and takes the poll
|
|
532
|
+
* back to its idle interval — which is the honest state: nothing is
|
|
533
|
+
* in progress any more. Leaving it set is what made this
|
|
534
|
+
* unrecoverable, because the ONLY other thing that clears it is the
|
|
535
|
+
* `val-ready` message the frame never sent.
|
|
536
|
+
*/
|
|
537
|
+
console.warn("Val: draft mode did not confirm in time. Falling back to the " + "idle poll — try toggling preview again.");
|
|
538
|
+
setIframeSrc(null);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
timeout = setTimeout(pollCurrentDraftMode, handshaking ? DRAFT_HANDSHAKE_POLL_MS : DRAFT_IDLE_POLL_MS);
|
|
495
542
|
});
|
|
496
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* When this spell of polling began.
|
|
546
|
+
*
|
|
547
|
+
* The effect re-runs when `iframeSrc` changes, so for the fast phase this is
|
|
548
|
+
* the moment the handshake started — which is what the deadline below is
|
|
549
|
+
* measured from.
|
|
550
|
+
*/
|
|
551
|
+
var startedAt = Date.now();
|
|
497
552
|
pollCurrentDraftMode();
|
|
498
553
|
return function () {
|
|
499
554
|
clearTimeout(timeout);
|
|
@@ -528,8 +583,23 @@ var ValNextProvider = function ValNextProvider(props) {
|
|
|
528
583
|
var moduleFilePath = (_event$detail3 = event.detail) === null || _event$detail3 === void 0 ? void 0 : _event$detail3.moduleFilePath;
|
|
529
584
|
var source = (_event$detail4 = event.detail) === null || _event$detail4 === void 0 ? void 0 : _event$detail4.source;
|
|
530
585
|
if (typeof moduleFilePath === "string" && source !== undefined) {
|
|
531
|
-
valStore.update(moduleFilePath, source);
|
|
532
|
-
|
|
586
|
+
var changed = valStore.update(moduleFilePath, source);
|
|
587
|
+
/**
|
|
588
|
+
* Armed by a CHANGE, not by a message.
|
|
589
|
+
*
|
|
590
|
+
* The editor re-sends everything it holds whenever this page
|
|
591
|
+
* becomes a new document — a reload, or the one `next dev` does
|
|
592
|
+
* when a publish rewrites the `.val.ts` files — and most of that
|
|
593
|
+
* snapshot is content this page already has. Counting those
|
|
594
|
+
* bought a whole-route request per publish whether or not the
|
|
595
|
+
* page was out of date, which with auto-save on is one per pause
|
|
596
|
+
* in typing.
|
|
597
|
+
*
|
|
598
|
+
* The catch-up that MATTERS still refreshes: a page whose server
|
|
599
|
+
* render predates the write has no value for that module, so the
|
|
600
|
+
* first arrival counts as a change.
|
|
601
|
+
*/
|
|
602
|
+
if (changed && !props.disableRefresh) {
|
|
533
603
|
rerenderCounterRef.current++;
|
|
534
604
|
window.dispatchEvent(new Event(VAL_EDIT_LANDED));
|
|
535
605
|
}
|
package/dist/{ValOverlayContext-ca3b6ebd.cjs.dev.js → ValOverlayContext-5bd7628b.cjs.dev.js}
RENAMED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
7
7
|
var defineProperty = require('./defineProperty-f90345d7.cjs.dev.js');
|
|
8
|
+
var patch = require('@valbuild/core/patch');
|
|
8
9
|
var React = require('react');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
11
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
@@ -181,8 +182,36 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
181
182
|
}
|
|
182
183
|
return _createClass(ValExternalStore, [{
|
|
183
184
|
key: "update",
|
|
184
|
-
value:
|
|
185
|
+
value:
|
|
186
|
+
/**
|
|
187
|
+
* Take a module's source from the editor.
|
|
188
|
+
*
|
|
189
|
+
* Returns whether this actually MOVED the value, which the caller needs and
|
|
190
|
+
* cannot work out for itself: the same source arrives more than once by
|
|
191
|
+
* design. The editor sends a catch-up snapshot of everything it holds every
|
|
192
|
+
* time the page becomes a new document — a reload, or the one `next dev` does
|
|
193
|
+
* when a publish rewrites the `.val.ts` files — and most of that snapshot is
|
|
194
|
+
* content this page already has.
|
|
195
|
+
*
|
|
196
|
+
* Without the answer, `ValNextProvider` armed its `router.refresh()` loop on
|
|
197
|
+
* the arrival rather than on the change, so every publish bought a whole-route
|
|
198
|
+
* request whether or not the page was out of date. With auto-save on that is
|
|
199
|
+
* one per pause in typing, which in development is a re-render (and sometimes
|
|
200
|
+
* a recompile) of the page — and it is what leaves the canvas looking
|
|
201
|
+
* permanently busy.
|
|
202
|
+
*/
|
|
203
|
+
function update(path, source) {
|
|
204
|
+
// `Json` has no `undefined`, so absent and "stored as undefined" cannot be
|
|
205
|
+
// confused: a miss here means this page has never been given this module.
|
|
206
|
+
var before = this.loadedSources.get(path);
|
|
207
|
+
var changed = before === undefined || !patch.deepEqual(before, source);
|
|
185
208
|
this.loadedSources.set(path, source);
|
|
209
|
+
if (!changed) {
|
|
210
|
+
// Nothing downstream to do: every subscriber's snapshot still answers
|
|
211
|
+
// with the same value, so invalidating them would be a re-render that
|
|
212
|
+
// shows exactly what is already on screen.
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
186
215
|
// Invalidate cached snapshots that include this path so the next get()
|
|
187
216
|
// rebuilds a fresh (new-reference) record, then notify their listeners.
|
|
188
217
|
for (var _i = 0, _Array$from = Array.from(this.snapshots.keys()); _i < _Array$from.length; _i++) {
|
|
@@ -210,6 +239,7 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
210
239
|
var listener = _Array$from2[_i2];
|
|
211
240
|
listener();
|
|
212
241
|
}
|
|
242
|
+
return true;
|
|
213
243
|
}
|
|
214
244
|
}, {
|
|
215
245
|
key: "emitChange",
|
package/dist/{ValOverlayContext-1d019b95.cjs.prod.js → ValOverlayContext-d690744f.cjs.prod.js}
RENAMED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
|
|
7
7
|
var defineProperty = require('./defineProperty-8951f469.cjs.prod.js');
|
|
8
|
+
var patch = require('@valbuild/core/patch');
|
|
8
9
|
var React = require('react');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
11
|
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
@@ -181,8 +182,36 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
181
182
|
}
|
|
182
183
|
return _createClass(ValExternalStore, [{
|
|
183
184
|
key: "update",
|
|
184
|
-
value:
|
|
185
|
+
value:
|
|
186
|
+
/**
|
|
187
|
+
* Take a module's source from the editor.
|
|
188
|
+
*
|
|
189
|
+
* Returns whether this actually MOVED the value, which the caller needs and
|
|
190
|
+
* cannot work out for itself: the same source arrives more than once by
|
|
191
|
+
* design. The editor sends a catch-up snapshot of everything it holds every
|
|
192
|
+
* time the page becomes a new document — a reload, or the one `next dev` does
|
|
193
|
+
* when a publish rewrites the `.val.ts` files — and most of that snapshot is
|
|
194
|
+
* content this page already has.
|
|
195
|
+
*
|
|
196
|
+
* Without the answer, `ValNextProvider` armed its `router.refresh()` loop on
|
|
197
|
+
* the arrival rather than on the change, so every publish bought a whole-route
|
|
198
|
+
* request whether or not the page was out of date. With auto-save on that is
|
|
199
|
+
* one per pause in typing, which in development is a re-render (and sometimes
|
|
200
|
+
* a recompile) of the page — and it is what leaves the canvas looking
|
|
201
|
+
* permanently busy.
|
|
202
|
+
*/
|
|
203
|
+
function update(path, source) {
|
|
204
|
+
// `Json` has no `undefined`, so absent and "stored as undefined" cannot be
|
|
205
|
+
// confused: a miss here means this page has never been given this module.
|
|
206
|
+
var before = this.loadedSources.get(path);
|
|
207
|
+
var changed = before === undefined || !patch.deepEqual(before, source);
|
|
185
208
|
this.loadedSources.set(path, source);
|
|
209
|
+
if (!changed) {
|
|
210
|
+
// Nothing downstream to do: every subscriber's snapshot still answers
|
|
211
|
+
// with the same value, so invalidating them would be a re-render that
|
|
212
|
+
// shows exactly what is already on screen.
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
186
215
|
// Invalidate cached snapshots that include this path so the next get()
|
|
187
216
|
// rebuilds a fresh (new-reference) record, then notify their listeners.
|
|
188
217
|
for (var _i = 0, _Array$from = Array.from(this.snapshots.keys()); _i < _Array$from.length; _i++) {
|
|
@@ -210,6 +239,7 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
210
239
|
var listener = _Array$from2[_i2];
|
|
211
240
|
listener();
|
|
212
241
|
}
|
|
242
|
+
return true;
|
|
213
243
|
}
|
|
214
244
|
}, {
|
|
215
245
|
key: "emitChange",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
|
|
3
3
|
import { a as _toPropertyKey, _ as _defineProperty } from './defineProperty-cca5affa.esm.js';
|
|
4
|
+
import { deepEqual } from '@valbuild/core/patch';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
7
|
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
|
@@ -173,8 +174,36 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
173
174
|
}
|
|
174
175
|
return _createClass(ValExternalStore, [{
|
|
175
176
|
key: "update",
|
|
176
|
-
value:
|
|
177
|
+
value:
|
|
178
|
+
/**
|
|
179
|
+
* Take a module's source from the editor.
|
|
180
|
+
*
|
|
181
|
+
* Returns whether this actually MOVED the value, which the caller needs and
|
|
182
|
+
* cannot work out for itself: the same source arrives more than once by
|
|
183
|
+
* design. The editor sends a catch-up snapshot of everything it holds every
|
|
184
|
+
* time the page becomes a new document — a reload, or the one `next dev` does
|
|
185
|
+
* when a publish rewrites the `.val.ts` files — and most of that snapshot is
|
|
186
|
+
* content this page already has.
|
|
187
|
+
*
|
|
188
|
+
* Without the answer, `ValNextProvider` armed its `router.refresh()` loop on
|
|
189
|
+
* the arrival rather than on the change, so every publish bought a whole-route
|
|
190
|
+
* request whether or not the page was out of date. With auto-save on that is
|
|
191
|
+
* one per pause in typing, which in development is a re-render (and sometimes
|
|
192
|
+
* a recompile) of the page — and it is what leaves the canvas looking
|
|
193
|
+
* permanently busy.
|
|
194
|
+
*/
|
|
195
|
+
function update(path, source) {
|
|
196
|
+
// `Json` has no `undefined`, so absent and "stored as undefined" cannot be
|
|
197
|
+
// confused: a miss here means this page has never been given this module.
|
|
198
|
+
var before = this.loadedSources.get(path);
|
|
199
|
+
var changed = before === undefined || !deepEqual(before, source);
|
|
177
200
|
this.loadedSources.set(path, source);
|
|
201
|
+
if (!changed) {
|
|
202
|
+
// Nothing downstream to do: every subscriber's snapshot still answers
|
|
203
|
+
// with the same value, so invalidating them would be a re-render that
|
|
204
|
+
// shows exactly what is already on screen.
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
178
207
|
// Invalidate cached snapshots that include this path so the next get()
|
|
179
208
|
// rebuilds a fresh (new-reference) record, then notify their listeners.
|
|
180
209
|
for (var _i = 0, _Array$from = Array.from(this.snapshots.keys()); _i < _Array$from.length; _i++) {
|
|
@@ -202,6 +231,7 @@ var ValExternalStore = /*#__PURE__*/function () {
|
|
|
202
231
|
var listener = _Array$from2[_i2];
|
|
203
232
|
listener();
|
|
204
233
|
}
|
|
234
|
+
return true;
|
|
205
235
|
}
|
|
206
236
|
}, {
|
|
207
237
|
key: "emitChange",
|
|
@@ -7,7 +7,7 @@ var objectSpread2 = require('./objectSpread2-58024783.cjs.dev.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var internal = require('@valbuild/react/internal');
|
|
10
|
-
var ValNextProvider = require('./ValNextProvider-
|
|
10
|
+
var ValNextProvider = require('./ValNextProvider-f206d2ea.cjs.dev.js');
|
|
11
11
|
var NextImage = require('next/image');
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-c1c3ef55.cjs.dev.js');
|
|
@@ -7,7 +7,7 @@ var objectSpread2 = require('./objectSpread2-13f847a9.cjs.prod.js');
|
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var internal = require('@valbuild/react/internal');
|
|
10
|
-
var ValNextProvider = require('./ValNextProvider-
|
|
10
|
+
var ValNextProvider = require('./ValNextProvider-bd3f89d3.cjs.prod.js');
|
|
11
11
|
var NextImage = require('next/image');
|
|
12
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
13
|
var ValApp = require('./ValApp-90c4171d.cjs.prod.js');
|
|
@@ -6,7 +6,7 @@ export { core as expr };
|
|
|
6
6
|
export { GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
|
|
7
7
|
import { stegaEncode, stegaDecodeStrings, attrs, raw, autoTagJSX } from '@valbuild/react/stega';
|
|
8
8
|
export { ValRichText } from '@valbuild/react/internal';
|
|
9
|
-
import { ValNextProvider } from './ValNextProvider-
|
|
9
|
+
import { ValNextProvider } from './ValNextProvider-588f2ff0.esm.js';
|
|
10
10
|
import NextImage from 'next/image';
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
export { ValApp } from './ValApp-e17eb734.esm.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.108.
|
|
15
|
+
"version": "0.108.4",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
50
|
"@valbuild/core": "0.106.0",
|
|
51
|
-
"@valbuild/language-server": "0.108.
|
|
52
|
-
"@valbuild/react": "0.108.
|
|
53
|
-
"@valbuild/
|
|
51
|
+
"@valbuild/language-server": "0.108.4",
|
|
52
|
+
"@valbuild/react": "0.108.4",
|
|
53
|
+
"@valbuild/server": "0.108.4",
|
|
54
54
|
"@valbuild/shared": "0.108.0",
|
|
55
|
-
"@valbuild/
|
|
55
|
+
"@valbuild/ui": "0.108.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@testing-library/react": "^16.3.3",
|