@archont561/qgis-sdk 0.3.0 → 0.5.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/README.md +35 -33
- package/dist/bridge.d.ts +2 -205
- package/dist/bridge.js +3 -4
- package/dist/host.d.ts +2 -157
- package/dist/host.js +72 -430
- package/dist/index.d.ts +62 -95
- package/dist/index.js +399 -12
- package/dist/react.d.ts +61 -161
- package/dist/react.js +70 -139
- package/dist/shared/chunk-2hwva3a3.js +14 -0
- package/dist/shared/chunk-3zscfm3y.d.ts +342 -0
- package/dist/shared/chunk-7tgzmz0m.d.ts +252 -0
- package/dist/shared/chunk-8gawbn19.js +433 -0
- package/dist/shared/chunk-a33y575v.d.ts +155 -0
- package/dist/shared/chunk-pdj2fxjb.d.ts +17 -0
- package/dist/shared/chunk-stre69mw.js +777 -0
- package/dist/shared/chunk-t1vpt5yq.js +895 -0
- package/dist/shared/chunk-wtv4vt4q.d.ts +280 -0
- package/dist/svelte.d.ts +75 -0
- package/dist/svelte.js +70 -0
- package/dist/testing.d.ts +58 -30
- package/dist/testing.js +51 -5
- package/dist/vue.d.ts +106 -0
- package/dist/vue.js +91 -0
- package/package.json +21 -3
- package/dist/shared/chunk-0fknax6w.js +0 -207
- package/dist/shared/chunk-a7bjgeve.js +0 -422
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { QgisSdkError2 } from "./chunk-pdj2fxjb.js";
|
|
2
|
+
declare const MAX_SAFE_INTEGER2: number;
|
|
3
|
+
declare const MIN_SAFE_INTEGER2: number;
|
|
4
|
+
declare const PLUGIN_DESCRIPTION_SCHEMA_VERSION2: 1;
|
|
5
|
+
type ValidationDirection2 = "request" | "result";
|
|
6
|
+
interface SerializedValidationIssue2 {
|
|
7
|
+
readonly path: (string | number)[];
|
|
8
|
+
readonly code: string;
|
|
9
|
+
}
|
|
10
|
+
interface SerializedContractValidationError2 {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly direction: ValidationDirection2;
|
|
13
|
+
readonly issues: SerializedValidationIssue2[];
|
|
14
|
+
}
|
|
15
|
+
interface ActionDescription2 {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly title: string;
|
|
18
|
+
readonly handler: string;
|
|
19
|
+
readonly request: Readonly<Record<string, unknown>>;
|
|
20
|
+
readonly result: Readonly<Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
/** The event kinds a stream may declare; the frame carries the same three. */
|
|
23
|
+
type StreamEventKind2 = "data" | "progress" | "state";
|
|
24
|
+
/**
|
|
25
|
+
* A declared stream (decision-28): a request in, one payload schema per
|
|
26
|
+
* declared event kind out. There is no `result`: the reply to a subscription is
|
|
27
|
+
* the protocol's acknowledgement, not something an author declares.
|
|
28
|
+
*/
|
|
29
|
+
interface StreamDescription2 {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly title: string;
|
|
32
|
+
readonly handler: string;
|
|
33
|
+
readonly request: Readonly<Record<string, unknown>>;
|
|
34
|
+
readonly events: Readonly<Partial<Record<StreamEventKind2, Readonly<Record<string, unknown>>>>>;
|
|
35
|
+
}
|
|
36
|
+
interface PluginDescription2 {
|
|
37
|
+
readonly schema_version: 1;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly actions: readonly ActionDescription2[];
|
|
41
|
+
/** Declared streams; a description from a host that predates them is empty. */
|
|
42
|
+
readonly streams: readonly StreamDescription2[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Return whether `value` is a finite integer within the JavaScript-safe wire range.
|
|
46
|
+
*/
|
|
47
|
+
declare function isSafeJsonInteger2(value: unknown): value is number;
|
|
48
|
+
/**
|
|
49
|
+
* A declaration cannot be represented or parsed in the versioned contract.
|
|
50
|
+
*/
|
|
51
|
+
declare class QgisSdkDeclarationError2 extends QgisSdkError2 {
|
|
52
|
+
constructor(message: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Safe, structured location and category for a rejected contract value.
|
|
56
|
+
*/
|
|
57
|
+
declare class QgisSdkValidationIssue2 {
|
|
58
|
+
readonly path: readonly (string | number)[];
|
|
59
|
+
readonly code: string;
|
|
60
|
+
constructor(path: readonly (string | number)[], code: string);
|
|
61
|
+
toJSON(): SerializedValidationIssue2;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A request or result did not satisfy its declared wire contract.
|
|
65
|
+
*/
|
|
66
|
+
declare class QgisSdkContractValidationError2 extends QgisSdkError2 {
|
|
67
|
+
readonly direction: ValidationDirection2;
|
|
68
|
+
readonly issues: readonly QgisSdkValidationIssue2[];
|
|
69
|
+
constructor(direction: ValidationDirection2, issues: readonly QgisSdkValidationIssue2[]);
|
|
70
|
+
toJSON(): SerializedContractValidationError2;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parse and validate a version 1 `PluginDescription` emitted by `describe_plugin`.
|
|
74
|
+
*/
|
|
75
|
+
declare function parsePluginDescription2(input: string | Readonly<Record<string, unknown>>): PluginDescription2;
|
|
76
|
+
declare const BRIDGE_PROTOCOL_VERSION2: 1;
|
|
77
|
+
declare const MAX_CALL_ID_LENGTH2: number;
|
|
78
|
+
/** A failure reply, as the host serialized it. */
|
|
79
|
+
interface BridgeFailure2 {
|
|
80
|
+
readonly code: string;
|
|
81
|
+
readonly message: string;
|
|
82
|
+
}
|
|
83
|
+
/** A reply to one invocation: exactly one of `value` or `error` is present. */
|
|
84
|
+
type InvokeReply2 = {
|
|
85
|
+
readonly protocol: 1;
|
|
86
|
+
readonly call_id: string;
|
|
87
|
+
readonly ok: true;
|
|
88
|
+
readonly value: unknown;
|
|
89
|
+
} | {
|
|
90
|
+
readonly protocol: 1;
|
|
91
|
+
readonly call_id: string;
|
|
92
|
+
readonly ok: false;
|
|
93
|
+
readonly error: BridgeFailure2;
|
|
94
|
+
};
|
|
95
|
+
/** Why a subscription stopped. */
|
|
96
|
+
type StreamTerminalKind2 = "complete" | "error" | "cancelled" | "gap" | "disposed";
|
|
97
|
+
/** One event on a subscription. */
|
|
98
|
+
interface BridgeStreamEvent2 {
|
|
99
|
+
readonly kind: StreamEventKind2;
|
|
100
|
+
readonly payload: unknown;
|
|
101
|
+
}
|
|
102
|
+
/** The end of a subscription, as the host described it. */
|
|
103
|
+
interface BridgeStreamTerminal2 {
|
|
104
|
+
readonly kind: StreamTerminalKind2;
|
|
105
|
+
readonly message?: string;
|
|
106
|
+
readonly dropped?: number;
|
|
107
|
+
}
|
|
108
|
+
/** A frame carrying one event. */
|
|
109
|
+
interface BridgeEventFrame2 {
|
|
110
|
+
readonly protocol: 1;
|
|
111
|
+
readonly subscription_id: string;
|
|
112
|
+
readonly seq: number;
|
|
113
|
+
readonly event: BridgeStreamEvent2;
|
|
114
|
+
}
|
|
115
|
+
/** The frame that ends a subscription. */
|
|
116
|
+
interface BridgeTerminalFrame2 {
|
|
117
|
+
readonly protocol: 1;
|
|
118
|
+
readonly subscription_id: string;
|
|
119
|
+
readonly seq: number;
|
|
120
|
+
readonly terminal: BridgeStreamTerminal2;
|
|
121
|
+
}
|
|
122
|
+
/** Anything the host may send for a subscription. */
|
|
123
|
+
type BridgeStreamFrame2 = BridgeEventFrame2 | BridgeTerminalFrame2;
|
|
124
|
+
/** The transport a client speaks through; a QWebChannel adapter or a script. */
|
|
125
|
+
interface WireTransport2 {
|
|
126
|
+
send(message: unknown): void;
|
|
127
|
+
subscribe(listener: (message: unknown) => void): () => void;
|
|
128
|
+
}
|
|
129
|
+
/** Options for {@link BridgeClient}. */
|
|
130
|
+
interface BridgeClientOptions2 {
|
|
131
|
+
readonly timeoutMs?: number;
|
|
132
|
+
}
|
|
133
|
+
/** Options for one invocation. */
|
|
134
|
+
interface InvokeOptions2 {
|
|
135
|
+
readonly signal?: AbortSignal;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* An envelope or reply does not match the versioned bridge protocol.
|
|
139
|
+
*/
|
|
140
|
+
declare class QgisSdkBridgeProtocolError2 extends QgisSdkError2 {
|
|
141
|
+
constructor(message: string);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The host did not answer in time. The call may still have run, so this is an
|
|
145
|
+
* unknown outcome: retrying automatically is forbidden, deciding is the caller's.
|
|
146
|
+
*/
|
|
147
|
+
declare class QgisSdkBridgeTimeoutError2 extends QgisSdkError2 {
|
|
148
|
+
readonly callId: string;
|
|
149
|
+
constructor(callId: string, timeoutMs: number);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The caller aborted locally. Distinct from the host cancelling the operation,
|
|
153
|
+
* which arrives as a failure reply carrying the `cancelled` code.
|
|
154
|
+
*/
|
|
155
|
+
declare class QgisSdkBridgeAbortedError2 extends QgisSdkError2 {
|
|
156
|
+
readonly callId: string;
|
|
157
|
+
constructor(callId: string);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The client was closed, so pending calls can no longer be answered.
|
|
161
|
+
*/
|
|
162
|
+
declare class QgisSdkBridgeClosedError2 extends QgisSdkError2 {
|
|
163
|
+
constructor();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A subscription's frames were not the sequence the host promised.
|
|
167
|
+
*
|
|
168
|
+
* The client does not try to reassemble: a missed frame is a fact about the
|
|
169
|
+
* subscription, not something to paper over.
|
|
170
|
+
*/
|
|
171
|
+
declare class QgisSdkBridgeSequenceError2 extends QgisSdkError2 {
|
|
172
|
+
readonly subscriptionId: string;
|
|
173
|
+
readonly expected: number;
|
|
174
|
+
readonly received: number;
|
|
175
|
+
constructor(subscriptionId: string, expected: number, received: number);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The subscription ended with a terminal frame the caller may want to inspect.
|
|
179
|
+
*/
|
|
180
|
+
declare class QgisSdkBridgeStreamEndedError2 extends QgisSdkError2 {
|
|
181
|
+
readonly subscriptionId: string;
|
|
182
|
+
readonly terminal: BridgeStreamTerminal2;
|
|
183
|
+
constructor(subscriptionId: string, terminal: BridgeStreamTerminal2);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The host refused or failed the operation; `failure.code` is the contract.
|
|
187
|
+
*/
|
|
188
|
+
declare class QgisSdkBridgeRemoteError2 extends QgisSdkError2 {
|
|
189
|
+
readonly failure: BridgeFailure2;
|
|
190
|
+
readonly callId: string;
|
|
191
|
+
constructor(callId: string, failure: BridgeFailure2);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Parse one reply, refusing anything the host could not legitimately have sent.
|
|
195
|
+
*/
|
|
196
|
+
declare function parseInvokeReply2(raw: unknown): InvokeReply2;
|
|
197
|
+
/**
|
|
198
|
+
* Parse one stream frame, refusing anything the host could not legitimately
|
|
199
|
+
* have sent.
|
|
200
|
+
*
|
|
201
|
+
* Exactly one of `event` and `terminal` has to be present: a frame that carries
|
|
202
|
+
* both leaves the client guessing which one wins, and a client that guesses is
|
|
203
|
+
* a client that will eventually deliver an event after the end of a stream.
|
|
204
|
+
*/
|
|
205
|
+
declare function parseStreamFrame2(raw: unknown): BridgeStreamFrame2;
|
|
206
|
+
/** Callbacks a subscription reports through. */
|
|
207
|
+
interface SubscriptionHandlers2 {
|
|
208
|
+
readonly onEvent?: (event: BridgeStreamEvent2) => void;
|
|
209
|
+
readonly onTerminal?: (terminal: BridgeStreamTerminal2) => void;
|
|
210
|
+
}
|
|
211
|
+
/** A live subscription, as the caller holds it. */
|
|
212
|
+
interface BridgeSubscription2 {
|
|
213
|
+
readonly id: string;
|
|
214
|
+
readonly closed: boolean;
|
|
215
|
+
close(): void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Correlate invocations with replies over an injected transport.
|
|
219
|
+
*
|
|
220
|
+
* The client never retries: a timeout, an abort and a closed client are three
|
|
221
|
+
* different answers, and each is reported as itself.
|
|
222
|
+
*/
|
|
223
|
+
declare class BridgeClient2 {
|
|
224
|
+
private readonly transport;
|
|
225
|
+
private readonly timeoutMs;
|
|
226
|
+
private readonly pending;
|
|
227
|
+
private readonly subscriptions;
|
|
228
|
+
private readonly disposals;
|
|
229
|
+
private readonly unsubscribe;
|
|
230
|
+
private counter;
|
|
231
|
+
private closed;
|
|
232
|
+
private unmatched;
|
|
233
|
+
private breaks;
|
|
234
|
+
private lastProtocolError;
|
|
235
|
+
constructor(transport: WireTransport2, options?: BridgeClientOptions2);
|
|
236
|
+
/** Whether {@link close} has run; a closed client answers nothing. */
|
|
237
|
+
get isClosed(): boolean;
|
|
238
|
+
/** Replies that named no pending call: a late duplicate, or a stray message. */
|
|
239
|
+
get unmatchedReplies(): number;
|
|
240
|
+
/** Number of calls still waiting for a reply. */
|
|
241
|
+
get pendingCalls(): number;
|
|
242
|
+
/**
|
|
243
|
+
* Invoke one operation and settle with its value or with a typed failure.
|
|
244
|
+
*/
|
|
245
|
+
invoke(operation: string, payload?: Readonly<Record<string, unknown>>, options?: InvokeOptions2): Promise<unknown>;
|
|
246
|
+
/**
|
|
247
|
+
* Open a subscription and resolve once the host has acknowledged it.
|
|
248
|
+
*
|
|
249
|
+
* Frames are matched to the subscription by id and by sequence; a frame that
|
|
250
|
+
* does not continue the sequence ends the subscription instead of being
|
|
251
|
+
* delivered out of order.
|
|
252
|
+
*/
|
|
253
|
+
subscribe(operation: string, payload?: Readonly<Record<string, unknown>>, handlers?: SubscriptionHandlers2, options?: InvokeOptions2): Promise<BridgeSubscription2>;
|
|
254
|
+
/**
|
|
255
|
+
* Ask the host for the handshake: the contract this view may use.
|
|
256
|
+
*
|
|
257
|
+
* The host bound the view before its first message, so this is a call, not
|
|
258
|
+
* a binding. The value is what `Dispatcher.handshake` builds - protocol,
|
|
259
|
+
* generation, the plugin description, the host schema version and the
|
|
260
|
+
* operations this view is authorized for.
|
|
261
|
+
*/
|
|
262
|
+
handshake(options?: InvokeOptions2): Promise<unknown>;
|
|
263
|
+
/** Subscriptions still open; a leak check for callers and tests. */
|
|
264
|
+
get activeSubscriptions(): readonly string[];
|
|
265
|
+
/** Frames that did not continue their subscription's sequence. */
|
|
266
|
+
get sequenceBreaks(): number;
|
|
267
|
+
private send;
|
|
268
|
+
/**
|
|
269
|
+
* Refuse further calls, reject what is still pending, and stop listening.
|
|
270
|
+
*/
|
|
271
|
+
close(): void;
|
|
272
|
+
private settle;
|
|
273
|
+
private handle;
|
|
274
|
+
private handleFrame;
|
|
275
|
+
private endSubscription;
|
|
276
|
+
private disposeSubscription;
|
|
277
|
+
/** The last malformed message this client refused, if any. */
|
|
278
|
+
get protocolError(): Error | null;
|
|
279
|
+
}
|
|
280
|
+
export { MAX_SAFE_INTEGER2, MIN_SAFE_INTEGER2, PLUGIN_DESCRIPTION_SCHEMA_VERSION2, ValidationDirection2, SerializedValidationIssue2, SerializedContractValidationError2, ActionDescription2, StreamEventKind2, StreamDescription2, PluginDescription2, isSafeJsonInteger2, QgisSdkDeclarationError2, QgisSdkValidationIssue2, QgisSdkContractValidationError2, parsePluginDescription2, BRIDGE_PROTOCOL_VERSION2, MAX_CALL_ID_LENGTH2, BridgeFailure2, InvokeReply2, StreamTerminalKind2, BridgeStreamEvent2, BridgeStreamTerminal2, BridgeEventFrame2, BridgeTerminalFrame2, BridgeStreamFrame2, WireTransport2, BridgeClientOptions2, InvokeOptions2, QgisSdkBridgeProtocolError2, QgisSdkBridgeTimeoutError2, QgisSdkBridgeAbortedError2, QgisSdkBridgeClosedError2, QgisSdkBridgeSequenceError2, QgisSdkBridgeStreamEndedError2, QgisSdkBridgeRemoteError2, parseInvokeReply2, parseStreamFrame2, SubscriptionHandlers2, BridgeSubscription2, BridgeClient2 };
|
package/dist/svelte.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import "./shared/chunk-wtv4vt4q.js";
|
|
2
|
+
import "./shared/chunk-7tgzmz0m.js";
|
|
3
|
+
import { OperationMap2, StreamMap2, QgisSdkCore2, QgisSdk2 } from "./shared/chunk-a33y575v.js";
|
|
4
|
+
import { Store2, OperationState2, Operation2, OperationStore2, StreamTerminalLike2, StreamHandleLike2, StreamHandlersLike2, Stream2, StreamState2, StreamStore2, FormOptions2, FormStore2, HostQueryStore2 } from "./shared/chunk-3zscfm3y.js";
|
|
5
|
+
import { QgisSdkError2 } from "./shared/chunk-pdj2fxjb.js";
|
|
6
|
+
/** A helper was used outside the shape it needs. */
|
|
7
|
+
declare class QgisSdkBridgeSvelteError extends QgisSdkError2 {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** The context key `setQgisSdk` writes and `getQgisSdk` reads. */
|
|
11
|
+
declare const QGIS_SDK_CONTEXT: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* Share a `QgisSdk` with the component subtree; call during component
|
|
14
|
+
* initialisation. The SDK is shared as given and never closed here.
|
|
15
|
+
*/
|
|
16
|
+
declare function setQgisSdk<T extends QgisSdkCore2<unknown, unknown>>(qgis: T): T;
|
|
17
|
+
/**
|
|
18
|
+
* The `QgisSdk` the nearest `setQgisSdk` shared.
|
|
19
|
+
*
|
|
20
|
+
* The type parameters name the generated `Operations` and `Streams`; they are
|
|
21
|
+
* the caller's claim, the same way the ancestor's argument was the page's.
|
|
22
|
+
*/
|
|
23
|
+
declare function getQgisSdk<
|
|
24
|
+
O = OperationMap2,
|
|
25
|
+
S = StreamMap2
|
|
26
|
+
>(): QgisSdk2<O, S>;
|
|
27
|
+
/**
|
|
28
|
+
* An operation store whose in-flight call is aborted when the component is
|
|
29
|
+
* destroyed; read it as `$op` or pass it to {@link toRune}.
|
|
30
|
+
*/
|
|
31
|
+
declare function operation<
|
|
32
|
+
I,
|
|
33
|
+
R
|
|
34
|
+
>(operation: Operation2<I, R>): OperationStore2<I, R>;
|
|
35
|
+
/**
|
|
36
|
+
* A stream store closed when the component is destroyed. Pass the input now
|
|
37
|
+
* or later with `store.setInput(...)`; `$effect(() => store.setInput(input))`
|
|
38
|
+
* follows a reactive one, by content.
|
|
39
|
+
*/
|
|
40
|
+
declare function stream<
|
|
41
|
+
I,
|
|
42
|
+
E
|
|
43
|
+
>(open: Stream2<I, E>, input?: I | null, handlers?: StreamHandlersLike2<E>): StreamStore2<I, E>;
|
|
44
|
+
type RequestOf<
|
|
45
|
+
O,
|
|
46
|
+
K extends keyof O
|
|
47
|
+
> = O[K] extends {
|
|
48
|
+
readonly request: infer Req;
|
|
49
|
+
} ? Req : never;
|
|
50
|
+
type ResultOf<
|
|
51
|
+
O,
|
|
52
|
+
K extends keyof O
|
|
53
|
+
> = O[K] extends {
|
|
54
|
+
readonly result: infer Res;
|
|
55
|
+
} ? Res : never;
|
|
56
|
+
/**
|
|
57
|
+
* The form of one declared action, disposed with the component: render
|
|
58
|
+
* `form.fields`, bind `$form.values`, call `form.submit()`.
|
|
59
|
+
*/
|
|
60
|
+
declare function form<
|
|
61
|
+
O,
|
|
62
|
+
K extends keyof O & string
|
|
63
|
+
>(qgis: QgisSdkCore2<O, unknown>, id: K, options?: FormOptions2): FormStore2<RequestOf<O, K> & object, ResultOf<O, K>>;
|
|
64
|
+
/**
|
|
65
|
+
* A host query store refreshed now (unless `auto` is `false`) and aborted
|
|
66
|
+
* when the component is destroyed: `hostQuery(layersQuery(qgis))`.
|
|
67
|
+
*/
|
|
68
|
+
declare function hostQuery<T>(store: HostQueryStore2<T>, options?: {
|
|
69
|
+
readonly auto?: boolean;
|
|
70
|
+
}): HostQueryStore2<T>;
|
|
71
|
+
/** A runes-friendly view of any store: `const op = toRune(store); op.current`. */
|
|
72
|
+
declare function toRune<T>(store: Store2<T>): {
|
|
73
|
+
readonly current: T;
|
|
74
|
+
};
|
|
75
|
+
export { Operation2 as Operation, OperationState2 as OperationState, QGIS_SDK_CONTEXT, QgisSdkBridgeSvelteError, Stream2 as Stream, StreamHandleLike2 as StreamHandleLike, StreamHandlersLike2 as StreamHandlersLike, StreamState2 as StreamState, StreamTerminalLike2 as StreamTerminalLike, form, getQgisSdk, hostQuery, operation, setQgisSdk, stream, toRune };
|
package/dist/svelte.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import"./shared/chunk-8gawbn19.js";
|
|
2
|
+
import {
|
|
3
|
+
OperationStore2,
|
|
4
|
+
StreamStore2,
|
|
5
|
+
FormStore2
|
|
6
|
+
} from "./shared/chunk-t1vpt5yq.js";
|
|
7
|
+
import {
|
|
8
|
+
QgisSdkError2
|
|
9
|
+
} from "./shared/chunk-2hwva3a3.js";
|
|
10
|
+
|
|
11
|
+
// src/svelte.ts
|
|
12
|
+
import { getContext, onDestroy, setContext } from "svelte";
|
|
13
|
+
import { fromStore } from "svelte/store";
|
|
14
|
+
class QgisSdkBridgeSvelteError extends QgisSdkError2 {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message, "svelte_binding");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var QGIS_SDK_CONTEXT = Symbol("qgis-sdk");
|
|
20
|
+
function setQgisSdk(qgis) {
|
|
21
|
+
setContext(QGIS_SDK_CONTEXT, qgis);
|
|
22
|
+
return qgis;
|
|
23
|
+
}
|
|
24
|
+
function getQgisSdk() {
|
|
25
|
+
const qgis = getContext(QGIS_SDK_CONTEXT);
|
|
26
|
+
if (qgis === undefined) {
|
|
27
|
+
throw new QgisSdkBridgeSvelteError("getQgisSdk needs setQgisSdk in an ancestor component");
|
|
28
|
+
}
|
|
29
|
+
return qgis;
|
|
30
|
+
}
|
|
31
|
+
function operation(operation) {
|
|
32
|
+
const store = new OperationStore2(operation);
|
|
33
|
+
onDestroy(store.abort);
|
|
34
|
+
return store;
|
|
35
|
+
}
|
|
36
|
+
function stream(open, input = null, handlers = {}) {
|
|
37
|
+
const store = new StreamStore2(open, handlers);
|
|
38
|
+
store.setInput(input);
|
|
39
|
+
onDestroy(store.close);
|
|
40
|
+
return store;
|
|
41
|
+
}
|
|
42
|
+
function form(qgis, id, options) {
|
|
43
|
+
const store = new FormStore2(qgis, id, options);
|
|
44
|
+
onDestroy(() => store.dispose());
|
|
45
|
+
return store;
|
|
46
|
+
}
|
|
47
|
+
function hostQuery(store, options = {}) {
|
|
48
|
+
if (options.auto !== false) {
|
|
49
|
+
store.refresh();
|
|
50
|
+
}
|
|
51
|
+
onDestroy(store.abort);
|
|
52
|
+
return store;
|
|
53
|
+
}
|
|
54
|
+
function toRune(store) {
|
|
55
|
+
return fromStore(store);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
QGIS_SDK_CONTEXT,
|
|
59
|
+
QgisSdkBridgeSvelteError,
|
|
60
|
+
form,
|
|
61
|
+
getQgisSdk,
|
|
62
|
+
hostQuery,
|
|
63
|
+
operation,
|
|
64
|
+
setQgisSdk,
|
|
65
|
+
stream,
|
|
66
|
+
toRune
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//# debugId=A88CE88B3B7681A364756E2164756E21
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL3N2ZWx0ZS50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICAgICIvKipcbiAqIFRoaW4gU3ZlbHRlIDUgYmluZGluZ3Mgb3ZlciB0aGUgc3RvcmUgY29yZSAoZGVjaXNpb24tNDcpLlxuICpcbiAqIFRoaXMgZW50cnkgcG9pbnQgaXMgb3B0aW9uYWwgYW5kIGlzIHRoZSBvbmx5IG9uZSB0aGF0IGltcG9ydHMgU3ZlbHRlLiBUaGVcbiAqIHN0b3JlcyBpbiBgLi9zdG9yZXNgIGFscmVhZHkgc2F0aXNmeSBTdmVsdGUncyBzdG9yZSBjb250cmFjdCAtIGBzdWJzY3JpYmVgXG4gKiBjYWxscyBhdCBvbmNlIGFuZCBvbiBldmVyeSBjaGFuZ2UgYW5kIHJldHVybnMgdGhlIHVuc3Vic2NyaWJlciAtIHNvIGFcbiAqIGNvbXBvbmVudCB3cml0ZXMgYCRzdGF0ZWAgb3ZlciBhbnkgb2YgdGhlbSB3aXRoIG5vIHdyYXBwZXIuIFdoYXQgdGhpc1xuICogbW9kdWxlIGFkZHMgaXMgdGhlIGxpdHRsZSBTdmVsdGUgYXNr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OyIsCiAgImRlYnVnSWQiOiAiQTg4Q0U4OEIzQjc2ODFBMzY0NzU2RTIxNjQ3NTZFMjEiLAogICJuYW1lcyI6IFtdCn0=
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly code: string;
|
|
6
|
-
constructor(message: string, code?: string);
|
|
7
|
-
}
|
|
8
|
-
/** The kinds of event a stream may carry; only `progress` may be coalesced. */
|
|
9
|
-
type StreamEventKind2 = "data" | "progress" | "state";
|
|
10
|
-
/** Why a subscription stopped. */
|
|
11
|
-
type StreamTerminalKind = "complete" | "error" | "cancelled" | "gap" | "disposed";
|
|
12
|
-
/** The end of a subscription, as the host described it. */
|
|
13
|
-
interface BridgeStreamTerminal {
|
|
14
|
-
readonly kind: StreamTerminalKind;
|
|
15
|
-
readonly message?: string;
|
|
16
|
-
readonly dropped?: number;
|
|
17
|
-
}
|
|
18
|
-
/** The transport a client speaks through; a QWebChannel adapter or a script. */
|
|
19
|
-
interface WireTransport {
|
|
20
|
-
send(message: unknown): void;
|
|
21
|
-
subscribe(listener: (message: unknown) => void): () => void;
|
|
22
|
-
}
|
|
1
|
+
import { StreamEventKind2, BridgeStreamTerminal2, WireTransport2 } from "./shared/chunk-wtv4vt4q.js";
|
|
2
|
+
import { HostOperationId2 } from "./shared/chunk-7tgzmz0m.js";
|
|
3
|
+
import { OperationShape2, StreamShape2, BridgeSchema2, QgisSdkHostTheme2 } from "./shared/chunk-a33y575v.js";
|
|
4
|
+
import { QgisSdkError2 } from "./shared/chunk-pdj2fxjb.js";
|
|
23
5
|
/** A scripted host failure, returned from an expectation's handler. */
|
|
24
6
|
interface ScriptedFault {
|
|
25
7
|
readonly fault: {
|
|
@@ -43,7 +25,8 @@ type ScriptedReply<Res> = Res | ScriptedFault | typeof SILENCE | Promise<Res | S
|
|
|
43
25
|
/** A message the client sent, as the harness recorded it. */
|
|
44
26
|
interface RecordedCall {
|
|
45
27
|
readonly callId: string;
|
|
46
|
-
readonly kind: "invoke" | "subscribe" | "unsubscribe";
|
|
28
|
+
readonly kind: "invoke" | "subscribe" | "unsubscribe" | "handshake";
|
|
29
|
+
/** Empty for a handshake, which names no operation. */
|
|
47
30
|
readonly operation: string;
|
|
48
31
|
readonly payload?: Readonly<Record<string, unknown>>;
|
|
49
32
|
readonly subscriptionId?: string;
|
|
@@ -58,7 +41,7 @@ interface ScriptedStream {
|
|
|
58
41
|
/** `false` once the host ended it or the page closed it. */
|
|
59
42
|
readonly open: boolean;
|
|
60
43
|
emit(kind: StreamEventKind2, payload: unknown): void;
|
|
61
|
-
end(terminal:
|
|
44
|
+
end(terminal: BridgeStreamTerminal2): void;
|
|
62
45
|
/** Advance the sequence without sending, so the next frame is a gap. */
|
|
63
46
|
skip(frames: number): void;
|
|
64
47
|
}
|
|
@@ -67,15 +50,32 @@ interface SubscribeOptions {
|
|
|
67
50
|
/** Delay the acknowledgement until this promise settles. */
|
|
68
51
|
readonly ack?: () => Promise<void>;
|
|
69
52
|
}
|
|
53
|
+
/** Options for {@link createBridgeHarness}. */
|
|
54
|
+
interface HarnessOptions {
|
|
55
|
+
/**
|
|
56
|
+
* The host operation ids the scripted handshake advertises; every curated
|
|
57
|
+
* id by default. A narrowed list is how a test proves a page respects
|
|
58
|
+
* `qgis.host.granted`. A call outside it is still answered
|
|
59
|
+
* by whatever the test scripted - typically `fault("not_authorized", ...)` -
|
|
60
|
+
* because that refusal is the host's, not the harness's.
|
|
61
|
+
*/
|
|
62
|
+
readonly granted?: readonly HostOperationId2[];
|
|
63
|
+
/**
|
|
64
|
+
* The palette the scripted handshake carries as `theme`; none by default,
|
|
65
|
+
* which is what a page outside QGIS sees. The same shape the WebEngine
|
|
66
|
+
* adapter sends, so a test can prove a page takes the host's colours.
|
|
67
|
+
*/
|
|
68
|
+
readonly theme?: QgisSdkHostTheme2;
|
|
69
|
+
}
|
|
70
70
|
/**
|
|
71
71
|
* A test's script went wrong: an unmet or unexpected call, a leaked
|
|
72
72
|
* subscription, a handler that threw, or an envelope that is not protocol 1.
|
|
73
73
|
*/
|
|
74
|
-
declare class QgisSdkBridgeHarnessError extends
|
|
74
|
+
declare class QgisSdkBridgeHarnessError extends QgisSdkError2 {
|
|
75
75
|
constructor(message: string);
|
|
76
76
|
}
|
|
77
77
|
/** The harness a test holds; also the transport its client is built on. */
|
|
78
|
-
interface BridgeHarness<Op extends string = string> extends
|
|
78
|
+
interface BridgeHarness<Op extends string = string> extends WireTransport2 {
|
|
79
79
|
/** Every message the client sent, in order. */
|
|
80
80
|
readonly calls: readonly RecordedCall[];
|
|
81
81
|
/** Calls no expectation covered; each was answered `unexpected_call`. */
|
|
@@ -102,8 +102,36 @@ interface BridgeHarness<Op extends string = string> extends WireTransport {
|
|
|
102
102
|
assertSatisfied(): void;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* the
|
|
105
|
+
* The harness {@link createBridgeHarness} returns for a schema: the same
|
|
106
|
+
* harness, with `expectInvoke` and `expectSubscribe` typed by the schema's
|
|
107
|
+
* `Operations` and `Streams` - a payload is the declared request, a reply the
|
|
108
|
+
* declared result - and by the curated host ids, whose shapes the host module
|
|
109
|
+
* owns.
|
|
110
|
+
*/
|
|
111
|
+
interface SchemaBridgeHarness<
|
|
112
|
+
O,
|
|
113
|
+
S
|
|
114
|
+
> extends Omit<BridgeHarness<Extract<keyof O | keyof S, string> | HostOperationId2>, "expectInvoke" | "expectSubscribe"> {
|
|
115
|
+
expectInvoke<K extends Extract<keyof O, string>>(operation: K, handler: (payload: O[K] extends OperationShape2 ? O[K]["request"] : never) => ScriptedReply<O[K] extends OperationShape2 ? O[K]["result"] : never>): void;
|
|
116
|
+
expectInvoke<
|
|
117
|
+
Req extends object = Readonly<Record<string, unknown>>,
|
|
118
|
+
Res = unknown
|
|
119
|
+
>(operation: HostOperationId2, handler: (payload: Req) => ScriptedReply<Res>): void;
|
|
120
|
+
expectSubscribe<K extends Extract<keyof S, string>>(operation: K, script: SubscribeScript<S[K] extends StreamShape2 ? S[K]["request"] : never>, options?: SubscribeOptions): void;
|
|
121
|
+
expectSubscribe<Req extends object = Readonly<Record<string, unknown>>>(operation: HostOperationId2, script: SubscribeScript<Req>, options?: SubscribeOptions): void;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a harness.
|
|
125
|
+
*
|
|
126
|
+
* Given the generated `bridge.schema.ts` default export, the harness is typed
|
|
127
|
+
* by it: `expectInvoke("sites.summary", (payload) => ...)` sees the declared
|
|
128
|
+
* request and must answer with the declared result, and the handshake it
|
|
129
|
+
* answers advertises the schema's operations. Without one, `Op` narrows the
|
|
130
|
+
* operations a test may expect, typically a generated `OperationId`.
|
|
107
131
|
*/
|
|
108
|
-
declare function createBridgeHarness<Op extends string = string>(): BridgeHarness<Op>;
|
|
109
|
-
|
|
132
|
+
declare function createBridgeHarness<Op extends string = string>(options?: HarnessOptions): BridgeHarness<Op>;
|
|
133
|
+
declare function createBridgeHarness<
|
|
134
|
+
O,
|
|
135
|
+
S
|
|
136
|
+
>(schema: BridgeSchema2<O, S>, options?: HarnessOptions): SchemaBridgeHarness<O, S>;
|
|
137
|
+
export { BridgeHarness, HarnessOptions, QgisSdkBridgeHarnessError, RecordedCall, SILENCE, SchemaBridgeHarness, ScriptedFault, ScriptedRefusal, ScriptedReply, ScriptedStream, SubscribeOptions, SubscribeScript, createBridgeHarness, fault };
|