@valbuild/shared 0.152.0 → 0.153.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 +50 -0
- package/client/dist/valbuild-shared-client.cjs.dev.js +2 -3
- package/client/dist/valbuild-shared-client.cjs.prod.js +2 -3
- package/client/dist/valbuild-shared-client.esm.js +1 -1
- package/dist/declarations/src/internal/ApiRoutes.d.ts +123 -100
- package/dist/declarations/src/internal/elementPicker.d.ts +12 -5
- package/dist/declarations/src/internal/pageInspection.d.ts +1 -1
- package/dist/declarations/src/internal/pageScreenshot.d.ts +2 -3
- package/dist/declarations/src/internal/quickPreview.d.ts +3 -27
- package/dist/declarations/src/internal/valCanvasProtocol.d.ts +27 -16
- package/dist/declarations/src/publish/builder.d.ts +7 -2
- package/dist/{getSitemapTree-59c5ed5d.cjs.dev.js → getSitemapTree-32643b50.cjs.dev.js} +25 -128
- package/dist/{getSitemapTree-6b9024d1.cjs.prod.js → getSitemapTree-a4738117.cjs.prod.js} +25 -128
- package/dist/{getSitemapTree-3c1b9e57.esm.js → getSitemapTree-a887fed4.esm.js} +25 -127
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +118 -158
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +118 -158
- package/internal/dist/valbuild-shared-internal.esm.js +116 -157
- package/package.json +3 -3
|
@@ -27,12 +27,11 @@ var VAL_AI_SESSION_STORAGE_KEY = "val-ai-session";
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A quick preview: a proposal's page, running the proposal's CLIENT code
|
|
30
|
-
* built in the
|
|
31
|
-
* (valbuild/home `docs/design-tab.md`).
|
|
30
|
+
* built in the Studio, without a build being uploaded or served.
|
|
32
31
|
*
|
|
33
32
|
* A full build of a proposal bundles the app for the server and the browser,
|
|
34
33
|
* uploads it, and has the platform render every page before it is served --
|
|
35
|
-
* minutes. Most of what the
|
|
34
|
+
* minutes. Most of what the assistant changes is components and styles,
|
|
36
35
|
* which the browser half alone shows. So the tab bundles the app in its
|
|
37
36
|
* builder worker, and a service worker on the proposal's address hands the
|
|
38
37
|
* page that bundle instead of the served one:
|
|
@@ -50,7 +49,7 @@ var VAL_AI_SESSION_STORAGE_KEY = "val-ai-session";
|
|
|
50
49
|
* 4. It takes it over by RENDERING it, not by hydrating it. Hydration keeps
|
|
51
50
|
* the markup the server sent wherever only an attribute differs -- React
|
|
52
51
|
* mends text, never a `className` -- so a change to classes and props,
|
|
53
|
-
* which is most of what the
|
|
52
|
+
* which is most of what the assistant changes, hydrated into the old
|
|
54
53
|
* page and showed nothing. The worker adds a script to the end of that
|
|
55
54
|
* document's `<body>` ({@link QUICK_PREVIEW_RENDER_SCRIPT}) that takes the
|
|
56
55
|
* server's markup out before the app's scripts run, so hydration finds
|
|
@@ -205,114 +204,6 @@ function withQuickPreviewParam(url, id) {
|
|
|
205
204
|
return parsed.toString();
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
/**
|
|
209
|
-
* The one origin allowed to send this page a quick preview: the site's, where
|
|
210
|
-
* the design tab is, as this page's own Val server says it (the proposals
|
|
211
|
-
* list's `siteUrl`). `null` when it does not say.
|
|
212
|
-
*
|
|
213
|
-
* A quick preview is code that runs on this address, so the bridge takes one
|
|
214
|
-
* only from its parent, and only when that parent is the site: a page that
|
|
215
|
-
* framed this one could otherwise post a script into the worker and open
|
|
216
|
-
* the frame on it.
|
|
217
|
-
*/
|
|
218
|
-
function quickPreviewSiteOrigin(_x4) {
|
|
219
|
-
return _quickPreviewSiteOrigin.apply(this, arguments);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/** The site's origin, as this page's server named it: asked once per page. */
|
|
223
|
-
function _quickPreviewSiteOrigin() {
|
|
224
|
-
_quickPreviewSiteOrigin = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2(api) {
|
|
225
|
-
var fetchImpl,
|
|
226
|
-
res,
|
|
227
|
-
body,
|
|
228
|
-
siteUrl,
|
|
229
|
-
_args2 = arguments;
|
|
230
|
-
return createForOfIteratorHelper._regenerator().w(function (_context2) {
|
|
231
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
232
|
-
case 0:
|
|
233
|
-
fetchImpl = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : fetch;
|
|
234
|
-
_context2.n = 1;
|
|
235
|
-
return fetchImpl("".concat(api.replace(/\/+$/, ""), "/proposals-api"), {
|
|
236
|
-
credentials: "same-origin",
|
|
237
|
-
headers: {
|
|
238
|
-
Accept: "application/json"
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
case 1:
|
|
242
|
-
res = _context2.v;
|
|
243
|
-
if (res.ok) {
|
|
244
|
-
_context2.n = 2;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
return _context2.a(2, null);
|
|
248
|
-
case 2:
|
|
249
|
-
_context2.n = 3;
|
|
250
|
-
return res.json();
|
|
251
|
-
case 3:
|
|
252
|
-
body = _context2.v;
|
|
253
|
-
if (!(createForOfIteratorHelper._typeof(body) !== "object" || body === null || !("siteUrl" in body))) {
|
|
254
|
-
_context2.n = 4;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
return _context2.a(2, null);
|
|
258
|
-
case 4:
|
|
259
|
-
siteUrl = body.siteUrl;
|
|
260
|
-
if (!(typeof siteUrl !== "string")) {
|
|
261
|
-
_context2.n = 5;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
return _context2.a(2, null);
|
|
265
|
-
case 5:
|
|
266
|
-
_context2.p = 5;
|
|
267
|
-
return _context2.a(2, new URL(siteUrl).origin);
|
|
268
|
-
case 6:
|
|
269
|
-
_context2.p = 6;
|
|
270
|
-
_context2.v;
|
|
271
|
-
return _context2.a(2, null);
|
|
272
|
-
}
|
|
273
|
-
}, _callee2, null, [[5, 6]]);
|
|
274
|
-
}));
|
|
275
|
-
return _quickPreviewSiteOrigin.apply(this, arguments);
|
|
276
|
-
}
|
|
277
|
-
var siteOriginOnce = null;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Whether `origin` may ask this page for what only the design tab should
|
|
281
|
-
* have -- what is on it (`readPage`), or code to run (`quickPreview`): this
|
|
282
|
-
* page's own origin (the Studio's canvas), or the site's, where the design
|
|
283
|
-
* tab is ({@link quickPreviewSiteOrigin}). Asked of the server once, and
|
|
284
|
-
* again only while it has not said.
|
|
285
|
-
*/
|
|
286
|
-
function isDesignTabOrigin(_x5, _x6) {
|
|
287
|
-
return _isDesignTabOrigin.apply(this, arguments);
|
|
288
|
-
}
|
|
289
|
-
function _isDesignTabOrigin() {
|
|
290
|
-
_isDesignTabOrigin = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3(origin, options) {
|
|
291
|
-
var site;
|
|
292
|
-
return createForOfIteratorHelper._regenerator().w(function (_context3) {
|
|
293
|
-
while (1) switch (_context3.n) {
|
|
294
|
-
case 0:
|
|
295
|
-
if (!(origin === options.own)) {
|
|
296
|
-
_context3.n = 1;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
return _context3.a(2, true);
|
|
300
|
-
case 1:
|
|
301
|
-
siteOriginOnce !== null && siteOriginOnce !== void 0 ? siteOriginOnce : siteOriginOnce = quickPreviewSiteOrigin(options.api, options.fetchImpl)["catch"](function () {
|
|
302
|
-
return null;
|
|
303
|
-
});
|
|
304
|
-
_context3.n = 2;
|
|
305
|
-
return siteOriginOnce;
|
|
306
|
-
case 2:
|
|
307
|
-
site = _context3.v;
|
|
308
|
-
if (site === null) siteOriginOnce = null;
|
|
309
|
-
return _context3.a(2, site !== null && site === origin);
|
|
310
|
-
}
|
|
311
|
-
}, _callee3);
|
|
312
|
-
}));
|
|
313
|
-
return _isDesignTabOrigin.apply(this, arguments);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
207
|
/** Marks a page load as the studio's canvas frame. */
|
|
317
208
|
var VAL_CANVAS_PARAM = "val_canvas";
|
|
318
209
|
|
|
@@ -359,7 +250,7 @@ function isValCanvasPageMessage(data) {
|
|
|
359
250
|
if (createForOfIteratorHelper._typeof(data) !== "object" || data === null) return false;
|
|
360
251
|
var message = data;
|
|
361
252
|
if (message.val !== VAL_CANVAS_MESSAGE) return false;
|
|
362
|
-
return message.type === "ready" && isModulePathList(data.holds) && isHeldVersions(data.holdsVersions) || message.type === "elements" || message.type === "clicked" || message.type === "pinch" || message.type === "zoom" || message.type === "refreshing" || message.type === "elementPickingStopped" || message.type === "elementPicked" && isPickedElement(data.element) || message.type === "location" && isPageLocation(data) || message.type === "pageRead" && typeof data.requestId === "string" || message.type === "pageScreenshot" && typeof data.requestId === "string" || message.type === "quickPreviewStored" && typeof data.id === "string";
|
|
253
|
+
return message.type === "ready" && isModulePathList(data.holds) && isHeldVersions(data.holdsVersions) || message.type === "elements" || message.type === "clicked" || message.type === "pinch" || message.type === "zoom" || message.type === "refreshing" || message.type === "elementPickingStopped" || message.type === "pickingStopped" || message.type === "elementPicked" && isPickedElement(data.element) || message.type === "location" && isPageLocation(data) || message.type === "pageRead" && typeof data.requestId === "string" || message.type === "pageScreenshot" && typeof data.requestId === "string" || message.type === "quickPreviewStored" && typeof data.id === "string";
|
|
363
254
|
}
|
|
364
255
|
|
|
365
256
|
/** `holdsVersions` on `ready`: absent, or a version per module path. */
|
|
@@ -422,7 +313,7 @@ function isValCanvasStudioMessage(data) {
|
|
|
422
313
|
}
|
|
423
314
|
if (message.type === "pickElements") {
|
|
424
315
|
var pick = data;
|
|
425
|
-
return typeof pick.enabled === "boolean" && typeof pick.active === "boolean" && typeof pick.keepPicked === "boolean" && PICK_MODIFIERS.includes(pick.modifier);
|
|
316
|
+
return typeof pick.enabled === "boolean" && typeof pick.active === "boolean" && typeof pick.keepPicked === "boolean" && PICK_MODIFIERS.includes(pick.modifier) && (pick.fieldsOnly === undefined || typeof pick.fieldsOnly === "boolean") && (pick.color === undefined || isCanvasSelectionColor(pick.color));
|
|
426
317
|
}
|
|
427
318
|
if (message.type === "scrollTo") {
|
|
428
319
|
var scroll = data;
|
|
@@ -485,9 +376,9 @@ function withValCanvasParam(url) {
|
|
|
485
376
|
/**
|
|
486
377
|
* Pointing at anything on a page, as Lovable's picker does: hover outlines
|
|
487
378
|
* the element under the pointer, a click picks it, and the assistant is told
|
|
488
|
-
* which
|
|
379
|
+
* which.
|
|
489
380
|
*
|
|
490
|
-
* ANY element, not only what Val marks. The
|
|
381
|
+
* ANY element, not only what Val marks. The assistant changes code, and the
|
|
491
382
|
* thing a person wants changed is as often a wrapper, a gap or a button as a
|
|
492
383
|
* field -- so a field's path is extra information when there is one
|
|
493
384
|
* (`valPath`), never the condition for picking.
|
|
@@ -498,9 +389,8 @@ function withValCanvasParam(url) {
|
|
|
498
389
|
*
|
|
499
390
|
* Plain DOM, nothing of React's or the Studio's, and in `shared` because
|
|
500
391
|
* both halves need it: the canvas bridge (`@valbuild/next`,
|
|
501
|
-
* `@valbuild/tanstack`) runs it inside the
|
|
502
|
-
*
|
|
503
|
-
* reached; the Studio's stories run it on a page of their own. Only the
|
|
392
|
+
* `@valbuild/tanstack`) runs it inside the page, the only place the page's
|
|
393
|
+
* elements can be reached; the Studio's stories run it on a page of their own. Only the
|
|
504
394
|
* `PickedElement` crosses the frame (`valCanvasProtocol.ts`).
|
|
505
395
|
*/
|
|
506
396
|
|
|
@@ -581,8 +471,15 @@ function attachElementPicker(root, options) {
|
|
|
581
471
|
var picking = function picking(event) {
|
|
582
472
|
return options.active() || held(event, options.modifier);
|
|
583
473
|
};
|
|
474
|
+
var pickable = function pickable(element) {
|
|
475
|
+
var _options$fieldsOnly;
|
|
476
|
+
if (element === null || !root.contains(element)) return null;
|
|
477
|
+
if (((_options$fieldsOnly = options.fieldsOnly) === null || _options$fieldsOnly === void 0 ? void 0 : _options$fieldsOnly.call(options)) !== true) return element;
|
|
478
|
+
var field = element.closest("[data-val-path]");
|
|
479
|
+
return field !== null && root.contains(field) ? field : null;
|
|
480
|
+
};
|
|
584
481
|
var target = function target(event) {
|
|
585
|
-
return event.target instanceof Element
|
|
482
|
+
return pickable(event.target instanceof Element ? event.target : null);
|
|
586
483
|
};
|
|
587
484
|
var onMove = function onMove(event) {
|
|
588
485
|
last = {
|
|
@@ -643,8 +540,7 @@ function attachElementPicker(root, options) {
|
|
|
643
540
|
return;
|
|
644
541
|
}
|
|
645
542
|
if (last === null) return;
|
|
646
|
-
|
|
647
|
-
options.onHover(under !== null && root.contains(under) ? under : null);
|
|
543
|
+
options.onHover(pickable(root.ownerDocument.elementFromPoint(last.x, last.y)));
|
|
648
544
|
};
|
|
649
545
|
var onLeave = function onLeave() {
|
|
650
546
|
last = null;
|
|
@@ -746,7 +642,9 @@ function createPickerOverlay(doc, initialColor) {
|
|
|
746
642
|
left: "".concat(rect.left - 2, "px"),
|
|
747
643
|
width: "".concat(rect.width + 4, "px"),
|
|
748
644
|
height: "".concat(rect.height + 4, "px"),
|
|
749
|
-
|
|
645
|
+
// Dashed, both: it is what the assistant is pointed at, and the
|
|
646
|
+
// canvas's own field outlines -- Content's Select -- are solid.
|
|
647
|
+
border: "2px dashed ".concat(color)
|
|
750
648
|
});
|
|
751
649
|
if (kind === "hover") {
|
|
752
650
|
label.textContent = elementLabel(element);
|
|
@@ -817,6 +715,7 @@ function startElementPicking(root, options) {
|
|
|
817
715
|
var detach = attachElementPicker(root, {
|
|
818
716
|
modifier: options.modifier,
|
|
819
717
|
active: options.active,
|
|
718
|
+
fieldsOnly: options.fieldsOnly,
|
|
820
719
|
onHover: function onHover(element) {
|
|
821
720
|
return overlay.show("hover", element);
|
|
822
721
|
},
|
|
@@ -1199,9 +1098,8 @@ function selectorOf(element, root) {
|
|
|
1199
1098
|
* `screenshot_page`, so it can see a change it made rather than only read it
|
|
1200
1099
|
* (`read_page` gives the words and the boxes).
|
|
1201
1100
|
*
|
|
1202
|
-
* Taken HERE
|
|
1203
|
-
* the
|
|
1204
|
-
* frame of another origin. So the bridge renders its own document --
|
|
1101
|
+
* Taken HERE, in the page: a browser lets no page photograph a frame, so
|
|
1102
|
+
* the bridge renders its own document --
|
|
1205
1103
|
* `modern-screenshot` draws the DOM, with its computed styles, fonts and
|
|
1206
1104
|
* same-origin images, into a canvas -- and hands back a JPEG.
|
|
1207
1105
|
*
|
|
@@ -1589,7 +1487,7 @@ exports.getPageRouterSitemapTree = getPageRouterSitemapTree;
|
|
|
1589
1487
|
exports.getPageRouterSourceFolder = getPageRouterSourceFolder;
|
|
1590
1488
|
exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
|
|
1591
1489
|
exports.getTanStackRouterSourceFolder = getTanStackRouterSourceFolder;
|
|
1592
|
-
exports.
|
|
1490
|
+
exports.isCanvasSelectionColor = isCanvasSelectionColor;
|
|
1593
1491
|
exports.isQuickPreviewFiles = isQuickPreviewFiles;
|
|
1594
1492
|
exports.isTanStackRoutesFolder = isTanStackRoutesFolder;
|
|
1595
1493
|
exports.isValCanvasFrame = isValCanvasFrame;
|
|
@@ -1598,7 +1496,6 @@ exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
|
|
|
1598
1496
|
exports.modifierLabel = modifierLabel;
|
|
1599
1497
|
exports.pageLocationOf = pageLocationOf;
|
|
1600
1498
|
exports.parseRoutePattern = parseRoutePattern;
|
|
1601
|
-
exports.quickPreviewSiteOrigin = quickPreviewSiteOrigin;
|
|
1602
1499
|
exports.readPageSnapshot = readPageSnapshot;
|
|
1603
1500
|
exports.restoreScroll = restoreScroll;
|
|
1604
1501
|
exports.screenshotPage = screenshotPage;
|
|
@@ -27,12 +27,11 @@ var VAL_AI_SESSION_STORAGE_KEY = "val-ai-session";
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A quick preview: a proposal's page, running the proposal's CLIENT code
|
|
30
|
-
* built in the
|
|
31
|
-
* (valbuild/home `docs/design-tab.md`).
|
|
30
|
+
* built in the Studio, without a build being uploaded or served.
|
|
32
31
|
*
|
|
33
32
|
* A full build of a proposal bundles the app for the server and the browser,
|
|
34
33
|
* uploads it, and has the platform render every page before it is served --
|
|
35
|
-
* minutes. Most of what the
|
|
34
|
+
* minutes. Most of what the assistant changes is components and styles,
|
|
36
35
|
* which the browser half alone shows. So the tab bundles the app in its
|
|
37
36
|
* builder worker, and a service worker on the proposal's address hands the
|
|
38
37
|
* page that bundle instead of the served one:
|
|
@@ -50,7 +49,7 @@ var VAL_AI_SESSION_STORAGE_KEY = "val-ai-session";
|
|
|
50
49
|
* 4. It takes it over by RENDERING it, not by hydrating it. Hydration keeps
|
|
51
50
|
* the markup the server sent wherever only an attribute differs -- React
|
|
52
51
|
* mends text, never a `className` -- so a change to classes and props,
|
|
53
|
-
* which is most of what the
|
|
52
|
+
* which is most of what the assistant changes, hydrated into the old
|
|
54
53
|
* page and showed nothing. The worker adds a script to the end of that
|
|
55
54
|
* document's `<body>` ({@link QUICK_PREVIEW_RENDER_SCRIPT}) that takes the
|
|
56
55
|
* server's markup out before the app's scripts run, so hydration finds
|
|
@@ -205,114 +204,6 @@ function withQuickPreviewParam(url, id) {
|
|
|
205
204
|
return parsed.toString();
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
/**
|
|
209
|
-
* The one origin allowed to send this page a quick preview: the site's, where
|
|
210
|
-
* the design tab is, as this page's own Val server says it (the proposals
|
|
211
|
-
* list's `siteUrl`). `null` when it does not say.
|
|
212
|
-
*
|
|
213
|
-
* A quick preview is code that runs on this address, so the bridge takes one
|
|
214
|
-
* only from its parent, and only when that parent is the site: a page that
|
|
215
|
-
* framed this one could otherwise post a script into the worker and open
|
|
216
|
-
* the frame on it.
|
|
217
|
-
*/
|
|
218
|
-
function quickPreviewSiteOrigin(_x4) {
|
|
219
|
-
return _quickPreviewSiteOrigin.apply(this, arguments);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/** The site's origin, as this page's server named it: asked once per page. */
|
|
223
|
-
function _quickPreviewSiteOrigin() {
|
|
224
|
-
_quickPreviewSiteOrigin = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee2(api) {
|
|
225
|
-
var fetchImpl,
|
|
226
|
-
res,
|
|
227
|
-
body,
|
|
228
|
-
siteUrl,
|
|
229
|
-
_args2 = arguments;
|
|
230
|
-
return createForOfIteratorHelper._regenerator().w(function (_context2) {
|
|
231
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
232
|
-
case 0:
|
|
233
|
-
fetchImpl = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : fetch;
|
|
234
|
-
_context2.n = 1;
|
|
235
|
-
return fetchImpl("".concat(api.replace(/\/+$/, ""), "/proposals-api"), {
|
|
236
|
-
credentials: "same-origin",
|
|
237
|
-
headers: {
|
|
238
|
-
Accept: "application/json"
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
case 1:
|
|
242
|
-
res = _context2.v;
|
|
243
|
-
if (res.ok) {
|
|
244
|
-
_context2.n = 2;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
return _context2.a(2, null);
|
|
248
|
-
case 2:
|
|
249
|
-
_context2.n = 3;
|
|
250
|
-
return res.json();
|
|
251
|
-
case 3:
|
|
252
|
-
body = _context2.v;
|
|
253
|
-
if (!(createForOfIteratorHelper._typeof(body) !== "object" || body === null || !("siteUrl" in body))) {
|
|
254
|
-
_context2.n = 4;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
return _context2.a(2, null);
|
|
258
|
-
case 4:
|
|
259
|
-
siteUrl = body.siteUrl;
|
|
260
|
-
if (!(typeof siteUrl !== "string")) {
|
|
261
|
-
_context2.n = 5;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
return _context2.a(2, null);
|
|
265
|
-
case 5:
|
|
266
|
-
_context2.p = 5;
|
|
267
|
-
return _context2.a(2, new URL(siteUrl).origin);
|
|
268
|
-
case 6:
|
|
269
|
-
_context2.p = 6;
|
|
270
|
-
_context2.v;
|
|
271
|
-
return _context2.a(2, null);
|
|
272
|
-
}
|
|
273
|
-
}, _callee2, null, [[5, 6]]);
|
|
274
|
-
}));
|
|
275
|
-
return _quickPreviewSiteOrigin.apply(this, arguments);
|
|
276
|
-
}
|
|
277
|
-
var siteOriginOnce = null;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Whether `origin` may ask this page for what only the design tab should
|
|
281
|
-
* have -- what is on it (`readPage`), or code to run (`quickPreview`): this
|
|
282
|
-
* page's own origin (the Studio's canvas), or the site's, where the design
|
|
283
|
-
* tab is ({@link quickPreviewSiteOrigin}). Asked of the server once, and
|
|
284
|
-
* again only while it has not said.
|
|
285
|
-
*/
|
|
286
|
-
function isDesignTabOrigin(_x5, _x6) {
|
|
287
|
-
return _isDesignTabOrigin.apply(this, arguments);
|
|
288
|
-
}
|
|
289
|
-
function _isDesignTabOrigin() {
|
|
290
|
-
_isDesignTabOrigin = createForOfIteratorHelper._asyncToGenerator(/*#__PURE__*/createForOfIteratorHelper._regenerator().m(function _callee3(origin, options) {
|
|
291
|
-
var site;
|
|
292
|
-
return createForOfIteratorHelper._regenerator().w(function (_context3) {
|
|
293
|
-
while (1) switch (_context3.n) {
|
|
294
|
-
case 0:
|
|
295
|
-
if (!(origin === options.own)) {
|
|
296
|
-
_context3.n = 1;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
return _context3.a(2, true);
|
|
300
|
-
case 1:
|
|
301
|
-
siteOriginOnce !== null && siteOriginOnce !== void 0 ? siteOriginOnce : siteOriginOnce = quickPreviewSiteOrigin(options.api, options.fetchImpl)["catch"](function () {
|
|
302
|
-
return null;
|
|
303
|
-
});
|
|
304
|
-
_context3.n = 2;
|
|
305
|
-
return siteOriginOnce;
|
|
306
|
-
case 2:
|
|
307
|
-
site = _context3.v;
|
|
308
|
-
if (site === null) siteOriginOnce = null;
|
|
309
|
-
return _context3.a(2, site !== null && site === origin);
|
|
310
|
-
}
|
|
311
|
-
}, _callee3);
|
|
312
|
-
}));
|
|
313
|
-
return _isDesignTabOrigin.apply(this, arguments);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
207
|
/** Marks a page load as the studio's canvas frame. */
|
|
317
208
|
var VAL_CANVAS_PARAM = "val_canvas";
|
|
318
209
|
|
|
@@ -359,7 +250,7 @@ function isValCanvasPageMessage(data) {
|
|
|
359
250
|
if (createForOfIteratorHelper._typeof(data) !== "object" || data === null) return false;
|
|
360
251
|
var message = data;
|
|
361
252
|
if (message.val !== VAL_CANVAS_MESSAGE) return false;
|
|
362
|
-
return message.type === "ready" && isModulePathList(data.holds) && isHeldVersions(data.holdsVersions) || message.type === "elements" || message.type === "clicked" || message.type === "pinch" || message.type === "zoom" || message.type === "refreshing" || message.type === "elementPickingStopped" || message.type === "elementPicked" && isPickedElement(data.element) || message.type === "location" && isPageLocation(data) || message.type === "pageRead" && typeof data.requestId === "string" || message.type === "pageScreenshot" && typeof data.requestId === "string" || message.type === "quickPreviewStored" && typeof data.id === "string";
|
|
253
|
+
return message.type === "ready" && isModulePathList(data.holds) && isHeldVersions(data.holdsVersions) || message.type === "elements" || message.type === "clicked" || message.type === "pinch" || message.type === "zoom" || message.type === "refreshing" || message.type === "elementPickingStopped" || message.type === "pickingStopped" || message.type === "elementPicked" && isPickedElement(data.element) || message.type === "location" && isPageLocation(data) || message.type === "pageRead" && typeof data.requestId === "string" || message.type === "pageScreenshot" && typeof data.requestId === "string" || message.type === "quickPreviewStored" && typeof data.id === "string";
|
|
363
254
|
}
|
|
364
255
|
|
|
365
256
|
/** `holdsVersions` on `ready`: absent, or a version per module path. */
|
|
@@ -422,7 +313,7 @@ function isValCanvasStudioMessage(data) {
|
|
|
422
313
|
}
|
|
423
314
|
if (message.type === "pickElements") {
|
|
424
315
|
var pick = data;
|
|
425
|
-
return typeof pick.enabled === "boolean" && typeof pick.active === "boolean" && typeof pick.keepPicked === "boolean" && PICK_MODIFIERS.includes(pick.modifier);
|
|
316
|
+
return typeof pick.enabled === "boolean" && typeof pick.active === "boolean" && typeof pick.keepPicked === "boolean" && PICK_MODIFIERS.includes(pick.modifier) && (pick.fieldsOnly === undefined || typeof pick.fieldsOnly === "boolean") && (pick.color === undefined || isCanvasSelectionColor(pick.color));
|
|
426
317
|
}
|
|
427
318
|
if (message.type === "scrollTo") {
|
|
428
319
|
var scroll = data;
|
|
@@ -485,9 +376,9 @@ function withValCanvasParam(url) {
|
|
|
485
376
|
/**
|
|
486
377
|
* Pointing at anything on a page, as Lovable's picker does: hover outlines
|
|
487
378
|
* the element under the pointer, a click picks it, and the assistant is told
|
|
488
|
-
* which
|
|
379
|
+
* which.
|
|
489
380
|
*
|
|
490
|
-
* ANY element, not only what Val marks. The
|
|
381
|
+
* ANY element, not only what Val marks. The assistant changes code, and the
|
|
491
382
|
* thing a person wants changed is as often a wrapper, a gap or a button as a
|
|
492
383
|
* field -- so a field's path is extra information when there is one
|
|
493
384
|
* (`valPath`), never the condition for picking.
|
|
@@ -498,9 +389,8 @@ function withValCanvasParam(url) {
|
|
|
498
389
|
*
|
|
499
390
|
* Plain DOM, nothing of React's or the Studio's, and in `shared` because
|
|
500
391
|
* both halves need it: the canvas bridge (`@valbuild/next`,
|
|
501
|
-
* `@valbuild/tanstack`) runs it inside the
|
|
502
|
-
*
|
|
503
|
-
* reached; the Studio's stories run it on a page of their own. Only the
|
|
392
|
+
* `@valbuild/tanstack`) runs it inside the page, the only place the page's
|
|
393
|
+
* elements can be reached; the Studio's stories run it on a page of their own. Only the
|
|
504
394
|
* `PickedElement` crosses the frame (`valCanvasProtocol.ts`).
|
|
505
395
|
*/
|
|
506
396
|
|
|
@@ -581,8 +471,15 @@ function attachElementPicker(root, options) {
|
|
|
581
471
|
var picking = function picking(event) {
|
|
582
472
|
return options.active() || held(event, options.modifier);
|
|
583
473
|
};
|
|
474
|
+
var pickable = function pickable(element) {
|
|
475
|
+
var _options$fieldsOnly;
|
|
476
|
+
if (element === null || !root.contains(element)) return null;
|
|
477
|
+
if (((_options$fieldsOnly = options.fieldsOnly) === null || _options$fieldsOnly === void 0 ? void 0 : _options$fieldsOnly.call(options)) !== true) return element;
|
|
478
|
+
var field = element.closest("[data-val-path]");
|
|
479
|
+
return field !== null && root.contains(field) ? field : null;
|
|
480
|
+
};
|
|
584
481
|
var target = function target(event) {
|
|
585
|
-
return event.target instanceof Element
|
|
482
|
+
return pickable(event.target instanceof Element ? event.target : null);
|
|
586
483
|
};
|
|
587
484
|
var onMove = function onMove(event) {
|
|
588
485
|
last = {
|
|
@@ -643,8 +540,7 @@ function attachElementPicker(root, options) {
|
|
|
643
540
|
return;
|
|
644
541
|
}
|
|
645
542
|
if (last === null) return;
|
|
646
|
-
|
|
647
|
-
options.onHover(under !== null && root.contains(under) ? under : null);
|
|
543
|
+
options.onHover(pickable(root.ownerDocument.elementFromPoint(last.x, last.y)));
|
|
648
544
|
};
|
|
649
545
|
var onLeave = function onLeave() {
|
|
650
546
|
last = null;
|
|
@@ -746,7 +642,9 @@ function createPickerOverlay(doc, initialColor) {
|
|
|
746
642
|
left: "".concat(rect.left - 2, "px"),
|
|
747
643
|
width: "".concat(rect.width + 4, "px"),
|
|
748
644
|
height: "".concat(rect.height + 4, "px"),
|
|
749
|
-
|
|
645
|
+
// Dashed, both: it is what the assistant is pointed at, and the
|
|
646
|
+
// canvas's own field outlines -- Content's Select -- are solid.
|
|
647
|
+
border: "2px dashed ".concat(color)
|
|
750
648
|
});
|
|
751
649
|
if (kind === "hover") {
|
|
752
650
|
label.textContent = elementLabel(element);
|
|
@@ -817,6 +715,7 @@ function startElementPicking(root, options) {
|
|
|
817
715
|
var detach = attachElementPicker(root, {
|
|
818
716
|
modifier: options.modifier,
|
|
819
717
|
active: options.active,
|
|
718
|
+
fieldsOnly: options.fieldsOnly,
|
|
820
719
|
onHover: function onHover(element) {
|
|
821
720
|
return overlay.show("hover", element);
|
|
822
721
|
},
|
|
@@ -1199,9 +1098,8 @@ function selectorOf(element, root) {
|
|
|
1199
1098
|
* `screenshot_page`, so it can see a change it made rather than only read it
|
|
1200
1099
|
* (`read_page` gives the words and the boxes).
|
|
1201
1100
|
*
|
|
1202
|
-
* Taken HERE
|
|
1203
|
-
* the
|
|
1204
|
-
* frame of another origin. So the bridge renders its own document --
|
|
1101
|
+
* Taken HERE, in the page: a browser lets no page photograph a frame, so
|
|
1102
|
+
* the bridge renders its own document --
|
|
1205
1103
|
* `modern-screenshot` draws the DOM, with its computed styles, fonts and
|
|
1206
1104
|
* same-origin images, into a canvas -- and hands back a JPEG.
|
|
1207
1105
|
*
|
|
@@ -1589,7 +1487,7 @@ exports.getPageRouterSitemapTree = getPageRouterSitemapTree;
|
|
|
1589
1487
|
exports.getPageRouterSourceFolder = getPageRouterSourceFolder;
|
|
1590
1488
|
exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
|
|
1591
1489
|
exports.getTanStackRouterSourceFolder = getTanStackRouterSourceFolder;
|
|
1592
|
-
exports.
|
|
1490
|
+
exports.isCanvasSelectionColor = isCanvasSelectionColor;
|
|
1593
1491
|
exports.isQuickPreviewFiles = isQuickPreviewFiles;
|
|
1594
1492
|
exports.isTanStackRoutesFolder = isTanStackRoutesFolder;
|
|
1595
1493
|
exports.isValCanvasFrame = isValCanvasFrame;
|
|
@@ -1598,7 +1496,6 @@ exports.isValCanvasStudioMessage = isValCanvasStudioMessage;
|
|
|
1598
1496
|
exports.modifierLabel = modifierLabel;
|
|
1599
1497
|
exports.pageLocationOf = pageLocationOf;
|
|
1600
1498
|
exports.parseRoutePattern = parseRoutePattern;
|
|
1601
|
-
exports.quickPreviewSiteOrigin = quickPreviewSiteOrigin;
|
|
1602
1499
|
exports.readPageSnapshot = readPageSnapshot;
|
|
1603
1500
|
exports.restoreScroll = restoreScroll;
|
|
1604
1501
|
exports.screenshotPage = screenshotPage;
|