Line data Source code
1 : import * as app_event from '@ankoh/dashql-jsonschema/app_event.js';
2 :
3 : import { VariantKind } from "../../utils/variant.js";
4 : import { PlatformFile } from "../file/file.js";
5 :
6 1 : export const DROP_EVENT = Symbol("DROP_EVENT");
7 1 : export const DRAG_EVENT = Symbol("DRAG_EVENT");
8 1 : export const DRAG_STOP_EVENT = Symbol("DRAG_STOP_EVENT");
9 :
10 : /// A drag event
11 : export interface PlatformDragEvent {
12 : /// The page x-coordinate value
13 : pageX: number;
14 : /// The page y-coordinate value
15 : pageY: number;
16 : }
17 :
18 : export interface PlatformDropEvent extends PlatformDragEvent {
19 : /// The file
20 : file: PlatformFile;
21 : }
22 :
23 : export type PlatformDragDropEventVariant =
24 : | VariantKind<typeof DRAG_EVENT, PlatformDragEvent>
25 : | VariantKind<typeof DRAG_STOP_EVENT, null>
26 : | VariantKind<typeof DROP_EVENT, PlatformDropEvent>
27 : ;
28 :
29 :
30 1 : export const OAUTH_BROADCAST_CHANNEL = "dashql_oauth";
31 :
32 : /// Envelope kind for app events sent via window.postMessage.
33 : /// Required because a global window "message" listener otherwise receives
34 : /// unrelated traffic (devtools bridges, extensions, etc.).
35 1 : export const APP_EVENT_POST_MESSAGE_KIND = "dashql:app_event";
36 :
37 : export interface AppEventPostMessage {
38 : kind: typeof APP_EVENT_POST_MESSAGE_KIND;
39 : data: string;
40 : }
41 :
42 1 : export function isAppEventPostMessage(msg: any): msg is AppEventPostMessage {
43 1 : return msg != null
44 1 : && typeof msg === "object"
45 1 : && msg.kind === APP_EVENT_POST_MESSAGE_KIND
46 1 : && typeof msg.data === "string";
47 1 : }
48 :
49 1 : export const SETUP_SESSION = Symbol("SETUP_SESSION");
50 1 : export const SETUP_SESSION_URL = Symbol("SETUP_SESSION_URL");
51 :
52 : export type SetupEventVariant =
53 : | VariantKind<typeof SETUP_SESSION, Uint8Array> // Session ZIP bytes
54 : | VariantKind<typeof SETUP_SESSION_URL, string> // Public dashql-session.json URL
55 : ;
|