@graview/graverse 0.0.0-stage → 0.2.20

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/LICENSE ADDED
@@ -0,0 +1,96 @@
1
+ Elastic License 2.0
2
+
3
+ ## Acceptance
4
+
5
+ By using the software, you agree to all of the terms and conditions below.
6
+
7
+ ## Copyright License
8
+
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
10
+ non-sublicensable, non-transferable license to use, copy, distribute, make
11
+ available, and prepare derivative works of the software, in each case subject
12
+ to the limitations and conditions below.
13
+
14
+ ## Limitations
15
+
16
+ You may not provide the software to third parties as a hosted or managed
17
+ service, where the service provides users with access to any substantial set
18
+ of the features or functionality of the software.
19
+
20
+ You may not move, change, disable, or circumvent the license key
21
+ functionality in the software, and you may not remove or obscure any
22
+ functionality in the software that is protected by the license key.
23
+
24
+ You may not alter, remove, or obscure any licensing, copyright, or other
25
+ notices of the licensor in the software. Any use of the licensor's trademarks
26
+ is subject to applicable law.
27
+
28
+ ## Patents
29
+
30
+ The licensor grants you a license, under any patent claims the licensor can
31
+ license, or becomes able to license, to make, have made, use, sell, offer for
32
+ sale, import and have imported the software, in each case subject to the
33
+ limitations and conditions in this license. This license does not cover any
34
+ patent claims that you cause to be infringed by modifications or additions to
35
+ the software. If you or your company make any written claim that the software
36
+ infringes or contributes to infringement of any patent, your patent license
37
+ for the software granted under these terms ends immediately. If your company
38
+ makes such a claim, your patent license ends immediately for work on behalf
39
+ of your company.
40
+
41
+ ## Notices
42
+
43
+ You must ensure that anyone who gets a copy of any part of the software from
44
+ you also gets a copy of these terms.
45
+
46
+ If you modify the software, you must include in any modified copies of the
47
+ software prominent notices stating that you have modified the software.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not imply any licenses other than those expressly granted in
52
+ these terms.
53
+
54
+ ## Termination
55
+
56
+ If you use the software in violation of these terms, such use is not
57
+ licensed, and your licenses will automatically terminate. If the licensor
58
+ provides you with a notice of your violation, and you cease all violation of
59
+ this license no later than 30 days after you receive that notice, your
60
+ licenses will be reinstated retroactively. However, if you violate these
61
+ terms after such reinstatement, any additional violation of these terms will
62
+ cause your licenses to terminate automatically and permanently.
63
+
64
+ ## No Liability
65
+
66
+ *As far as the law allows, the software comes as is, without any warranty or
67
+ condition, and the licensor will not be liable to you for any damages arising
68
+ out of these terms or the use or nature of the software, under any kind of
69
+ legal claim.*
70
+
71
+ ## Definitions
72
+
73
+ The **licensor** is the entity offering these terms, and the **software** is
74
+ the software the licensor makes available under these terms, including any
75
+ portion of it.
76
+
77
+ **you** refers to the individual or entity agreeing to these terms.
78
+
79
+ **your company** is any legal entity, sole proprietorship, or other kind of
80
+ organization that you work for, plus all organizations that have control
81
+ over, are under the control of, or are under common control with that
82
+ organization. **control** means ownership of substantially all the assets of
83
+ an entity, or the power to direct its management and policies by vote,
84
+ contract, or otherwise. Control can be direct or indirect.
85
+
86
+ **your licenses** are all the licenses granted to you for the software under
87
+ these terms.
88
+
89
+ **use** means anything you do with the software requiring one of your
90
+ licenses.
91
+
92
+ **trademark** means trademarks, service marks, and similar rights.
93
+
94
+ ---
95
+
96
+ Copyright 2025-2026 En Dash Consulting
package/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # @graview/graverse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Graverse: every app the local hub reaches, drawn as one space, found
4
+ across from one box, and opened at its own page through the hub. Read and
5
+ navigate; nothing here changes an app, though its last part changes which
6
+ apps the hub knows. Experimental.
7
+
8
+ ```sh
9
+ graview hub start # prints the address to open; the Graverse is the hub's own page
10
+ ```
11
+
12
+ The `graview` tool carries this page, built, in `dist/graverse/`, and the
13
+ hub serves it at its address. Nothing here is a product's dependency, and
14
+ no app's page carries it or `three`.
15
+
16
+ ## The page
17
+
18
+ `mountGraverse(element)` draws the plain page: the index of spaces and
19
+ apps, the search box, the matches grouped by app with every field that
20
+ matched, a breadcrumb, where to start, and the detail of what is chosen,
21
+ with an app's records changed lately. It is the whole page with WebGL off,
22
+ and the whole page from the keyboard: Tab to an app, Enter to choose it,
23
+ Tab to Open. `/` finds, and Escape steps back along the breadcrumb, then
24
+ clears the search once nothing is chosen.
25
+
26
+ It asks the hub three things (`hubClient`): the universe described
27
+ (`POST /universe/describe`), a find read one app's answer at a time as each
28
+ arrives (`POST /universe/find`, lines of JSON), and one app's cloud, its
29
+ records as the seat sees them, asked live when the camera comes near
30
+ (`POST /universe/cloud`). Records are never kept by the hub for the page.
31
+
32
+ At the end of the index, "Apps on this machine" manages which apps the hub
33
+ knows: each registered app and its checkouts, to remove one or make another
34
+ current; a folder to add, looked at first so the address it lands at is said
35
+ before anything is written; and "Find Graview apps on this machine", a scan
36
+ whose findings arrive as it walks, each added with one press. Its body,
37
+ fetched the first time it is opened, asks the hub's
38
+ `/hub/apps`, `/hub/look`, `/hub/use` and `/hub/scan`; looking and scanning
39
+ read manifests alone, and only adding runs an app's declaration, on the hub.
40
+
41
+ Where WebGL is there (`canDrawSpace`), the page fetches its drawing,
42
+ `@graview/graverse/space` (`mountSpace`), which is the only module that
43
+ imports `three`. Spaces are faint grounds; an app far away is one point of
44
+ light, as bright as it is recent; come near and its records gather into
45
+ its kinds where its city map puts them (`cityMap` from
46
+ `@graview/core/city`). At rest one label per space shows; while a search
47
+ is on, every app with matches is labeled with its count.
48
+
49
+ ## The arithmetic
50
+
51
+ `@graview/graverse/camera` is the camera with no drawing library:
52
+ `dragTo` keeps the grabbed point under the pointer, `zoomAbout` keeps the
53
+ point under the pointer where it is, `turnAbout` keeps the pressed point
54
+ where it was, `glide` moves between two cameras (a cut under reduced
55
+ motion), and `project`, `pointUnder` and `framing` read the screen.
56
+ `@graview/graverse/layout` places everything, the same way every time:
57
+ `universeLayout` packs a space's apps by the cube root of their records,
58
+ `kindPlaces` stands an app's kinds on its city map and `recordPlaces`
59
+ puts each record by its own id.
60
+
61
+ Elastic License 2.0
@@ -0,0 +1,108 @@
1
+ export interface Vec3 {
2
+ readonly x: number;
3
+ readonly y: number;
4
+ readonly z: number;
5
+ }
6
+ export interface CameraState {
7
+ readonly target: Vec3;
8
+ readonly distance: number;
9
+ readonly yaw: number;
10
+ readonly pitch: number;
11
+ /** The vertical field of view, in degrees. */
12
+ readonly fov: number;
13
+ }
14
+ export interface Viewport {
15
+ readonly width: number;
16
+ readonly height: number;
17
+ /**
18
+ * What the page's panels cover at each edge, in pixels: the picture is
19
+ * centered in what is left, so what the camera looks at stands in the
20
+ * middle of what a person can see, not under a panel.
21
+ */
22
+ readonly inset?: {
23
+ readonly top: number;
24
+ readonly right: number;
25
+ readonly bottom: number;
26
+ readonly left: number;
27
+ };
28
+ }
29
+ /** A point on the screen, in CSS pixels from the top left, and how far in front of the camera it stands. */
30
+ export interface ScreenPoint {
31
+ readonly x: number;
32
+ readonly y: number;
33
+ readonly depth: number;
34
+ }
35
+ export declare const vec: (x: number, y: number, z: number) => Vec3;
36
+ export declare const add: (a: Vec3, b: Vec3) => Vec3;
37
+ export declare const sub: (a: Vec3, b: Vec3) => Vec3;
38
+ export declare const scale: (a: Vec3, k: number) => Vec3;
39
+ export declare const dot: (a: Vec3, b: Vec3) => number;
40
+ export declare const cross: (a: Vec3, b: Vec3) => Vec3;
41
+ export declare const length: (a: Vec3) => number;
42
+ export declare const distance: (a: Vec3, b: Vec3) => number;
43
+ /** How high a camera may look from: never under the ground, never quite straight down. */
44
+ export declare const PITCH_LOWEST = 0.06;
45
+ export declare const PITCH_HIGHEST = 1.5;
46
+ /** How near and how far a camera may stand from what it looks at. */
47
+ export declare const NEAREST = 2;
48
+ /** Where the camera stands. */
49
+ export declare function positionOf(camera: CameraState): Vec3;
50
+ /** The camera's own axes: where it looks, its right and its up. */
51
+ export declare function axesOf(camera: CameraState): {
52
+ readonly forward: Vec3;
53
+ readonly right: Vec3;
54
+ readonly up: Vec3;
55
+ };
56
+ /** Where a point in the world falls on the screen. A point behind the camera has a depth of zero or less. */
57
+ export declare function project(camera: CameraState, view: Viewport, point: Vec3): ScreenPoint;
58
+ /** The ray from the camera through a pixel of the screen. */
59
+ export declare function rayAt(camera: CameraState, view: Viewport, x: number, y: number): {
60
+ readonly origin: Vec3;
61
+ readonly direction: Vec3;
62
+ };
63
+ /**
64
+ * THE WORLD POINT UNDER A PIXEL, at the depth of `through`: on the plane
65
+ * through it that faces the camera. What a drag grabs and a zoom keeps.
66
+ */
67
+ export declare function pointUnder(camera: CameraState, view: Viewport, x: number, y: number, through: Vec3): Vec3;
68
+ /**
69
+ * A DRAG: the camera moved so the grabbed point stands under the pointer.
70
+ * The camera only slides; nothing turns or comes nearer.
71
+ */
72
+ export declare function dragTo(camera: CameraState, view: Viewport, grabbed: Vec3, x: number, y: number): CameraState;
73
+ /**
74
+ * A ZOOM ABOUT A POINT: the camera comes nearer (`factor` under one) or goes
75
+ * farther, along the line to `anchor`, so the anchor, and everything at its
76
+ * depth, stays where it is on the screen.
77
+ */
78
+ export declare function zoomAbout(camera: CameraState, anchor: Vec3, factor: number, farthest?: number): CameraState;
79
+ /**
80
+ * A TURN ABOUT A POINT: the view swings round `pivot` (`yaw` about the
81
+ * vertical, `pitch` up or down), and the pivot stays where it was on the
82
+ * screen. The pitch is held between the ground and straight down.
83
+ */
84
+ export declare function turnAbout(camera: CameraState, pivot: Vec3, yaw: number, pitch: number): CameraState;
85
+ /** The camera's offset for three's `setViewOffset`: the picture moved so its middle is the middle of what is seen. */
86
+ export declare function viewOffset(view: Viewport): {
87
+ readonly x: number;
88
+ readonly y: number;
89
+ };
90
+ /**
91
+ * A camera that frames a ball of `radius` about `center`, from the same
92
+ * direction, in what the panels leave of the screen: narrower of its
93
+ * width and height, so a phone sees all of it too.
94
+ */
95
+ export declare function framing(camera: CameraState, center: Vec3, radius: number, view?: Viewport): CameraState;
96
+ /**
97
+ * A GLIDE from one camera to another: farther or deeper takes a little
98
+ * longer, never long. With reduced motion it is a cut: no time at all, and
99
+ * the first frame is the last.
100
+ */
101
+ export interface Glide {
102
+ readonly ms: number;
103
+ at(elapsedMs: number): CameraState;
104
+ }
105
+ export declare function glide(from: CameraState, to: CameraState, options?: {
106
+ readonly reducedMotion?: boolean;
107
+ }): Glide;
108
+ //# sourceMappingURL=camera.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACnH;AAQD,4GAA4G;AAC5G,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,GAAG,GAAI,GAAG,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AAE,MAAM,GAAG,WAAW,CAAC;CACpC;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,KAAK,CAwBnH"}
package/dist/camera.js ADDED
@@ -0,0 +1,169 @@
1
+ /*
2
+ * THE GRAVERSE'S CAMERA, AS ARITHMETIC (Graview HQ feature:f-graverse-page).
3
+ *
4
+ * Moving is direct: a drag keeps the grabbed point under the pointer, a
5
+ * zoom keeps the point under the pointer where it is, and a turn keeps the
6
+ * pressed point where it was. Each is an exact move of one camera, worked
7
+ * out here with no drawing library, so the drawing (`./space`) and a test
8
+ * read one camera, and what a test holds is what a person feels.
9
+ *
10
+ * The camera looks at `target` from `distance` away, turned `yaw` about the
11
+ * vertical and raised `pitch` above the ground; up is always up. It is the
12
+ * camera a perspective drawing makes with a vertical field of view `fov`
13
+ * (degrees) and `lookAt(target)`.
14
+ */
15
+ /** How far the middle of what is seen stands from the middle of the screen. */
16
+ function shiftOf(view) {
17
+ const inset = view.inset;
18
+ return inset ? { x: (inset.left - inset.right) / 2, y: (inset.top - inset.bottom) / 2 } : { x: 0, y: 0 };
19
+ }
20
+ export const vec = (x, y, z) => ({ x, y, z });
21
+ export const add = (a, b) => vec(a.x + b.x, a.y + b.y, a.z + b.z);
22
+ export const sub = (a, b) => vec(a.x - b.x, a.y - b.y, a.z - b.z);
23
+ export const scale = (a, k) => vec(a.x * k, a.y * k, a.z * k);
24
+ export const dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z;
25
+ export const cross = (a, b) => vec(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
26
+ export const length = (a) => Math.hypot(a.x, a.y, a.z);
27
+ export const distance = (a, b) => length(sub(a, b));
28
+ const normal = (a) => {
29
+ const n = length(a);
30
+ return n === 0 ? vec(0, 0, 0) : scale(a, 1 / n);
31
+ };
32
+ const UP = vec(0, 1, 0);
33
+ /** How high a camera may look from: never under the ground, never quite straight down. */
34
+ export const PITCH_LOWEST = 0.06;
35
+ export const PITCH_HIGHEST = 1.5;
36
+ /** How near and how far a camera may stand from what it looks at. */
37
+ export const NEAREST = 2;
38
+ const clamp = (x, low, high) => Math.max(low, Math.min(high, x));
39
+ /** Where the camera stands. */
40
+ export function positionOf(camera) {
41
+ const level = Math.cos(camera.pitch);
42
+ return add(camera.target, vec(camera.distance * level * Math.sin(camera.yaw), camera.distance * Math.sin(camera.pitch), camera.distance * level * Math.cos(camera.yaw)));
43
+ }
44
+ /** The camera's own axes: where it looks, its right and its up. */
45
+ export function axesOf(camera) {
46
+ const forward = normal(sub(camera.target, positionOf(camera)));
47
+ const right = normal(cross(forward, UP));
48
+ return { forward, right, up: cross(right, forward) };
49
+ }
50
+ /** Where a point in the world falls on the screen. A point behind the camera has a depth of zero or less. */
51
+ export function project(camera, view, point) {
52
+ const { forward, right, up } = axesOf(camera);
53
+ const from = sub(point, positionOf(camera));
54
+ const depth = dot(from, forward);
55
+ const half = Math.tan((camera.fov * Math.PI) / 360);
56
+ const aspect = view.width / view.height;
57
+ const nx = dot(from, right) / (depth * half * aspect);
58
+ const ny = dot(from, up) / (depth * half);
59
+ const shift = shiftOf(view);
60
+ return { x: ((nx + 1) / 2) * view.width + shift.x, y: ((1 - ny) / 2) * view.height + shift.y, depth };
61
+ }
62
+ /** The ray from the camera through a pixel of the screen. */
63
+ export function rayAt(camera, view, x, y) {
64
+ const { forward, right, up } = axesOf(camera);
65
+ const half = Math.tan((camera.fov * Math.PI) / 360);
66
+ const shift = shiftOf(view);
67
+ const nx = ((x - shift.x) / view.width) * 2 - 1;
68
+ const ny = 1 - ((y - shift.y) / view.height) * 2;
69
+ return { origin: positionOf(camera), direction: normal(add(forward, add(scale(right, nx * half * (view.width / view.height)), scale(up, ny * half)))) };
70
+ }
71
+ /**
72
+ * THE WORLD POINT UNDER A PIXEL, at the depth of `through`: on the plane
73
+ * through it that faces the camera. What a drag grabs and a zoom keeps.
74
+ */
75
+ export function pointUnder(camera, view, x, y, through) {
76
+ const { forward } = axesOf(camera);
77
+ const ray = rayAt(camera, view, x, y);
78
+ const facing = dot(ray.direction, forward);
79
+ if (facing <= 1e-9)
80
+ return through;
81
+ const t = dot(sub(through, ray.origin), forward) / facing;
82
+ return add(ray.origin, scale(ray.direction, t));
83
+ }
84
+ /**
85
+ * A DRAG: the camera moved so the grabbed point stands under the pointer.
86
+ * The camera only slides; nothing turns or comes nearer.
87
+ */
88
+ export function dragTo(camera, view, grabbed, x, y) {
89
+ const under = pointUnder(camera, view, x, y, grabbed);
90
+ return { ...camera, target: add(camera.target, sub(grabbed, under)) };
91
+ }
92
+ /**
93
+ * A ZOOM ABOUT A POINT: the camera comes nearer (`factor` under one) or goes
94
+ * farther, along the line to `anchor`, so the anchor, and everything at its
95
+ * depth, stays where it is on the screen.
96
+ */
97
+ export function zoomAbout(camera, anchor, factor, farthest = Infinity) {
98
+ const next = clamp(camera.distance * factor, NEAREST, farthest);
99
+ const k = next / camera.distance;
100
+ return { ...camera, target: add(anchor, scale(sub(camera.target, anchor), k)), distance: next };
101
+ }
102
+ /** Turns a vector about an axis through the origin (Rodrigues). */
103
+ function turnVector(v, axis, angle) {
104
+ const k = normal(axis);
105
+ const c = Math.cos(angle);
106
+ const s = Math.sin(angle);
107
+ return add(add(scale(v, c), scale(cross(k, v), s)), scale(k, dot(k, v) * (1 - c)));
108
+ }
109
+ /**
110
+ * A TURN ABOUT A POINT: the view swings round `pivot` (`yaw` about the
111
+ * vertical, `pitch` up or down), and the pivot stays where it was on the
112
+ * screen. The pitch is held between the ground and straight down.
113
+ */
114
+ export function turnAbout(camera, pivot, yaw, pitch) {
115
+ const lifted = clamp(camera.pitch + pitch, PITCH_LOWEST, PITCH_HIGHEST) - camera.pitch;
116
+ // The whole camera turns as one body about the pivot: where it stands and what it looks at.
117
+ let offset = turnVector(sub(camera.target, pivot), UP, yaw);
118
+ const yawed = camera.yaw + yaw;
119
+ const right = vec(Math.cos(yawed), 0, -Math.sin(yawed));
120
+ offset = turnVector(offset, right, -lifted);
121
+ return { ...camera, target: add(pivot, offset), yaw: yawed, pitch: camera.pitch + lifted };
122
+ }
123
+ /** The camera's offset for three's `setViewOffset`: the picture moved so its middle is the middle of what is seen. */
124
+ export function viewOffset(view) {
125
+ const shift = shiftOf(view);
126
+ return { x: -shift.x, y: -shift.y };
127
+ }
128
+ /**
129
+ * A camera that frames a ball of `radius` about `center`, from the same
130
+ * direction, in what the panels leave of the screen: narrower of its
131
+ * width and height, so a phone sees all of it too.
132
+ */
133
+ export function framing(camera, center, radius, view) {
134
+ const tan = Math.tan((camera.fov * Math.PI) / 360);
135
+ const inset = view?.inset ?? { top: 0, right: 0, bottom: 0, left: 0 };
136
+ const seenHigh = view ? Math.max(1, view.height - inset.top - inset.bottom) / view.height : 1;
137
+ const seenWide = view ? Math.max(1, view.width - inset.left - inset.right) / view.height : 1;
138
+ const half = tan * Math.min(seenHigh, seenWide);
139
+ return { ...camera, target: center, distance: Math.max(NEAREST, (radius / half) * 1.15) };
140
+ }
141
+ export function glide(from, to, options = {}) {
142
+ if (options.reducedMotion)
143
+ return { ms: 0, at: () => to };
144
+ const across = distance(from.target, to.target) / Math.max(from.distance, to.distance, 1e-6);
145
+ const deeper = Math.abs(Math.log(to.distance / from.distance));
146
+ const ms = Math.round(clamp(500 + Math.log10(1 + across) * 550 + deeper * 100, 500, 1400));
147
+ // Yaw goes the short way round.
148
+ let turn = (to.yaw - from.yaw) % (Math.PI * 2);
149
+ if (turn > Math.PI)
150
+ turn -= Math.PI * 2;
151
+ if (turn < -Math.PI)
152
+ turn += Math.PI * 2;
153
+ return {
154
+ ms,
155
+ at(elapsed) {
156
+ const k = clamp(elapsed / ms, 0, 1);
157
+ const e = k < 0.5 ? 4 * k ** 3 : 1 - (-2 * k + 2) ** 3 / 2;
158
+ return {
159
+ target: add(from.target, scale(sub(to.target, from.target), e)),
160
+ // Distance moves by ratio, so a long dive feels even.
161
+ distance: from.distance * Math.pow(to.distance / from.distance, e),
162
+ yaw: from.yaw + turn * e,
163
+ pitch: from.pitch + (to.pitch - from.pitch) * e,
164
+ fov: from.fov + (to.fov - from.fov) * e,
165
+ };
166
+ },
167
+ };
168
+ }
169
+ //# sourceMappingURL=camera.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA4BH,+EAA+E;AAC/E,SAAS,OAAO,CAAC,IAAc;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3G,CAAC;AASD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CA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runtime";
2
+ /** What the hub said to a change of its apps: done or not, in a sentence. */
3
+ export interface HubSaid {
4
+ readonly ok: boolean;
5
+ readonly said: string;
6
+ readonly address?: AppAddress;
7
+ }
8
+ export interface GraverseClient {
9
+ describe(options?: {
10
+ readonly after?: string;
11
+ }): Promise<UniverseDescription | Refused>;
12
+ cloud(app: AppAddress, signal?: AbortSignal): Promise<AppCloud | Refused>;
13
+ find(query: string, options?: {
14
+ readonly cursor?: string;
15
+ readonly signal?: AbortSignal;
16
+ }): AsyncIterable<EverywhereEvent>;
17
+ /** The apps registered with the hub, and their checkouts. */
18
+ apps(): Promise<{
19
+ readonly apps: readonly ManagedApp[];
20
+ readonly home?: string;
21
+ } | Refused>;
22
+ /** A folder looked at before it is added: the address it lands at. Nothing is written. */
23
+ look(path: string, options?: {
24
+ readonly space?: string;
25
+ readonly signal?: AbortSignal;
26
+ }): Promise<FolderLook | Refused>;
27
+ /** Registers a folder: this reads and runs its declaration, on the hub. */
28
+ add(path: string, options?: {
29
+ readonly space?: string;
30
+ readonly sameApp?: boolean;
31
+ }): Promise<HubSaid>;
32
+ /** Removes an app by its address, or one checkout of it by its folder. */
33
+ remove(target: {
34
+ readonly address: AppAddress;
35
+ } | {
36
+ readonly path: string;
37
+ }): Promise<HubSaid>;
38
+ /** Makes a checkout the current one of its app. */
39
+ use(path: string): Promise<HubSaid>;
40
+ /** Finds the Graview apps in the folders named, one line at a time; the signal stops it. */
41
+ scan(roots: readonly string[], signal?: AbortSignal): AsyncIterable<ScanEvent>;
42
+ }
43
+ /** The hub at `base` (the page's own origin unless told), asked with `fetcher`. */
44
+ export declare function hubClient(base?: string, fetcher?: typeof fetch): GraverseClient;
45
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAA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