@dolphy-app/extension-sdk 0.2.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/README.md +25 -8
- package/dist/answer-element-BOQcuxYh.js +114 -0
- package/dist/answer-view-D6wnyThb.d.ts +28 -0
- package/dist/index.d.ts +107 -27
- package/dist/index.js +48 -117
- package/dist/runtime.d.ts +17 -0
- package/dist/runtime.js +24 -0
- package/dist/testing.d.ts +330 -11
- package/dist/testing.js +722 -11
- package/docs/debugging.md +210 -0
- package/docs/no-build.md +99 -0
- package/docs/quick-start.md +172 -0
- package/docs/recipe-command-panel.md +211 -0
- package/docs/recipe-event-storage.md +266 -0
- package/docs/recipe-exercise-type.md +379 -0
- package/docs/recipe-import-export.md +241 -0
- package/docs/recipe-settings.md +161 -0
- package/docs/recipe-theme.md +116 -0
- package/docs/recipe-ui-kit.md +172 -0
- package/docs/recipe-when-dependencies.md +158 -0
- package/package.json +10 -4
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,204 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as AnswerView } from "./answer-view-D6wnyThb.js";
|
|
2
|
+
import { AnswerChangeDetail, AnswerElementProps, CommandOutcome, ExportInput, ExportResult, ExtensionCommands, ExtensionEvents, ExtensionExporters, ExtensionImporters, ExtensionLogger, ExtensionModule, ExtensionNotification, ExtensionNotifications, ExtensionSchedule, ExtensionSecrets, ExtensionSettings, ExtensionStats, ExtensionStorage, GradePolicyInput, GradeResult, GradeValue, ImportInput, ImportResult, ImporterInputKind, JsonSchema, JsonValue, LearningEventName, LearningEventPayloads, LibraryReader, PanelContextInfo, PanelModule, SettingContribution, SettingValue, WidgetModule } from "@dolphy-app/extension-api";
|
|
2
3
|
//#region packages/extension-sdk/src/testing.d.ts
|
|
3
4
|
export declare const createMemoryLibrary: (files: Readonly<Record<string, string>>) => LibraryReader;
|
|
5
|
+
/**
|
|
6
|
+
* In-memory storage with the same limits and errors as the engine
|
|
7
|
+
* (`EXTENSION_STORAGE_LIMITS`, `StorageQuotaError`): values are stored as
|
|
8
|
+
* JSON text and returned as copies; on rejection nothing changes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createMemoryStorage: () => ExtensionStorage;
|
|
11
|
+
/** In-memory secrets for tests: `ExtensionSecrets` plus a switch that imitates a missing system key store. */
|
|
12
|
+
export interface MemorySecrets extends ExtensionSecrets {
|
|
13
|
+
/** Imitates the system key store becoming (un)available; stored values are kept. */
|
|
14
|
+
setAvailable(available: boolean): void;
|
|
15
|
+
}
|
|
16
|
+
export interface MemorySecretsOptions {
|
|
17
|
+
/** Default `true`; `false` imitates Linux `basic_text`, no key store, or an app that is not ready. */
|
|
18
|
+
available?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* In-memory secrets with the engine's limits and errors
|
|
22
|
+
* (`EXTENSION_SECRET_LIMITS`, `StorageQuotaError`, `SecretsUnavailableError`):
|
|
23
|
+
* without a key store `set` and `get` of an existing key throw, `get` of a
|
|
24
|
+
* missing key gives `undefined` and `delete` works.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createMemorySecrets: (options?: MemorySecretsOptions) => MemorySecrets;
|
|
27
|
+
export interface MemorySettings extends ExtensionSettings {
|
|
28
|
+
/**
|
|
29
|
+
* Changes the value as the user does in the dialog: the value is validated
|
|
30
|
+
* against the definition, and `onDidChange` subscribers are called if it changed.
|
|
31
|
+
* Unlike the host, a handler failure is not swallowed but rejects the promise.
|
|
32
|
+
*/
|
|
33
|
+
set(id: string, value: SettingValue): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** In-memory settings from manifest definitions; `initial` provides user values in place of `default`. */
|
|
36
|
+
export declare const createMemorySettings: (definitions: readonly SettingContribution[], initial?: Readonly<Record<string, SettingValue>>) => MemorySettings;
|
|
37
|
+
export interface MemoryEvents extends ExtensionEvents {
|
|
38
|
+
/**
|
|
39
|
+
* Sends the event to the subscribed handler and awaits it. With no subscription,
|
|
40
|
+
* the event is skipped, as in the host. Unlike the host, a handler failure
|
|
41
|
+
* is not swallowed but rejects the promise, and the 2 s handler timeout is not applied.
|
|
42
|
+
*/
|
|
43
|
+
emit<N extends LearningEventName>(name: N, payload: LearningEventPayloads[N]): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface MemoryEventsOptions {
|
|
46
|
+
/** Events from `contributes.events`: subscribing to another throws, as in the host. Unset — any are allowed. */
|
|
47
|
+
declared?: readonly LearningEventName[];
|
|
48
|
+
/** false — subscribing throws `PermissionError`, as for an extension without `learning.events`. Defaults to true. */
|
|
49
|
+
permitted?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** In-memory learning event subscriptions: one handler per event, as in the host. */
|
|
52
|
+
export declare const createMemoryEvents: (options?: MemoryEventsOptions) => MemoryEvents;
|
|
53
|
+
export interface MemoryCommands extends ExtensionCommands {
|
|
54
|
+
/**
|
|
55
|
+
* Runs a registered command the way the host does: the same
|
|
56
|
+
* argument and result bounds, the same result normalization. An unregistered
|
|
57
|
+
* command and an invalid result reject the promise. The 10 s handler timeout is not applied.
|
|
58
|
+
*/
|
|
59
|
+
run(id: string, args?: JsonValue): Promise<CommandOutcome>;
|
|
60
|
+
/** Registered commands in registration order. */
|
|
61
|
+
ids(): string[];
|
|
62
|
+
}
|
|
63
|
+
export interface MemoryCommandsOptions {
|
|
64
|
+
/** Commands from `contributes.commands`: registering another throws, as in the host. Unset — any are allowed. */
|
|
65
|
+
declaredCommands?: readonly string[];
|
|
66
|
+
/** Panels from `contributes.panels`: `openPanel` on another is invalid, as in the host. Unset — any. */
|
|
67
|
+
declaredPanels?: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/** In-memory commands: the same registration rules and result parsing as the host. */
|
|
70
|
+
export declare const createMemoryCommands: (options?: MemoryCommandsOptions) => MemoryCommands;
|
|
71
|
+
export interface MemorySchedule extends ExtensionSchedule {
|
|
72
|
+
/**
|
|
73
|
+
* Fires a schedule the way the host does and awaits the handler: resolves
|
|
74
|
+
* `true` once the handler returned. With no subscription, or while the
|
|
75
|
+
* handler of the previous firing is still running, the firing is skipped and
|
|
76
|
+
* resolves `false`. Unlike the host, a handler failure is not swallowed but
|
|
77
|
+
* rejects the promise, and the 10 s handler timeout is not applied.
|
|
78
|
+
*/
|
|
79
|
+
fire(id: string): Promise<boolean>;
|
|
80
|
+
/** Subscribed schedules in subscription order. */
|
|
81
|
+
ids(): string[];
|
|
82
|
+
}
|
|
83
|
+
export interface MemoryScheduleOptions {
|
|
84
|
+
/** Schedules from `contributes.schedules`: subscribing to another throws, as in the host. Unset — any are allowed. */
|
|
85
|
+
declared?: readonly string[];
|
|
86
|
+
}
|
|
87
|
+
/** In-memory schedule subscriptions: one handler per schedule and no overlapping firings, as in the host. */
|
|
88
|
+
export declare const createMemorySchedule: (options?: MemoryScheduleOptions) => MemorySchedule;
|
|
89
|
+
export interface MemoryImporters extends ExtensionImporters {
|
|
90
|
+
/**
|
|
91
|
+
* Runs a registered importer the way the host does: the input must have the
|
|
92
|
+
* form the importer declares (`text` unless `input: 'bytes'`) and at most
|
|
93
|
+
* `EXTENSION_TRANSFER_LIMITS.inputBytes`; the result goes through the host's
|
|
94
|
+
* rules (`normalizeImportResult`: paths, sizes, number of files). An
|
|
95
|
+
* unregistered importer and an invalid result reject the promise. The 30 s
|
|
96
|
+
* handler timeout is not applied.
|
|
97
|
+
*/
|
|
98
|
+
run(id: string, input: ImportInput): Promise<ImportResult>;
|
|
99
|
+
/** Registered importers in registration order. */
|
|
100
|
+
ids(): string[];
|
|
101
|
+
}
|
|
102
|
+
export interface MemoryImportersOptions {
|
|
103
|
+
/** Importers from `contributes.importers`: registering another throws and `input` is checked, as in the host. Unset — any are allowed. */
|
|
104
|
+
declaredImporters?: readonly {
|
|
105
|
+
id: string;
|
|
106
|
+
input?: ImporterInputKind;
|
|
107
|
+
}[];
|
|
108
|
+
}
|
|
109
|
+
/** In-memory importers: the same registration rules and result checks as the host. */
|
|
110
|
+
export declare const createMemoryImporters: (options?: MemoryImportersOptions) => MemoryImporters;
|
|
111
|
+
export interface MemoryExporters extends ExtensionExporters {
|
|
112
|
+
/**
|
|
113
|
+
* Runs a registered exporter the way the host does: the input must match the
|
|
114
|
+
* exporter's declared `scope` and a course snapshot is at most
|
|
115
|
+
* `EXTENSION_TRANSFER_LIMITS.totalBytes`; the result goes through the host's
|
|
116
|
+
* rules (`normalizeExportResult`: file name, size, `text` xor `bytes`). An
|
|
117
|
+
* unregistered exporter and an invalid result reject the promise. The 30 s
|
|
118
|
+
* handler timeout is not applied.
|
|
119
|
+
*/
|
|
120
|
+
run(id: string, input: ExportInput): Promise<ExportResult>;
|
|
121
|
+
/** Registered exporters in registration order. */
|
|
122
|
+
ids(): string[];
|
|
123
|
+
}
|
|
124
|
+
export interface MemoryExportersOptions {
|
|
125
|
+
/** Exporters from `contributes.exporters`: registering another throws and `scope` is checked, as in the host. Unset — any are allowed. */
|
|
126
|
+
declaredExporters?: readonly {
|
|
127
|
+
id: string;
|
|
128
|
+
scope: ExportInput['scope'];
|
|
129
|
+
}[];
|
|
130
|
+
}
|
|
131
|
+
/** In-memory exporters: the same registration rules and result checks as the host. */
|
|
132
|
+
export declare const createMemoryExporters: (options?: MemoryExportersOptions) => MemoryExporters;
|
|
133
|
+
export interface MemoryStatsAttempt {
|
|
134
|
+
/** When the attempt happened: epoch milliseconds, a `Date`, or an ISO-8601 string. */
|
|
135
|
+
at: number | Date | string;
|
|
136
|
+
/** Grade 1-5; 3 and higher counts as correct, as in the app. */
|
|
137
|
+
grade: number;
|
|
138
|
+
/** Course of the attempt, for the `courseId` filter. Without it the attempt belongs to no course. */
|
|
139
|
+
courseId?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface MemoryStatsOptions {
|
|
142
|
+
/** Attempts the statistics start with; more arrive through `record`. */
|
|
143
|
+
attempts?: readonly MemoryStatsAttempt[];
|
|
144
|
+
/** IANA time zone whose local days are counted. Defaults to the time zone of this process. */
|
|
145
|
+
timeZone?: string;
|
|
146
|
+
/** The current time, for the `current` streak. Defaults to `Date.now`. */
|
|
147
|
+
now?: () => number;
|
|
148
|
+
/** false — every call rejects with `PermissionError('learning.stats')`, as for an extension without the permission. Defaults to true. */
|
|
149
|
+
permitted?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface MemoryStats extends ExtensionStats {
|
|
152
|
+
/** Adds an attempt to the history. */
|
|
153
|
+
record(attempt: MemoryStatsAttempt): void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* In-memory statistics with the semantics of the app: local days in a time zone,
|
|
157
|
+
* correct at grade 3 or higher, `current` streak not broken while today has no
|
|
158
|
+
* attempts yet, one `daily` entry per date (at most `EXTENSION_STATS_LIMITS.dailyDays`).
|
|
159
|
+
*/
|
|
160
|
+
export declare const createMemoryStats: (options?: MemoryStatsOptions) => MemoryStats;
|
|
161
|
+
export interface MemoryNotificationsOptions {
|
|
162
|
+
/** false — every call rejects with `PermissionError('notifications')`, as for an extension without the permission. Defaults to true. */
|
|
163
|
+
permitted?: boolean;
|
|
164
|
+
/** false — the operating system does not support notifications: `show` resolves `false`. Defaults to true. */
|
|
165
|
+
supported?: boolean;
|
|
166
|
+
/** false — the user switched notifications off for the extension: `show` resolves `false`. Defaults to true. */
|
|
167
|
+
enabled?: boolean;
|
|
168
|
+
/** The current time for the rate windows. Defaults to `Date.now`. */
|
|
169
|
+
now?: () => number;
|
|
170
|
+
}
|
|
171
|
+
export interface MemoryNotifications extends ExtensionNotifications {
|
|
172
|
+
/** Notifications handed to the (imitated) operating system, oldest first, as the app shows them: sanitized text. */
|
|
173
|
+
readonly shown: readonly ExtensionNotification[];
|
|
174
|
+
/** The user's switch "Notifications" of the extension. */
|
|
175
|
+
setEnabled(enabled: boolean): void;
|
|
176
|
+
/** Whether the imitated operating system supports notifications. */
|
|
177
|
+
setSupported(supported: boolean): void;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* In-memory notifications with the engine's rules: the text is sanitized and
|
|
181
|
+
* limited, `perMinute`/`perHour` windows throw `NotificationRateLimitError`,
|
|
182
|
+
* a switched-off extension or an unsupporting system resolves `false` (and
|
|
183
|
+
* does not use the rate limit). `shown` is the log the app's fake notifier
|
|
184
|
+
* would keep.
|
|
185
|
+
*/
|
|
186
|
+
export declare const createMemoryNotifications: (options?: MemoryNotificationsOptions) => MemoryNotifications;
|
|
187
|
+
/** What a test replaces in the extension context; by default everything is in memory and silent. */
|
|
188
|
+
export interface LoadOptions {
|
|
189
|
+
library?: LibraryReader;
|
|
190
|
+
logger?: ExtensionLogger;
|
|
191
|
+
storage?: ExtensionStorage;
|
|
192
|
+
secrets?: ExtensionSecrets;
|
|
193
|
+
settings?: ExtensionSettings;
|
|
194
|
+
events?: ExtensionEvents;
|
|
195
|
+
commands?: ExtensionCommands;
|
|
196
|
+
importers?: ExtensionImporters;
|
|
197
|
+
exporters?: ExtensionExporters;
|
|
198
|
+
stats?: ExtensionStats;
|
|
199
|
+
notifications?: ExtensionNotifications;
|
|
200
|
+
schedule?: ExtensionSchedule;
|
|
201
|
+
}
|
|
4
202
|
export declare const createSchemaValidator: (schema: JsonSchema) => (value: unknown) => string[];
|
|
5
203
|
export interface LoadedExerciseType {
|
|
6
204
|
project(spec: unknown, options?: {
|
|
@@ -21,20 +219,141 @@ export interface LoadedExerciseType {
|
|
|
21
219
|
} | {
|
|
22
220
|
found: false;
|
|
23
221
|
}>;
|
|
24
|
-
/**
|
|
222
|
+
/** Deactivates the extension module. */
|
|
25
223
|
dispose(): Promise<void>;
|
|
26
224
|
}
|
|
27
|
-
export declare const loadExerciseType: (module: ExtensionModule, type: string, options?:
|
|
28
|
-
library?: LibraryReader;
|
|
29
|
-
logger?: ExtensionLogger;
|
|
30
|
-
}) => Promise<LoadedExerciseType>;
|
|
225
|
+
export declare const loadExerciseType: (module: ExtensionModule, type: string, options?: LoadOptions) => Promise<LoadedExerciseType>;
|
|
31
226
|
export interface LoadedGradePolicy {
|
|
32
227
|
evaluate(input: GradePolicyInput): Promise<GradeValue | null>;
|
|
33
|
-
/**
|
|
228
|
+
/** Deactivates the extension module. */
|
|
34
229
|
dispose(): Promise<void>;
|
|
35
230
|
}
|
|
36
|
-
export declare const loadGradePolicy: (module: ExtensionModule, id: string, options?:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
231
|
+
export declare const loadGradePolicy: (module: ExtensionModule, id: string, options?: LoadOptions) => Promise<LoadedGradePolicy>;
|
|
232
|
+
export interface LoadedEvents {
|
|
233
|
+
/** Events are delivered as in the host: to the subscribed handler, one at a time. See `MemoryEvents.emit`. */
|
|
234
|
+
emit: MemoryEvents['emit'];
|
|
235
|
+
storage: ExtensionStorage;
|
|
236
|
+
secrets: ExtensionSecrets;
|
|
237
|
+
settings: MemorySettings;
|
|
238
|
+
/** Deactivates the extension module. */
|
|
239
|
+
dispose(): Promise<void>;
|
|
240
|
+
}
|
|
241
|
+
export interface LoadEventsOptions extends Omit<LoadOptions, 'storage' | 'secrets' | 'settings' | 'events'>, MemoryEventsOptions {
|
|
242
|
+
storage?: ExtensionStorage;
|
|
243
|
+
secrets?: ExtensionSecrets;
|
|
244
|
+
/** Definitions from the manifest's `contributes.settings`; values are read and changed through `settings`. */
|
|
245
|
+
settings?: readonly SettingContribution[];
|
|
246
|
+
/** User values in place of `default`. */
|
|
247
|
+
settingValues?: Readonly<Record<string, SettingValue>>;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Activates the module with in-memory storage, settings, and events, and lets the test
|
|
251
|
+
* send events and change settings.
|
|
252
|
+
*/
|
|
253
|
+
export declare const loadEvents: (module: ExtensionModule, options?: LoadEventsOptions) => Promise<LoadedEvents>;
|
|
254
|
+
export interface LoadedCommands {
|
|
255
|
+
run: MemoryCommands['run'];
|
|
256
|
+
ids: MemoryCommands['ids'];
|
|
257
|
+
/** Deactivates the extension module. */
|
|
258
|
+
dispose(): Promise<void>;
|
|
259
|
+
}
|
|
260
|
+
export interface LoadCommandsOptions extends Omit<LoadOptions, 'commands'>, MemoryCommandsOptions {}
|
|
261
|
+
/** Activates the module with in-memory commands and lets the test invoke them like the host. */
|
|
262
|
+
export declare const loadCommands: (module: ExtensionModule, options?: LoadCommandsOptions) => Promise<LoadedCommands>;
|
|
263
|
+
export interface LoadedImporters {
|
|
264
|
+
run: MemoryImporters['run'];
|
|
265
|
+
ids: MemoryImporters['ids'];
|
|
266
|
+
/** Deactivates the extension module. */
|
|
267
|
+
dispose(): Promise<void>;
|
|
268
|
+
}
|
|
269
|
+
export interface LoadImportersOptions extends Omit<LoadOptions, 'importers'>, MemoryImportersOptions {}
|
|
270
|
+
/** Activates the module with in-memory importers and lets the test run them like the host. */
|
|
271
|
+
export declare const loadImporters: (module: ExtensionModule, options?: LoadImportersOptions) => Promise<LoadedImporters>;
|
|
272
|
+
export interface LoadedExporters {
|
|
273
|
+
run: MemoryExporters['run'];
|
|
274
|
+
ids: MemoryExporters['ids'];
|
|
275
|
+
/** Deactivates the extension module. */
|
|
276
|
+
dispose(): Promise<void>;
|
|
277
|
+
}
|
|
278
|
+
export interface LoadExportersOptions extends Omit<LoadOptions, 'exporters'>, MemoryExportersOptions {}
|
|
279
|
+
/** Activates the module with in-memory exporters and lets the test run them like the host; `stats` feeds `ctx.stats` of a progress exporter. */
|
|
280
|
+
export declare const loadExporters: (module: ExtensionModule, options?: LoadExportersOptions) => Promise<LoadedExporters>;
|
|
281
|
+
export interface LoadedSchedules {
|
|
282
|
+
fire: MemorySchedule['fire'];
|
|
283
|
+
ids: MemorySchedule['ids'];
|
|
284
|
+
/** Deactivates the extension module. */
|
|
285
|
+
dispose(): Promise<void>;
|
|
286
|
+
}
|
|
287
|
+
export interface LoadSchedulesOptions extends Omit<LoadOptions, 'schedule'>, MemoryScheduleOptions {}
|
|
288
|
+
/** Activates the module with in-memory schedules and lets the test fire them like the host. */
|
|
289
|
+
export declare const loadSchedules: (module: ExtensionModule, options?: LoadSchedulesOptions) => Promise<LoadedSchedules>;
|
|
290
|
+
export interface LoadViewOptions extends Partial<AnswerElementProps> {
|
|
291
|
+
/** `aria-label` of the host element, as the app sets it. */
|
|
292
|
+
label?: string;
|
|
293
|
+
/** Where to mount; defaults to a new `div` in `document.body`. */
|
|
294
|
+
container?: HTMLElement;
|
|
295
|
+
}
|
|
296
|
+
export interface LoadedView {
|
|
297
|
+
/** The kind's custom element, as the app creates it. */
|
|
298
|
+
readonly element: HTMLElement;
|
|
299
|
+
/** The element's shadow root: the view renders its UI here. */
|
|
300
|
+
readonly root: ShadowRoot;
|
|
301
|
+
/** `dolphy-answer-change` events in order. */
|
|
302
|
+
readonly changes: readonly AnswerChangeDetail[];
|
|
303
|
+
/** How many times the view asked to submit the answer (`dolphy-answer-submit`). */
|
|
304
|
+
readonly submissions: number;
|
|
305
|
+
/** Sets element properties and waits for the view to apply the update. */
|
|
306
|
+
update(props: Partial<AnswerElementProps>): Promise<void>;
|
|
307
|
+
query<E extends Element = Element>(selector: string): E | null;
|
|
308
|
+
queryAll<E extends Element = Element>(selector: string): E[];
|
|
309
|
+
/** Removes the element from the document; the view receives `destroy()`. */
|
|
310
|
+
dispose(): void;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Mounts a view from `views[id]` in the test DOM environment with the same element
|
|
314
|
+
* the app creates (test tags are issued; the manifest `element` is not needed).
|
|
315
|
+
*/
|
|
316
|
+
export declare const loadView: (views: Readonly<Record<string, AnswerView>>, id: string, options?: LoadViewOptions) => Promise<LoadedView>;
|
|
317
|
+
export interface LoadPanelOptions {
|
|
318
|
+
/** Properties the panel was opened with (`openPanel(id, props)`). */
|
|
319
|
+
props?: JsonValue;
|
|
320
|
+
/** Reply to `ctx.call`; by default the call is rejected. */
|
|
321
|
+
call?: (commandId: string, args: JsonValue | undefined) => JsonValue | undefined | Promise<JsonValue | undefined>;
|
|
322
|
+
/** The surroundings the frame starts with (`ctx.context`); defaults to all courses (`courseId: null`). */
|
|
323
|
+
context?: PanelContextInfo;
|
|
324
|
+
/** Where to mount; defaults to a new `div` in `document.body`. */
|
|
325
|
+
container?: HTMLElement;
|
|
326
|
+
}
|
|
327
|
+
export interface LoadWidgetOptions {
|
|
328
|
+
/** Reply to `ctx.call`; by default the call is rejected. */
|
|
329
|
+
call?: LoadPanelOptions['call'];
|
|
330
|
+
/** The surroundings the frame starts with (`ctx.context`); defaults to all courses (`courseId: null`). */
|
|
331
|
+
context?: PanelContextInfo;
|
|
332
|
+
/** Where to mount; defaults to a new `div` in `document.body`. */
|
|
333
|
+
container?: HTMLElement;
|
|
334
|
+
}
|
|
335
|
+
export interface LoadedFrame {
|
|
336
|
+
/** Container the module received in `mount`. */
|
|
337
|
+
readonly container: HTMLElement;
|
|
338
|
+
/** `ctx.call` invocations in order. */
|
|
339
|
+
readonly calls: readonly {
|
|
340
|
+
commandId: string;
|
|
341
|
+
args: JsonValue | undefined;
|
|
342
|
+
}[];
|
|
343
|
+
/** Whether `ctx.signal` was aborted (after `dispose()`). */
|
|
344
|
+
readonly aborted: boolean;
|
|
345
|
+
/** The app focused another course: updates `ctx.context` and notifies `ctx.onContextChange` subscribers. */
|
|
346
|
+
setContext(context: PanelContextInfo): void;
|
|
347
|
+
/** Closes the frame: aborts `ctx.signal` and removes the container. */
|
|
348
|
+
dispose(): void;
|
|
349
|
+
}
|
|
350
|
+
export interface LoadedPanel extends LoadedFrame {
|
|
351
|
+
/** Sends new properties to the panel (`ctx.onProps`). */
|
|
352
|
+
setProps(props: JsonValue | undefined): void;
|
|
353
|
+
}
|
|
354
|
+
export type LoadedWidget = LoadedFrame;
|
|
355
|
+
/** Mounts a panel from `panels[id]` in the test DOM environment with the same context the frame provides. */
|
|
356
|
+
export declare const loadPanel: (panels: Readonly<Record<string, PanelModule<HTMLElement>>>, id: string, options?: LoadPanelOptions) => Promise<LoadedPanel>;
|
|
357
|
+
/** Mounts a widget from `widgets[id]` in the test DOM environment with the same context the frame provides. */
|
|
358
|
+
export declare const loadWidget: (widgets: Readonly<Record<string, WidgetModule<HTMLElement>>>, id: string, options?: LoadWidgetOptions) => Promise<LoadedWidget>;
|
|
40
359
|
//#endregion
|