@graview/pages 0.2.4 → 0.2.6
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/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +73 -65
- package/dist/context-menu.js.map +1 -1
- package/dist/href-of.d.ts +8 -0
- package/dist/href-of.d.ts.map +1 -0
- package/dist/href-of.js +9 -0
- package/dist/href-of.js.map +1 -0
- package/dist/one-place-city.d.ts.map +1 -1
- package/dist/one-place-city.js +151 -24
- package/dist/one-place-city.js.map +1 -1
- package/dist/one-place-geometry.d.ts +63 -0
- package/dist/one-place-geometry.d.ts.map +1 -1
- package/dist/one-place-geometry.js +81 -0
- package/dist/one-place-geometry.js.map +1 -1
- package/dist/one-place-signs.d.ts +7 -0
- package/dist/one-place-signs.d.ts.map +1 -1
- package/dist/one-place-signs.js +55 -3
- package/dist/one-place-signs.js.map +1 -1
- package/dist/one-place.d.ts.map +1 -1
- package/dist/one-place.js +55 -4
- package/dist/one-place.js.map +1 -1
- package/dist/page-context.d.ts +9 -1
- package/dist/page-context.d.ts.map +1 -1
- package/dist/page-context.js.map +1 -1
- package/dist/page-list.d.ts.map +1 -1
- package/dist/page-list.js +1 -0
- package/dist/page-list.js.map +1 -1
- package/dist/page-places.js +1 -1
- package/dist/page-places.js.map +1 -1
- package/dist/page-problems.d.ts.map +1 -1
- package/dist/page-problems.js +2 -1
- package/dist/page-problems.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +2 -3
- package/dist/router.js.map +1 -1
- package/package.json +6 -6
package/dist/one-place-city.js
CHANGED
|
@@ -7,7 +7,7 @@ import { sceneCss } from "@graview/primitives/scene";
|
|
|
7
7
|
import { useGraview, useNavigation, useViolations } from "@graview/react/provider";
|
|
8
8
|
import { useOneFace } from "./one-place-control.js";
|
|
9
9
|
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
10
|
-
import { aimAt, anchorOf, BOARD_ASPECT, carriedBetween, carriedThrough, frameSpacingAt, boardFaceWidth, boardLeast, boardMost, boardWidthFor, fitBeside, fitCamera, SIGN_GAP, SIGN_POST, signRoom, cameraBetween, cameraPutting, CITY, cityArea, footOf, leaveFrom, routeLine, LEVEL_LIVE, levelZooms, PAGE, pageBox, PANEL, panelBox, PHONE, project, restingLevel, SHEET_ORIGIN, standingAt, standingCss, unionOf } from "./one-place-geometry.js";
|
|
10
|
+
import { aimAt, anchorOf, BOARD_ASPECT, carriedBetween, carriedThrough, frameSpacingAt, boardFaceWidth, framedTogether, homeReadableZoom, boardLeast, boardMost, boardWidthFor, fitBeside, fitCamera, SIGN_GAP, SIGN_POST, signRoom, cameraBetween, cameraPutting, CITY, cityArea, footOf, leaveFrom, routeLine, LEVEL_LIVE, levelZooms, PAGE, pageBox, PANEL, panelBox, PHONE, project, restingLevel, SHEET_ORIGIN, standingAt, standingCss, unionOf, wordOnScreen } from "./one-place-geometry.js";
|
|
11
11
|
import { placeSigns } from "./one-place-signs.js";
|
|
12
12
|
import { pluralOf } from "./page-typography.js";
|
|
13
13
|
/*
|
|
@@ -397,6 +397,16 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
397
397
|
let lastPanel = "";
|
|
398
398
|
/** When the city was last read, and what it was read for. */
|
|
399
399
|
let lastRead = -Infinity;
|
|
400
|
+
/*
|
|
401
|
+
* When the city was last read moved by a hand: a scroll's or a drag's
|
|
402
|
+
* last step can reach the picture a frame after the read that took the
|
|
403
|
+
* hand's word for it (the face's layers pan the camera, the Scene
|
|
404
|
+
* paints it next frame). Read within the let-go time of one, the move
|
|
405
|
+
* is still the hand's. (Not `handAt` below, which says when a hand last
|
|
406
|
+
* moved the city at all — a settle, a pinch — and holds back placing a
|
|
407
|
+
* zoom it wrote.)
|
|
408
|
+
*/
|
|
409
|
+
let handReadAt = -Infinity;
|
|
400
410
|
let lastReadKey = "";
|
|
401
411
|
let resized = false;
|
|
402
412
|
let handSince = 0;
|
|
@@ -417,6 +427,11 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
417
427
|
let calmRun = 0;
|
|
418
428
|
/** The page a board was last placed for at once: one with no place to stand is not placed again every frame. */
|
|
419
429
|
let placedFor = "";
|
|
430
|
+
/** A zoom the hand wrote, carried and not yet placed for; and when a hand last moved the city. */
|
|
431
|
+
let regrow = false;
|
|
432
|
+
/** What a pan holds was stopped half-way through a settle: two held on each other are placed afresh. */
|
|
433
|
+
let heldHalfWay = false;
|
|
434
|
+
let handAt = -Infinity;
|
|
420
435
|
let placeSeenAt = 0;
|
|
421
436
|
let placeSeen = "";
|
|
422
437
|
const drawnSince = (placeKey, now) => {
|
|
@@ -542,6 +557,9 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
542
557
|
};
|
|
543
558
|
const all = [...[...placed.feet].map(([key, foot]) => ({ key, box: cardOf(key, foot) })), ...[...placed.names].map(([kind, box]) => ({ key: `name:${kind}`, box }))];
|
|
544
559
|
const standing = all.filter((one) => holds.has(one.key));
|
|
560
|
+
// And held where a settle stopped half-way, one held on another: never kept so.
|
|
561
|
+
if (heldHalfWay && standing.some((one, at) => standing.some((other, then) => then > at && across(one.box, other.box))))
|
|
562
|
+
return true;
|
|
545
563
|
return all.some((one) => !holds.has(one.key) && standing.some((other) => across(one.box, other.box)));
|
|
546
564
|
};
|
|
547
565
|
/** What nothing of the city's is drawn under at rest: the bar, the page beside the city, the level control. */
|
|
@@ -591,8 +609,9 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
591
609
|
const reserved = footNow().now.map((box) => ({ x: box.x - 6, y: box.y - 6, width: box.width + 12, height: box.height + 12 }));
|
|
592
610
|
const round = (n) => Math.round(n / 2) * 2;
|
|
593
611
|
const rel = (box) => [round(box.x - origin.x), round(box.y - origin.y), round(box.width), round(box.height)];
|
|
594
|
-
|
|
595
|
-
const
|
|
612
|
+
// A district's "+n" keeps its size on the screen as the picture zooms (`wordOnScreen`); a building grows with it.
|
|
613
|
+
const buildingsOnScreen = [...w.buildings].map(([key, box]) => (key.startsWith(REST_KEY) ? wordOnScreen(cam, box) : onScreen(box)));
|
|
614
|
+
const restsOnScreen = [...w.buildings].filter(([key]) => key.startsWith(REST_KEY)).map(([, box]) => wordOnScreen(cam, box));
|
|
596
615
|
// What decides the placing, the city's own lattice taken from where it stands: a pan of fewer than 24 pixels places nothing again.
|
|
597
616
|
/*
|
|
598
617
|
* What a pan leaves as it was — the level, the window, the boards'
|
|
@@ -815,33 +834,45 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
815
834
|
* THE HOME BESIDE THE CITY: the city framed in the part the page leaves
|
|
816
835
|
* it — left of the panel on a desk, over the sheet on a phone — never
|
|
817
836
|
* the whole window, where the districts nearest the page stood behind it.
|
|
837
|
+
*
|
|
838
|
+
* AND READ AT A SIZE (Graview HQ feature:f-one-face-home-nearby-reads-at-size):
|
|
839
|
+
* never further out than `homeReadableZoom`. Where the whole city
|
|
840
|
+
* stands beside the page at that zoom or closer, it is framed whole;
|
|
841
|
+
* where it does not, the districts the home's views show are framed,
|
|
842
|
+
* and the rest of the city is a pan away. Fitted whole at any zoom the
|
|
843
|
+
* camera reaches, a rich app's plots were drawn at three fifths of a
|
|
844
|
+
* record page's, and its boards could not be read.
|
|
818
845
|
*/
|
|
819
846
|
if (lvl === PANEL && (now.where.type === "home" || now.where.type === "overview")) {
|
|
820
847
|
const city = unionOf([...world.plots.values()]);
|
|
821
848
|
if (city) {
|
|
822
849
|
const shown = nearbyShown();
|
|
823
850
|
const fit = fitCamera(city, shown, 16, s);
|
|
824
|
-
|
|
825
|
-
const least = (camera.current?.range.min ?? 0) / zoomNow;
|
|
851
|
+
const least = Math.max(homeReadableZoom(now.view), camera.current?.range.min ?? 0) / zoomNow;
|
|
826
852
|
// Said on the city, for a reader of the page: whether the whole city stands beside the page here.
|
|
827
853
|
box.current?.toggleAttribute("data-graview-nearby-holds-the-city", fit.s >= least);
|
|
828
854
|
if (fit.s >= least)
|
|
829
855
|
return fit;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
856
|
+
// The districts the home's views show, in the order the page shows them.
|
|
857
|
+
const kinds = [...new Set(markedOnPage().flatMap((id) => {
|
|
858
|
+
const kind = store.graph.getNode(id)?.kind;
|
|
859
|
+
return kind ? [kind] : [];
|
|
860
|
+
}))];
|
|
861
|
+
const plots = kinds.flatMap((kind) => {
|
|
835
862
|
const plot = world.plots.get(kind);
|
|
836
863
|
return plot ? [plot] : [];
|
|
837
|
-
})
|
|
838
|
-
|
|
864
|
+
});
|
|
865
|
+
// As many of them as stand beside the page together at the least zoom: the first the page shows first.
|
|
866
|
+
const what = framedTogether(plots, shown, least);
|
|
867
|
+
// A page that shows no records: the city's middle in the middle of its side, the rest a pan away.
|
|
868
|
+
if (!what)
|
|
869
|
+
return cameraPutting(middle(city), middle(shown), least);
|
|
839
870
|
/*
|
|
840
871
|
* THE CITY AS NEAR THE MIDDLE OF ITS SIDE AS ITS VIEWS' DISTRICTS
|
|
841
872
|
* LET IT, they in the side whole: at the zoom that fits them where
|
|
842
|
-
* they fit
|
|
843
|
-
*
|
|
844
|
-
*
|
|
873
|
+
* they fit closer (never closer than the home's Nearby), else at the
|
|
874
|
+
* least. Fitted on them alone, the city stood off to one side of a
|
|
875
|
+
* narrow strip with room to come to its middle.
|
|
845
876
|
*/
|
|
846
877
|
const close = fitCamera(what, shown, 16, s);
|
|
847
878
|
const held = cameraPutting(middle(city), middle(shown), Math.max(close.s, least));
|
|
@@ -884,9 +915,11 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
884
915
|
whole = whole ? box(whole) : null;
|
|
885
916
|
settle = null;
|
|
886
917
|
drawnThrough = null;
|
|
887
|
-
|
|
918
|
+
handReadAt = -Infinity;
|
|
919
|
+
world = { plots: new Map([...world.plots].map(([key, b]) => [key, box(b)])), buildings: new Map([...world.buildings].map(([key, b]) => [key, key.startsWith(REST_KEY) ? wordOnScreen(to, b) : box(b)])) };
|
|
888
920
|
};
|
|
889
921
|
const moveTo = (cam, toLevel, anchor, now, arm = true) => {
|
|
922
|
+
regrow = false;
|
|
890
923
|
reframeArmed = arm && toLevel === PANEL && state.current.where.type === "record";
|
|
891
924
|
const from = painted;
|
|
892
925
|
/*
|
|
@@ -1008,6 +1041,23 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1008
1041
|
// Written too recently for a new move to be painted safely: the Scene settles what is painted a beat after a commit.
|
|
1009
1042
|
const calm = now - committedAt >= QUIET_MS;
|
|
1010
1043
|
if (between) {
|
|
1044
|
+
/*
|
|
1045
|
+
* A HAND ON THE CITY MID-SETTLE: what was going over to a new place
|
|
1046
|
+
* stops where it is drawn, fastened to the ground the hand moves —
|
|
1047
|
+
* a settle carried on under a pan slid every board and name across
|
|
1048
|
+
* the ground while the hand had it (Graview HQ
|
|
1049
|
+
* feature:f-one-face-pinch-and-pan-together-holds). The pan let go
|
|
1050
|
+
* of holds them there, as any pan does — unless, stopped half-way
|
|
1051
|
+
* between two placings, two stand on each other: then the city is
|
|
1052
|
+
* placed afresh, each going on from where it is drawn.
|
|
1053
|
+
*/
|
|
1054
|
+
if (!move && !asking.scrubbing && settle && now - settle.start < SETTLE_MS) {
|
|
1055
|
+
slots = drawnSlots(now);
|
|
1056
|
+
names = drawnNames(now);
|
|
1057
|
+
scales = drawnScales(now);
|
|
1058
|
+
settle = null;
|
|
1059
|
+
heldHalfWay = true;
|
|
1060
|
+
}
|
|
1011
1061
|
painted = live;
|
|
1012
1062
|
drawnThrough = live;
|
|
1013
1063
|
}
|
|
@@ -1058,20 +1108,51 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1058
1108
|
* own camera, and the city settling a pixel or two from it after
|
|
1059
1109
|
* is placed fresh for the level, as it always was.
|
|
1060
1110
|
*/
|
|
1061
|
-
const byHand = drawnThrough !== null || nudged.current;
|
|
1111
|
+
const byHand = drawnThrough !== null || nudged.current || now - handReadAt < LET_GO_MS;
|
|
1112
|
+
if (drawnThrough !== null || nudged.current)
|
|
1113
|
+
handReadAt = now;
|
|
1062
1114
|
nudged.current = false;
|
|
1115
|
+
// A hand that writes each move into the view (a drag begun on a sign) is a hand on the city too.
|
|
1116
|
+
if (byHand)
|
|
1117
|
+
handAt = now;
|
|
1063
1118
|
const panned = byHand && carry !== null && carry !== LEVEL_LIVE && Math.abs(carry.s - 1) < 1e-3;
|
|
1064
1119
|
/*
|
|
1065
1120
|
* What is held is where each stands, not where a settle caught part
|
|
1066
1121
|
* way had it: two boards half-way between two placings may stand on
|
|
1067
|
-
* each other, and held there they would stay so. A
|
|
1068
|
-
*
|
|
1122
|
+
* each other, and held there they would stay so. A settle a hand
|
|
1123
|
+
* came on in the middle of stopped where it was drawn: held there,
|
|
1124
|
+
* unless two stand on each other (`heldHalfWay`).
|
|
1069
1125
|
*/
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1126
|
+
/*
|
|
1127
|
+
* A HAND'S ZOOM WRITTEN WHILE THE HAND IS STILL ON (Graview HQ
|
|
1128
|
+
* feature:f-one-face-pinch-and-pan-together-holds): a pinch a
|
|
1129
|
+
* beat still, a wheel's zoom with a pan straight after, two
|
|
1130
|
+
* fingers let go of and one put down again. Placed again for the
|
|
1131
|
+
* new zoom there and then, the boards and names went off over a
|
|
1132
|
+
* settle while the hand moved the ground on under them. Carried
|
|
1133
|
+
* by the zoom instead — where the last frame drew them, fastened
|
|
1134
|
+
* to the ground — and placed again for the zoom only once the
|
|
1135
|
+
* hand has been off the city a moment (`regrow`); a zoom written
|
|
1136
|
+
* before that is carried the same.
|
|
1137
|
+
*/
|
|
1138
|
+
if (byHand && carry !== null && carry !== LEVEL_LIVE && (!panned || regrow)) {
|
|
1139
|
+
slots = new Map(drawnBefore.slots);
|
|
1140
|
+
names = new Map(drawnBefore.names);
|
|
1141
|
+
scales = new Map(drawnBefore.scales);
|
|
1142
|
+
posts = new Map([...posts].map(([one, length]) => [one, length * carry.s]));
|
|
1143
|
+
whole = whole ? { ...project(carry, whole), width: whole.width * carry.s, height: whole.height * carry.s } : null;
|
|
1144
|
+
settle = null;
|
|
1145
|
+
regrow = true;
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
const goals = { slots: carriedThrough(carry ?? LEVEL_LIVE, slots), names: carriedThrough(carry ?? LEVEL_LIVE, names), scales: new Map(scales) };
|
|
1149
|
+
const holds = standAll(world, cam.zoom(), LEVEL_LIVE, shownAt(rest), rest, panned ? goals : undefined);
|
|
1150
|
+
// What a pan let go of put away and placed again comes up where it lands, as one placed for the first time does: it was not seen where it stood.
|
|
1151
|
+
const from = panned && holds.size > 0 ? { slots: new Map([...drawnBefore.slots].filter(([one]) => holds.has(one))), names: new Map([...drawnBefore.names].filter(([kind]) => holds.has(`name:${kind}`))), scales: drawnBefore.scales } : drawnBefore;
|
|
1152
|
+
settle = { ...from, start: now };
|
|
1153
|
+
regrow = false;
|
|
1154
|
+
}
|
|
1155
|
+
heldHalfWay = false;
|
|
1075
1156
|
drawnThrough = null;
|
|
1076
1157
|
}
|
|
1077
1158
|
lastRead = now;
|
|
@@ -1085,6 +1166,19 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1085
1166
|
* its board: a jump before the move began. Placed at once, where the
|
|
1086
1167
|
* camera rests.
|
|
1087
1168
|
*/
|
|
1169
|
+
/*
|
|
1170
|
+
* THE HAND OFF THE CITY A MOMENT, a zoom it wrote is placed for: each
|
|
1171
|
+
* board and name goes from where it is drawn to where it stands at the
|
|
1172
|
+
* new zoom, as a zoom let go of always did — once nothing is moving
|
|
1173
|
+
* the ground under them.
|
|
1174
|
+
*/
|
|
1175
|
+
if (between || settling || cam.pinching())
|
|
1176
|
+
handAt = now;
|
|
1177
|
+
if (regrow && world.plots.size > 0 && rest !== PAGE && !move && !asking.scrubbing && level(painted) && now - handAt >= LET_GO_MS) {
|
|
1178
|
+
regrow = false;
|
|
1179
|
+
settle = { slots: drawnSlots(now), names: drawnNames(now), scales: drawnScales(now), start: now };
|
|
1180
|
+
standAll(world, cam.zoom(), LEVEL_LIVE, shownAt(rest), rest);
|
|
1181
|
+
}
|
|
1088
1182
|
if (world.plots.size > 0 && rest !== PAGE && !move && level(painted) && !slots.has(at.current) && placedFor !== at.current) {
|
|
1089
1183
|
placedFor = at.current;
|
|
1090
1184
|
standAll(world, cam.zoom(), LEVEL_LIVE, shownAt(rest), rest);
|
|
@@ -1262,6 +1356,7 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1262
1356
|
cam.commit();
|
|
1263
1357
|
// A panel sized by hand is not a hand's pan of the city: what it leaves beside the page is placed afresh for it, as the districts say it moved.
|
|
1264
1358
|
drawnThrough = null;
|
|
1359
|
+
handReadAt = -Infinity;
|
|
1265
1360
|
committedAt = performance.now();
|
|
1266
1361
|
ownZoom = null;
|
|
1267
1362
|
}
|
|
@@ -1977,10 +2072,35 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1977
2072
|
const [a, b] = [...down.values()];
|
|
1978
2073
|
return a && b ? Math.hypot(a.x - b.x, a.y - b.y) : 0;
|
|
1979
2074
|
};
|
|
2075
|
+
/*
|
|
2076
|
+
* A FINGER ON A SIGN IS ONE OF THE HAND'S (Graview HQ
|
|
2077
|
+
* feature:f-one-face-pinch-and-pan-together-holds). Two fingers, one on
|
|
2078
|
+
* a board and one on the ground beside it, were two gestures: the one on
|
|
2079
|
+
* the board panned the city's view, a layout a move, the one on the
|
|
2080
|
+
* ground dragged its picture, and nothing zoomed — the boards and names,
|
|
2081
|
+
* placed through the picture, stood still while the view moved the
|
|
2082
|
+
* ground under them. Every touch here is handed to the Scene's own hand,
|
|
2083
|
+
* read with those on the ground: two fingers anywhere over the city are
|
|
2084
|
+
* one pinch, which zooms and pans the picture together, and the boards
|
|
2085
|
+
* and names are drawn through it every frame. One finger alone on a sign
|
|
2086
|
+
* still drags the city from here.
|
|
2087
|
+
*/
|
|
2088
|
+
const handed = (event) => {
|
|
2089
|
+
const cam = camera.current;
|
|
2090
|
+
if (event.pointerType !== "touch" || !cam)
|
|
2091
|
+
return false;
|
|
2092
|
+
cam.finger(event);
|
|
2093
|
+
return cam.pinching();
|
|
2094
|
+
};
|
|
1980
2095
|
const onDown = (event) => {
|
|
1981
2096
|
if (event.pointerType === "mouse" && event.button !== 0)
|
|
1982
2097
|
return;
|
|
1983
2098
|
down.set(event.pointerId, { x: event.clientX, y: event.clientY });
|
|
2099
|
+
if (handed(event)) {
|
|
2100
|
+
dragging = true;
|
|
2101
|
+
pinchFrom = null;
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
1984
2104
|
dragging = false;
|
|
1985
2105
|
pinchFrom = down.size === 2 ? spread() : null;
|
|
1986
2106
|
};
|
|
@@ -1989,6 +2109,12 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
1989
2109
|
const cam = camera.current;
|
|
1990
2110
|
if (!was || !cam)
|
|
1991
2111
|
return;
|
|
2112
|
+
// Two fingers over the city are the Scene's pinch: it zooms and pans the picture, and nothing here moves the view.
|
|
2113
|
+
if (handed(event)) {
|
|
2114
|
+
dragging = true;
|
|
2115
|
+
down.set(event.pointerId, { x: event.clientX, y: event.clientY });
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
1992
2118
|
const dx = event.clientX - was.x;
|
|
1993
2119
|
const dy = event.clientY - was.y;
|
|
1994
2120
|
if (down.size >= 2) {
|
|
@@ -2020,6 +2146,7 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
|
|
|
2020
2146
|
const onUp = (event) => {
|
|
2021
2147
|
if (!down.has(event.pointerId))
|
|
2022
2148
|
return;
|
|
2149
|
+
handed(event);
|
|
2023
2150
|
down.delete(event.pointerId);
|
|
2024
2151
|
if (dragging)
|
|
2025
2152
|
swallow = true;
|