@valbuild/tanstack 0.153.6 → 0.154.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/dist/valbuild-tanstack.cjs.dev.js +383 -17
- package/dist/valbuild-tanstack.cjs.prod.js +383 -17
- package/dist/valbuild-tanstack.esm.js +384 -18
- package/dist/{version-bee0c459.cjs.dev.js → version-208d50df.cjs.dev.js} +1 -1
- package/dist/{version-83ae9dc3.esm.js → version-59dbc545.esm.js} +1 -1
- package/dist/{version-c72b9e12.cjs.prod.js → version-961b447c.cjs.prod.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
|
@@ -5,14 +5,14 @@ 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, V as VERSION$1 } from './version-
|
|
8
|
+
import { r as readValEnableCookie, V as VERSION$1 } from './version-59dbc545.esm.js';
|
|
9
9
|
import { isDraft, windowCodeChangedReporter, createDraftStore, draftHolds, draftHoldsVersions, startRefreshLoop, dispatchCodeChanged, applyValEvent } from '@valbuild/react/internal';
|
|
10
10
|
export { ValRichText } from '@valbuild/react/internal';
|
|
11
11
|
import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID, VAL_APP_ID } from '@valbuild/ui';
|
|
12
12
|
import { useRouter, useRouterState } from '@tanstack/react-router';
|
|
13
13
|
import React, { useEffect, useRef, useState } from 'react';
|
|
14
14
|
import { V as ValOverlayProvider } from './ValOverlayContext-bd2f453c.esm.js';
|
|
15
|
-
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, VAL_CANVAS_MESSAGE, watchPageLocation, startElementPicking, installPageLog, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, BRIDGE_CAPABILITIES, isValCanvasStudioMessage, restoreScroll, storeQuickPreview, QUICK_PREVIEW_SERVICE_WORKER_PATH, isCodeChangedDetail, screenshotPage, readPageSnapshot, installPageLogInCanvasFrame, isValCanvasFrame } from '@valbuild/shared/client';
|
|
15
|
+
import { VAL_CONFIG_SESSION_STORAGE_KEY, VAL_THEME_SESSION_STORAGE_KEY, markEmptyTextFields, VAL_CANVAS_MESSAGE, watchPageLocation, startElementPicking, EMPTY_TEXT_RULES, installPageLog, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, BRIDGE_CAPABILITIES, isValCanvasStudioMessage, restoreScroll, interactWithPage, storeQuickPreview, QUICK_PREVIEW_SERVICE_WORKER_PATH, replayKeys, isCodeChangedDetail, holdKeys, startInlineEditing, screenshotPage, readPageSnapshot, installPageLogInCanvasFrame, isValCanvasFrame } from '@valbuild/shared/client';
|
|
16
16
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
17
|
import { D as DEMO_CLAIM_MESSAGE, a as DEMO_SERVICE_WORKER_PATH, b as DEMO_RELAY_MESSAGE } from './demoServiceWorker-56fd96cf.esm.js';
|
|
18
18
|
|
|
@@ -240,6 +240,13 @@ var DEFAULT_SELECTION = {
|
|
|
240
240
|
*/
|
|
241
241
|
var RESCAN_INTERVAL_MS = 5000;
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* This document, among the ones the frame loads: sent with every `ready`
|
|
245
|
+
* (see `document` there). Made when the module is evaluated, which is once
|
|
246
|
+
* per document. Not `crypto.randomUUID`, which an insecure context lacks.
|
|
247
|
+
*/
|
|
248
|
+
var DOCUMENT_ID = "".concat(Date.now().toString(36), "-").concat(Math.random().toString(36).slice(2));
|
|
249
|
+
|
|
243
250
|
/**
|
|
244
251
|
* The page's half of the canvas protocol.
|
|
245
252
|
*
|
|
@@ -304,6 +311,50 @@ function ValCanvasBridge(_ref) {
|
|
|
304
311
|
return (_stopRestoring$curren = stopRestoring.current) === null || _stopRestoring$curren === void 0 ? void 0 : _stopRestoring$curren.call(stopRestoring);
|
|
305
312
|
};
|
|
306
313
|
}, []);
|
|
314
|
+
/**
|
|
315
|
+
* The field being edited on the page itself (`editInline`), or the last
|
|
316
|
+
* one that was, while its copy waits for the page to catch up. See
|
|
317
|
+
* `inlineEditing.ts` in `@valbuild/shared`, which both bindings run.
|
|
318
|
+
*/
|
|
319
|
+
var inlineEditing = React.useRef(null);
|
|
320
|
+
React.useEffect(function () {
|
|
321
|
+
return function () {
|
|
322
|
+
var _inlineEditing$curren;
|
|
323
|
+
return (_inlineEditing$curren = inlineEditing.current) === null || _inlineEditing$curren === void 0 ? void 0 : _inlineEditing$curren.release();
|
|
324
|
+
};
|
|
325
|
+
}, []);
|
|
326
|
+
/**
|
|
327
|
+
* The last pick: the element and where on it. `editInline` is the Studio's
|
|
328
|
+
* answer to a `clicked`, and the caret belongs where that click was.
|
|
329
|
+
*/
|
|
330
|
+
var lastPick = React.useRef(null);
|
|
331
|
+
/**
|
|
332
|
+
* The page's texts as the Studio last said (`textFields`), and the origin
|
|
333
|
+
* that said it, which is the only one an edit started from them answers.
|
|
334
|
+
* `null` until it says: a Studio that predates it never does, and every
|
|
335
|
+
* click then asks, as before.
|
|
336
|
+
*/
|
|
337
|
+
var textFields = React.useRef(null);
|
|
338
|
+
/**
|
|
339
|
+
* Whether the edit in progress was started here, in a click, rather than
|
|
340
|
+
* by `editInline`: an `editInline` that arrives after it answers a click
|
|
341
|
+
* from before it, and must not take the caret away.
|
|
342
|
+
*/
|
|
343
|
+
var startedOnClick = React.useRef(false);
|
|
344
|
+
/**
|
|
345
|
+
* The keys pressed since a click the Studio was asked about, until it
|
|
346
|
+
* answers: see `inlineEditKeys.ts`.
|
|
347
|
+
*/
|
|
348
|
+
var heldKeys = React.useRef(null);
|
|
349
|
+
React.useEffect(function () {
|
|
350
|
+
return function () {
|
|
351
|
+
var _heldKeys$current;
|
|
352
|
+
(_heldKeys$current = heldKeys.current) === null || _heldKeys$current === void 0 || _heldKeys$current.release();
|
|
353
|
+
};
|
|
354
|
+
}, []);
|
|
355
|
+
// Read when an edit starts, long after the render that set it.
|
|
356
|
+
var selectionColor = React.useRef(selectionColors.selection);
|
|
357
|
+
selectionColor.current = selectionColors.selection;
|
|
307
358
|
var post = React.useCallback(function (message) {
|
|
308
359
|
// `*` as the target origin: the studio and the page share an origin today,
|
|
309
360
|
// but the frame does not know the parent's origin for certain and naming
|
|
@@ -325,6 +376,10 @@ function ValCanvasBridge(_ref) {
|
|
|
325
376
|
|
|
326
377
|
/** Every element Val tagged, with where it is on the page. */
|
|
327
378
|
var scan = React.useCallback(function () {
|
|
379
|
+
var _textFields$current$e, _textFields$current;
|
|
380
|
+
// Before measuring: an emptied text measures with the room it is given
|
|
381
|
+
// while Select is on, so the Studio's outline of it has a size too.
|
|
382
|
+
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, Internal$1.splitJoinedSourcePaths);
|
|
328
383
|
var elements = [];
|
|
329
384
|
var scrollX = window.scrollX;
|
|
330
385
|
var scrollY = window.scrollY;
|
|
@@ -415,6 +470,7 @@ function ValCanvasBridge(_ref) {
|
|
|
415
470
|
// What this bridge answers, so the Studio never waits on a request
|
|
416
471
|
// it would not: see `capabilities` in the protocol.
|
|
417
472
|
capabilities: _toConsumableArray(BRIDGE_CAPABILITIES),
|
|
473
|
+
document: DOCUMENT_ID,
|
|
418
474
|
bridge: {
|
|
419
475
|
"package": "@valbuild/tanstack",
|
|
420
476
|
version: VERSION$1
|
|
@@ -532,6 +588,22 @@ function ValCanvasBridge(_ref) {
|
|
|
532
588
|
setPicking(message.picking);
|
|
533
589
|
return;
|
|
534
590
|
}
|
|
591
|
+
if (message.type === "textFields") {
|
|
592
|
+
// What starts an edit on a click, so as `editInline`: only from the
|
|
593
|
+
// frame's parent, when that is the Studio here.
|
|
594
|
+
if (event.source !== window.parent) return;
|
|
595
|
+
if (event.origin !== window.location.origin) return;
|
|
596
|
+
textFields.current = {
|
|
597
|
+
editing: message.editing,
|
|
598
|
+
editable: new Map(message.editable.map(function (candidate) {
|
|
599
|
+
return [candidate.path, candidate];
|
|
600
|
+
})),
|
|
601
|
+
empty: new Set(message.empty),
|
|
602
|
+
origin: event.origin
|
|
603
|
+
};
|
|
604
|
+
scan();
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
535
607
|
if (message.type === "pickElements") {
|
|
536
608
|
var _message$color;
|
|
537
609
|
setElementPicking({
|
|
@@ -574,15 +646,50 @@ function ValCanvasBridge(_ref) {
|
|
|
574
646
|
window.parent.postMessage(readPageLogReply(message), _asker);
|
|
575
647
|
return;
|
|
576
648
|
}
|
|
649
|
+
if (message.type === "interact") {
|
|
650
|
+
// The assistant's `interact_page`: do something on the page and
|
|
651
|
+
// read it once it settled (`pageInteraction.ts`) -- a click or
|
|
652
|
+
// Enter/Space only once the person allowed it. As
|
|
653
|
+
// `readPage`: only for the frame's parent, when that is the Studio
|
|
654
|
+
// here, and answered to it alone.
|
|
655
|
+
if (event.source !== window.parent) return;
|
|
656
|
+
var _asker2 = event.origin;
|
|
657
|
+
if (_asker2 !== window.location.origin) return;
|
|
658
|
+
var requestId = message.requestId;
|
|
659
|
+
void interactWithPage(window, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
660
|
+
action: message.action
|
|
661
|
+
}, message.maxItems !== undefined ? {
|
|
662
|
+
maxItems: message.maxItems
|
|
663
|
+
} : {}), message.timeoutMs !== undefined ? {
|
|
664
|
+
timeoutMs: message.timeoutMs
|
|
665
|
+
} : {}), message.logFrom !== undefined ? {
|
|
666
|
+
logFrom: message.logFrom
|
|
667
|
+
} : {}), message.approved !== undefined ? {
|
|
668
|
+
approved: message.approved
|
|
669
|
+
} : {}), {}, {
|
|
670
|
+
document: DOCUMENT_ID
|
|
671
|
+
}), pageLog()).then(function (outcome) {
|
|
672
|
+
var answer = {
|
|
673
|
+
val: VAL_CANVAS_MESSAGE,
|
|
674
|
+
type: "interacted",
|
|
675
|
+
requestId: requestId,
|
|
676
|
+
outcome: outcome,
|
|
677
|
+
// Which document answered: see `interacted` in the protocol.
|
|
678
|
+
document: DOCUMENT_ID
|
|
679
|
+
};
|
|
680
|
+
window.parent.postMessage(answer, _asker2);
|
|
681
|
+
});
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
577
684
|
if (message.type === "screenshotPage") {
|
|
578
685
|
// The assistant's `screenshot_page`: a picture of the page, drawn
|
|
579
686
|
// here. As `readPage`: only for the frame's parent, when that is the
|
|
580
687
|
// Studio here, and answered to it alone.
|
|
581
688
|
if (event.source !== window.parent) return;
|
|
582
|
-
var
|
|
583
|
-
if (
|
|
689
|
+
var _asker3 = event.origin;
|
|
690
|
+
if (_asker3 !== window.location.origin) return;
|
|
584
691
|
void screenshotReply(message).then(function (reply) {
|
|
585
|
-
return window.parent.postMessage(reply,
|
|
692
|
+
return window.parent.postMessage(reply, _asker3);
|
|
586
693
|
});
|
|
587
694
|
return;
|
|
588
695
|
}
|
|
@@ -633,6 +740,98 @@ function ValCanvasBridge(_ref) {
|
|
|
633
740
|
}))();
|
|
634
741
|
return;
|
|
635
742
|
}
|
|
743
|
+
if (message.type === "stopInlineEdit") {
|
|
744
|
+
var _inlineEditing$curren2;
|
|
745
|
+
(_inlineEditing$curren2 = inlineEditing.current) === null || _inlineEditing$curren2 === void 0 || _inlineEditing$curren2.stop();
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
if (message.type === "focusInlineEdit") {
|
|
749
|
+
var _inlineEditing$curren3;
|
|
750
|
+
(_inlineEditing$curren3 = inlineEditing.current) === null || _inlineEditing$curren3 === void 0 || _inlineEditing$curren3.focus();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (message.type === "applyInlineEdit") {
|
|
754
|
+
// What one of the Studio's controls made of the text being typed
|
|
755
|
+
// in. It replaces what is on the page, so as `editInline`: only
|
|
756
|
+
// from the frame's parent, when that is the Studio here.
|
|
757
|
+
if (event.source !== window.parent) return;
|
|
758
|
+
if (event.origin !== window.location.origin) return;
|
|
759
|
+
var editing = inlineEditing.current;
|
|
760
|
+
if (editing === null || !editing.isActive()) return;
|
|
761
|
+
if (editing.path !== message.path) return;
|
|
762
|
+
editing.apply(message.value, message.selection);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (message.type === "markInlineEdit") {
|
|
766
|
+
// Bold pressed with only a caret: for what is typed next. From the
|
|
767
|
+
// Studio only, as `applyInlineEdit`.
|
|
768
|
+
if (event.source !== window.parent) return;
|
|
769
|
+
if (event.origin !== window.location.origin) return;
|
|
770
|
+
var _editing = inlineEditing.current;
|
|
771
|
+
if (_editing === null || !_editing.isActive()) return;
|
|
772
|
+
if (_editing.path !== message.path) return;
|
|
773
|
+
_editing.mark(message.styles, message.selection);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
if (message.type === "editInline") {
|
|
777
|
+
var _held$release, _inlineEditing$curren4, _inlineEditing$curren5;
|
|
778
|
+
// A field's words go back as they are typed, unpublished ones
|
|
779
|
+
// included. As `readPage`: only for the frame's parent, when that
|
|
780
|
+
// is the Studio here, and answered to it alone.
|
|
781
|
+
if (event.source !== window.parent) return;
|
|
782
|
+
var _asker4 = event.origin;
|
|
783
|
+
if (_asker4 !== window.location.origin) return;
|
|
784
|
+
var reply = function reply(answer) {
|
|
785
|
+
return window.parent.postMessage(answer, _asker4);
|
|
786
|
+
};
|
|
787
|
+
var pick = lastPick.current;
|
|
788
|
+
lastPick.current = null;
|
|
789
|
+
var held = heldKeys.current;
|
|
790
|
+
heldKeys.current = null;
|
|
791
|
+
var keys = (_held$release = held === null || held === void 0 ? void 0 : held.release()) !== null && _held$release !== void 0 ? _held$release : [];
|
|
792
|
+
// The answer to a click from before the one that started the edit
|
|
793
|
+
// in progress, by itself: that click is what the person did last.
|
|
794
|
+
if (pick === null && startedOnClick.current && ((_inlineEditing$curren4 = inlineEditing.current) === null || _inlineEditing$curren4 === void 0 ? void 0 : _inlineEditing$curren4.isActive()) === true) {
|
|
795
|
+
reply({
|
|
796
|
+
val: VAL_CANVAS_MESSAGE,
|
|
797
|
+
type: "inlineEditUnavailable",
|
|
798
|
+
requestId: message.requestId
|
|
799
|
+
});
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
// One edit at a time, and the element of the last one back as the
|
|
803
|
+
// page has it: it may be the very one asked for again.
|
|
804
|
+
(_inlineEditing$curren5 = inlineEditing.current) === null || _inlineEditing$curren5 === void 0 || _inlineEditing$curren5.release();
|
|
805
|
+
inlineEditing.current = null;
|
|
806
|
+
startedOnClick.current = false;
|
|
807
|
+
var started = startFirst(message.candidates, pick, {
|
|
808
|
+
color: selectionColor.current,
|
|
809
|
+
reply: reply
|
|
810
|
+
});
|
|
811
|
+
if (started !== null) {
|
|
812
|
+
inlineEditing.current = started.editing;
|
|
813
|
+
reply({
|
|
814
|
+
val: VAL_CANVAS_MESSAGE,
|
|
815
|
+
type: "inlineEditStarted",
|
|
816
|
+
requestId: message.requestId,
|
|
817
|
+
path: started.path
|
|
818
|
+
});
|
|
819
|
+
// What was typed while the Studio was being asked, now that
|
|
820
|
+
// there is somewhere for it to go: after `inlineEditStarted`,
|
|
821
|
+
// so the Studio is listening for what it types.
|
|
822
|
+
replayKeys(document, keys);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
// Nothing on the page shows one of them and nothing else: the
|
|
826
|
+
// Studio opens the field in its own column, and the keys pressed
|
|
827
|
+
// meanwhile are dropped, as on a page that is not being typed in.
|
|
828
|
+
reply({
|
|
829
|
+
val: VAL_CANVAS_MESSAGE,
|
|
830
|
+
type: "inlineEditUnavailable",
|
|
831
|
+
requestId: message.requestId
|
|
832
|
+
});
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
636
835
|
if (message.type === "theme") {
|
|
637
836
|
setSelectionColors({
|
|
638
837
|
selection: message.selection,
|
|
@@ -748,18 +947,85 @@ function ValCanvasBridge(_ref) {
|
|
|
748
947
|
*/
|
|
749
948
|
React.useEffect(function () {
|
|
750
949
|
var onClick = function onClick(event) {
|
|
751
|
-
|
|
950
|
+
var _heldKeys$current2;
|
|
752
951
|
var target = event.target;
|
|
753
952
|
if (!(target instanceof Element)) return;
|
|
953
|
+
// A click in the field being typed in places the caret, and that is
|
|
954
|
+
// all it does: it is neither a pick nor a click on the link or button
|
|
955
|
+
// the text happens to be in. (The caret is the mousedown's, so
|
|
956
|
+
// cancelling the click leaves it where it was put.)
|
|
957
|
+
var editing = inlineEditing.current;
|
|
958
|
+
if (editing !== null && editing.isActive() && editing.contains(target)) {
|
|
959
|
+
event.preventDefault();
|
|
960
|
+
event.stopPropagation();
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
if (!pickingRef.current) return;
|
|
754
964
|
var tagged = target.closest("[data-val-path]");
|
|
755
965
|
var attribute = tagged === null || tagged === void 0 ? void 0 : tagged.getAttribute("data-val-path");
|
|
756
|
-
if (!attribute) return;
|
|
966
|
+
if (!tagged || !attribute) return;
|
|
757
967
|
event.preventDefault();
|
|
758
968
|
event.stopPropagation();
|
|
969
|
+
var paths = Internal$1.splitJoinedSourcePaths(attribute);
|
|
970
|
+
var pick = {
|
|
971
|
+
element: tagged,
|
|
972
|
+
x: event.clientX,
|
|
973
|
+
y: event.clientY
|
|
974
|
+
};
|
|
975
|
+
(_heldKeys$current2 = heldKeys.current) === null || _heldKeys$current2 === void 0 || _heldKeys$current2.release();
|
|
976
|
+
heldKeys.current = null;
|
|
977
|
+
/*
|
|
978
|
+
* Select & edit, and the Studio has said which of this element's
|
|
979
|
+
* fields are texts and what they hold: the edit starts HERE, in the
|
|
980
|
+
* click, rather than a round trip across the frame later. Keys typed
|
|
981
|
+
* straight after the click then go into the text -- in that round
|
|
982
|
+
* trip they went to the page's body, which drops them -- and a phone
|
|
983
|
+
* opens its keyboard, which it does only for a focus given in the tap.
|
|
984
|
+
* Which element shows a field is still decided as `editInline` decides
|
|
985
|
+
* it (`canEditInline`), from the values the Studio sent.
|
|
986
|
+
*/
|
|
987
|
+
var known = textFields.current;
|
|
988
|
+
var offered = known !== null && known.editing ? paths.flatMap(function (path) {
|
|
989
|
+
var _known$editable$get;
|
|
990
|
+
return (_known$editable$get = known.editable.get(path)) !== null && _known$editable$get !== void 0 ? _known$editable$get : [];
|
|
991
|
+
}) : [];
|
|
992
|
+
if (known !== null && offered.length > 0) {
|
|
993
|
+
var _inlineEditing$curren6;
|
|
994
|
+
var reply = function reply(answer) {
|
|
995
|
+
return window.parent.postMessage(answer, known.origin);
|
|
996
|
+
};
|
|
997
|
+
(_inlineEditing$curren6 = inlineEditing.current) === null || _inlineEditing$curren6 === void 0 || _inlineEditing$curren6.release();
|
|
998
|
+
inlineEditing.current = null;
|
|
999
|
+
startedOnClick.current = false;
|
|
1000
|
+
var started = startFirst(offered, pick, {
|
|
1001
|
+
color: selectionColor.current,
|
|
1002
|
+
reply: reply
|
|
1003
|
+
});
|
|
1004
|
+
if (started !== null) {
|
|
1005
|
+
inlineEditing.current = started.editing;
|
|
1006
|
+
startedOnClick.current = true;
|
|
1007
|
+
lastPick.current = null;
|
|
1008
|
+
reply({
|
|
1009
|
+
val: VAL_CANVAS_MESSAGE,
|
|
1010
|
+
type: "inlineEditStarted",
|
|
1011
|
+
requestId: null,
|
|
1012
|
+
path: started.path
|
|
1013
|
+
});
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
/*
|
|
1017
|
+
* A text, but not as the Studio last said: its value changed since
|
|
1018
|
+
* (an edit a moment ago, still on its way). The Studio is asked, as
|
|
1019
|
+
* for any pick, and the keys pressed until it answers are held
|
|
1020
|
+
* rather than lost.
|
|
1021
|
+
*/
|
|
1022
|
+
heldKeys.current = holdKeys(window);
|
|
1023
|
+
}
|
|
1024
|
+
lastPick.current = pick;
|
|
759
1025
|
post({
|
|
760
1026
|
val: VAL_CANVAS_MESSAGE,
|
|
761
1027
|
type: "clicked",
|
|
762
|
-
paths:
|
|
1028
|
+
paths: paths
|
|
763
1029
|
});
|
|
764
1030
|
};
|
|
765
1031
|
document.addEventListener("click", onClick, {
|
|
@@ -772,6 +1038,17 @@ function ValCanvasBridge(_ref) {
|
|
|
772
1038
|
};
|
|
773
1039
|
}, [post]);
|
|
774
1040
|
|
|
1041
|
+
// Select off: an emptied text has its room taken away, and keys held for
|
|
1042
|
+
// an answer to a pick are dropped. Select on: it has its room again.
|
|
1043
|
+
React.useEffect(function () {
|
|
1044
|
+
if (!picking) {
|
|
1045
|
+
var _heldKeys$current3;
|
|
1046
|
+
(_heldKeys$current3 = heldKeys.current) === null || _heldKeys$current3 === void 0 || _heldKeys$current3.release();
|
|
1047
|
+
heldKeys.current = null;
|
|
1048
|
+
}
|
|
1049
|
+
scan();
|
|
1050
|
+
}, [picking, scan]);
|
|
1051
|
+
|
|
775
1052
|
// Esc while picking fields: the key goes to the page, which has the focus
|
|
776
1053
|
// once it has been clicked, so the studio hears of it only from here.
|
|
777
1054
|
React.useEffect(function () {
|
|
@@ -979,7 +1256,11 @@ function ValCanvasBridge(_ref) {
|
|
|
979
1256
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
980
1257
|
// close the selector early.
|
|
981
1258
|
dangerouslySetInnerHTML: {
|
|
982
|
-
__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, "; }") : "",
|
|
1259
|
+
__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, "; }") : "",
|
|
1260
|
+
// The one rule here that moves the page, and only while Select is
|
|
1261
|
+
// on: an emptied text's line of room, without which it cannot be
|
|
1262
|
+
// pointed at. See `emptyTextFields.ts` for why, and how narrowly.
|
|
1263
|
+
picking ? EMPTY_TEXT_RULES : "", highlighted ? highlightRule(highlighted, selectionColors.selection) : ""].filter(Boolean).join("\n")
|
|
983
1264
|
}
|
|
984
1265
|
});
|
|
985
1266
|
}
|
|
@@ -1076,23 +1357,108 @@ function isScrollable(el) {
|
|
|
1076
1357
|
};
|
|
1077
1358
|
return scrolls(style.overflowY) && el.scrollHeight > el.clientHeight || scrolls(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
1078
1359
|
}
|
|
1360
|
+
var NO_PATHS = new Set();
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Start editing the first of `candidates` an element on the page shows and
|
|
1364
|
+
* nothing else: the picked element when it carries the candidate's path,
|
|
1365
|
+
* else the first element that does. `null` when none can be.
|
|
1366
|
+
*
|
|
1367
|
+
* What `editInline` does, and what a click does by itself when the Studio has
|
|
1368
|
+
* said ahead of it what the element's texts hold (`textFields`): one way to
|
|
1369
|
+
* start, whichever asked.
|
|
1370
|
+
*/
|
|
1371
|
+
function startFirst(candidates, pick, options) {
|
|
1372
|
+
var reply = options.reply;
|
|
1373
|
+
var _iterator = _createForOfIteratorHelper(candidates),
|
|
1374
|
+
_step;
|
|
1375
|
+
try {
|
|
1376
|
+
var _loop = function _loop() {
|
|
1377
|
+
var candidate = _step.value;
|
|
1378
|
+
var picked = pick !== null && pick.element.isConnected && pathOn(pick.element, candidate.path) !== null ? pick.element : null;
|
|
1379
|
+
var element = picked !== null && picked !== void 0 ? picked : findByPath(candidate.path);
|
|
1380
|
+
if (element === null) return 0; // continue
|
|
1381
|
+
var path = pathOn(element, candidate.path);
|
|
1382
|
+
if (path === null) return 0; // continue
|
|
1383
|
+
var editing = startInlineEditing(element, candidate, {
|
|
1384
|
+
// Where the click was, when it was on this element.
|
|
1385
|
+
at: picked !== null && pick !== null ? {
|
|
1386
|
+
x: pick.x,
|
|
1387
|
+
y: pick.y
|
|
1388
|
+
} : null,
|
|
1389
|
+
color: options.color,
|
|
1390
|
+
onChange: function onChange(value) {
|
|
1391
|
+
return reply({
|
|
1392
|
+
val: VAL_CANVAS_MESSAGE,
|
|
1393
|
+
type: "inlineEdit",
|
|
1394
|
+
path: path,
|
|
1395
|
+
value: value
|
|
1396
|
+
});
|
|
1397
|
+
},
|
|
1398
|
+
onEnd: function onEnd() {
|
|
1399
|
+
return reply({
|
|
1400
|
+
val: VAL_CANVAS_MESSAGE,
|
|
1401
|
+
type: "inlineEditEnded",
|
|
1402
|
+
path: path
|
|
1403
|
+
});
|
|
1404
|
+
},
|
|
1405
|
+
onSelection: function onSelection(selection, rect, caret) {
|
|
1406
|
+
return reply({
|
|
1407
|
+
val: VAL_CANVAS_MESSAGE,
|
|
1408
|
+
type: "inlineEditSelection",
|
|
1409
|
+
path: path,
|
|
1410
|
+
selection: selection,
|
|
1411
|
+
rect: rect,
|
|
1412
|
+
caret: caret
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
if (editing !== null) return {
|
|
1417
|
+
v: {
|
|
1418
|
+
editing: editing,
|
|
1419
|
+
path: path
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
},
|
|
1423
|
+
_ret;
|
|
1424
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1425
|
+
_ret = _loop();
|
|
1426
|
+
if (_ret === 0) continue;
|
|
1427
|
+
if (_ret) return _ret.v;
|
|
1428
|
+
}
|
|
1429
|
+
} catch (err) {
|
|
1430
|
+
_iterator.e(err);
|
|
1431
|
+
} finally {
|
|
1432
|
+
_iterator.f();
|
|
1433
|
+
}
|
|
1434
|
+
return null;
|
|
1435
|
+
}
|
|
1079
1436
|
function findByPath(path) {
|
|
1080
1437
|
var elements = document.querySelectorAll("[data-val-path]");
|
|
1081
1438
|
for (var _i = 0, _Array$from = Array.from(elements); _i < _Array$from.length; _i++) {
|
|
1082
1439
|
var el = _Array$from[_i];
|
|
1083
|
-
|
|
1084
|
-
if (!attribute) continue;
|
|
1085
|
-
// Compared as strings: the split returns branded `SourcePath`s and what
|
|
1086
|
-
// came back over `postMessage` is a plain string, which is the same value.
|
|
1087
|
-
if (Internal$1.splitJoinedSourcePaths(attribute).some(function (candidate) {
|
|
1088
|
-
return candidate === path;
|
|
1089
|
-
})) {
|
|
1090
|
-
return el;
|
|
1091
|
-
}
|
|
1440
|
+
if (pathOn(el, path) !== null) return el;
|
|
1092
1441
|
}
|
|
1093
1442
|
return null;
|
|
1094
1443
|
}
|
|
1095
1444
|
|
|
1445
|
+
/**
|
|
1446
|
+
* `path` as `element` carries it, or null when it does not.
|
|
1447
|
+
*
|
|
1448
|
+
* Compared as strings: the split returns branded `SourcePath`s and what came
|
|
1449
|
+
* back over `postMessage` is a plain string, which is the same value. What is
|
|
1450
|
+
* returned is the element's own, so it is a `SourcePath` without anyone
|
|
1451
|
+
* having to say so.
|
|
1452
|
+
*/
|
|
1453
|
+
function pathOn(element, path) {
|
|
1454
|
+
var _Internal$splitJoined;
|
|
1455
|
+
var attribute = element.getAttribute("data-val-path");
|
|
1456
|
+
if (!attribute) return null;
|
|
1457
|
+
return (_Internal$splitJoined = Internal$1.splitJoinedSourcePaths(attribute).find(function (candidate) {
|
|
1458
|
+
return candidate === path;
|
|
1459
|
+
})) !== null && _Internal$splitJoined !== void 0 ? _Internal$splitJoined : null;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1096
1462
|
/** What `screenshotPage` answers: the picture, or why it could not be taken. */
|
|
1097
1463
|
function screenshotReply(_x) {
|
|
1098
1464
|
return _screenshotReply.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"tanstack-router",
|
|
15
15
|
"react"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.154.0",
|
|
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.153.5",
|
|
56
|
-
"@valbuild/language-server": "0.
|
|
57
|
-
"@valbuild/mcp": "0.
|
|
58
|
-
"@valbuild/react": "0.
|
|
59
|
-
"@valbuild/server": "0.
|
|
60
|
-
"@valbuild/shared": "0.
|
|
61
|
-
"@valbuild/ui": "0.
|
|
56
|
+
"@valbuild/language-server": "0.154.0",
|
|
57
|
+
"@valbuild/mcp": "0.154.0",
|
|
58
|
+
"@valbuild/react": "0.154.0",
|
|
59
|
+
"@valbuild/server": "0.154.0",
|
|
60
|
+
"@valbuild/shared": "0.154.0",
|
|
61
|
+
"@valbuild/ui": "0.154.0"
|
|
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-208d50df.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-bd6ec82c.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-961b447c.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-56656438.cjs.prod.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as VERSION, s as setValEnableCookieReader } from '../../dist/version-
|
|
1
|
+
import { V as VERSION, s as setValEnableCookieReader } from '../../dist/version-59dbc545.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 } from '../../dist/typeof-3e1a1d11.esm.js';
|