@edgestation/sdk 0.4.0 → 0.6.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 CHANGED
@@ -33,12 +33,15 @@ my-widget/
33
33
  "name": "My widget",
34
34
  "minAppVersion": "0.1.0",
35
35
  "main": "dist/main.js",
36
- "size": { "w": 2, "h": 1 }
36
+ "size": { "w": 2, "h": 1 },
37
+ "permissions": ["system"]
37
38
  }
38
39
  ```
39
40
 
40
41
  `minAppVersion` is the oldest EdgeStation that can run the widget: set it to the version of this package you build with (they are released together), and older apps show an error card instead of a broken widget.
41
42
 
43
+ `permissions` lists the parts of the `api` the widget uses. The examples below call `api.system()`, so they need `system`.
44
+
42
45
  ### Plain JavaScript or TypeScript
43
46
 
44
47
  ```js
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { WidgetModule } from './types.js';
2
2
  export type * from './types.js';
3
3
  /**
4
- * Types a widget's default export, so editors know `el` and `api` without annotations, in
5
- * plain JavaScript too:
4
+ * Gives the types to the default export of a widget. Editors then know `el` and `api` without
5
+ * annotations, also in plain JavaScript:
6
6
  *
7
7
  * ```js
8
8
  * export default defineWidget({
@@ -12,6 +12,6 @@ export type * from './types.js';
12
12
  * });
13
13
  * ```
14
14
  *
15
- * Returns `widget` unchanged: the host only needs the object.
15
+ * Returns `widget` with no change. The host only needs the object.
16
16
  */
17
17
  export declare function defineWidget(widget: WidgetModule): WidgetModule;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Types a widget's default export, so editors know `el` and `api` without annotations, in
3
- * plain JavaScript too:
2
+ * Gives the types to the default export of a widget. Editors then know `el` and `api` without
3
+ * annotations, also in plain JavaScript:
4
4
  *
5
5
  * ```js
6
6
  * export default defineWidget({
@@ -10,7 +10,7 @@
10
10
  * });
11
11
  * ```
12
12
  *
13
- * Returns `widget` unchanged: the host only needs the object.
13
+ * Returns `widget` with no change. The host only needs the object.
14
14
  */
