@valbuild/next 0.153.6 → 0.154.1
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 +65 -0
- package/dist/{ValCanvasBridge-1f98937c.cjs.dev.js → ValCanvasBridge-85e75bdb.cjs.dev.js} +384 -17
- package/dist/{ValCanvasBridge-4f025b11.esm.js → ValCanvasBridge-d18c2be6.esm.js} +385 -18
- package/dist/ValCanvasBridge-fc476670.cjs.js +7 -0
- package/dist/{ValCanvasBridge-d0230cd2.cjs.prod.js → ValCanvasBridge-fc476670.cjs.prod.js} +384 -17
- package/dist/ValNextProvider-27242758.esm.js +1 -1
- package/dist/ValNextProvider-4838fed0.cjs.dev.js +1 -1
- package/dist/ValNextProvider-9343dc1e.cjs.prod.js +1 -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/dist/{version-6bcddc39.cjs.dev.js → version-2a0df4d8.cjs.dev.js} +1 -1
- package/dist/{version-6df1633a.cjs.prod.js → version-48aba9c6.cjs.prod.js} +1 -1
- package/dist/{version-73b4e0ba.esm.js → version-d945c1eb.esm.js} +1 -1
- package/package.json +7 -7
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +1 -1
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +1 -1
- package/rsc/dist/valbuild-next-rsc.esm.js +1 -1
- package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-next-server.esm.js +1 -1
- package/dist/ValCanvasBridge-d0230cd2.cjs.js +0 -7
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var createForOfIteratorHelper = require('./createForOfIteratorHelper-8459fbc7.cjs.prod.js');
|
|
6
7
|
var asyncToGenerator = require('./asyncToGenerator-8e5c36c8.cjs.prod.js');
|
|
7
8
|
var unsupportedIterableToArray = require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
8
9
|
var objectSpread2 = require('./objectSpread2-469273e9.cjs.prod.js');
|
|
@@ -10,7 +11,7 @@ var slicedToArray = require('./slicedToArray-0fc63719.cjs.prod.js');
|
|
|
10
11
|
var React = require('react');
|
|
11
12
|
var core = require('@valbuild/core');
|
|
12
13
|
var client = require('@valbuild/shared/client');
|
|
13
|
-
var version = require('./version-
|
|
14
|
+
var version = require('./version-48aba9c6.cjs.prod.js');
|
|
14
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
16
|
|
|
16
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -47,6 +48,13 @@ var DEFAULT_SELECTION = {
|
|
|
47
48
|
*/
|
|
48
49
|
var RESCAN_INTERVAL_MS = 5000;
|
|
49
50
|
|
|
51
|
+
/**
|
|
52
|
+
* This document, among the ones the frame loads: sent with every `ready`
|
|
53
|
+
* (see `document` there). Made when the module is evaluated, which is once
|
|
54
|
+
* per document. Not `crypto.randomUUID`, which an insecure context lacks.
|
|
55
|
+
*/
|
|
56
|
+
var DOCUMENT_ID = "".concat(Date.now().toString(36), "-").concat(Math.random().toString(36).slice(2));
|
|
57
|
+
|
|
50
58
|
/**
|
|
51
59
|
* The page's half of the canvas protocol.
|
|
52
60
|
*
|
|
@@ -111,6 +119,50 @@ function ValCanvasBridge(_ref) {
|
|
|
111
119
|
return (_stopRestoring$curren = stopRestoring.current) === null || _stopRestoring$curren === void 0 ? void 0 : _stopRestoring$curren.call(stopRestoring);
|
|
112
120
|
};
|
|
113
121
|
}, []);
|
|
122
|
+
/**
|
|
123
|
+
* The field being edited on the page itself (`editInline`), or the last
|
|
124
|
+
* one that was, while its copy waits for the page to catch up. See
|
|
125
|
+
* `inlineEditing.ts` in `@valbuild/shared`, which both bindings run.
|
|
126
|
+
*/
|
|
127
|
+
var inlineEditing = React__default["default"].useRef(null);
|
|
128
|
+
React__default["default"].useEffect(function () {
|
|
129
|
+
return function () {
|
|
130
|
+
var _inlineEditing$curren;
|
|
131
|
+
return (_inlineEditing$curren = inlineEditing.current) === null || _inlineEditing$curren === void 0 ? void 0 : _inlineEditing$curren.release();
|
|
132
|
+
};
|
|
133
|
+
}, []);
|
|
134
|
+
/**
|
|
135
|
+
* The last pick: the element and where on it. `editInline` is the Studio's
|
|
136
|
+
* answer to a `clicked`, and the caret belongs where that click was.
|
|
137
|
+
*/
|
|
138
|
+
var lastPick = React__default["default"].useRef(null);
|
|
139
|
+
/**
|
|
140
|
+
* The page's texts as the Studio last said (`textFields`), and the origin
|
|
141
|
+
* that said it, which is the only one an edit started from them answers.
|
|
142
|
+
* `null` until it says: a Studio that predates it never does, and every
|
|
143
|
+
* click then asks, as before.
|
|
144
|
+
*/
|
|
145
|
+
var textFields = React__default["default"].useRef(null);
|
|
146
|
+
/**
|
|
147
|
+
* Whether the edit in progress was started here, in a click, rather than
|
|
148
|
+
* by `editInline`: an `editInline` that arrives after it answers a click
|
|
149
|
+
* from before it, and must not take the caret away.
|
|
150
|
+
*/
|
|
151
|
+
var startedOnClick = React__default["default"].useRef(false);
|
|
152
|
+
/**
|
|
153
|
+
* The keys pressed since a click the Studio was asked about, until it
|
|
154
|
+
* answers: see `inlineEditKeys.ts`.
|
|
155
|
+
*/
|
|
156
|
+
var heldKeys = React__default["default"].useRef(null);
|
|
157
|
+
React__default["default"].useEffect(function () {
|
|
158
|
+
return function () {
|
|
159
|
+
var _heldKeys$current;
|
|
160
|
+
(_heldKeys$current = heldKeys.current) === null || _heldKeys$current === void 0 || _heldKeys$current.release();
|
|
161
|
+
};
|
|
162
|
+
}, []);
|
|
163
|
+
// Read when an edit starts, long after the render that set it.
|
|
164
|
+
var selectionColor = React__default["default"].useRef(selectionColors.selection);
|
|
165
|
+
selectionColor.current = selectionColors.selection;
|
|
114
166
|
var post = React__default["default"].useCallback(function (message) {
|
|
115
167
|
// `*` as the target origin: the studio and the page share an origin today,
|
|
116
168
|
// but the frame does not know the parent's origin for certain and naming
|
|
@@ -132,6 +184,10 @@ function ValCanvasBridge(_ref) {
|
|
|
132
184
|
|
|
133
185
|
/** Every element Val tagged, with where it is on the page. */
|
|
134
186
|
var scan = React__default["default"].useCallback(function () {
|
|
187
|
+
var _textFields$current$e, _textFields$current;
|
|
188
|
+
// Before measuring: an emptied text measures with the room it is given
|
|
189
|
+
// while Select is on, so the Studio's outline of it has a size too.
|
|
190
|
+
client.markEmptyTextFields(document, pickingRef.current ? (_textFields$current$e = (_textFields$current = textFields.current) === null || _textFields$current === void 0 ? void 0 : _textFields$current.empty) !== null && _textFields$current$e !== void 0 ? _textFields$current$e : NO_PATHS : NO_PATHS, core.Internal.splitJoinedSourcePaths);
|
|
135
191
|
var elements = [];
|
|
136
192
|
var scrollX = window.scrollX;
|
|
137
193
|
var scrollY = window.scrollY;
|
|
@@ -222,6 +278,7 @@ function ValCanvasBridge(_ref) {
|
|
|
222
278
|
// What this bridge answers, so the Studio never waits on a request
|
|
223
279
|
// it would not: see `capabilities` in the protocol.
|
|
224
280
|
capabilities: _toConsumableArray(client.BRIDGE_CAPABILITIES),
|
|
281
|
+
document: DOCUMENT_ID,
|
|
225
282
|
bridge: {
|
|
226
283
|
"package": "@valbuild/next",
|
|
227
284
|
version: version.VERSION
|
|
@@ -339,6 +396,22 @@ function ValCanvasBridge(_ref) {
|
|
|
339
396
|
setPicking(message.picking);
|
|
340
397
|
return;
|
|
341
398
|
}
|
|
399
|
+
if (message.type === "textFields") {
|
|
400
|
+
// What starts an edit on a click, so as `editInline`: only from the
|
|
401
|
+
// frame's parent, when that is the Studio here.
|
|
402
|
+
if (event.source !== window.parent) return;
|
|
403
|
+
if (event.origin !== window.location.origin) return;
|
|
404
|
+
textFields.current = {
|
|
405
|
+
editing: message.editing,
|
|
406
|
+
editable: new Map(message.editable.map(function (candidate) {
|
|
407
|
+
return [candidate.path, candidate];
|
|
408
|
+
})),
|
|
409
|
+
empty: new Set(message.empty),
|
|
410
|
+
origin: event.origin
|
|
411
|
+
};
|
|
412
|
+
scan();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
342
415
|
if (message.type === "pickElements") {
|
|
343
416
|
var _message$color;
|
|
344
417
|
setElementPicking({
|
|
@@ -381,15 +454,50 @@ function ValCanvasBridge(_ref) {
|
|
|
381
454
|
window.parent.postMessage(readPageLogReply(message), _asker);
|
|
382
455
|
return;
|
|
383
456
|
}
|
|
457
|
+
if (message.type === "interact") {
|
|
458
|
+
// The assistant's `interact_page`: do something on the page and
|
|
459
|
+
// read it once it settled (`pageInteraction.ts`) -- a click or
|
|
460
|
+
// Enter/Space only once the person allowed it. As
|
|
461
|
+
// `readPage`: only for the frame's parent, when that is the Studio
|
|
462
|
+
// here, and answered to it alone.
|
|
463
|
+
if (event.source !== window.parent) return;
|
|
464
|
+
var _asker2 = event.origin;
|
|
465
|
+
if (_asker2 !== window.location.origin) return;
|
|
466
|
+
var requestId = message.requestId;
|
|
467
|
+
void client.interactWithPage(window, objectSpread2._objectSpread2(objectSpread2._objectSpread2(objectSpread2._objectSpread2(objectSpread2._objectSpread2(objectSpread2._objectSpread2({
|
|
468
|
+
action: message.action
|
|
469
|
+
}, message.maxItems !== undefined ? {
|
|
470
|
+
maxItems: message.maxItems
|
|
471
|
+
} : {}), message.timeoutMs !== undefined ? {
|
|
472
|
+
timeoutMs: message.timeoutMs
|
|
473
|
+
} : {}), message.logFrom !== undefined ? {
|
|
474
|
+
logFrom: message.logFrom
|
|
475
|
+
} : {}), message.approved !== undefined ? {
|
|
476
|
+
approved: message.approved
|
|
477
|
+
} : {}), {}, {
|
|
478
|
+
document: DOCUMENT_ID
|
|
479
|
+
}), pageLog()).then(function (outcome) {
|
|
480
|
+
var answer = {
|
|
481
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
482
|
+
type: "interacted",
|
|
483
|
+
requestId: requestId,
|
|
484
|
+
outcome: outcome,
|
|
485
|
+
// Which document answered: see `interacted` in the protocol.
|
|
486
|
+
document: DOCUMENT_ID
|
|
487
|
+
};
|
|
488
|
+
window.parent.postMessage(answer, _asker2);
|
|
489
|
+
});
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
384
492
|
if (message.type === "screenshotPage") {
|
|
385
493
|
// The assistant's `screenshot_page`: a picture of the page, drawn
|
|
386
494
|
// here. As `readPage`: only for the frame's parent, when that is the
|
|
387
495
|
// Studio here, and answered to it alone.
|
|
388
496
|
if (event.source !== window.parent) return;
|
|
389
|
-
var
|
|
390
|
-
if (
|
|
497
|
+
var _asker3 = event.origin;
|
|
498
|
+
if (_asker3 !== window.location.origin) return;
|
|
391
499
|
void screenshotReply(message).then(function (reply) {
|
|
392
|
-
return window.parent.postMessage(reply,
|
|
500
|
+
return window.parent.postMessage(reply, _asker3);
|
|
393
501
|
});
|
|
394
502
|
return;
|
|
395
503
|
}
|
|
@@ -440,6 +548,98 @@ function ValCanvasBridge(_ref) {
|
|
|
440
548
|
}))();
|
|
441
549
|
return;
|
|
442
550
|
}
|
|
551
|
+
if (message.type === "stopInlineEdit") {
|
|
552
|
+
var _inlineEditing$curren2;
|
|
553
|
+
(_inlineEditing$curren2 = inlineEditing.current) === null || _inlineEditing$curren2 === void 0 || _inlineEditing$curren2.stop();
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (message.type === "focusInlineEdit") {
|
|
557
|
+
var _inlineEditing$curren3;
|
|
558
|
+
(_inlineEditing$curren3 = inlineEditing.current) === null || _inlineEditing$curren3 === void 0 || _inlineEditing$curren3.focus();
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (message.type === "applyInlineEdit") {
|
|
562
|
+
// What one of the Studio's controls made of the text being typed
|
|
563
|
+
// in. It replaces what is on the page, so as `editInline`: only
|
|
564
|
+
// from the frame's parent, when that is the Studio here.
|
|
565
|
+
if (event.source !== window.parent) return;
|
|
566
|
+
if (event.origin !== window.location.origin) return;
|
|
567
|
+
var editing = inlineEditing.current;
|
|
568
|
+
if (editing === null || !editing.isActive()) return;
|
|
569
|
+
if (editing.path !== message.path) return;
|
|
570
|
+
editing.apply(message.value, message.selection);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (message.type === "markInlineEdit") {
|
|
574
|
+
// Bold pressed with only a caret: for what is typed next. From the
|
|
575
|
+
// Studio only, as `applyInlineEdit`.
|
|
576
|
+
if (event.source !== window.parent) return;
|
|
577
|
+
if (event.origin !== window.location.origin) return;
|
|
578
|
+
var _editing = inlineEditing.current;
|
|
579
|
+
if (_editing === null || !_editing.isActive()) return;
|
|
580
|
+
if (_editing.path !== message.path) return;
|
|
581
|
+
_editing.mark(message.styles, message.selection);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (message.type === "editInline") {
|
|
585
|
+
var _held$release, _inlineEditing$curren4, _inlineEditing$curren5;
|
|
586
|
+
// A field's words go back as they are typed, unpublished ones
|
|
587
|
+
// included. As `readPage`: only for the frame's parent, when that
|
|
588
|
+
// is the Studio here, and answered to it alone.
|
|
589
|
+
if (event.source !== window.parent) return;
|
|
590
|
+
var _asker4 = event.origin;
|
|
591
|
+
if (_asker4 !== window.location.origin) return;
|
|
592
|
+
var reply = function reply(answer) {
|
|
593
|
+
return window.parent.postMessage(answer, _asker4);
|
|
594
|
+
};
|
|
595
|
+
var pick = lastPick.current;
|
|
596
|
+
lastPick.current = null;
|
|
597
|
+
var held = heldKeys.current;
|
|
598
|
+
heldKeys.current = null;
|
|
599
|
+
var keys = (_held$release = held === null || held === void 0 ? void 0 : held.release()) !== null && _held$release !== void 0 ? _held$release : [];
|
|
600
|
+
// The answer to a click from before the one that started the edit
|
|
601
|
+
// in progress, by itself: that click is what the person did last.
|
|
602
|
+
if (pick === null && startedOnClick.current && ((_inlineEditing$curren4 = inlineEditing.current) === null || _inlineEditing$curren4 === void 0 ? void 0 : _inlineEditing$curren4.isActive()) === true) {
|
|
603
|
+
reply({
|
|
604
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
605
|
+
type: "inlineEditUnavailable",
|
|
606
|
+
requestId: message.requestId
|
|
607
|
+
});
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
// One edit at a time, and the element of the last one back as the
|
|
611
|
+
// page has it: it may be the very one asked for again.
|
|
612
|
+
(_inlineEditing$curren5 = inlineEditing.current) === null || _inlineEditing$curren5 === void 0 || _inlineEditing$curren5.release();
|
|
613
|
+
inlineEditing.current = null;
|
|
614
|
+
startedOnClick.current = false;
|
|
615
|
+
var started = startFirst(message.candidates, pick, {
|
|
616
|
+
color: selectionColor.current,
|
|
617
|
+
reply: reply
|
|
618
|
+
});
|
|
619
|
+
if (started !== null) {
|
|
620
|
+
inlineEditing.current = started.editing;
|
|
621
|
+
reply({
|
|
622
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
623
|
+
type: "inlineEditStarted",
|
|
624
|
+
requestId: message.requestId,
|
|
625
|
+
path: started.path
|
|
626
|
+
});
|
|
627
|
+
// What was typed while the Studio was being asked, now that
|
|
628
|
+
// there is somewhere for it to go: after `inlineEditStarted`,
|
|
629
|
+
// so the Studio is listening for what it types.
|
|
630
|
+
client.replayKeys(document, keys);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
// Nothing on the page shows one of them and nothing else: the
|
|
634
|
+
// Studio opens the field in its own column, and the keys pressed
|
|
635
|
+
// meanwhile are dropped, as on a page that is not being typed in.
|
|
636
|
+
reply({
|
|
637
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
638
|
+
type: "inlineEditUnavailable",
|
|
639
|
+
requestId: message.requestId
|
|
640
|
+
});
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
443
643
|
if (message.type === "theme") {
|
|
444
644
|
setSelectionColors({
|
|
445
645
|
selection: message.selection,
|
|
@@ -555,18 +755,85 @@ function ValCanvasBridge(_ref) {
|
|
|
555
755
|
*/
|
|
556
756
|
React__default["default"].useEffect(function () {
|
|
557
757
|
var onClick = function onClick(event) {
|
|
558
|
-
|
|
758
|
+
var _heldKeys$current2;
|
|
559
759
|
var target = event.target;
|
|
560
760
|
if (!(target instanceof Element)) return;
|
|
761
|
+
// A click in the field being typed in places the caret, and that is
|
|
762
|
+
// all it does: it is neither a pick nor a click on the link or button
|
|
763
|
+
// the text happens to be in. (The caret is the mousedown's, so
|
|
764
|
+
// cancelling the click leaves it where it was put.)
|
|
765
|
+
var editing = inlineEditing.current;
|
|
766
|
+
if (editing !== null && editing.isActive() && editing.contains(target)) {
|
|
767
|
+
event.preventDefault();
|
|
768
|
+
event.stopPropagation();
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
if (!pickingRef.current) return;
|
|
561
772
|
var tagged = target.closest("[data-val-path]");
|
|
562
773
|
var attribute = tagged === null || tagged === void 0 ? void 0 : tagged.getAttribute("data-val-path");
|
|
563
|
-
if (!attribute) return;
|
|
774
|
+
if (!tagged || !attribute) return;
|
|
564
775
|
event.preventDefault();
|
|
565
776
|
event.stopPropagation();
|
|
777
|
+
var paths = core.Internal.splitJoinedSourcePaths(attribute);
|
|
778
|
+
var pick = {
|
|
779
|
+
element: tagged,
|
|
780
|
+
x: event.clientX,
|
|
781
|
+
y: event.clientY
|
|
782
|
+
};
|
|
783
|
+
(_heldKeys$current2 = heldKeys.current) === null || _heldKeys$current2 === void 0 || _heldKeys$current2.release();
|
|
784
|
+
heldKeys.current = null;
|
|
785
|
+
/*
|
|
786
|
+
* Select & edit, and the Studio has said which of this element's
|
|
787
|
+
* fields are texts and what they hold: the edit starts HERE, in the
|
|
788
|
+
* click, rather than a round trip across the frame later. Keys typed
|
|
789
|
+
* straight after the click then go into the text -- in that round
|
|
790
|
+
* trip they went to the page's body, which drops them -- and a phone
|
|
791
|
+
* opens its keyboard, which it does only for a focus given in the tap.
|
|
792
|
+
* Which element shows a field is still decided as `editInline` decides
|
|
793
|
+
* it (`canEditInline`), from the values the Studio sent.
|
|
794
|
+
*/
|
|
795
|
+
var known = textFields.current;
|
|
796
|
+
var offered = known !== null && known.editing ? paths.flatMap(function (path) {
|
|
797
|
+
var _known$editable$get;
|
|
798
|
+
return (_known$editable$get = known.editable.get(path)) !== null && _known$editable$get !== void 0 ? _known$editable$get : [];
|
|
799
|
+
}) : [];
|
|
800
|
+
if (known !== null && offered.length > 0) {
|
|
801
|
+
var _inlineEditing$curren6;
|
|
802
|
+
var reply = function reply(answer) {
|
|
803
|
+
return window.parent.postMessage(answer, known.origin);
|
|
804
|
+
};
|
|
805
|
+
(_inlineEditing$curren6 = inlineEditing.current) === null || _inlineEditing$curren6 === void 0 || _inlineEditing$curren6.release();
|
|
806
|
+
inlineEditing.current = null;
|
|
807
|
+
startedOnClick.current = false;
|
|
808
|
+
var started = startFirst(offered, pick, {
|
|
809
|
+
color: selectionColor.current,
|
|
810
|
+
reply: reply
|
|
811
|
+
});
|
|
812
|
+
if (started !== null) {
|
|
813
|
+
inlineEditing.current = started.editing;
|
|
814
|
+
startedOnClick.current = true;
|
|
815
|
+
lastPick.current = null;
|
|
816
|
+
reply({
|
|
817
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
818
|
+
type: "inlineEditStarted",
|
|
819
|
+
requestId: null,
|
|
820
|
+
path: started.path
|
|
821
|
+
});
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
/*
|
|
825
|
+
* A text, but not as the Studio last said: its value changed since
|
|
826
|
+
* (an edit a moment ago, still on its way). The Studio is asked, as
|
|
827
|
+
* for any pick, and the keys pressed until it answers are held
|
|
828
|
+
* rather than lost.
|
|
829
|
+
*/
|
|
830
|
+
heldKeys.current = client.holdKeys(window);
|
|
831
|
+
}
|
|
832
|
+
lastPick.current = pick;
|
|
566
833
|
post({
|
|
567
834
|
val: client.VAL_CANVAS_MESSAGE,
|
|
568
835
|
type: "clicked",
|
|
569
|
-
paths:
|
|
836
|
+
paths: paths
|
|
570
837
|
});
|
|
571
838
|
};
|
|
572
839
|
document.addEventListener("click", onClick, {
|
|
@@ -579,6 +846,17 @@ function ValCanvasBridge(_ref) {
|
|
|
579
846
|
};
|
|
580
847
|
}, [post]);
|
|
581
848
|
|
|
849
|
+
// Select off: an emptied text has its room taken away, and keys held for
|
|
850
|
+
// an answer to a pick are dropped. Select on: it has its room again.
|
|
851
|
+
React__default["default"].useEffect(function () {
|
|
852
|
+
if (!picking) {
|
|
853
|
+
var _heldKeys$current3;
|
|
854
|
+
(_heldKeys$current3 = heldKeys.current) === null || _heldKeys$current3 === void 0 || _heldKeys$current3.release();
|
|
855
|
+
heldKeys.current = null;
|
|
856
|
+
}
|
|
857
|
+
scan();
|
|
858
|
+
}, [picking, scan]);
|
|
859
|
+
|
|
582
860
|
// Esc while picking fields: the key goes to the page, which has the focus
|
|
583
861
|
// once it has been clicked, so the studio hears of it only from here.
|
|
584
862
|
React__default["default"].useEffect(function () {
|
|
@@ -786,7 +1064,11 @@ function ValCanvasBridge(_ref) {
|
|
|
786
1064
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
787
1065
|
// close the selector early.
|
|
788
1066
|
dangerouslySetInnerHTML: {
|
|
789
|
-
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n[data-val-path]:hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "",
|
|
1067
|
+
__html: [picking ? "[data-val-path] { outline: 1px solid ".concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n[data-val-path]:hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "",
|
|
1068
|
+
// The one rule here that moves the page, and only while Select is
|
|
1069
|
+
// on: an emptied text's line of room, without which it cannot be
|
|
1070
|
+
// pointed at. See `emptyTextFields.ts` for why, and how narrowly.
|
|
1071
|
+
picking ? client.EMPTY_TEXT_RULES : "", highlighted ? highlightRule(highlighted, selectionColors.selection) : ""].filter(Boolean).join("\n")
|
|
790
1072
|
}
|
|
791
1073
|
});
|
|
792
1074
|
}
|
|
@@ -883,23 +1165,108 @@ function isScrollable(el) {
|
|
|
883
1165
|
};
|
|
884
1166
|
return scrolls(style.overflowY) && el.scrollHeight > el.clientHeight || scrolls(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
885
1167
|
}
|
|
1168
|
+
var NO_PATHS = new Set();
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Start editing the first of `candidates` an element on the page shows and
|
|
1172
|
+
* nothing else: the picked element when it carries the candidate's path,
|
|
1173
|
+
* else the first element that does. `null` when none can be.
|
|
1174
|
+
*
|
|
1175
|
+
* What `editInline` does, and what a click does by itself when the Studio has
|
|
1176
|
+
* said ahead of it what the element's texts hold (`textFields`): one way to
|
|
1177
|
+
* start, whichever asked.
|
|
1178
|
+
*/
|
|
1179
|
+
function startFirst(candidates, pick, options) {
|
|
1180
|
+
var reply = options.reply;
|
|
1181
|
+
var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(candidates),
|
|
1182
|
+
_step;
|
|
1183
|
+
try {
|
|
1184
|
+
var _loop = function _loop() {
|
|
1185
|
+
var candidate = _step.value;
|
|
1186
|
+
var picked = pick !== null && pick.element.isConnected && pathOn(pick.element, candidate.path) !== null ? pick.element : null;
|
|
1187
|
+
var element = picked !== null && picked !== void 0 ? picked : findByPath(candidate.path);
|
|
1188
|
+
if (element === null) return 0; // continue
|
|
1189
|
+
var path = pathOn(element, candidate.path);
|
|
1190
|
+
if (path === null) return 0; // continue
|
|
1191
|
+
var editing = client.startInlineEditing(element, candidate, {
|
|
1192
|
+
// Where the click was, when it was on this element.
|
|
1193
|
+
at: picked !== null && pick !== null ? {
|
|
1194
|
+
x: pick.x,
|
|
1195
|
+
y: pick.y
|
|
1196
|
+
} : null,
|
|
1197
|
+
color: options.color,
|
|
1198
|
+
onChange: function onChange(value) {
|
|
1199
|
+
return reply({
|
|
1200
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1201
|
+
type: "inlineEdit",
|
|
1202
|
+
path: path,
|
|
1203
|
+
value: value
|
|
1204
|
+
});
|
|
1205
|
+
},
|
|
1206
|
+
onEnd: function onEnd() {
|
|
1207
|
+
return reply({
|
|
1208
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1209
|
+
type: "inlineEditEnded",
|
|
1210
|
+
path: path
|
|
1211
|
+
});
|
|
1212
|
+
},
|
|
1213
|
+
onSelection: function onSelection(selection, rect, caret) {
|
|
1214
|
+
return reply({
|
|
1215
|
+
val: client.VAL_CANVAS_MESSAGE,
|
|
1216
|
+
type: "inlineEditSelection",
|
|
1217
|
+
path: path,
|
|
1218
|
+
selection: selection,
|
|
1219
|
+
rect: rect,
|
|
1220
|
+
caret: caret
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
if (editing !== null) return {
|
|
1225
|
+
v: {
|
|
1226
|
+
editing: editing,
|
|
1227
|
+
path: path
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
},
|
|
1231
|
+
_ret;
|
|
1232
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1233
|
+
_ret = _loop();
|
|
1234
|
+
if (_ret === 0) continue;
|
|
1235
|
+
if (_ret) return _ret.v;
|
|
1236
|
+
}
|
|
1237
|
+
} catch (err) {
|
|
1238
|
+
_iterator.e(err);
|
|
1239
|
+
} finally {
|
|
1240
|
+
_iterator.f();
|
|
1241
|
+
}
|
|
1242
|
+
return null;
|
|
1243
|
+
}
|
|
886
1244
|
function findByPath(path) {
|
|
887
1245
|
var elements = document.querySelectorAll("[data-val-path]");
|
|
888
1246
|
for (var _i = 0, _Array$from = Array.from(elements); _i < _Array$from.length; _i++) {
|
|
889
1247
|
var el = _Array$from[_i];
|
|
890
|
-
|
|
891
|
-
if (!attribute) continue;
|
|
892
|
-
// Compared as strings: the split returns branded `SourcePath`s and what
|
|
893
|
-
// came back over `postMessage` is a plain string, which is the same value.
|
|
894
|
-
if (core.Internal.splitJoinedSourcePaths(attribute).some(function (candidate) {
|
|
895
|
-
return candidate === path;
|
|
896
|
-
})) {
|
|
897
|
-
return el;
|
|
898
|
-
}
|
|
1248
|
+
if (pathOn(el, path) !== null) return el;
|
|
899
1249
|
}
|
|
900
1250
|
return null;
|
|
901
1251
|
}
|
|
902
1252
|
|
|
1253
|
+
/**
|
|
1254
|
+
* `path` as `element` carries it, or null when it does not.
|
|
1255
|
+
*
|
|
1256
|
+
* Compared as strings: the split returns branded `SourcePath`s and what came
|
|
1257
|
+
* back over `postMessage` is a plain string, which is the same value. What is
|
|
1258
|
+
* returned is the element's own, so it is a `SourcePath` without anyone
|
|
1259
|
+
* having to say so.
|
|
1260
|
+
*/
|
|
1261
|
+
function pathOn(element, path) {
|
|
1262
|
+
var _Internal$splitJoined;
|
|
1263
|
+
var attribute = element.getAttribute("data-val-path");
|
|
1264
|
+
if (!attribute) return null;
|
|
1265
|
+
return (_Internal$splitJoined = core.Internal.splitJoinedSourcePaths(attribute).find(function (candidate) {
|
|
1266
|
+
return candidate === path;
|
|
1267
|
+
})) !== null && _Internal$splitJoined !== void 0 ? _Internal$splitJoined : null;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
903
1270
|
/** What `screenshotPage` answers: the picture, or why it could not be taken. */
|
|
904
1271
|
function screenshotReply(_x) {
|
|
905
1272
|
return _screenshotReply.apply(this, arguments);
|
|
@@ -13,7 +13,7 @@ import { isDraft, windowCodeChangedReporter, createDraftStore, draftHolds, draft
|
|
|
13
13
|
import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-0d915c59.esm.js';
|
|
14
14
|
import { VAL_THEME_SESSION_STORAGE_KEY, installPageLogInCanvasFrame, isValCanvasFrame } from '@valbuild/shared/client';
|
|
15
15
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-9209e9dd.esm.js';
|
|
16
|
-
import { ValCanvasBridge } from './ValCanvasBridge-
|
|
16
|
+
import { ValCanvasBridge } from './ValCanvasBridge-d18c2be6.esm.js';
|
|
17
17
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
18
18
|
import './unsupportedIterableToArray-f57eb659.esm.js';
|
|
19
19
|
|
|
@@ -17,7 +17,7 @@ var internal = require('@valbuild/react/internal');
|
|
|
17
17
|
var fallbackColors = require('./fallbackColors-38f01ad2.cjs.dev.js');
|
|
18
18
|
var client = require('@valbuild/shared/client');
|
|
19
19
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
|
|
20
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
20
|
+
var ValCanvasBridge = require('./ValCanvasBridge-85e75bdb.cjs.dev.js');
|
|
21
21
|
var jsxRuntime = require('react/jsx-runtime');
|
|
22
22
|
require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
23
23
|
|
|
@@ -17,7 +17,7 @@ var internal = require('@valbuild/react/internal');
|
|
|
17
17
|
var fallbackColors = require('./fallbackColors-d9a7b81e.cjs.prod.js');
|
|
18
18
|
var client = require('@valbuild/shared/client');
|
|
19
19
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-8459fbc7.cjs.prod.js');
|
|
20
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
20
|
+
var ValCanvasBridge = require('./ValCanvasBridge-fc476670.cjs.prod.js');
|
|
21
21
|
var jsxRuntime = require('react/jsx-runtime');
|
|
22
22
|
require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
23
23
|
|
|
@@ -14,7 +14,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
14
14
|
var ValVideo = require('./ValVideo-15e5c4fa.cjs.dev.js');
|
|
15
15
|
var ValApp = require('./ValApp-826dca6c.cjs.dev.js');
|
|
16
16
|
var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
|
|
17
|
-
var version = require('./version-
|
|
17
|
+
var version = require('./version-2a0df4d8.cjs.dev.js');
|
|
18
18
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
|
|
19
19
|
require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
20
20
|
|
|
@@ -14,7 +14,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
14
14
|
var ValVideo = require('./ValVideo-02f43a7c.cjs.prod.js');
|
|
15
15
|
var ValApp = require('./ValApp-866089f6.cjs.prod.js');
|
|
16
16
|
var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
|
|
17
|
-
var version = require('./version-
|
|
17
|
+
var version = require('./version-48aba9c6.cjs.prod.js');
|
|
18
18
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-8459fbc7.cjs.prod.js');
|
|
19
19
|
require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
20
20
|
|
|
@@ -13,7 +13,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
13
13
|
export { ValVideo } from './ValVideo-8acf31b6.esm.js';
|
|
14
14
|
export { ValApp } from './ValApp-69cd599c.esm.js';
|
|
15
15
|
export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
|
|
16
|
-
import { V as VERSION } from './version-
|
|
16
|
+
import { V as VERSION } from './version-d945c1eb.esm.js';
|
|
17
17
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-9209e9dd.esm.js';
|
|
18
18
|
import './unsupportedIterableToArray-f57eb659.esm.js';
|
|
19
19
|
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.154.1",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
50
|
"@valbuild/core": "0.153.5",
|
|
51
|
-
"@valbuild/language-server": "0.
|
|
52
|
-
"@valbuild/mcp": "0.
|
|
53
|
-
"@valbuild/react": "0.
|
|
54
|
-
"@valbuild/server": "0.
|
|
55
|
-
"@valbuild/shared": "0.
|
|
56
|
-
"@valbuild/ui": "0.
|
|
51
|
+
"@valbuild/language-server": "0.154.1",
|
|
52
|
+
"@valbuild/mcp": "0.154.1",
|
|
53
|
+
"@valbuild/react": "0.154.1",
|
|
54
|
+
"@valbuild/server": "0.154.1",
|
|
55
|
+
"@valbuild/shared": "0.154.1",
|
|
56
|
+
"@valbuild/ui": "0.154.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/react": "^16.3.3",
|
|
@@ -10,7 +10,7 @@ var internal$1 = require('@valbuild/react/internal');
|
|
|
10
10
|
var core = require('@valbuild/core');
|
|
11
11
|
var internal$2 = require('@valbuild/shared/internal');
|
|
12
12
|
var internal = require('@valbuild/server/internal');
|
|
13
|
-
var version = require('../../dist/version-
|
|
13
|
+
var version = require('../../dist/version-2a0df4d8.cjs.dev.js');
|
|
14
14
|
var routeFromVal = require('../../dist/routeFromVal-a1e0a8be.cjs.dev.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
@@ -10,7 +10,7 @@ var internal$1 = require('@valbuild/react/internal');
|
|
|
10
10
|
var core = require('@valbuild/core');
|
|
11
11
|
var internal$2 = require('@valbuild/shared/internal');
|
|
12
12
|
var internal = require('@valbuild/server/internal');
|
|
13
|
-
var version = require('../../dist/version-
|
|
13
|
+
var version = require('../../dist/version-48aba9c6.cjs.prod.js');
|
|
14
14
|
var routeFromVal = require('../../dist/routeFromVal-c4dace91.cjs.prod.js');
|
|
15
15
|
require('../../dist/createForOfIteratorHelper-8459fbc7.cjs.prod.js');
|
|
16
16
|
require('../../dist/unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
@@ -6,7 +6,7 @@ import { fetchValFrom, isJsonValuesRecordSchema, awaitResolved, resolveValEntry,
|
|
|
6
6
|
import { Internal } from '@valbuild/core';
|
|
7
7
|
import { readerSchemaVersion } from '@valbuild/shared/internal';
|
|
8
8
|
import { createValRuntime, readDraftChanges, draftForRequest } from '@valbuild/server/internal';
|
|
9
|
-
import { V as VERSION } from '../../dist/version-
|
|
9
|
+
import { V as VERSION } from '../../dist/version-d945c1eb.esm.js';
|
|
10
10
|
import { i as initValRouteFromVal, g as getValRouteUrlFromVal } from '../../dist/routeFromVal-80976677.esm.js';
|
|
11
11
|
import '../../dist/createForOfIteratorHelper-9209e9dd.esm.js';
|
|
12
12
|
import '../../dist/unsupportedIterableToArray-f57eb659.esm.js';
|