@fieldnotes/core 0.64.0 → 0.65.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/dist/index.cjs +819 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +430 -2
- package/dist/index.d.ts +430 -2
- package/dist/index.js +809 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2205,6 +2205,434 @@ declare class RemoteFocusReceiver {
|
|
|
2205
2205
|
dispose(): void;
|
|
2206
2206
|
}
|
|
2207
2207
|
|
|
2208
|
+
/**
|
|
2209
|
+
* Sender identity carried on every awareness frame. `id` is the app's stable
|
|
2210
|
+
* peer id (a character id, a user id); `name`, `color`, and `role` are
|
|
2211
|
+
* self-asserted display data. Receivers MUST treat `name` as untrusted text
|
|
2212
|
+
* (render through canvas text or `textContent`, never as HTML) and MUST NOT
|
|
2213
|
+
* gate anything security-relevant on any of these fields — the relay does not
|
|
2214
|
+
* authenticate presence payloads.
|
|
2215
|
+
*/
|
|
2216
|
+
interface AwarenessIdentity {
|
|
2217
|
+
readonly id: string;
|
|
2218
|
+
readonly name?: string;
|
|
2219
|
+
readonly color?: string;
|
|
2220
|
+
readonly role?: string;
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* The wire shape of one awareness frame. Every frame is the sender's COMPLETE
|
|
2224
|
+
* state (identity + whatever it publishes), so any coalescer that keeps only
|
|
2225
|
+
* the newest frame — the relay's per-kind throttle lane, a slow consumer — is
|
|
2226
|
+
* correct by construction: latest wins. Absent fields mean "none / not
|
|
2227
|
+
* published"; there is no delta encoding. A `cleared` frame says the sender is
|
|
2228
|
+
* going away (receivers drop it now instead of waiting for stale expiry).
|
|
2229
|
+
* Presence only: never elements, undo history, persisted canvas state, or
|
|
2230
|
+
* durable operations.
|
|
2231
|
+
*/
|
|
2232
|
+
interface AwarenessPresence extends AwarenessIdentity {
|
|
2233
|
+
readonly kind: 'awareness';
|
|
2234
|
+
/** World-space pointer position; absent = no cursor to show. */
|
|
2235
|
+
readonly cursor?: Point;
|
|
2236
|
+
/** Selected element ids the sender chose to publish; absent = none. */
|
|
2237
|
+
readonly selection?: readonly string[];
|
|
2238
|
+
/** Active tool name; absent = not published. */
|
|
2239
|
+
readonly tool?: string;
|
|
2240
|
+
readonly cleared?: true;
|
|
2241
|
+
}
|
|
2242
|
+
declare const AWARENESS_PRESENCE_KIND = "awareness";
|
|
2243
|
+
/** Cap on `selection` entries; longer payloads are rejected outright. */
|
|
2244
|
+
declare const AWARENESS_MAX_SELECTION = 256;
|
|
2245
|
+
/**
|
|
2246
|
+
* Wire-boundary guard, fail closed: any violated cap rejects the whole frame
|
|
2247
|
+
* (nothing is clamped or sanitised). Unknown extra fields are tolerated so a
|
|
2248
|
+
* newer sender can add fields without breaking older receivers. `cleared`,
|
|
2249
|
+
* when present, must be exactly `true`; `cleared: false` rejects the whole
|
|
2250
|
+
* frame.
|
|
2251
|
+
*/
|
|
2252
|
+
declare function isAwarenessPresence(data: unknown): data is AwarenessPresence;
|
|
2253
|
+
|
|
2254
|
+
/** One remote peer as last seen. Liveness timestamps are deliberately not exposed. */
|
|
2255
|
+
interface Peer extends AwarenessIdentity {
|
|
2256
|
+
/** The relay's server-owned per-socket sender key (the envelope `from`). */
|
|
2257
|
+
readonly from: string;
|
|
2258
|
+
readonly cursor: Point | null;
|
|
2259
|
+
readonly selection: readonly string[];
|
|
2260
|
+
readonly tool: string | null;
|
|
2261
|
+
}
|
|
2262
|
+
type PeerLeaveReason = 'left' | 'cleared' | 'stale';
|
|
2263
|
+
interface PeerRosterOptions {
|
|
2264
|
+
/**
|
|
2265
|
+
* A sender with no valid frame for this long is dropped (row and discovery
|
|
2266
|
+
* entry) with reason `'stale'`. Default `45000` (3× the publisher heartbeat);
|
|
2267
|
+
* `0` disables expiry.
|
|
2268
|
+
*/
|
|
2269
|
+
staleMs?: number;
|
|
2270
|
+
/** Clock seam for tests; default `Date.now`. */
|
|
2271
|
+
now?: () => number;
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Last-known awareness state per remote sender, keyed by the relay's
|
|
2275
|
+
* server-owned `from`. Two books are kept deliberately separate:
|
|
2276
|
+
*
|
|
2277
|
+
* - **Rows** are visible membership: created by any valid non-cleared frame,
|
|
2278
|
+
* removed by a `cleared` frame, by `remove()` (the server-authored
|
|
2279
|
+
* presence-leave), or by stale expiry.
|
|
2280
|
+
* - **Discovery entries** are the re-announce budget: touched by EVERY valid
|
|
2281
|
+
* frame (cleared included) and dropped ONLY by `remove()` or by `staleMs`
|
|
2282
|
+
* without any valid frame. `onDiscover` fires when a valid frame arrives from
|
|
2283
|
+
* a sender with no entry — at most once per socket lifetime, so a client
|
|
2284
|
+
* cycling full → cleared → full cannot make every peer re-announce.
|
|
2285
|
+
*
|
|
2286
|
+
* `getPeers()` returns the same array until a visible field or membership
|
|
2287
|
+
* changes (a heartbeat carrying identical state is silent), which makes it a
|
|
2288
|
+
* valid `useSyncExternalStore` snapshot. Remote clocks are never trusted; all
|
|
2289
|
+
* timing is local.
|
|
2290
|
+
*/
|
|
2291
|
+
declare class PeerRoster {
|
|
2292
|
+
private readonly staleMs;
|
|
2293
|
+
private readonly now;
|
|
2294
|
+
private readonly rows;
|
|
2295
|
+
private readonly discovered;
|
|
2296
|
+
private readonly changeListeners;
|
|
2297
|
+
private readonly discoverListeners;
|
|
2298
|
+
private readonly leaveListeners;
|
|
2299
|
+
private snapshot;
|
|
2300
|
+
private snapshotDirty;
|
|
2301
|
+
private staleTimer;
|
|
2302
|
+
private isDisposed;
|
|
2303
|
+
constructor(options?: PeerRosterOptions);
|
|
2304
|
+
get disposed(): boolean;
|
|
2305
|
+
/**
|
|
2306
|
+
* Applies a presence payload from `from`. Non-awareness or malformed payloads
|
|
2307
|
+
* return `false` untouched, so hosts can feed every presence frame through.
|
|
2308
|
+
*/
|
|
2309
|
+
apply(from: string, data: unknown): boolean;
|
|
2310
|
+
/** Server-authored presence-leave: drops the row AND the discovery entry. */
|
|
2311
|
+
remove(from: string): void;
|
|
2312
|
+
getPeers(): readonly Peer[];
|
|
2313
|
+
getPeer(from: string): Peer | undefined;
|
|
2314
|
+
/** Fires only when `getPeers()` would return a new reference. */
|
|
2315
|
+
onChange(listener: () => void): () => void;
|
|
2316
|
+
/** First valid frame from a sender since its discovery entry was last dropped. */
|
|
2317
|
+
onDiscover(listener: (from: string) => void): () => void;
|
|
2318
|
+
onLeave(listener: (peer: Peer, reason: PeerLeaveReason) => void): () => void;
|
|
2319
|
+
dispose(): void;
|
|
2320
|
+
private dropRow;
|
|
2321
|
+
private changed;
|
|
2322
|
+
private emit;
|
|
2323
|
+
private armStaleTimer;
|
|
2324
|
+
private expireStale;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
/** The viewport capabilities the publisher reads; `Viewport` satisfies it. */
|
|
2328
|
+
interface LocalAwarenessHost {
|
|
2329
|
+
readonly camera: {
|
|
2330
|
+
screenToWorld(screen: Point): Point;
|
|
2331
|
+
};
|
|
2332
|
+
/** The pointer listener attaches to `domLayer.parentElement` (the wrapper). */
|
|
2333
|
+
readonly domLayer: HTMLElement;
|
|
2334
|
+
onSelectionChange(listener: () => void): () => void;
|
|
2335
|
+
getSelectedIds(): string[];
|
|
2336
|
+
readonly toolManager: {
|
|
2337
|
+
onChange(listener: (name: string) => void): () => void;
|
|
2338
|
+
readonly activeTool: {
|
|
2339
|
+
readonly name: string;
|
|
2340
|
+
} | null;
|
|
2341
|
+
};
|
|
2342
|
+
}
|
|
2343
|
+
interface AwarenessFields {
|
|
2344
|
+
cursor?: boolean;
|
|
2345
|
+
/** Off by default: selection ids are a disclosure the moment they are sent. */
|
|
2346
|
+
selection?: boolean;
|
|
2347
|
+
tool?: boolean;
|
|
2348
|
+
}
|
|
2349
|
+
interface LocalAwarenessOptions {
|
|
2350
|
+
identity: AwarenessIdentity;
|
|
2351
|
+
/** Default `{ cursor: true, selection: false, tool: true }`. */
|
|
2352
|
+
fields?: AwarenessFields;
|
|
2353
|
+
/**
|
|
2354
|
+
* Host projection applied to selected ids before they leave the client.
|
|
2355
|
+
* Fails closed: if it throws or returns anything but an array of strings,
|
|
2356
|
+
* frames carry NO selection (never the unfiltered ids) until it next
|
|
2357
|
+
* succeeds, and the error goes to `onError`.
|
|
2358
|
+
*/
|
|
2359
|
+
selectionFilter?: (ids: readonly string[]) => readonly string[];
|
|
2360
|
+
onError?: (error: unknown) => void;
|
|
2361
|
+
/** Minimum spacing between frames. Default `50` (the relay lane throttle). */
|
|
2362
|
+
intervalMs?: number;
|
|
2363
|
+
/** Full-state re-send while idle, measured from the last send. Default `15000`; `0` disables. */
|
|
2364
|
+
heartbeatMs?: number;
|
|
2365
|
+
/** Pointer listener target override; default `host.domLayer.parentElement`. */
|
|
2366
|
+
element?: HTMLElement;
|
|
2367
|
+
send: (data: AwarenessPresence) => void;
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Publishes this client's awareness state (identity, pointer in world space,
|
|
2371
|
+
* selection, active tool) as full-snapshot frames through `send`. Sources are
|
|
2372
|
+
* a passive primary-pointer listener on the viewport wrapper, the viewport's
|
|
2373
|
+
* selection-change event, and the tool manager's change event. Any change
|
|
2374
|
+
* marks the state dirty; a leading-edge frame goes out at once when idle,
|
|
2375
|
+
* otherwise one trailing frame per `intervalMs` carries every change made in
|
|
2376
|
+
* the window. A heartbeat re-sends the state while idle. `dispose` sends one
|
|
2377
|
+
* `cleared` frame. Nothing here touches elements, history, or the camera.
|
|
2378
|
+
*
|
|
2379
|
+
* Frames are valid by construction: identity is truncated to the wire caps
|
|
2380
|
+
* (`name`/`color` to 64 characters, `role` to 32) so a sender can never
|
|
2381
|
+
* publish a frame the wire guard would reject outright; truncation is
|
|
2382
|
+
* reported through `onError` (a `RangeError`) rather than silent. An
|
|
2383
|
+
* invalid `id` (empty or over 128 characters) throws instead of truncating.
|
|
2384
|
+
* `tool` is never truncated: a tool name over 64 characters is omitted from
|
|
2385
|
+
* the frame rather than corrupted. An over-long or empty selection id fails
|
|
2386
|
+
* the selection closed (like a non-string filter entry) rather than being
|
|
2387
|
+
* sent. `intervalMs` and `heartbeatMs` are normalised so a non-finite or
|
|
2388
|
+
* out-of-range value (e.g. `Infinity`) can never arm a near-zero busy-loop
|
|
2389
|
+
* timer. The selection filter is re-applied before every frame that carries
|
|
2390
|
+
* a selection, so a policy change takes effect on the next frame without a
|
|
2391
|
+
* selection event.
|
|
2392
|
+
*/
|
|
2393
|
+
declare class LocalAwareness {
|
|
2394
|
+
private readonly host;
|
|
2395
|
+
private readonly element;
|
|
2396
|
+
private readonly send;
|
|
2397
|
+
private readonly selectionFilter;
|
|
2398
|
+
private readonly onError;
|
|
2399
|
+
private readonly intervalMs;
|
|
2400
|
+
private readonly heartbeatMs;
|
|
2401
|
+
private identity;
|
|
2402
|
+
private fields;
|
|
2403
|
+
private lastPointer;
|
|
2404
|
+
private selection;
|
|
2405
|
+
private selectionFailed;
|
|
2406
|
+
private tool;
|
|
2407
|
+
private dirty;
|
|
2408
|
+
private lastSentAt;
|
|
2409
|
+
private throttleTimer;
|
|
2410
|
+
private heartbeatTimer;
|
|
2411
|
+
private readonly unsubscribers;
|
|
2412
|
+
private isDisposed;
|
|
2413
|
+
private readonly handlePointerMove;
|
|
2414
|
+
private readonly handlePointerEnd;
|
|
2415
|
+
constructor(host: LocalAwarenessHost, options: LocalAwarenessOptions);
|
|
2416
|
+
get disposed(): boolean;
|
|
2417
|
+
getFields(): Readonly<Required<AwarenessFields>>;
|
|
2418
|
+
setIdentity(identity: AwarenessIdentity): void;
|
|
2419
|
+
/** Merges the given flags into the current policy; `undefined` keys are ignored. */
|
|
2420
|
+
setFields(fields: AwarenessFields): void;
|
|
2421
|
+
/**
|
|
2422
|
+
* Requests a full frame: immediate when idle, otherwise folded into the
|
|
2423
|
+
* pending trailing frame (so N simultaneous requests cost one frame). Hosts
|
|
2424
|
+
* call it when the connection becomes live or reconnects.
|
|
2425
|
+
*/
|
|
2426
|
+
announce(): void;
|
|
2427
|
+
/**
|
|
2428
|
+
* The complete state a frame carries right now. Side-effecting when
|
|
2429
|
+
* selection publishing is on: re-reads `getSelectedIds()`, re-runs
|
|
2430
|
+
* `selectionFilter`, updates the fail-closed selection state, and may call
|
|
2431
|
+
* `onError`. A no-op with respect to selection while publishing is off.
|
|
2432
|
+
*/
|
|
2433
|
+
getState(): AwarenessPresence;
|
|
2434
|
+
dispose(): void;
|
|
2435
|
+
private now;
|
|
2436
|
+
private onPointerMove;
|
|
2437
|
+
private onPointerEnd;
|
|
2438
|
+
private refreshSelection;
|
|
2439
|
+
private schedule;
|
|
2440
|
+
private flush;
|
|
2441
|
+
private armHeartbeat;
|
|
2442
|
+
private safeSend;
|
|
2443
|
+
private report;
|
|
2444
|
+
/**
|
|
2445
|
+
* Truncates identity strings to the wire caps and rejects an invalid id, so a
|
|
2446
|
+
* sender can never publish a frame that the wire guard would drop outright.
|
|
2447
|
+
* A truncated field is reported through `onError` (a `RangeError`) rather
|
|
2448
|
+
* than silently shortened, so a caller passing an over-long name finds out.
|
|
2449
|
+
*/
|
|
2450
|
+
private normalizeIdentity;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
/** The viewport capabilities the overlay needs; `Viewport` satisfies it. */
|
|
2454
|
+
interface RemoteCursorOverlayHost {
|
|
2455
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
2456
|
+
requestRender(): void;
|
|
2457
|
+
/** Read at draw time so glyph and label keep a constant screen size. */
|
|
2458
|
+
readonly camera: {
|
|
2459
|
+
readonly zoom: number;
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
interface RemoteCursorOverlayOptions {
|
|
2463
|
+
/**
|
|
2464
|
+
* Host colour resolver consulted first (e.g. a campaign's per-player colour
|
|
2465
|
+
* table keyed by `peer.id`). Return `undefined` to fall through to the wire
|
|
2466
|
+
* `color`, then to `defaultPeerColor(peer.id)`.
|
|
2467
|
+
*/
|
|
2468
|
+
colorFor?: (peer: Peer) => string | undefined;
|
|
2469
|
+
/** Draw the name chip next to the arrow. Default `true`. */
|
|
2470
|
+
showLabels?: boolean;
|
|
2471
|
+
/** Default `'12px sans-serif'`. */
|
|
2472
|
+
labelFont?: string;
|
|
2473
|
+
}
|
|
2474
|
+
/** Twelve well-separated hues so peers stay distinguishable without a colour on the wire. */
|
|
2475
|
+
declare const PEER_COLORS: readonly string[];
|
|
2476
|
+
/**
|
|
2477
|
+
* Deterministic palette colour for a stable peer id (FNV-1a over UTF-16 code
|
|
2478
|
+
* units), so every client shows the same peer in the same colour without any
|
|
2479
|
+
* colour travelling on the wire.
|
|
2480
|
+
*/
|
|
2481
|
+
declare function defaultPeerColor(seed: string): string;
|
|
2482
|
+
/**
|
|
2483
|
+
* Renders every roster peer that has a cursor as an arrow glyph plus a name
|
|
2484
|
+
* chip, in world space but at constant screen size (scaled by `1 / zoom`).
|
|
2485
|
+
* Names are drawn as canvas text, so untrusted display text is inert. Reads
|
|
2486
|
+
* the roster only; never re-parses payloads, never moves the camera, never
|
|
2487
|
+
* touches the store.
|
|
2488
|
+
*/
|
|
2489
|
+
declare class RemoteCursorOverlay {
|
|
2490
|
+
private readonly host;
|
|
2491
|
+
private readonly roster;
|
|
2492
|
+
private readonly colorFor;
|
|
2493
|
+
private readonly showLabels;
|
|
2494
|
+
private readonly labelFont;
|
|
2495
|
+
private readonly labelWidths;
|
|
2496
|
+
private unregister;
|
|
2497
|
+
private unsubscribe;
|
|
2498
|
+
private isDisposed;
|
|
2499
|
+
constructor(host: RemoteCursorOverlayHost, roster: PeerRoster, options?: RemoteCursorOverlayOptions);
|
|
2500
|
+
get disposed(): boolean;
|
|
2501
|
+
resolveColor(peer: Peer): string;
|
|
2502
|
+
dispose(): void;
|
|
2503
|
+
private render;
|
|
2504
|
+
private drawLabel;
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
/** The viewport capabilities the overlay needs; `Viewport` satisfies it. */
|
|
2508
|
+
interface RemoteSelectionOverlayHost {
|
|
2509
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
2510
|
+
requestRender(): void;
|
|
2511
|
+
readonly camera: {
|
|
2512
|
+
readonly zoom: number;
|
|
2513
|
+
};
|
|
2514
|
+
readonly store: ElementStore;
|
|
2515
|
+
readonly layerManager: LayerManager;
|
|
2516
|
+
}
|
|
2517
|
+
interface RemoteSelectionOverlayOptions {
|
|
2518
|
+
/** Same precedence as `RemoteCursorOverlay`: resolver → wire colour → `defaultPeerColor`. */
|
|
2519
|
+
colorFor?: (peer: Peer) => string | undefined;
|
|
2520
|
+
/** Outline opacity. Default `0.6`. */
|
|
2521
|
+
alpha?: number;
|
|
2522
|
+
/** Outline width in screen pixels. Default `2`. */
|
|
2523
|
+
lineWidthPx?: number;
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* Outlines the elements other peers have selected. Only ids that exist in the
|
|
2527
|
+
* LOCAL store AND sit on a locally visible layer are drawn; this is a
|
|
2528
|
+
* rendering courtesy on top of the sender-side opt-in (`fields.selection`) and
|
|
2529
|
+
* `selectionFilter` — privacy is decided at publish time, not here. The store
|
|
2530
|
+
* is rescanned only when some peer's selection reference or resolved colour
|
|
2531
|
+
* changed, or when the store or layer visibility changed; cursor-only roster
|
|
2532
|
+
* updates never scan. When two peers select the same element, the peer
|
|
2533
|
+
* earlier in `roster.getPeers()` order (insertion order: whoever the roster
|
|
2534
|
+
* saw first) supplies the outline colour for it.
|
|
2535
|
+
*/
|
|
2536
|
+
declare class RemoteSelectionOverlay {
|
|
2537
|
+
private readonly host;
|
|
2538
|
+
private readonly roster;
|
|
2539
|
+
private readonly colorFor;
|
|
2540
|
+
private readonly alpha;
|
|
2541
|
+
private readonly lineWidthPx;
|
|
2542
|
+
private signatures;
|
|
2543
|
+
private outlines;
|
|
2544
|
+
private storeDirty;
|
|
2545
|
+
private unregister;
|
|
2546
|
+
private readonly unsubscribers;
|
|
2547
|
+
private isDisposed;
|
|
2548
|
+
constructor(host: RemoteSelectionOverlayHost, roster: PeerRoster, options?: RemoteSelectionOverlayOptions);
|
|
2549
|
+
get disposed(): boolean;
|
|
2550
|
+
dispose(): void;
|
|
2551
|
+
private resolveColor;
|
|
2552
|
+
/** Recomputes outlines only when the selection signature or the store/layers changed. */
|
|
2553
|
+
private rebuild;
|
|
2554
|
+
private render;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
/**
|
|
2558
|
+
* The three presence primitives every Field Notes transport exposes. The raw
|
|
2559
|
+
* `SyncClient`, `ManagedSyncConnection`, and host wrappers all satisfy it
|
|
2560
|
+
* structurally, so core never depends on `@fieldnotes/sync`. `from` is the
|
|
2561
|
+
* relay's opaque per-sender key.
|
|
2562
|
+
*/
|
|
2563
|
+
interface PresenceChannel {
|
|
2564
|
+
sendPresence(data: unknown): void;
|
|
2565
|
+
onPresence(handler: (from: string, data: unknown) => void): () => void;
|
|
2566
|
+
onPresenceLeave(handler: (from: string) => void): () => void;
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* What `attachAwareness` needs from a viewport; `Viewport` satisfies it.
|
|
2570
|
+
*
|
|
2571
|
+
* This does not `extends LocalAwarenessHost, RemoteCursorOverlayHost,
|
|
2572
|
+
* RemoteSelectionOverlayHost`: those three declare `camera` with different
|
|
2573
|
+
* member sets (`screenToWorld` vs `zoom`), and TypeScript rejects an
|
|
2574
|
+
* interface that extends multiple parents whose same-named property types
|
|
2575
|
+
* are not identical or mutually assignable. Listing the members directly
|
|
2576
|
+
* (with `camera` widened to carry both) keeps `AwarenessViewport`
|
|
2577
|
+
* structurally assignable to all three host types.
|
|
2578
|
+
*/
|
|
2579
|
+
interface AwarenessViewport {
|
|
2580
|
+
readonly camera: {
|
|
2581
|
+
readonly zoom: number;
|
|
2582
|
+
screenToWorld(screen: Point): Point;
|
|
2583
|
+
};
|
|
2584
|
+
/** The pointer listener attaches to `domLayer.parentElement` (the wrapper). */
|
|
2585
|
+
readonly domLayer: HTMLElement;
|
|
2586
|
+
readonly store: ElementStore;
|
|
2587
|
+
readonly layerManager: LayerManager;
|
|
2588
|
+
onSelectionChange(listener: () => void): () => void;
|
|
2589
|
+
getSelectedIds(): string[];
|
|
2590
|
+
readonly toolManager: {
|
|
2591
|
+
onChange(listener: (name: string) => void): () => void;
|
|
2592
|
+
readonly activeTool: {
|
|
2593
|
+
readonly name: string;
|
|
2594
|
+
} | null;
|
|
2595
|
+
};
|
|
2596
|
+
registerOverlay(draw: OverlayRenderer): () => void;
|
|
2597
|
+
requestRender(): void;
|
|
2598
|
+
}
|
|
2599
|
+
interface AttachAwarenessOptions extends Omit<LocalAwarenessOptions, 'send'> {
|
|
2600
|
+
roster?: PeerRosterOptions;
|
|
2601
|
+
/** Named cursor overlay options, or `false` to render no cursors. Default on. */
|
|
2602
|
+
cursors?: RemoteCursorOverlayOptions | false;
|
|
2603
|
+
/** Selection outline overlay: options or `true` to enable. Default off. */
|
|
2604
|
+
selections?: RemoteSelectionOverlayOptions | boolean;
|
|
2605
|
+
/**
|
|
2606
|
+
* `false` builds a receive-only attachment (no `LocalAwareness`). Default
|
|
2607
|
+
* `true`. When `false`, `identity` is ignored: there is no publisher to
|
|
2608
|
+
* carry it.
|
|
2609
|
+
*/
|
|
2610
|
+
publish?: boolean;
|
|
2611
|
+
}
|
|
2612
|
+
interface AwarenessHandle {
|
|
2613
|
+
readonly roster: PeerRoster;
|
|
2614
|
+
/** `null` when `publish: false`. */
|
|
2615
|
+
readonly local: LocalAwareness | null;
|
|
2616
|
+
readonly cursors: RemoteCursorOverlay | null;
|
|
2617
|
+
readonly selections: RemoteSelectionOverlay | null;
|
|
2618
|
+
/** Call when the connection becomes live or reconnects. No-op when receive-only. */
|
|
2619
|
+
announce(): void;
|
|
2620
|
+
/** Forwards to `LocalAwareness.setFields` (merge). No-op when receive-only. */
|
|
2621
|
+
setFields(fields: AwarenessFields): void;
|
|
2622
|
+
dispose(): void;
|
|
2623
|
+
}
|
|
2624
|
+
/**
|
|
2625
|
+
* Binds the awareness lifecycle to a presence channel: incoming frames feed
|
|
2626
|
+
* the roster, presence-leave drops rows and discovery budget, and each newly
|
|
2627
|
+
* discovered sender makes this client re-announce once, coalesced by the
|
|
2628
|
+
* publisher's interval: from a cold start the first discovery goes out on
|
|
2629
|
+
* the leading edge and later ones fold into a single trailing frame, so N
|
|
2630
|
+
* simultaneous joiners cost at most two frames; while already active, one.
|
|
2631
|
+
* Dispose order: publisher (sends `cleared`) → overlays → roster → channel
|
|
2632
|
+
* unsubscribes.
|
|
2633
|
+
*/
|
|
2634
|
+
declare function attachAwareness(viewport: AwarenessViewport, channel: PresenceChannel, options: AttachAwarenessOptions): AwarenessHandle;
|
|
2635
|
+
|
|
2208
2636
|
interface ActiveFormats {
|
|
2209
2637
|
bold: boolean;
|
|
2210
2638
|
italic: boolean;
|
|
@@ -2611,6 +3039,6 @@ declare class TemplateTool implements Tool {
|
|
|
2611
3039
|
private notifyOptionsChange;
|
|
2612
3040
|
}
|
|
2613
3041
|
|
|
2614
|
-
declare const VERSION = "0.
|
|
3042
|
+
declare const VERSION = "0.65.0";
|
|
2615
3043
|
|
|
2616
|
-
export { type ActivationOptions, type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraAnimationEndReason, CameraAnimator, type CameraAnimatorOptions, type CameraChangeInfo, type CameraOptions, type CameraView, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DiagonalRule, type DistributeAxis, type ElementActivationEvent, type ElementChangeMeta, type ElementRect, type ElementRectMatch, type ElementRectMatchError, ElementRectTracker, type ElementRectTrackerOptions, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, FOCUS_PRESENCE_KIND, type FocusAudience, type FocusPresence, type FocusRole, type FontSizePreset, type Footprint, type FrameScheduler, type GridElement, type GridInfo, type GridMetric, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HitTestOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type HtmlPaintContext, type HtmlPaintDiagnostic, type HtmlPainter, HtmlPainterMissingError, HtmlPainterRegistry, type HtmlRenderTarget, type HtmlRouting, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalStorageAdapter, MEASURE_PRESENCE_KIND, type MeasureEmission, type MeasurePresence, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, MinimapController, type MinimapControllerOptions, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PATH_PRESENCE_KIND, PATH_PRESENCE_MAX_POINTS, PING_PRESENCE_KIND, type PathAnchor, type PathDistance, type PathEmission, type PathPresence, type PathRangeBand, type PathSegment, PathTool, type PathToolOptions, PencilTool, type PencilToolOptions, type PingEmission, PingInput, type PingInputHost, type PingInputOptions, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, type RectTrackerHost, RemoteFocusReceiver, type RemoteFocusReceiverHost, type RemoteFocusReceiverOptions, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemoteMeasureOverlay, type RemoteMeasureOverlayHost, type RemoteMeasureOverlayOptions, RemotePathOverlay, type RemotePathOverlayHost, type RemotePathOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type SelectionStyleDetails, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, applyCameraView, boundsIntersect, cameraOriginForView, captureCameraView, computeElementRects, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, elementRectsEqual, exportImage, exportSvg, fitZoomForView, footprintFromSize, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, gridDistanceCells, isFocusPresence, isLaserTrailPresence, isMeasurePresence, isNearBezier, isPathPresence, isPingPresence, pathDistanceCells, resolveHtmlRouting, setFontSize, smartSnap, snapFootprintCenter, snapPoint, snapToCellCenter, snapToHexCenter, styleToPatch, toFocusPresence, toLaserTrailPresence, toMeasurePresence, toPathPresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
|
3044
|
+
export { AWARENESS_MAX_SELECTION, AWARENESS_PRESENCE_KIND, type ActivationOptions, type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, type AttachAwarenessOptions, AutoSave, type AutoSaveOptions, type AwarenessFields, type AwarenessHandle, type AwarenessIdentity, type AwarenessPresence, type AwarenessViewport, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraAnimationEndReason, CameraAnimator, type CameraAnimatorOptions, type CameraChangeInfo, type CameraOptions, type CameraView, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DiagonalRule, type DistributeAxis, type ElementActivationEvent, type ElementChangeMeta, type ElementRect, type ElementRectMatch, type ElementRectMatchError, ElementRectTracker, type ElementRectTrackerOptions, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportAssetError, type ExportAssetErrorReason, type ExportImageOptions, type ExportResourceOptions, type ExportSvgOptions, FOCUS_PRESENCE_KIND, type FocusAudience, type FocusPresence, type FocusRole, type FontSizePreset, type Footprint, type FrameScheduler, type GridElement, type GridInfo, type GridMetric, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HitTestOptions, type HtmlElement, type HtmlExportError, type HtmlExportErrorReason, type HtmlExportOptions, type HtmlExportRenderer, type HtmlPaintContext, type HtmlPaintDiagnostic, type HtmlPainter, HtmlPainterMissingError, HtmlPainterRegistry, type HtmlRenderTarget, type HtmlRouting, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LASER_TRAIL_PRESENCE_KIND, LaserTool, type LaserToolOptions, type LaserTrailEmission, type LaserTrailPresence, type Layer, LayerManager, LocalAwareness, type LocalAwarenessHost, type LocalAwarenessOptions, LocalStorageAdapter, MEASURE_PRESENCE_KIND, type MeasureEmission, type MeasurePresence, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, MinimapController, type MinimapControllerOptions, type NoteElement, NoteTool, type NoteToolOptions, type OverlayRenderer, PATH_PRESENCE_KIND, PATH_PRESENCE_MAX_POINTS, PEER_COLORS, PING_PRESENCE_KIND, type PathAnchor, type PathDistance, type PathEmission, type PathPresence, type PathRangeBand, type PathSegment, PathTool, type PathToolOptions, type Peer, type PeerLeaveReason, PeerRoster, type PeerRosterOptions, PencilTool, type PencilToolOptions, type PingEmission, PingInput, type PingInputHost, type PingInputOptions, type PingPresence, PingTool, type PingToolOptions, type Point, type PointerState, type PresenceChannel, type RectTrackerHost, RemoteCursorOverlay, type RemoteCursorOverlayHost, type RemoteCursorOverlayOptions, RemoteFocusReceiver, type RemoteFocusReceiverHost, type RemoteFocusReceiverOptions, RemoteLaserOverlay, type RemoteLaserOverlayHost, type RemoteLaserOverlayOptions, RemoteMeasureOverlay, type RemoteMeasureOverlayHost, type RemoteMeasureOverlayOptions, RemotePathOverlay, type RemotePathOverlayHost, type RemotePathOverlayOptions, RemotePingOverlay, type RemotePingOverlayHost, type RemotePingOverlayOptions, RemoteSelectionOverlay, type RemoteSelectionOverlayHost, type RemoteSelectionOverlayOptions, type RenderStatsSnapshot, type RotateDirection, SelectTool, type SelectionStyleDetails, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, applyCameraView, attachAwareness, boundsIntersect, cameraOriginForView, captureCameraView, computeElementRects, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, defaultPeerColor, drawHexPath, elementRectsEqual, exportImage, exportSvg, fitZoomForView, footprintFromSize, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, gridDistanceCells, isAwarenessPresence, isFocusPresence, isLaserTrailPresence, isMeasurePresence, isNearBezier, isPathPresence, isPingPresence, pathDistanceCells, resolveHtmlRouting, setFontSize, smartSnap, snapFootprintCenter, snapPoint, snapToCellCenter, snapToHexCenter, styleToPatch, toFocusPresence, toLaserTrailPresence, toMeasurePresence, toPathPresence, toPingPresence, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|