15
15
  export function defineWidget(widget) {
16
16
  return widget;
package/dist/react.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { type ComponentType } from 'react';
2
2
  import type { WidgetModule, WidgetProps } from './types.js';
3
3
  /**
4
- * Makes a widget out of a React component: `export default reactWidget(Clock)`. The component
5
- * is rendered in a React root on the widget's root with the `api` as its prop, and the root is
6
- * unmounted with the widget.
4
+ * Makes a widget from a React component: `export default reactWidget(Clock)`. The adapter
5
+ * renders the component in a React root on the root of the widget, with the `api` as its prop.
6
+ * It unmounts the React root when the widget unmounts.
7
7
  *
8
- * With React 19, an error thrown while rendering that no error boundary of yours catches shows
9
- * the widget's error card.
8
+ * With React 19, the widget shows its error card when the component throws an error in render
9
+ * and none of your error boundaries catches it.
10
10
  */
11
11
  export declare function reactWidget(component: ComponentType<WidgetProps>): WidgetModule;
package/dist/react.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { createElement } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
- import { report } from './report.js';
3
+ import { report } from './report-error.js';
4
4
  /**
5
- * Makes a widget out of a React component: `export default reactWidget(Clock)`. The component
6
- * is rendered in a React root on the widget's root with the `api` as its prop, and the root is
7
- * unmounted with the widget.
5
+ * Makes a widget from a React component: `export default reactWidget(Clock)`. The adapter
6
+ * renders the component in a React root on the root of the widget, with the `api` as its prop.
7
+ * It unmounts the React root when the widget unmounts.
8
8
  *
9
- * With React 19, an error thrown while rendering that no error boundary of yours catches shows
10
- * the widget's error card.
9
+ * With React 19, the widget shows its error card when the component throws an error in render
10
+ * and none of your error boundaries catches it.
11
11
  */
12
12
  export function reactWidget(component) {
13
13
  return {
@@ -0,0 +1,6 @@
1
+ import type { WidgetApi } from './types.js';
2
+ /**
3
+ * Shows `error` on the error card of the widget. The API has no direct call for this, so a
4
+ * guarded callback throws the error.
5
+ */
6
+ export declare function report(api: WidgetApi, error: unknown): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shows `error` on the error card of the widget. The API has no direct call for this, so a
3
+ * guarded callback throws the error.
4
+ */
5
+ export function report(api, error) {
6
+ api.guard(() => {
7
+ throw error;
8
+ })();
9
+ }
package/dist/svelte.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { type Component } from 'svelte';
2
2
  import type { WidgetModule, WidgetProps } from './types.js';
3
3
  /**
4
- * Makes a widget out of a Svelte 5 component: `export default svelteWidget(Clock)`. The
5
- * component is mounted in the widget's root with the `api` as its prop, and unmounted with
6
- * the widget.
4
+ * Makes a widget from a Svelte 5 component: `export default svelteWidget(Clock)`. The adapter
5
+ * mounts the component in the root of the widget with the `api` as its prop, and unmounts it
6
+ * with the widget.
7
7
  *
8
- * Its `<style>` blocks reach the widget's shadow root when the component is compiled with
9
- * injected CSS (`svelte({ emitCss: false })` in the Vite config). Errors thrown while Svelte
10
- * draws don't show the error card; errors in callbacks wrapped with `api.guard`,
11
- * `api.every` or `api.after` do.
8
+ * The `<style>` blocks of the component get into the shadow root of the widget only if you
9
+ * compile it with injected CSS. For this, use `svelte({ emitCss: false })` in the Vite config.
10
+ * An error that the component throws when Svelte draws it does not show the error card. An
11
+ * error in a callback that `api.guard`, `api.every` or `api.after` wraps shows it.
12
12
  */
13
13
  export declare function svelteWidget(component: Component<WidgetProps>): WidgetModule;
package/dist/svelte.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { mount, unmount } from 'svelte';
2
2
  /**
3
- * Makes a widget out of a Svelte 5 component: `export default svelteWidget(Clock)`. The
4
- * component is mounted in the widget's root with the `api` as its prop, and unmounted with
5
- * the widget.
3
+ * Makes a widget from a Svelte 5 component: `export default svelteWidget(Clock)`. The adapter
4
+ * mounts the component in the root of the widget with the `api` as its prop, and unmounts it
5
+ * with the widget.
6
6
  *
7
- * Its `<style>` blocks reach the widget's shadow root when the component is compiled with
8
- * injected CSS (`svelte({ emitCss: false })` in the Vite config). Errors thrown while Svelte
9
- * draws don't show the error card; errors in callbacks wrapped with `api.guard`,
10
- * `api.every` or `api.after` do.
7
+ * The `<style>` blocks of the component get into the shadow root of the widget only if you
8
+ * compile it with injected CSS. For this, use `svelte({ emitCss: false })` in the Vite config.
9
+ * An error that the component throws when Svelte draws it does not show the error card. An
10
+ * error in a callback that `api.guard`, `api.every` or `api.after` wraps shows it.
11
11
  */
12
12
  export function svelteWidget(component) {
13
13
  return {
@@ -0,0 +1,28 @@
1
+ /** The apps in the All apps list of the Start menu, which is the Apps folder of the shell. */
2
+ export interface AppsApi {
3
+ /** All apps in name order. The host reads them when you call this function. */
4
+ list(): Promise<AppInfo[]>;
5
+ /**
6
+ * Starts the app `id` as the Start menu does. It asks for the app window on the main screen,
7
+ * not on the Edge. An app that keeps its last position can still open there. Rejects if the
8
+ * app is gone.
9
+ */
10
+ launch(id: string): Promise<void>;
11
+ /**
12
+ * The URL of the icon of the app `id`, for an `<img>`. The icon is a square PNG of `size`
13
+ * pixels (16 to 256, default 64). Ask for the size that it shows at, in device pixels. Icons
14
+ * at a larger size are sharper.
15
+ */
16
+ icon(id: string, size?: number): string;
17
+ }
18
+ /** An app as the Start menu lists it. */
19
+ export interface AppInfo {
20
+ /**
21
+ * The value that launches the app and draws its icon. It is the name of the app in the Apps
22
+ * folder of the shell. This is the AppUserModelID of the app or, for a program without one,
23
+ * a path to the program. It stays the same across restarts, so widgets can save it.
24
+ */
25
+ id: string;
26
+ /** The name that the Start menu shows. */
27
+ name: string;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,118 @@
1
+ import type { Cleanup } from '../cleanup.js';
2
+ /**
3
+ * The sound of the machine, as the Windows volume mixer shows it. Nothing listens between
4
+ * calls.
5
+ */
6
+ export interface AudioApi {
7
+ /**
8
+ * The default output and microphone, and the apps on that output. The host reads them when
9
+ * you call this function.
10
+ */
11
+ mixer(): Promise<AudioMixer>;
12
+ /** How loud the default output, the microphone and each app are now. */
13
+ levels(): Promise<AudioLevels>;
14
+ /**
15
+ * Calls `fn` when the mixer changes: a volume, a mute, the default device, or the sound of an
16
+ * app when it opens, closes, starts or stops. Then read `mixer()`. Windows tells the app
17
+ * about changes, so nothing polls. While the page of the widget is off screen or the Edge is
18
+ * frozen, it waits and calls `fn` once when the widget shows again. It stops on unmount, and
19
+ * the returned function stops it earlier.
20
+ */
21
+ onChange(fn: () => unknown): Cleanup;
22
+ /**
23
+ * Calls `fn` with the levels 25 times a second while there is sound, and for two seconds
24
+ * after, so meters can fall. Then it does not call `fn` until there is sound again. New sound
25
+ * shows within a quarter of a second. It calls `fn` only while the page of the widget shows
26
+ * and the Edge is not frozen. It stops on unmount, and the returned function stops it earlier.
27
+ */
28
+ onLevels(fn: (levels: AudioLevels) => unknown): Cleanup;
29
+ /**
30
+ * Sets the volume of `target`, from 0 to 1. It clamps values outside this range. Resolves to
31
+ * `false` if `target` is gone: the app closed, or the device is not there anymore.
32
+ */
33
+ setVolume(target: AudioTarget, volume: number): Promise<boolean>;
34
+ /**
35
+ * Mutes or unmutes `target`, like `setVolume`. For `'input'`, it mutes the default
36
+ * microphone. If the default microphone for calls is a different device, it mutes it too.
37
+ */
38
+ setMuted(target: AudioTarget, muted: boolean): Promise<boolean>;
39
+ /**
40
+ * The output devices that are plugged in and enabled, in name order. The host reads them when
41
+ * you call this function.
42
+ */
43
+ outputs(): Promise<AudioOutput[]>;
44
+ /**
45
+ * Makes the output `id` the default output, as "Set as default device" in Sound settings
46
+ * does. Calls keep the device that the user selected for them. Resolves to `false` if the
47
+ * device is not plugged in anymore. Windows has no public API for this, so it uses the API
48
+ * of Sound settings.
49
+ */
50
+ setOutput(id: string): Promise<boolean>;
51
+ /**
52
+ * The URL of the icon of the executable of an app (`AudioApp.path`), for an `<img>`. The icon
53
+ * is a square PNG of `size` pixels (16 to 256, default 64).
54
+ */
55
+ icon(path: string, size?: number): string;
56
+ }
57
+ /** What `setVolume` and `setMuted` change: the default output, the microphone, or an app `id`. */
58
+ export type AudioTarget = 'output' | 'input' | (string & {});
59
+ export interface AudioMixer {
60
+ /** The default output, which the volume flyout shows. `null` if there is none. */
61
+ output: AudioDevice | null;
62
+ /**
63
+ * The default microphone. `null` if there is none. `muted` is `true` only if the default
64
+ * microphone for calls is also muted.
65
+ */
66
+ input: AudioDevice | null;
67
+ /** The apps with a sound session on the default output, in name order, System sounds last. */
68
+ apps: AudioApp[];
69
+ }
70
+ /** A sound device. */
71
+ export interface AudioDevice {
72
+ /** The Windows id of the device, as `outputs()` lists it. */
73
+ id: string;
74
+ /** The name that Sound settings shows, such as `Speakers (Realtek(R) Audio)`. */
75
+ name: string;
76
+ /** From 0 to 1, as the volume flyout shows it. */
77
+ volume: number;
78
+ muted: boolean;
79
+ }
80
+ /** The sound of an app: all the sessions that the Windows volume mixer shows as one. */
81
+ export interface AudioApp {
82
+ /**
83
+ * Identifies the sound of the app while it runs, for `setVolume` and `levels()`. It does not
84
+ * stay the same across restarts.
85
+ */
86
+ id: string;
87
+ /**
88
+ * The name that the app gives its sound. Else, the name that Task Manager shows, which is the
89
+ * description of its executable. Else, the file name of its executable.
90
+ */
91
+ name: string;
92
+ /** The path of its executable, for `icon()`. `null` for System sounds. */
93
+ path: string | null;
94
+ /**
95
+ * The file name of its executable, such as `Discord.exe`. It identifies the app across
96
+ * restarts and updates, so save this value. The folder of the app can change with them.
97
+ * `null` for System sounds.
98
+ */
99
+ program: string | null;
100
+ /** From 0 to 1, as a part of the output volume. */
101
+ volume: number;
102
+ muted: boolean;
103
+ /** `true` if the app plays sound now, `false` if it is open and silent. */
104
+ active: boolean;
105
+ }
106
+ /** The peak levels of the last few milliseconds, from 0 to 1. */
107
+ export interface AudioLevels {
108
+ output: number;
109
+ /** The default microphone while an app records from it. 0 at other times. */
110
+ input: number;
111
+ /** By app `id`. */
112
+ apps: Record<string, number>;
113
+ }
114
+ /** An output device that `setOutput` can switch to. */
115
+ export interface AudioOutput {
116
+ id: string;
117
+ name: string;
118
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ export interface MediaApi {
2
+ /** The session that Windows thinks is current, which the media keys control. `null` if none. */
3
+ current(): Promise<MediaInfo | null>;
4
+ /** The album art of the track from the last `current()` call, as a data URL. `null` if none. */
5
+ art(): Promise<string | null>;
6
+ /** Asks the app of the current session to play, pause or skip. Resolves `false` if it refused. */
7
+ control(action: MediaAction): Promise<boolean>;
8
+ }
9
+ export type MediaAction = 'play' | 'pause' | 'next' | 'previous';
10
+ /**
11
+ * A media session, as an app publishes it to Windows. The fields that the app does not set are
12
+ * empty.
13
+ */
14
+ export interface MediaInfo {
15
+ /** The app that owns the session, as Windows names it (`Spotify.exe`, `MSEdge`, ...). */
16
+ app: string;
17
+ title: string;
18
+ artist: string;
19
+ album: string;
20
+ playing: boolean;
21
+ /**
22
+ * The position in the track at the time of the call, in seconds. `null` if the app gives no
23
+ * timeline. Some apps clear it, for example Zen and Firefox about once a minute. Then it
24
+ * continues from the last position, if calls come at least every 5 seconds.
25
+ */
26
+ position: number | null;
27
+ duration: number | null;
28
+ /** Changes each time the album art changes. Then call `art()`. `null` if there is no art. */
29
+ art: number | null;
30
+ /** The `control()` actions that the app accepts now. */
31
+ can: Record<MediaAction, boolean>;
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /** Where a widget saves data. Select the scope that fits each value. */
2
+ export interface StorageApi {
3
+ /** Shared by all placements of this widget. */
4
+ readonly widget: WidgetStorage;
5
+ /** Only for this placement. Other copies of the widget do not see it. */
6
+ readonly instance: WidgetStorage;
7
+ }
8
+ /** Saved data: JSON values by key. The host writes them to disk shortly after each change. */
9
+ export interface WidgetStorage {
10
+ /** The value saved under `key`. `undefined` if there is none. */
11
+ get<T = unknown>(key: string): Promise<T | undefined>;
12
+ /** Saves `value` under `key` and replaces the previous value. JSON must be able to hold it. */
13
+ set(key: string, value: unknown): Promise<void>;
14
+ /** Removes `key`. Resolves `true` if it had a value. */
15
+ delete(key: string): Promise<boolean>;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ /** Network throughput in bytes per second. */
2
+ export interface NetRate {
3
+ down: number;
4
+ up: number;
5
+ }
6
+ /**
7
+ * The performance of the machine at the time of the call. The host measures the CPU load and
8
+ * network speeds since the previous call from any widget. Calls less than 500 ms apart share
9
+ * one reading.
10
+ */
11
+ export interface SystemInfo {
12
+ hostname: string;
13
+ /** The name of the connected Wi-Fi network (its Windows profile name). `null` if none. */
14
+ wifi: string | null;
15
+ /** The load of all CPU cores, in percent. */
16
+ cpu: {
17
+ load: number;
18
+ };
19
+ /** The first NVIDIA GPU (load in percent, temperature in °C). `null` if there is none. */
20
+ gpu: {
21
+ load: number;
22
+ temperature: number;
23
+ } | null;
24
+ /**
25
+ * The rate since the previous call, and the averages over the calls of the last 1, 5 and 15
26
+ * minutes. An average covers its full period while widgets continue to ask. It covers less
27
+ * time just after they start or resume.
28
+ */
29
+ net: NetRate & {
30
+ avg1m: NetRate;
31
+ avg5m: NetRate;
32
+ avg15m: NetRate;
33
+ };
34
+ }
35
+ /** The CPU use of a program: the sum of all processes that show the same name. */
36
+ export interface ProgramUsage {
37
+ /**
38
+ * The name that Task Manager shows. This is the description of its executable (`THE FINALS`,
39
+ * `Google Chrome`), else the executable file name (`crashpad_handler.exe`).
40
+ */
41
+ name: string;
42
+ /** The percent of all logical processors, as in Task Manager. */
43
+ cpu: number;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /** How `api.webview` opens its page. */
2
+ export interface WebviewOptions {
3
+ /**
4
+ * Shows the view to sites as Chrome on a phone, with the user agent and client hints. This
5
+ * applies to each page that the view loads. Sites that select their layout from the browser
6
+ * then serve their mobile layout. Sites that only follow the width fit the cell in both cases.
7
+ */
8
+ mobile?: boolean;
9
+ /**
10
+ * Shows a round Home button over the bottom right corner of the view, above the keyboard
11
+ * button. The button shows while the view is away from `url`, and takes the view back there.
12
+ * The view leaves a hole for it, because the button is an element in the root of the widget,
13
+ * like the picture. A page that `url` redirects to when it loads counts as `url`.
14
+ */
15
+ homeButton?: boolean;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ import type { AppsApi } from './api/apps.js';
2
+ import type { AudioApi } from './api/audio.js';
3
+ import type { MediaApi } from './api/media.js';
4
+ import type { StorageApi } from './api/storage.js';
5
+ import type { ProgramUsage, SystemInfo } from './api/system.js';
6
+ import type { WebviewOptions } from './api/webview.js';
7
+ import type { Cleanup } from './cleanup.js';
8
+ import type { WidgetManifest } from './manifest.js';
9
+ import type { WidgetSettingValues } from './settings.js';
10
+ /**
11
+ * What a widget gets from the host. It is small on purpose, because the full API is not
12
+ * designed yet. When the widget unmounts, the host releases all that the widget registered here.
13
+ * The members marked "Needs" work only if the `permissions` of the manifest list that
14
+ * permission. Else a call shows the error card and throws.
15
+ */
16
+ export interface WidgetApi {
17
+ /** The id of this placement. Two copies of a widget get different ids. */
18
+ readonly instanceId: string;
19
+ readonly manifest: WidgetManifest;
20
+ /**
21
+ * The settings of this placement. It has each key that the manifest declares, with its
22
+ * default if the user did not set it. The host mounts the widget again when the user
23
+ * changes a setting.
24
+ */
25
+ readonly settings: Readonly<WidgetSettingValues>;
26
+ /**
27
+ * The performance of the machine, read when you call it. Nothing monitors between calls.
28
+ * Needs `system`.
29
+ */
30
+ system(): Promise<SystemInfo>;
31
+ /**
32
+ * The programs that used the most CPU since the previous call from any widget, busiest
33
+ * first. It gives `count` programs at most, or fewer if fewer programs used the CPU. The
34
+ * host reads them when you call it. Needs `system`.
35
+ */
36
+ topPrograms(count: number): Promise<ProgramUsage[]>;
37
+ /**
38
+ * The media that plays on the machine, read when you call it, and its playback controls.
39
+ * Needs `media`.
40
+ */
41
+ readonly media: MediaApi;
42
+ /**
43
+ * The apps of the Start menu. It lists them when you call it, starts them and gives their
44
+ * icons. Needs `apps`.
45
+ */
46
+ readonly apps: AppsApi;
47
+ /**
48
+ * The sound of the machine, as the volume mixer shows it. This is the default output and
49
+ * microphone, the apps that play sound, their volumes and how loud they are. The host reads
50
+ * and changes these values when you call it. Needs `audio`.
51
+ */
52
+ readonly audio: AudioApi;
53
+ /**
54
+ * The web `fetch`, but the app sends the request, not the Edge page. Thus CORS does not
55
+ * apply, and any `http` or `https` URL answers as it would answer a server. You cannot set
56
+ * the headers that browsers forbid (`Cookie`, `Origin`, `Referer`, ...). The app keeps the
57
+ * cookies that sites set across restarts, and all widgets share them. If a request has no
58
+ * answer when the widget unmounts, the app cancels it. Needs `fetch`.
59
+ */
60
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
61
+ /**
62
+ * Data that stays across remounts and restarts. All placements of the widget share it, or
63
+ * this placement owns it. The host never deletes data in it automatically.
64
+ */
65
+ readonly storage: StorageApi;
66
+ /** The URL of a file in the widget folder (images, data, ...). */
67
+ asset(path: string): string;
68
+ /** Wraps a callback. If the callback throws an error, the error card of this widget shows it. */
69
+ guard<A extends unknown[]>(fn: (...args: A) => unknown): (...args: A) => void;
70
+ /**
71
+ * Tells the host that the widget loads data until `task` settles, and returns `task`. Until
72
+ * the first load ends, three dots show in the middle of the card and the widget stays hidden.
73
+ * Then the widget fades in. Each later load shows a bar at the top of the card. Loads that
74
+ * run at the same time show one indicator. Put all of the first load in one call, else the
75
+ * widget shows before it is ready. The page loads of `webview` count as loads too.
76
+ */
77
+ loading<T>(task: Promise<T>): Promise<T>;
78
+ /**
79
+ * A guarded `setInterval` that the host clears when the widget unmounts. It stops while the
80
+ * page of the widget is off screen or the Edge is frozen. The Edge is frozen when another
81
+ * app is full screen. When it starts again, it ticks immediately. Returns a function that
82
+ * stops it earlier.
83
+ */
84
+ every(ms: number, fn: () => unknown): Cleanup;
85
+ /**
86
+ * A guarded `setTimeout` that the host clears if the widget unmounts first. It waits while
87
+ * the page of the widget is off screen. If its time came in that period, it fires when the
88
+ * page is back. Unlike `every`, it still fires while the Edge is frozen. Returns a function
89
+ * that cancels it.
90
+ */
91
+ after(ms: number, fn: () => unknown): Cleanup;
92
+ /**
93
+ * Shows the web page `url` in a native browser view that lies over `target` and gets the
94
+ * touches there, for sites that refuse an iframe. The view is above the Edge, so it hides
95
+ * while pages slide and while `target` is not fully on screen. At these times, after its
96
+ * first show, a picture of it covers `target` (an `<img>` in the root of the widget). Its page
97
+ * loads show on the card as `loading` shows them. It opens the first time `target` is fully on
98
+ * screen, so a view on a page that nobody visits costs nothing. It stays hidden until its
99
+ * first page loads, so the dots show in place of a blank page. It uses the browser profile
100
+ * from the placement settings, Default if the user selects no other, and sign-ins in it stay
101
+ * across restarts. Needs `webview`. The host closes it when the widget unmounts, and the
102
+ * returned function closes it earlier.
103
+ */
104
+ webview(target: HTMLElement, url: string, options?: WebviewOptions): Cleanup;
105
+ /**
106
+ * Replaces the native scrollbars of `viewport` with the overlay scrollbars of the app.
107
+ * `viewport` is an element of the widget that scrolls, and the overlay scrollbars show while
108
+ * it scrolls. The app draws them in the parent of `viewport`, so put `viewport` in an element
109
+ * of its own. This parent takes the place of `viewport` in the layout, and `viewport` fills
110
+ * it. The host removes them when the widget unmounts, and the returned function removes them
111
+ * earlier.
112
+ */
113
+ scrollbars(viewport: HTMLElement): Cleanup;
114
+ /** Runs `fn` when the widget unmounts. */
115
+ onDispose(fn: Cleanup): void;
116
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type Cleanup = () => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { WidgetSetting } from './settings.js';
2
+ /**
3
+ * A part of `api` that a widget must ask for in `permissions`. `system` also gives
4
+ * `topPrograms`. The other members of `api` need no permission.
5
+ */
6
+ export type WidgetPermission = 'system' | 'media' | 'apps' | 'audio' | 'fetch' | 'webview';
7
+ /**
8
+ * The contents of the `manifest.json` of a widget, as the host gives it to the widget in
9
+ * `api.manifest`. The file does not contain `id`. The host sets `id` to the folder name of the
10
+ * widget.
11
+ */
12
+ export interface WidgetManifest {
13
+ id: string;
14
+ name: string;
15
+ version?: string;
16
+ description?: string;
17
+ author?: string;
18
+ /**
19
+ * The oldest EdgeStation version that the widget runs on, such as `"0.1.0"`. This is the
20
+ * version whose `api` the widget uses. Older versions show the error card of the widget and
21
+ * do not load it.
22
+ */
23
+ minAppVersion?: string;
24
+ /** The entry module, relative to the widget folder. The default is `main.js`. */
25
+ main?: string;
26
+ /** A stylesheet that the host loads into the shadow root of the widget. */
27
+ styles?: string;
28
+ /**
29
+ * An image that settings show next to the name of the widget, relative to the widget folder.
30
+ * Only its shape is important, because the host draws it in the accent color.
31
+ */
32
+ icon?: string;
33
+ /** The default size in grid cells when the user adds the widget to a page. */
34
+ size?: {
35
+ w: number;
36
+ h: number;
37
+ };
38
+ /** The options that the user can set for each placement, in display order. */
39
+ settings?: WidgetSetting[];
40
+ /**
41
+ * The parts of `api` that the widget uses. The marketplace tells the user what each one lets
42
+ * the widget do before the install, and before an update that adds one. A call to a part that
43
+ * is not in this list shows the error card and throws. `webview` also adds a Profile choice to
44
+ * the settings of the widget.
45
+ */
46
+ permissions?: WidgetPermission[];
47
+ }
@@ -0,0 +1 @@
1
+ export {};