@valbuild/tanstack 0.150.10 → 0.150.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/valbuild-tanstack.cjs.dev.js +119 -2
- package/dist/valbuild-tanstack.cjs.prod.js +119 -2
- package/dist/valbuild-tanstack.esm.js +120 -3
- package/dist/{version-dd9d61dc.esm.js → version-714daf1c.esm.js} +1 -1
- package/dist/{version-662ab951.cjs.prod.js → version-7fc90d7f.cjs.prod.js} +1 -1
- package/dist/{version-be9f137f.cjs.dev.js → version-f4d4c3b3.cjs.dev.js} +1 -1
- package/package.json +7 -7
- package/server/dist/valbuild-tanstack-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-tanstack-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-tanstack-server.esm.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @valbuild/tanstack
|
|
2
2
|
|
|
3
|
+
## 0.150.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#974](https://github.com/valbuild/val/pull/974) [`9c6bc8d`](https://github.com/valbuild/val/commit/9c6bc8d25f40427a6fb9eec6ff5506996b718a78) Thanks [@freekh](https://github.com/freekh)! - The design tab no longer makes you wait.
|
|
8
|
+
|
|
9
|
+
- **Quick preview.** A change to components, layout or styles is shown in seconds, without a build: the proposal's browser code is bundled in the tab and the page in the preview runs it. What runs on the server (loaders, server functions, the page's first render) stays the last build's, and the tab says so, with a button to build. The assistant has it too (`quick_preview`).
|
|
10
|
+
- **Cancel and Try again.** A build can be cancelled from the tab, and a build that stops making progress for three minutes is stopped, saying at which step, so it never spins until a reload. The assistant waits for a build with `wait` instead of holding its turn, and has `build_status` and `cancel_build`.
|
|
11
|
+
- **Each step of a build is timed**, and the Build check lists where the time went.
|
|
12
|
+
- **A new build fades in where you were**, at the same page and scroll, instead of the preview going blank and starting over at the top.
|
|
13
|
+
- **`read_page`** lets the assistant check its change on the page: the headings, text, links, images and inputs in order, and one element's computed styles and how many lines it wraps to, at desktop, tablet or phone width.
|
|
14
|
+
- **On a phone**, the design tab shows the preview, the assistant and the changes one at a time, as tabs. Picking is Select, then a tap, and a pick takes you to the assistant with it. On Safari and on an iPhone, where the tab cannot bundle code itself, the quick preview is prepared in a builder tab, as a build already is.
|
|
15
|
+
- **Queue messages in the assistant's chat.** Write while it answers: what you write waits and is sent when the answer is done, one at a time. A queued message can be taken back to edit, moved up or removed, and Stop or a failed answer holds the queue until you go on.
|
|
16
|
+
|
|
17
|
+
The quick preview and `read_page` run in the proposal's own page, through the canvas bridge in `@valbuild/next` and `@valbuild/tanstack`, so a site needs those packages at this version for them. The quick preview is served by a service worker on the proposal's address (`/api/val/quick-preview-sw.js`), which takes code only from the site's own design tab.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`9abd5ef`](https://github.com/valbuild/val/commit/9abd5efea0c1adc7e7ff2d05b2ea38b76af73b38), [`9c6bc8d`](https://github.com/valbuild/val/commit/9c6bc8d25f40427a6fb9eec6ff5506996b718a78)]:
|
|
20
|
+
- @valbuild/ui@0.150.11
|
|
21
|
+
- @valbuild/shared@0.150.11
|
|
22
|
+
- @valbuild/server@0.150.11
|
|
23
|
+
- @valbuild/react@0.150.11
|
|
24
|
+
- @valbuild/language-server@0.150.11
|
|
25
|
+
- @valbuild/mcp@0.150.11
|
|
26
|
+
|
|
3
27
|
## 0.150.10
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ var asyncToGenerator = require('./asyncToGenerator-c3823d62.cjs.dev.js');
|
|
|
6
6
|
var _typeof = require('./typeof-dd0246a1.cjs.dev.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
|
-
var version = require('./version-
|
|
9
|
+
var version = require('./version-f4d4c3b3.cjs.dev.js');
|
|
10
10
|
var internal = require('@valbuild/react/internal');
|
|
11
11
|
var ui = require('@valbuild/ui');
|
|
12
12
|
var reactRouter = require('@tanstack/react-router');
|
|
@@ -299,6 +299,14 @@ function ValCanvasBridge(_ref) {
|
|
|
299
299
|
var elementPickingActive = React__default["default"].useRef(false);
|
|
300
300
|
elementPickingActive.current = (elementPicking === null || elementPicking === void 0 ? void 0 : elementPicking.active) === true;
|
|
301
301
|
var elementPicker = React__default["default"].useRef(null);
|
|
302
|
+
/** A scroll back to where the last build was, still trying. */
|
|
303
|
+
var stopRestoring = React__default["default"].useRef(null);
|
|
304
|
+
React__default["default"].useEffect(function () {
|
|
305
|
+
return function () {
|
|
306
|
+
var _stopRestoring$curren;
|
|
307
|
+
return (_stopRestoring$curren = stopRestoring.current) === null || _stopRestoring$curren === void 0 ? void 0 : _stopRestoring$curren.call(stopRestoring);
|
|
308
|
+
};
|
|
309
|
+
}, []);
|
|
302
310
|
var post = React__default["default"].useCallback(function (message) {
|
|
303
311
|
// `*` as the target origin: the studio and the page share an origin today,
|
|
304
312
|
// but the frame does not know the parent's origin for certain and naming
|
|
@@ -524,6 +532,81 @@ function ValCanvasBridge(_ref) {
|
|
|
524
532
|
});
|
|
525
533
|
return;
|
|
526
534
|
}
|
|
535
|
+
if (message.type === "scrollTo") {
|
|
536
|
+
var _stopRestoring$curren2;
|
|
537
|
+
// Where the build before this one was: the design tab swaps a new
|
|
538
|
+
// build in at the same place.
|
|
539
|
+
(_stopRestoring$curren2 = stopRestoring.current) === null || _stopRestoring$curren2 === void 0 || _stopRestoring$curren2.call(stopRestoring);
|
|
540
|
+
stopRestoring.current = client.restoreScroll(window, message.x, message.y);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (message.type === "readPage") {
|
|
544
|
+
// The assistant's `read_page`: what is on the page, read here because
|
|
545
|
+
// the tab is another origin and cannot. The page's words, unpublished
|
|
546
|
+
// ones included, so only for the frame's parent, and only when that
|
|
547
|
+
// is the site's design tab or the Studio here -- and answered to it
|
|
548
|
+
// alone, not to `*`.
|
|
549
|
+
if (event.source !== window.parent) return;
|
|
550
|
+
var asker = event.origin;
|
|
551
|
+
void client.isDesignTabOrigin(asker, {
|
|
552
|
+
api: "/api/val",
|
|
553
|
+
own: window.location.origin
|
|
554
|
+
}).then(function (trusted) {
|
|
555
|
+
if (trusted) window.parent.postMessage(readPageReply(message), asker);
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (message.type === "quickPreview") {
|
|
560
|
+
// Code that will run on this address: only from the frame's parent,
|
|
561
|
+
// and only when that is the site's design tab. See `quickPreview.ts`.
|
|
562
|
+
if (event.source !== window.parent) return;
|
|
563
|
+
var id = message.id,
|
|
564
|
+
files = message.files;
|
|
565
|
+
var origin = event.origin;
|
|
566
|
+
void asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee() {
|
|
567
|
+
var site, _t;
|
|
568
|
+
return asyncToGenerator._regenerator().w(function (_context) {
|
|
569
|
+
while (1) switch (_context.p = _context.n) {
|
|
570
|
+
case 0:
|
|
571
|
+
_context.p = 0;
|
|
572
|
+
_context.n = 1;
|
|
573
|
+
return client.quickPreviewSiteOrigin("/api/val");
|
|
574
|
+
case 1:
|
|
575
|
+
site = _context.v;
|
|
576
|
+
if (!(site === null || site !== origin)) {
|
|
577
|
+
_context.n = 2;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
throw new Error("Only the site's design tab can show a quick preview of this proposal.");
|
|
581
|
+
case 2:
|
|
582
|
+
_context.n = 3;
|
|
583
|
+
return client.storeQuickPreview(id, files, {
|
|
584
|
+
swUrl: "/api/val".concat(client.QUICK_PREVIEW_SERVICE_WORKER_PATH)
|
|
585
|
+
});
|
|
586
|
+
case 3:
|
|
587
|
+
post({
|
|
588
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
589
|
+
type: "quickPreviewStored",
|
|
590
|
+
id: id
|
|
591
|
+
});
|
|
592
|
+
_context.n = 5;
|
|
593
|
+
break;
|
|
594
|
+
case 4:
|
|
595
|
+
_context.p = 4;
|
|
596
|
+
_t = _context.v;
|
|
597
|
+
post({
|
|
598
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
599
|
+
type: "quickPreviewStored",
|
|
600
|
+
id: id,
|
|
601
|
+
error: _t instanceof Error ? _t.message : String(_t)
|
|
602
|
+
});
|
|
603
|
+
case 5:
|
|
604
|
+
return _context.a(2);
|
|
605
|
+
}
|
|
606
|
+
}, _callee, null, [[0, 4]]);
|
|
607
|
+
}))();
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
527
610
|
if (message.type === "theme") {
|
|
528
611
|
setSelectionColors({
|
|
529
612
|
selection: message.selection,
|
|
@@ -572,7 +655,17 @@ function ValCanvasBridge(_ref) {
|
|
|
572
655
|
return function () {
|
|
573
656
|
return window.removeEventListener("message", listener);
|
|
574
657
|
};
|
|
575
|
-
}, [scan]);
|
|
658
|
+
}, [scan, post]);
|
|
659
|
+
|
|
660
|
+
// Where the page is, as it moves: the design tab opens a new build there.
|
|
661
|
+
React__default["default"].useEffect(function () {
|
|
662
|
+
return client.watchPageLocation(window, function (location) {
|
|
663
|
+
return post(_typeof._objectSpread2({
|
|
664
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
665
|
+
type: "location"
|
|
666
|
+
}, location));
|
|
667
|
+
});
|
|
668
|
+
}, [post]);
|
|
576
669
|
|
|
577
670
|
/**
|
|
578
671
|
* Picking.
|
|
@@ -908,6 +1001,30 @@ function findByPath(path) {
|
|
|
908
1001
|
return null;
|
|
909
1002
|
}
|
|
910
1003
|
|
|
1004
|
+
/** What `readPage` answers: the page read, or why it could not be. */
|
|
1005
|
+
function readPageReply(message) {
|
|
1006
|
+
try {
|
|
1007
|
+
return {
|
|
1008
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1009
|
+
type: "pageRead",
|
|
1010
|
+
requestId: message.requestId,
|
|
1011
|
+
snapshot: client.readPageSnapshot(document, _typeof._objectSpread2(_typeof._objectSpread2({}, message.selector !== undefined ? {
|
|
1012
|
+
selector: message.selector
|
|
1013
|
+
} : {}), message.maxItems !== undefined ? {
|
|
1014
|
+
maxItems: message.maxItems
|
|
1015
|
+
} : {}))
|
|
1016
|
+
};
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
return {
|
|
1019
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1020
|
+
type: "pageRead",
|
|
1021
|
+
requestId: message.requestId,
|
|
1022
|
+
snapshot: null,
|
|
1023
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
911
1028
|
/**
|
|
912
1029
|
* Whether the page should re-read the server on its own, right now.
|
|
913
1030
|
*
|
|
@@ -6,7 +6,7 @@ var asyncToGenerator = require('./asyncToGenerator-8e5c36c8.cjs.prod.js');
|
|
|
6
6
|
var _typeof = require('./typeof-8998e126.cjs.prod.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
|
-
var version = require('./version-
|
|
9
|
+
var version = require('./version-7fc90d7f.cjs.prod.js');
|
|
10
10
|
var internal = require('@valbuild/react/internal');
|
|
11
11
|
var ui = require('@valbuild/ui');
|
|
12
12
|
var reactRouter = require('@tanstack/react-router');
|
|
@@ -299,6 +299,14 @@ function ValCanvasBridge(_ref) {
|
|
|
299
299
|
var elementPickingActive = React__default["default"].useRef(false);
|
|
300
300
|
elementPickingActive.current = (elementPicking === null || elementPicking === void 0 ? void 0 : elementPicking.active) === true;
|
|
301
301
|
var elementPicker = React__default["default"].useRef(null);
|
|
302
|
+
/** A scroll back to where the last build was, still trying. */
|
|
303
|
+
var stopRestoring = React__default["default"].useRef(null);
|
|
304
|
+
React__default["default"].useEffect(function () {
|
|
305
|
+
return function () {
|
|
306
|
+
var _stopRestoring$curren;
|
|
307
|
+
return (_stopRestoring$curren = stopRestoring.current) === null || _stopRestoring$curren === void 0 ? void 0 : _stopRestoring$curren.call(stopRestoring);
|
|
308
|
+
};
|
|
309
|
+
}, []);
|
|
302
310
|
var post = React__default["default"].useCallback(function (message) {
|
|
303
311
|
// `*` as the target origin: the studio and the page share an origin today,
|
|
304
312
|
// but the frame does not know the parent's origin for certain and naming
|
|
@@ -524,6 +532,81 @@ function ValCanvasBridge(_ref) {
|
|
|
524
532
|
});
|
|
525
533
|
return;
|
|
526
534
|
}
|
|
535
|
+
if (message.type === "scrollTo") {
|
|
536
|
+
var _stopRestoring$curren2;
|
|
537
|
+
// Where the build before this one was: the design tab swaps a new
|
|
538
|
+
// build in at the same place.
|
|
539
|
+
(_stopRestoring$curren2 = stopRestoring.current) === null || _stopRestoring$curren2 === void 0 || _stopRestoring$curren2.call(stopRestoring);
|
|
540
|
+
stopRestoring.current = client.restoreScroll(window, message.x, message.y);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (message.type === "readPage") {
|
|
544
|
+
// The assistant's `read_page`: what is on the page, read here because
|
|
545
|
+
// the tab is another origin and cannot. The page's words, unpublished
|
|
546
|
+
// ones included, so only for the frame's parent, and only when that
|
|
547
|
+
// is the site's design tab or the Studio here -- and answered to it
|
|
548
|
+
// alone, not to `*`.
|
|
549
|
+
if (event.source !== window.parent) return;
|
|
550
|
+
var asker = event.origin;
|
|
551
|
+
void client.isDesignTabOrigin(asker, {
|
|
552
|
+
api: "/api/val",
|
|
553
|
+
own: window.location.origin
|
|
554
|
+
}).then(function (trusted) {
|
|
555
|
+
if (trusted) window.parent.postMessage(readPageReply(message), asker);
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (message.type === "quickPreview") {
|
|
560
|
+
// Code that will run on this address: only from the frame's parent,
|
|
561
|
+
// and only when that is the site's design tab. See `quickPreview.ts`.
|
|
562
|
+
if (event.source !== window.parent) return;
|
|
563
|
+
var id = message.id,
|
|
564
|
+
files = message.files;
|
|
565
|
+
var origin = event.origin;
|
|
566
|
+
void asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee() {
|
|
567
|
+
var site, _t;
|
|
568
|
+
return asyncToGenerator._regenerator().w(function (_context) {
|
|
569
|
+
while (1) switch (_context.p = _context.n) {
|
|
570
|
+
case 0:
|
|
571
|
+
_context.p = 0;
|
|
572
|
+
_context.n = 1;
|
|
573
|
+
return client.quickPreviewSiteOrigin("/api/val");
|
|
574
|
+
case 1:
|
|
575
|
+
site = _context.v;
|
|
576
|
+
if (!(site === null || site !== origin)) {
|
|
577
|
+
_context.n = 2;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
throw new Error("Only the site's design tab can show a quick preview of this proposal.");
|
|
581
|
+
case 2:
|
|
582
|
+
_context.n = 3;
|
|
583
|
+
return client.storeQuickPreview(id, files, {
|
|
584
|
+
swUrl: "/api/val".concat(client.QUICK_PREVIEW_SERVICE_WORKER_PATH)
|
|
585
|
+
});
|
|
586
|
+
case 3:
|
|
587
|
+
post({
|
|
588
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
589
|
+
type: "quickPreviewStored",
|
|
590
|
+
id: id
|
|
591
|
+
});
|
|
592
|
+
_context.n = 5;
|
|
593
|
+
break;
|
|
594
|
+
case 4:
|
|
595
|
+
_context.p = 4;
|
|
596
|
+
_t = _context.v;
|
|
597
|
+
post({
|
|
598
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
599
|
+
type: "quickPreviewStored",
|
|
600
|
+
id: id,
|
|
601
|
+
error: _t instanceof Error ? _t.message : String(_t)
|
|
602
|
+
});
|
|
603
|
+
case 5:
|
|
604
|
+
return _context.a(2);
|
|
605
|
+
}
|
|
606
|
+
}, _callee, null, [[0, 4]]);
|
|
607
|
+
}))();
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
527
610
|
if (message.type === "theme") {
|
|
528
611
|
setSelectionColors({
|
|
529
612
|
selection: message.selection,
|
|
@@ -572,7 +655,17 @@ function ValCanvasBridge(_ref) {
|
|
|
572
655
|
return function () {
|
|
573
656
|
return window.removeEventListener("message", listener);
|
|
574
657
|
};
|
|
575
|
-
}, [scan]);
|
|
658
|
+
}, [scan, post]);
|
|
659
|
+
|
|
660
|
+
// Where the page is, as it moves: the design tab opens a new build there.
|
|
661
|
+
React__default["default"].useEffect(function () {
|
|
662
|
+
return client.watchPageLocation(window, function (location) {
|
|
663
|
+
return post(_typeof._objectSpread2({
|
|
664
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
665
|
+
type: "location"
|
|
666
|
+
}, location));
|
|
667
|
+
});
|
|
668
|
+
}, [post]);
|
|
576
669
|
|
|
577
670
|
/**
|
|
578
671
|
* Picking.
|
|
@@ -908,6 +1001,30 @@ function findByPath(path) {
|
|
|
908
1001
|
return null;
|
|
909
1002
|
}
|
|
910
1003
|
|
|
1004
|
+
/** What `readPage` answers: the page read, or why it could not be. */
|
|
1005
|
+
function readPageReply(message) {
|
|
1006
|
+
try {
|
|
1007
|
+
return {
|
|
1008
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1009
|
+
type: "pageRead",
|
|
1010
|
+
requestId: message.requestId,
|
|
1011
|
+
snapshot: client.readPageSnapshot(document, _typeof._objectSpread2(_typeof._objectSpread2({}, message.selector !== undefined ? {
|
|
1012
|
+
selector: message.selector
|
|
1013
|
+
} : {}), message.maxItems !== undefined ? {
|
|
1014
|
+
maxItems: message.maxItems
|
|
1015
|
+
} : {}))
|
|
1016
|
+
};
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
return {
|
|
1019
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1020
|
+
type: "pageRead",
|
|
1021
|
+
requestId: message.requestId,
|
|
1022
|
+
snapshot: null,
|
|
1023
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
911
1028
|
/**
|
|
912
1029
|
* Whether the page should re-read the server on its own, right now.
|
|
913
1030
|
*
|
|
@@ -5,13 +5,13 @@ 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, isReactDevelopmentBuild, watchStegaLeaks, stegaLeakMessage, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX } from '@valbuild/react/stega';
|
|
8
|
-
import { r as readValEnableCookie, _ as _toConsumableArray, V as VERSION$1 } from './version-
|
|
8
|
+
import { r as readValEnableCookie, _ as _toConsumableArray, V as VERSION$1 } from './version-714daf1c.esm.js';
|
|
9
9
|
export { ValRichText } from '@valbuild/react/internal';
|
|
10
10
|
import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID, VAL_APP_ID } from '@valbuild/ui';
|
|
11
11
|
import { useRouter, useRouterState } from '@tanstack/react-router';
|
|
12
12
|
import React, { useEffect, useRef, useState } from 'react';
|
|
13
13
|
import { V as ValExternalStore, a as ValOverlayProvider } from './ValOverlayContext-6411bbe3.esm.js';
|
|
14
|
-
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, startElementPicking, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, isValCanvasFrame } from '@valbuild/shared/client';
|
|
14
|
+
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, watchPageLocation, startElementPicking, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, restoreScroll, isDesignTabOrigin, storeQuickPreview, QUICK_PREVIEW_SERVICE_WORKER_PATH, quickPreviewSiteOrigin, readPageSnapshot, isValCanvasFrame } from '@valbuild/shared/client';
|
|
15
15
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
16
|
import { D as DEMO_CLAIM_MESSAGE, a as DEMO_SERVICE_WORKER_PATH, b as DEMO_RELAY_MESSAGE } from './demoServiceWorker-56fd96cf.esm.js';
|
|
17
17
|
import '@valbuild/core/patch';
|
|
@@ -275,6 +275,14 @@ function ValCanvasBridge(_ref) {
|
|
|
275
275
|
var elementPickingActive = React.useRef(false);
|
|
276
276
|
elementPickingActive.current = (elementPicking === null || elementPicking === void 0 ? void 0 : elementPicking.active) === true;
|
|
277
277
|
var elementPicker = React.useRef(null);
|
|
278
|
+
/** A scroll back to where the last build was, still trying. */
|
|
279
|
+
var stopRestoring = React.useRef(null);
|
|
280
|
+
React.useEffect(function () {
|
|
281
|
+
return function () {
|
|
282
|
+
var _stopRestoring$curren;
|
|
283
|
+
return (_stopRestoring$curren = stopRestoring.current) === null || _stopRestoring$curren === void 0 ? void 0 : _stopRestoring$curren.call(stopRestoring);
|
|
284
|
+
};
|
|
285
|
+
}, []);
|
|
278
286
|
var post = React.useCallback(function (message) {
|
|
279
287
|
// `*` as the target origin: the studio and the page share an origin today,
|
|
280
288
|
// but the frame does not know the parent's origin for certain and naming
|
|
@@ -500,6 +508,81 @@ function ValCanvasBridge(_ref) {
|
|
|
500
508
|
});
|
|
501
509
|
return;
|
|
502
510
|
}
|
|
511
|
+
if (message.type === "scrollTo") {
|
|
512
|
+
var _stopRestoring$curren2;
|
|
513
|
+
// Where the build before this one was: the design tab swaps a new
|
|
514
|
+
// build in at the same place.
|
|
515
|
+
(_stopRestoring$curren2 = stopRestoring.current) === null || _stopRestoring$curren2 === void 0 || _stopRestoring$curren2.call(stopRestoring);
|
|
516
|
+
stopRestoring.current = restoreScroll(window, message.x, message.y);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (message.type === "readPage") {
|
|
520
|
+
// The assistant's `read_page`: what is on the page, read here because
|
|
521
|
+
// the tab is another origin and cannot. The page's words, unpublished
|
|
522
|
+
// ones included, so only for the frame's parent, and only when that
|
|
523
|
+
// is the site's design tab or the Studio here -- and answered to it
|
|
524
|
+
// alone, not to `*`.
|
|
525
|
+
if (event.source !== window.parent) return;
|
|
526
|
+
var asker = event.origin;
|
|
527
|
+
void isDesignTabOrigin(asker, {
|
|
528
|
+
api: "/api/val",
|
|
529
|
+
own: window.location.origin
|
|
530
|
+
}).then(function (trusted) {
|
|
531
|
+
if (trusted) window.parent.postMessage(readPageReply(message), asker);
|
|
532
|
+
});
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (message.type === "quickPreview") {
|
|
536
|
+
// Code that will run on this address: only from the frame's parent,
|
|
537
|
+
// and only when that is the site's design tab. See `quickPreview.ts`.
|
|
538
|
+
if (event.source !== window.parent) return;
|
|
539
|
+
var id = message.id,
|
|
540
|
+
files = message.files;
|
|
541
|
+
var origin = event.origin;
|
|
542
|
+
void _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
543
|
+
var site, _t;
|
|
544
|
+
return _regenerator().w(function (_context) {
|
|
545
|
+
while (1) switch (_context.p = _context.n) {
|
|
546
|
+
case 0:
|
|
547
|
+
_context.p = 0;
|
|
548
|
+
_context.n = 1;
|
|
549
|
+
return quickPreviewSiteOrigin("/api/val");
|
|
550
|
+
case 1:
|
|
551
|
+
site = _context.v;
|
|
552
|
+
if (!(site === null || site !== origin)) {
|
|
553
|
+
_context.n = 2;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
throw new Error("Only the site's design tab can show a quick preview of this proposal.");
|
|
557
|
+
case 2:
|
|
558
|
+
_context.n = 3;
|
|
559
|
+
return storeQuickPreview(id, files, {
|
|
560
|
+
swUrl: "/api/val".concat(QUICK_PREVIEW_SERVICE_WORKER_PATH)
|
|
561
|
+
});
|
|
562
|
+
case 3:
|
|
563
|
+
post({
|
|
564
|
+
val: VAL_CANVAS_MESSAGE,
|
|
565
|
+
type: "quickPreviewStored",
|
|
566
|
+
id: id
|
|
567
|
+
});
|
|
568
|
+
_context.n = 5;
|
|
569
|
+
break;
|
|
570
|
+
case 4:
|
|
571
|
+
_context.p = 4;
|
|
572
|
+
_t = _context.v;
|
|
573
|
+
post({
|
|
574
|
+
val: VAL_CANVAS_MESSAGE,
|
|
575
|
+
type: "quickPreviewStored",
|
|
576
|
+
id: id,
|
|
577
|
+
error: _t instanceof Error ? _t.message : String(_t)
|
|
578
|
+
});
|
|
579
|
+
case 5:
|
|
580
|
+
return _context.a(2);
|
|
581
|
+
}
|
|
582
|
+
}, _callee, null, [[0, 4]]);
|
|
583
|
+
}))();
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
503
586
|
if (message.type === "theme") {
|
|
504
587
|
setSelectionColors({
|
|
505
588
|
selection: message.selection,
|
|
@@ -548,7 +631,17 @@ function ValCanvasBridge(_ref) {
|
|
|
548
631
|
return function () {
|
|
549
632
|
return window.removeEventListener("message", listener);
|
|
550
633
|
};
|
|
551
|
-
}, [scan]);
|
|
634
|
+
}, [scan, post]);
|
|
635
|
+
|
|
636
|
+
// Where the page is, as it moves: the design tab opens a new build there.
|
|
637
|
+
React.useEffect(function () {
|
|
638
|
+
return watchPageLocation(window, function (location) {
|
|
639
|
+
return post(_objectSpread2({
|
|
640
|
+
val: VAL_CANVAS_MESSAGE,
|
|
641
|
+
type: "location"
|
|
642
|
+
}, location));
|
|
643
|
+
});
|
|
644
|
+
}, [post]);
|
|
552
645
|
|
|
553
646
|
/**
|
|
554
647
|
* Picking.
|
|
@@ -884,6 +977,30 @@ function findByPath(path) {
|
|
|
884
977
|
return null;
|
|
885
978
|
}
|
|
886
979
|
|
|
980
|
+
/** What `readPage` answers: the page read, or why it could not be. */
|
|
981
|
+
function readPageReply(message) {
|
|
982
|
+
try {
|
|
983
|
+
return {
|
|
984
|
+
val: VAL_CANVAS_MESSAGE,
|
|
985
|
+
type: "pageRead",
|
|
986
|
+
requestId: message.requestId,
|
|
987
|
+
snapshot: readPageSnapshot(document, _objectSpread2(_objectSpread2({}, message.selector !== undefined ? {
|
|
988
|
+
selector: message.selector
|
|
989
|
+
} : {}), message.maxItems !== undefined ? {
|
|
990
|
+
maxItems: message.maxItems
|
|
991
|
+
} : {}))
|
|
992
|
+
};
|
|
993
|
+
} catch (error) {
|
|
994
|
+
return {
|
|
995
|
+
val: VAL_CANVAS_MESSAGE,
|
|
996
|
+
type: "pageRead",
|
|
997
|
+
requestId: message.requestId,
|
|
998
|
+
snapshot: null,
|
|
999
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
887
1004
|
/**
|
|
888
1005
|
* Whether the page should re-read the server on its own, right now.
|
|
889
1006
|
*
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"tanstack-router",
|
|
15
15
|
"react"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.150.
|
|
17
|
+
"version": "0.150.11",
|
|
18
18
|
"main": "dist/valbuild-tanstack.cjs.js",
|
|
19
19
|
"module": "dist/valbuild-tanstack.esm.js",
|
|
20
20
|
"exports": {
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@valbuild/core": "0.150.3",
|
|
56
|
-
"@valbuild/
|
|
57
|
-
"@valbuild/
|
|
58
|
-
"@valbuild/react": "0.150.
|
|
59
|
-
"@valbuild/server": "0.150.
|
|
60
|
-
"@valbuild/shared": "0.150.
|
|
61
|
-
"@valbuild/ui": "0.150.
|
|
56
|
+
"@valbuild/mcp": "0.150.11",
|
|
57
|
+
"@valbuild/language-server": "0.150.11",
|
|
58
|
+
"@valbuild/react": "0.150.11",
|
|
59
|
+
"@valbuild/server": "0.150.11",
|
|
60
|
+
"@valbuild/shared": "0.150.11",
|
|
61
|
+
"@valbuild/ui": "0.150.11"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@tanstack/react-router": "^1.170.41",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('../../dist/version-
|
|
5
|
+
var version = require('../../dist/version-f4d4c3b3.cjs.dev.js');
|
|
6
6
|
var asyncToGenerator = require('../../dist/asyncToGenerator-c3823d62.cjs.dev.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var _typeof = require('../../dist/typeof-dd0246a1.cjs.dev.js');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = require('../../dist/version-
|
|
5
|
+
var version = require('../../dist/version-7fc90d7f.cjs.prod.js');
|
|
6
6
|
var asyncToGenerator = require('../../dist/asyncToGenerator-8e5c36c8.cjs.prod.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var _typeof = require('../../dist/typeof-8998e126.cjs.prod.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as VERSION, _ as _toConsumableArray, s as setValEnableCookieReader } from '../../dist/version-
|
|
1
|
+
import { V as VERSION, _ as _toConsumableArray, s as setValEnableCookieReader } from '../../dist/version-714daf1c.esm.js';
|
|
2
2
|
import { _ as _asyncToGenerator, a as _regenerator } from '../../dist/asyncToGenerator-500f022f.esm.js';
|
|
3
3
|
import { Internal } from '@valbuild/core';
|
|
4
4
|
import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper, g as _defineProperty, c as _typeof } from '../../dist/typeof-66e2d869.esm.js';
|