@valbuild/next 0.106.0 → 0.107.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.
@@ -327,6 +327,130 @@ function ValCanvasBridge(_ref) {
327
327
  };
328
328
  }, [post]);
329
329
 
330
+ /**
331
+ * Two-finger gestures, handed to the studio.
332
+ *
333
+ * The window around the page is the studio's, and the page is a frame: a
334
+ * finger that lands here is this document's and the studio never hears about
335
+ * it. So a pinch on the page could not zoom the window, which on a phone is
336
+ * the only zoom there is — the toolbar's + and - are a poor substitute for the
337
+ * gesture everyone already makes.
338
+ *
339
+ * Two fingers and only two. One finger is the page's: it scrolls it, taps its
340
+ * links, drags whatever the page put there. Two are the window's, for zooming
341
+ * and for moving the page around inside it. Nothing has to be moded, and the
342
+ * two cannot be confused for one another.
343
+ *
344
+ * `passive: false` because both handlers cancel: the default for two fingers
345
+ * is the browser's own page zoom, which inside a frame the studio is already
346
+ * scaling produces two zooms fighting over one gesture.
347
+ */
348
+ React.useEffect(function () {
349
+ var midpoint = function midpoint(touches) {
350
+ return {
351
+ x: (touches[0].clientX + touches[1].clientX) / 2,
352
+ y: (touches[0].clientY + touches[1].clientY) / 2
353
+ };
354
+ };
355
+ var span = function span(touches) {
356
+ return Math.hypot(touches[0].clientX - touches[1].clientX, touches[0].clientY - touches[1].clientY);
357
+ };
358
+ /**
359
+ * Whether a gesture is in progress.
360
+ *
361
+ * `touchend` fires per finger, so lifting one of two leaves a `touchend`
362
+ * carrying a single touch — which is the end of the gesture — and the
363
+ * second leaves one carrying none. Without this the second would post a
364
+ * second `end` for a gesture that was already over.
365
+ */
366
+ var active = false;
367
+ var onStart = function onStart(event) {
368
+ if (event.touches.length !== 2) return;
369
+ event.preventDefault();
370
+ active = true;
371
+ post({
372
+ val: VAL_CANVAS_MESSAGE,
373
+ type: "pinch",
374
+ phase: "start",
375
+ span: span(event.touches),
376
+ center: midpoint(event.touches)
377
+ });
378
+ };
379
+ var onMove = function onMove(event) {
380
+ if (event.touches.length !== 2 || !active) return;
381
+ event.preventDefault();
382
+ post({
383
+ val: VAL_CANVAS_MESSAGE,
384
+ type: "pinch",
385
+ phase: "move",
386
+ span: span(event.touches),
387
+ center: midpoint(event.touches)
388
+ });
389
+ };
390
+ var onEnd = function onEnd(event) {
391
+ if (!active || event.touches.length >= 2) return;
392
+ active = false;
393
+ post({
394
+ val: VAL_CANVAS_MESSAGE,
395
+ type: "pinch",
396
+ phase: "end",
397
+ span: 0,
398
+ center: {
399
+ x: 0,
400
+ y: 0
401
+ }
402
+ });
403
+ };
404
+ document.addEventListener("touchstart", onStart, {
405
+ passive: false
406
+ });
407
+ document.addEventListener("touchmove", onMove, {
408
+ passive: false
409
+ });
410
+ document.addEventListener("touchend", onEnd);
411
+ document.addEventListener("touchcancel", onEnd);
412
+ return function () {
413
+ document.removeEventListener("touchstart", onStart);
414
+ document.removeEventListener("touchmove", onMove);
415
+ document.removeEventListener("touchend", onEnd);
416
+ document.removeEventListener("touchcancel", onEnd);
417
+ };
418
+ }, [post]);
419
+
420
+ /**
421
+ * And ctrl/cmd + wheel, which is what a trackpad pinch reports as.
422
+ *
423
+ * The same problem as touches and the same answer: the wheel event lands on
424
+ * this document, so without relaying it a trackpad pinch over the page does
425
+ * nothing while the identical gesture over the canvas background zooms.
426
+ *
427
+ * A PLAIN wheel is deliberately left alone — that is the page scrolling
428
+ * itself, which is exactly what it should do.
429
+ */
430
+ React.useEffect(function () {
431
+ var onWheel = function onWheel(event) {
432
+ if (!event.ctrlKey && !event.metaKey) return;
433
+ event.preventDefault();
434
+ post({
435
+ val: VAL_CANVAS_MESSAGE,
436
+ type: "zoom",
437
+ // The same response curve the studio uses for a wheel on its own
438
+ // background, so the gesture feels the same on both sides of the frame.
439
+ factor: 1 - event.deltaY / 300,
440
+ center: {
441
+ x: event.clientX,
442
+ y: event.clientY
443
+ }
444
+ });
445
+ };
446
+ document.addEventListener("wheel", onWheel, {
447
+ passive: false
448
+ });
449
+ return function () {
450
+ return document.removeEventListener("wheel", onWheel);
451
+ };
452
+ }, [post]);
453
+
330
454
  /**
331
455
  * The outlines, as a stylesheet rather than as injected elements.
332
456
  *
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValCanvasBridge-32299c6e.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValCanvasBridge-32299c6e.cjs.dev.js");
7
+ }
@@ -335,6 +335,130 @@ function ValCanvasBridge(_ref) {
335
335
  };
336
336
  }, [post]);
337
337
 
338
+ /**
339
+ * Two-finger gestures, handed to the studio.
340
+ *
341
+ * The window around the page is the studio's, and the page is a frame: a
342
+ * finger that lands here is this document's and the studio never hears about
343
+ * it. So a pinch on the page could not zoom the window, which on a phone is
344
+ * the only zoom there is — the toolbar's + and - are a poor substitute for the
345
+ * gesture everyone already makes.
346
+ *
347
+ * Two fingers and only two. One finger is the page's: it scrolls it, taps its
348
+ * links, drags whatever the page put there. Two are the window's, for zooming
349
+ * and for moving the page around inside it. Nothing has to be moded, and the
350
+ * two cannot be confused for one another.
351
+ *
352
+ * `passive: false` because both handlers cancel: the default for two fingers
353
+ * is the browser's own page zoom, which inside a frame the studio is already
354
+ * scaling produces two zooms fighting over one gesture.
355
+ */
356
+ React__default["default"].useEffect(function () {
357
+ var midpoint = function midpoint(touches) {
358
+ return {
359
+ x: (touches[0].clientX + touches[1].clientX) / 2,
360
+ y: (touches[0].clientY + touches[1].clientY) / 2
361
+ };
362
+ };
363
+ var span = function span(touches) {
364
+ return Math.hypot(touches[0].clientX - touches[1].clientX, touches[0].clientY - touches[1].clientY);
365
+ };
366
+ /**
367
+ * Whether a gesture is in progress.
368
+ *
369
+ * `touchend` fires per finger, so lifting one of two leaves a `touchend`
370
+ * carrying a single touch — which is the end of the gesture — and the
371
+ * second leaves one carrying none. Without this the second would post a
372
+ * second `end` for a gesture that was already over.
373
+ */
374
+ var active = false;
375
+ var onStart = function onStart(event) {
376
+ if (event.touches.length !== 2) return;
377
+ event.preventDefault();
378
+ active = true;
379
+ post({
380
+ val: internal.VAL_CANVAS_MESSAGE,
381
+ type: "pinch",
382
+ phase: "start",
383
+ span: span(event.touches),
384
+ center: midpoint(event.touches)
385
+ });
386
+ };
387
+ var onMove = function onMove(event) {
388
+ if (event.touches.length !== 2 || !active) return;
389
+ event.preventDefault();
390
+ post({
391
+ val: internal.VAL_CANVAS_MESSAGE,
392
+ type: "pinch",
393
+ phase: "move",
394
+ span: span(event.touches),
395
+ center: midpoint(event.touches)
396
+ });
397
+ };
398
+ var onEnd = function onEnd(event) {
399
+ if (!active || event.touches.length >= 2) return;
400
+ active = false;
401
+ post({
402
+ val: internal.VAL_CANVAS_MESSAGE,
403
+ type: "pinch",
404
+ phase: "end",
405
+ span: 0,
406
+ center: {
407
+ x: 0,
408
+ y: 0
409
+ }
410
+ });
411
+ };
412
+ document.addEventListener("touchstart", onStart, {
413
+ passive: false
414
+ });
415
+ document.addEventListener("touchmove", onMove, {
416
+ passive: false
417
+ });
418
+ document.addEventListener("touchend", onEnd);
419
+ document.addEventListener("touchcancel", onEnd);
420
+ return function () {
421
+ document.removeEventListener("touchstart", onStart);
422
+ document.removeEventListener("touchmove", onMove);
423
+ document.removeEventListener("touchend", onEnd);
424
+ document.removeEventListener("touchcancel", onEnd);
425
+ };
426
+ }, [post]);
427
+
428
+ /**
429
+ * And ctrl/cmd + wheel, which is what a trackpad pinch reports as.
430
+ *
431
+ * The same problem as touches and the same answer: the wheel event lands on
432
+ * this document, so without relaying it a trackpad pinch over the page does
433
+ * nothing while the identical gesture over the canvas background zooms.
434
+ *
435
+ * A PLAIN wheel is deliberately left alone — that is the page scrolling
436
+ * itself, which is exactly what it should do.
437
+ */
438
+ React__default["default"].useEffect(function () {
439
+ var onWheel = function onWheel(event) {
440
+ if (!event.ctrlKey && !event.metaKey) return;
441
+ event.preventDefault();
442
+ post({
443
+ val: internal.VAL_CANVAS_MESSAGE,
444
+ type: "zoom",
445
+ // The same response curve the studio uses for a wheel on its own
446
+ // background, so the gesture feels the same on both sides of the frame.
447
+ factor: 1 - event.deltaY / 300,
448
+ center: {
449
+ x: event.clientX,
450
+ y: event.clientY
451
+ }
452
+ });
453
+ };
454
+ document.addEventListener("wheel", onWheel, {
455
+ passive: false
456
+ });
457
+ return function () {
458
+ return document.removeEventListener("wheel", onWheel);
459
+ };
460
+ }, [post]);
461
+
338
462
  /**
339
463
  * The outlines, as a stylesheet rather than as injected elements.
340
464
  *
@@ -335,6 +335,130 @@ function ValCanvasBridge(_ref) {
335
335
  };
336
336
  }, [post]);
337
337
 
338
+ /**
339
+ * Two-finger gestures, handed to the studio.
340
+ *
341
+ * The window around the page is the studio's, and the page is a frame: a
342
+ * finger that lands here is this document's and the studio never hears about
343
+ * it. So a pinch on the page could not zoom the window, which on a phone is
344
+ * the only zoom there is — the toolbar's + and - are a poor substitute for the
345
+ * gesture everyone already makes.
346
+ *
347
+ * Two fingers and only two. One finger is the page's: it scrolls it, taps its
348
+ * links, drags whatever the page put there. Two are the window's, for zooming
349
+ * and for moving the page around inside it. Nothing has to be moded, and the
350
+ * two cannot be confused for one another.
351
+ *
352
+ * `passive: false` because both handlers cancel: the default for two fingers
353
+ * is the browser's own page zoom, which inside a frame the studio is already
354
+ * scaling produces two zooms fighting over one gesture.
355
+ */
356
+ React__default["default"].useEffect(function () {
357
+ var midpoint = function midpoint(touches) {
358
+ return {
359
+ x: (touches[0].clientX + touches[1].clientX) / 2,
360
+ y: (touches[0].clientY + touches[1].clientY) / 2
361
+ };
362
+ };
363
+ var span = function span(touches) {
364
+ return Math.hypot(touches[0].clientX - touches[1].clientX, touches[0].clientY - touches[1].clientY);
365
+ };
366
+ /**
367
+ * Whether a gesture is in progress.
368
+ *
369
+ * `touchend` fires per finger, so lifting one of two leaves a `touchend`
370
+ * carrying a single touch — which is the end of the gesture — and the
371
+ * second leaves one carrying none. Without this the second would post a
372
+ * second `end` for a gesture that was already over.
373
+ */
374
+ var active = false;
375
+ var onStart = function onStart(event) {
376
+ if (event.touches.length !== 2) return;
377
+ event.preventDefault();
378
+ active = true;
379
+ post({
380
+ val: internal.VAL_CANVAS_MESSAGE,
381
+ type: "pinch",
382
+ phase: "start",
383
+ span: span(event.touches),
384
+ center: midpoint(event.touches)
385
+ });
386
+ };
387
+ var onMove = function onMove(event) {
388
+ if (event.touches.length !== 2 || !active) return;
389
+ event.preventDefault();
390
+ post({
391
+ val: internal.VAL_CANVAS_MESSAGE,
392
+ type: "pinch",
393
+ phase: "move",
394
+ span: span(event.touches),
395
+ center: midpoint(event.touches)
396
+ });
397
+ };
398
+ var onEnd = function onEnd(event) {
399
+ if (!active || event.touches.length >= 2) return;
400
+ active = false;
401
+ post({
402
+ val: internal.VAL_CANVAS_MESSAGE,
403
+ type: "pinch",
404
+ phase: "end",
405
+ span: 0,
406
+ center: {
407
+ x: 0,
408
+ y: 0
409
+ }
410
+ });
411
+ };
412
+ document.addEventListener("touchstart", onStart, {
413
+ passive: false
414
+ });
415
+ document.addEventListener("touchmove", onMove, {
416
+ passive: false
417
+ });
418
+ document.addEventListener("touchend", onEnd);
419
+ document.addEventListener("touchcancel", onEnd);
420
+ return function () {
421
+ document.removeEventListener("touchstart", onStart);
422
+ document.removeEventListener("touchmove", onMove);
423
+ document.removeEventListener("touchend", onEnd);
424
+ document.removeEventListener("touchcancel", onEnd);
425
+ };
426
+ }, [post]);
427
+
428
+ /**
429
+ * And ctrl/cmd + wheel, which is what a trackpad pinch reports as.
430
+ *
431
+ * The same problem as touches and the same answer: the wheel event lands on
432
+ * this document, so without relaying it a trackpad pinch over the page does
433
+ * nothing while the identical gesture over the canvas background zooms.
434
+ *
435
+ * A PLAIN wheel is deliberately left alone — that is the page scrolling
436
+ * itself, which is exactly what it should do.
437
+ */
438
+ React__default["default"].useEffect(function () {
439
+ var onWheel = function onWheel(event) {
440
+ if (!event.ctrlKey && !event.metaKey) return;
441
+ event.preventDefault();
442
+ post({
443
+ val: internal.VAL_CANVAS_MESSAGE,
444
+ type: "zoom",
445
+ // The same response curve the studio uses for a wheel on its own
446
+ // background, so the gesture feels the same on both sides of the frame.
447
+ factor: 1 - event.deltaY / 300,
448
+ center: {
449
+ x: event.clientX,
450
+ y: event.clientY
451
+ }
452
+ });
453
+ };
454
+ document.addEventListener("wheel", onWheel, {
455
+ passive: false
456
+ });
457
+ return function () {
458
+ return document.removeEventListener("wheel", onWheel);
459
+ };
460
+ }, [post]);
461
+
338
462
  /**
339
463
  * The outlines, as a stylesheet rather than as injected elements.
340
464
  *
@@ -11,7 +11,7 @@ import { SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
11
11
  import { VAL_THEME_SESSION_STORAGE_KEY, createValClient, isValCanvasFrame } from '@valbuild/shared/internal';
12
12
  import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-5ead2c26.esm.js';
13
13
  import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
14
- import { ValCanvasBridge } from './ValCanvasBridge-d8713d9d.esm.js';
14
+ import { ValCanvasBridge } from './ValCanvasBridge-1310aaeb.esm.js';
15
15
  import { jsxs, jsx } from 'react/jsx-runtime';
16
16
  import './unsupportedIterableToArray-5baabfdc.esm.js';
17
17
  import './defineProperty-cca5affa.esm.js';
@@ -15,7 +15,7 @@ var stega = require('@valbuild/react/stega');
15
15
  var internal = require('@valbuild/shared/internal');
16
16
  var fallbackColors = require('./fallbackColors-9a2ac53a.cjs.dev.js');
17
17
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
18
- var ValCanvasBridge = require('./ValCanvasBridge-96f67a41.cjs.dev.js');
18
+ var ValCanvasBridge = require('./ValCanvasBridge-cb2d9112.cjs.dev.js');
19
19
  var jsxRuntime = require('react/jsx-runtime');
20
20
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
21
21
  require('./defineProperty-f90345d7.cjs.dev.js');
@@ -15,7 +15,7 @@ var stega = require('@valbuild/react/stega');
15
15
  var internal = require('@valbuild/shared/internal');
16
16
  var fallbackColors = require('./fallbackColors-d4a5b0da.cjs.prod.js');
17
17
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
18
- var ValCanvasBridge = require('./ValCanvasBridge-f75509c6.cjs.prod.js');
18
+ var ValCanvasBridge = require('./ValCanvasBridge-32299c6e.cjs.prod.js');
19
19
  var jsxRuntime = require('react/jsx-runtime');
20
20
  require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
21
21
  require('./defineProperty-8951f469.cjs.prod.js');
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- "version": "0.106.0",
15
+ "version": "0.107.0",
16
16
  "main": "dist/valbuild-next.cjs.js",
17
17
  "module": "dist/valbuild-next.esm.js",
18
18
  "exports": {
@@ -48,11 +48,11 @@
48
48
  "client-only": "^0.0.1",
49
49
  "server-only": "^0.0.1",
50
50
  "@valbuild/core": "0.106.0",
51
- "@valbuild/language-server": "0.106.0",
52
- "@valbuild/react": "0.106.0",
53
- "@valbuild/server": "0.106.0",
54
- "@valbuild/shared": "0.106.0",
55
- "@valbuild/ui": "0.105.1"
51
+ "@valbuild/language-server": "0.107.0",
52
+ "@valbuild/react": "0.107.0",
53
+ "@valbuild/server": "0.107.0",
54
+ "@valbuild/shared": "0.107.0",
55
+ "@valbuild/ui": "0.107.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@testing-library/react": "^16.3.2",
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValCanvasBridge-f75509c6.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValCanvasBridge-f75509c6.cjs.dev.js");
7
- }