@archont561/qgis-sdk 0.0.0 → 0.4.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/LICENSE +21 -0
- package/README.md +40 -30
- package/dist/bridge.d.ts +2 -0
- package/dist/bridge.js +31 -0
- package/dist/host.d.ts +2 -0
- package/dist/host.js +51 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +732 -0
- package/dist/react.d.ts +137 -0
- package/dist/react.js +214 -0
- package/dist/shared/chunk-2hwva3a3.js +14 -0
- package/dist/shared/chunk-8gawbn19.js +433 -0
- package/dist/shared/chunk-jjx14tgd.d.ts +55 -0
- package/dist/shared/chunk-khemhx86.d.ts +158 -0
- package/dist/shared/chunk-pdj2fxjb.d.ts +17 -0
- package/dist/shared/chunk-tmca1ynt.d.ts +87 -0
- package/dist/shared/chunk-vqyymknv.js +414 -0
- package/dist/shared/chunk-wtv4vt4q.d.ts +280 -0
- package/dist/testing.d.ts +131 -0
- package/dist/testing.js +366 -0
- package/package.json +62 -8
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { QgisSdkError2 } from "./chunk-pdj2fxjb.js";
|
|
2
|
+
declare const HOST_ID2 = "qgis.host";
|
|
3
|
+
declare const HOST_FINGERPRINT2 = "sha256:f96bdf1046434de3c5eae01efb34c8ad2bcd1cf241a3dc42f6c4b613dc7d7d6f";
|
|
4
|
+
declare const HOST_SCHEMA_VERSION2 = 1;
|
|
5
|
+
/** Every declared operation id, so a name can be checked, not guessed. */
|
|
6
|
+
declare const HOST_OPERATIONS2: readonly ["files.export", "layers.get", "layers.list", "layers.open_vector", "network.fetch", "notifications.info", "project.layer_ids", "settings.get", "styles.apply"];
|
|
7
|
+
type HostOperationId2 = (typeof HOST_OPERATIONS2)[number];
|
|
8
|
+
interface HostInvokeOptions2 {
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** The client this module wraps: anything with a correlated invoke. */
|
|
12
|
+
interface HostClientLike2 {
|
|
13
|
+
invoke(operation: string, payload?: Readonly<Record<string, unknown>>, options?: HostInvokeOptions2): Promise<unknown>;
|
|
14
|
+
subscribe(operation: string, payload?: Readonly<Record<string, unknown>>, handlers?: HostStreamHandlers2<{
|
|
15
|
+
readonly kind: "data" | "progress" | "state";
|
|
16
|
+
readonly payload: unknown;
|
|
17
|
+
}>, options?: HostInvokeOptions2): Promise<HostStreamHandle2>;
|
|
18
|
+
}
|
|
19
|
+
/** How a stream ended; `dropped` is only present for a gap. */
|
|
20
|
+
interface HostStreamTerminal2 {
|
|
21
|
+
readonly kind: "complete" | "error" | "cancelled" | "gap" | "disposed";
|
|
22
|
+
readonly message?: string;
|
|
23
|
+
readonly dropped?: number;
|
|
24
|
+
}
|
|
25
|
+
/** What a stream reports: typed events, then exactly one end. */
|
|
26
|
+
interface HostStreamHandlers2<E> {
|
|
27
|
+
readonly onEvent?: (event: E) => void;
|
|
28
|
+
readonly onTerminal?: (terminal: HostStreamTerminal2) => void;
|
|
29
|
+
}
|
|
30
|
+
/** A live stream, as the caller holds it. */
|
|
31
|
+
interface HostStreamHandle2 {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly closed: boolean;
|
|
34
|
+
close(): void;
|
|
35
|
+
}
|
|
36
|
+
/** An argument or a response that does not match its declared schema. */
|
|
37
|
+
declare class QgisSdkHostContractError2 extends QgisSdkError2 {
|
|
38
|
+
readonly operation: string;
|
|
39
|
+
constructor(operation: string, message: string);
|
|
40
|
+
}
|
|
41
|
+
interface ExportRequest2 {
|
|
42
|
+
readonly content: string;
|
|
43
|
+
readonly file: FileRef2;
|
|
44
|
+
}
|
|
45
|
+
interface ExportResult2 {
|
|
46
|
+
readonly bytes_written: number;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
}
|
|
49
|
+
interface FetchRequest2 {
|
|
50
|
+
readonly auth_config?: string;
|
|
51
|
+
readonly body?: string;
|
|
52
|
+
readonly headers?: readonly HttpHeader2[];
|
|
53
|
+
readonly method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
|
54
|
+
readonly timeout_seconds?: number;
|
|
55
|
+
readonly url: string;
|
|
56
|
+
}
|
|
57
|
+
interface FileRef2 {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly kind: "file";
|
|
60
|
+
readonly name?: string;
|
|
61
|
+
readonly operations?: readonly ("read" | "write")[];
|
|
62
|
+
}
|
|
63
|
+
interface HttpHeader2 {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly value: string;
|
|
66
|
+
}
|
|
67
|
+
interface IdPage2 {
|
|
68
|
+
readonly items: readonly string[];
|
|
69
|
+
readonly next_cursor?: string;
|
|
70
|
+
readonly truncated: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface LayerPage2 {
|
|
73
|
+
readonly items: readonly VectorLayerInfo2[];
|
|
74
|
+
readonly next_cursor?: string;
|
|
75
|
+
readonly truncated: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface LayerRequest2 {
|
|
78
|
+
readonly layer_id: string;
|
|
79
|
+
}
|
|
80
|
+
interface NetworkFetchData2 {
|
|
81
|
+
readonly base64: string | null;
|
|
82
|
+
readonly headers: readonly HttpHeader2[];
|
|
83
|
+
readonly reason: string;
|
|
84
|
+
readonly status_code: number;
|
|
85
|
+
readonly text: string | null;
|
|
86
|
+
readonly url: string;
|
|
87
|
+
}
|
|
88
|
+
interface NotificationsInfoRequest2 {
|
|
89
|
+
readonly message: string;
|
|
90
|
+
}
|
|
91
|
+
interface OpenVectorRequest2 {
|
|
92
|
+
readonly file: FileRef2;
|
|
93
|
+
}
|
|
94
|
+
interface PageRequest2 {
|
|
95
|
+
readonly cursor?: string;
|
|
96
|
+
readonly limit?: number;
|
|
97
|
+
}
|
|
98
|
+
interface SettingsGetRequest2 {
|
|
99
|
+
readonly default?: string | null;
|
|
100
|
+
readonly key: string;
|
|
101
|
+
}
|
|
102
|
+
interface StylesApplyRequest2 {
|
|
103
|
+
readonly layer_id: string;
|
|
104
|
+
readonly style: string;
|
|
105
|
+
}
|
|
106
|
+
interface VectorLayerInfo2 {
|
|
107
|
+
readonly crs: string | null;
|
|
108
|
+
readonly field_names: readonly string[];
|
|
109
|
+
readonly geometry_type: "point" | "line" | "polygon" | "none";
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly name: string;
|
|
112
|
+
}
|
|
113
|
+
declare function ExportRequest2(value: unknown, strict?: boolean): value is ExportRequest2;
|
|
114
|
+
declare function ExportResult2(value: unknown, strict?: boolean): value is ExportResult2;
|
|
115
|
+
declare function FetchRequest2(value: unknown, strict?: boolean): value is FetchRequest2;
|
|
116
|
+
declare function IdPage2(value: unknown, strict?: boolean): value is IdPage2;
|
|
117
|
+
declare function LayerPage2(value: unknown, strict?: boolean): value is LayerPage2;
|
|
118
|
+
declare function LayerRequest2(value: unknown, strict?: boolean): value is LayerRequest2;
|
|
119
|
+
declare function NetworkFetchData2(value: unknown, strict?: boolean): value is NetworkFetchData2;
|
|
120
|
+
declare function NotificationsInfoRequest2(value: unknown, strict?: boolean): value is NotificationsInfoRequest2;
|
|
121
|
+
declare function OpenVectorRequest2(value: unknown, strict?: boolean): value is OpenVectorRequest2;
|
|
122
|
+
declare function PageRequest2(value: unknown, strict?: boolean): value is PageRequest2;
|
|
123
|
+
declare function SettingsGetRequest2(value: unknown, strict?: boolean): value is SettingsGetRequest2;
|
|
124
|
+
declare function StylesApplyRequest2(value: unknown, strict?: boolean): value is StylesApplyRequest2;
|
|
125
|
+
/** One event of `network.fetch`, narrowed by its kind. */
|
|
126
|
+
type NetworkFetchEvent2 = {
|
|
127
|
+
readonly kind: "data";
|
|
128
|
+
readonly payload: NetworkFetchData2;
|
|
129
|
+
};
|
|
130
|
+
declare function NetworkFetchEvent2(value: unknown, strict?: boolean): value is NetworkFetchEvent2;
|
|
131
|
+
/** Every operation this surface declares, as callable methods. */
|
|
132
|
+
interface HostOperations2 {
|
|
133
|
+
readonly files: {
|
|
134
|
+
readonly export: (input: ExportRequest2, options?: HostInvokeOptions2) => Promise<ExportResult2>;
|
|
135
|
+
};
|
|
136
|
+
readonly layers: {
|
|
137
|
+
readonly get: (input: LayerRequest2, options?: HostInvokeOptions2) => Promise<VectorLayerInfo2>;
|
|
138
|
+
readonly list: (input?: PageRequest2, options?: HostInvokeOptions2) => Promise<LayerPage2>;
|
|
139
|
+
readonly open_vector: (input: OpenVectorRequest2, options?: HostInvokeOptions2) => Promise<VectorLayerInfo2>;
|
|
140
|
+
};
|
|
141
|
+
readonly network: {
|
|
142
|
+
readonly fetch: (input: FetchRequest2, handlers: HostStreamHandlers2<NetworkFetchEvent2>, options?: HostInvokeOptions2) => Promise<HostStreamHandle2>;
|
|
143
|
+
};
|
|
144
|
+
readonly notifications: {
|
|
145
|
+
readonly info: (input: NotificationsInfoRequest2, options?: HostInvokeOptions2) => Promise<null>;
|
|
146
|
+
};
|
|
147
|
+
readonly project: {
|
|
148
|
+
readonly layer_ids: (input?: PageRequest2, options?: HostInvokeOptions2) => Promise<IdPage2>;
|
|
149
|
+
};
|
|
150
|
+
readonly settings: {
|
|
151
|
+
readonly get: (input: SettingsGetRequest2, options?: HostInvokeOptions2) => Promise<string | null>;
|
|
152
|
+
};
|
|
153
|
+
readonly styles: {
|
|
154
|
+
readonly apply: (input: StylesApplyRequest2, options?: HostInvokeOptions2) => Promise<null>;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
declare function createHost2(client: HostClientLike2): HostOperations2;
|
|
158
|
+
export { HOST_ID2, HOST_FINGERPRINT2, HOST_SCHEMA_VERSION2, HOST_OPERATIONS2, HostOperationId2, HostInvokeOptions2, HostClientLike2, HostStreamTerminal2, HostStreamHandlers2, HostStreamHandle2, QgisSdkHostContractError2, ExportRequest2, ExportResult2, FetchRequest2, FileRef2, HttpHeader2, IdPage2, LayerPage2, LayerRequest2, NetworkFetchData2, NotificationsInfoRequest2, OpenVectorRequest2, PageRequest2, SettingsGetRequest2, StylesApplyRequest2, VectorLayerInfo2, NetworkFetchEvent2, HostOperations2, createHost2 };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one error root of `@archont561/qgis-sdk`.
|
|
3
|
+
*
|
|
4
|
+
* Every error this package raises - transport, host contract, React binding,
|
|
5
|
+
* test harness - extends `QgisSdkError`, so a page can catch the family in one
|
|
6
|
+
* `instanceof` and switch on the stable wire `code` rather than on class names
|
|
7
|
+
* or message text. The class lives in its own module so the entry points can
|
|
8
|
+
* share it without importing each other.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Base class for expected SDK errors across the bridge boundary.
|
|
12
|
+
*/
|
|
13
|
+
declare class QgisSdkError2 extends Error {
|
|
14
|
+
readonly code: string;
|
|
15
|
+
constructor(message: string, code?: string);
|
|
16
|
+
}
|
|
17
|
+
export { QgisSdkError2 };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BridgeStreamTerminal2, WireTransport2, InvokeOptions2, BridgeSubscription2, BridgeClient2 } from "./chunk-wtv4vt4q.js";
|
|
2
|
+
import { HostOperationId2, HostOperations2 } from "./chunk-khemhx86.js";
|
|
3
|
+
import { OperationShape2, StreamShape2, OperationMap2, StreamMap2, BridgeSchema2 } from "./chunk-jjx14tgd.js";
|
|
4
|
+
/** Options for {@link QgisSdk.fromBridgeSchema}. */
|
|
5
|
+
interface QgisSdkOptions2 {
|
|
6
|
+
/** A transport to speak through; defaults to the page's QWebChannel. */
|
|
7
|
+
readonly transport?: WireTransport2;
|
|
8
|
+
/** A client the caller owns; `close()` leaves it open. Excludes `transport`. */
|
|
9
|
+
readonly client?: BridgeClient2;
|
|
10
|
+
/** Per-call timeout for an owned client. */
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
/** The channel object's name when the default transport is used. */
|
|
13
|
+
readonly channelObject?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Handlers for a typed stream: events as declared, then exactly one end. */
|
|
16
|
+
interface StreamHandlers2<E> {
|
|
17
|
+
readonly onEvent?: (event: E) => void;
|
|
18
|
+
readonly onTerminal?: (terminal: BridgeStreamTerminal2) => void;
|
|
19
|
+
}
|
|
20
|
+
/** A live stream, as the caller holds it. */
|
|
21
|
+
type StreamHandle2 = BridgeSubscription2;
|
|
22
|
+
/** The method one declared action becomes; an empty request may be omitted. */
|
|
23
|
+
type OperationMethod2<Op extends OperationShape2> = {} extends Op["request"] ? (request?: Op["request"], options?: InvokeOptions2) => Promise<Op["result"]> : (request: Op["request"], options?: InvokeOptions2) => Promise<Op["result"]>;
|
|
24
|
+
/** The method one declared stream becomes. */
|
|
25
|
+
type StreamMethod2<St extends StreamShape2> = (request: St["request"], handlers: StreamHandlers2<St["event"]>, options?: InvokeOptions2) => Promise<StreamHandle2>;
|
|
26
|
+
/** What the handshake told this page about the host (decision-27). */
|
|
27
|
+
interface QgisSdkHost2 extends HostOperations2 {
|
|
28
|
+
/**
|
|
29
|
+
* The host operation ids the handshake advertised for this view; empty
|
|
30
|
+
* until {@link QgisSdkCore.ready} has resolved.
|
|
31
|
+
*/
|
|
32
|
+
readonly granted: readonly HostOperationId2[];
|
|
33
|
+
}
|
|
34
|
+
/** The members every `QgisSdk` has, whatever its schema declares. */
|
|
35
|
+
interface QgisSdkCore2<
|
|
36
|
+
O = OperationMap2,
|
|
37
|
+
S = StreamMap2
|
|
38
|
+
> {
|
|
39
|
+
/** The schema this instance was built from. */
|
|
40
|
+
readonly schema: BridgeSchema2<O, S>;
|
|
41
|
+
/** The client under the methods, for what a method does not cover. */
|
|
42
|
+
readonly client: BridgeClient2;
|
|
43
|
+
/** The curated host surface, and what this view was granted of it. */
|
|
44
|
+
readonly host: QgisSdkHost2;
|
|
45
|
+
/** Resolves once the handshake answered; rejects when the host refused it. */
|
|
46
|
+
readonly ready: Promise<void>;
|
|
47
|
+
/** Close an owned client; a client the caller passed in is left alone. */
|
|
48
|
+
close(): void;
|
|
49
|
+
}
|
|
50
|
+
/** The first segment of a dotted id, or the whole id when it has none. */
|
|
51
|
+
type Head<K extends string> = K extends `${infer H}.${string}` ? H : K;
|
|
52
|
+
/** The members of `M` under one head, keyed by the rest of their ids. */
|
|
53
|
+
type Under<
|
|
54
|
+
M,
|
|
55
|
+
H extends string
|
|
56
|
+
> = { [K in keyof M & string as K extends `${H}.${infer Rest}` ? Rest : never] : M[K] };
|
|
57
|
+
/**
|
|
58
|
+
* The declared actions as a tree: a plain id is a method, a dotted id nests
|
|
59
|
+
* one object per segment. An id that is both a leaf and a prefix of another
|
|
60
|
+
* is refused at run time, so the type need not say what it would mean.
|
|
61
|
+
*/
|
|
62
|
+
type OperationTree2<O> = { readonly [H in Head<keyof O & string>] : H extends keyof O ? O[H] extends OperationShape2 ? OperationMethod2<O[H]> : never : OperationTree2<Under<O, H>> };
|
|
63
|
+
/** The declared streams as the same tree, with a stream method at each leaf. */
|
|
64
|
+
type StreamTree2<S> = { readonly [H in Head<keyof S & string>] : H extends keyof S ? S[H] extends StreamShape2 ? StreamMethod2<S[H]> : never : StreamTree2<Under<S, H>> };
|
|
65
|
+
/**
|
|
66
|
+
* A page's handle on QGIS: the core, plus one method per declared operation
|
|
67
|
+
* nested under the segments of its id.
|
|
68
|
+
*/
|
|
69
|
+
type QgisSdk2<
|
|
70
|
+
O = OperationMap2,
|
|
71
|
+
S = StreamMap2
|
|
72
|
+
> = QgisSdkCore2<O, S> & OperationTree2<O> & StreamTree2<S>;
|
|
73
|
+
/** Names {@link QgisSdkCore} keeps; a declared id may not start with one. */
|
|
74
|
+
declare const QGIS_SDK_MEMBERS2: readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* The entry point: `QgisSdk.fromBridgeSchema(schema)`.
|
|
77
|
+
*
|
|
78
|
+
* A namespace rather than a constant so the value and the instance type share
|
|
79
|
+
* one name through every declaration bundler.
|
|
80
|
+
*/
|
|
81
|
+
declare namespace QgisSdk2 {
|
|
82
|
+
function fromBridgeSchema<
|
|
83
|
+
O extends Record<keyof O, OperationShape2>,
|
|
84
|
+
S extends Record<keyof S, StreamShape2>
|
|
85
|
+
>(schema: BridgeSchema2<O, S>, options?: QgisSdkOptions2): QgisSdk2<O, S>;
|
|
86
|
+
}
|
|
87
|
+
export { QgisSdkOptions2, StreamHandlers2, StreamHandle2, OperationMethod2, StreamMethod2, QgisSdkHost2, QgisSdkCore2, OperationTree2, StreamTree2, QGIS_SDK_MEMBERS2, QgisSdk2 };
|