@swipt/api 0.1.0-nightly.9 → 0.1.0-nightly.90
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 +1 -1
- package/accessibility.d.ts +97 -29
- package/accessibility.mjs +5 -2
- package/app-intents.d.ts +127 -0
- package/app-intents.mjs +11 -0
- package/device.d.ts +38 -8
- package/device.mjs +5 -3
- package/file-system.d.ts +14 -1
- package/file-system.mjs +1 -0
- package/http.d.ts +46 -0
- package/http.mjs +8 -0
- package/image.d.ts +61 -17
- package/image.mjs +3 -1
- package/index.d.ts +30 -9
- package/index.mjs +7 -1
- package/input.d.ts +41 -9
- package/input.mjs +3 -1
- package/localization.d.ts +3 -0
- package/localization.mjs +7 -0
- package/maps.d.ts +6 -0
- package/maps.mjs +7 -0
- package/package.json +43 -4
- package/process.d.ts +190 -0
- package/process.mjs +9 -0
- package/repl.d.ts +5 -2
- package/screen.d.ts +27 -53
- package/screen.mjs +4 -7
- package/swift-ui.d.ts +323 -0
- package/swift-ui.mjs +9 -0
- package/swiplet.d.ts +77 -53
- package/swiplet.mjs +4 -1
package/swift-ui.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/** @available apiLevel 3 */
|
|
2
|
+
import type { CommonViewModifierProps } from "@expo/ui/swift-ui";
|
|
3
|
+
import type { ModifierConfig } from "@expo/ui/swift-ui/modifiers";
|
|
4
|
+
import type { ReactElement } from "react";
|
|
5
|
+
import type { ColorValue } from "react-native";
|
|
6
|
+
|
|
7
|
+
export type ChartValue = number | string | Date;
|
|
8
|
+
|
|
9
|
+
export type ChartDimension =
|
|
10
|
+
number | { readonly ratio: number } | { readonly inset: number };
|
|
11
|
+
|
|
12
|
+
export type ChartForegroundStyle =
|
|
13
|
+
ColorValue | { readonly gradient: readonly ColorValue[] };
|
|
14
|
+
|
|
15
|
+
export type ChartInterpolation =
|
|
16
|
+
| "linear"
|
|
17
|
+
| "catmullRom"
|
|
18
|
+
| "cardinal"
|
|
19
|
+
| "monotone"
|
|
20
|
+
| "stepStart"
|
|
21
|
+
| "stepCenter"
|
|
22
|
+
| "stepEnd";
|
|
23
|
+
|
|
24
|
+
export type ChartSymbol =
|
|
25
|
+
| "circle"
|
|
26
|
+
| "square"
|
|
27
|
+
| "triangle"
|
|
28
|
+
| "diamond"
|
|
29
|
+
| "pentagon"
|
|
30
|
+
| "plus"
|
|
31
|
+
| "cross"
|
|
32
|
+
| "asterisk";
|
|
33
|
+
|
|
34
|
+
export type ChartStacking = "standard" | "normalized" | "center" | "unstacked";
|
|
35
|
+
|
|
36
|
+
export interface ChartLineStyle {
|
|
37
|
+
readonly width?: number;
|
|
38
|
+
readonly dash?: readonly number[];
|
|
39
|
+
readonly cap?: "butt" | "round" | "square";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ChartDatum {
|
|
43
|
+
readonly series?: string;
|
|
44
|
+
readonly group?: string;
|
|
45
|
+
readonly color?: ColorValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ChartPoint extends ChartDatum {
|
|
49
|
+
readonly x: ChartValue;
|
|
50
|
+
readonly y: ChartValue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ChartVerticalSpan extends ChartDatum {
|
|
54
|
+
readonly x: ChartValue;
|
|
55
|
+
readonly yStart: ChartValue;
|
|
56
|
+
readonly yEnd: ChartValue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ChartHorizontalSpan extends ChartDatum {
|
|
60
|
+
readonly xStart: ChartValue;
|
|
61
|
+
readonly xEnd: ChartValue;
|
|
62
|
+
readonly y: ChartValue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ChartArea extends ChartDatum {
|
|
66
|
+
readonly xStart: ChartValue;
|
|
67
|
+
readonly xEnd: ChartValue;
|
|
68
|
+
readonly yStart: ChartValue;
|
|
69
|
+
readonly yEnd: ChartValue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ChartSector extends ChartDatum {
|
|
73
|
+
readonly value: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ChartMarkStyle {
|
|
77
|
+
readonly foregroundStyle?: ChartForegroundStyle;
|
|
78
|
+
readonly opacity?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface LineMark extends ChartMarkStyle {
|
|
82
|
+
readonly type: "line";
|
|
83
|
+
readonly data: readonly ChartPoint[];
|
|
84
|
+
readonly interpolation?: ChartInterpolation;
|
|
85
|
+
readonly lineStyle?: ChartLineStyle;
|
|
86
|
+
readonly symbol?: ChartSymbol;
|
|
87
|
+
readonly symbolSize?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface AreaMark extends ChartMarkStyle {
|
|
91
|
+
readonly type: "area";
|
|
92
|
+
readonly data: readonly (
|
|
93
|
+
ChartPoint | ChartVerticalSpan | ChartHorizontalSpan
|
|
94
|
+
)[];
|
|
95
|
+
readonly interpolation?: ChartInterpolation;
|
|
96
|
+
readonly stacking?: ChartStacking;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface BarMark extends ChartMarkStyle {
|
|
100
|
+
readonly type: "bar";
|
|
101
|
+
readonly data: readonly (
|
|
102
|
+
ChartPoint | ChartVerticalSpan | ChartHorizontalSpan
|
|
103
|
+
)[];
|
|
104
|
+
readonly stacking?: ChartStacking;
|
|
105
|
+
readonly width?: ChartDimension;
|
|
106
|
+
readonly height?: ChartDimension;
|
|
107
|
+
readonly cornerRadius?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface PointMark extends ChartMarkStyle {
|
|
111
|
+
readonly type: "point";
|
|
112
|
+
readonly data: readonly ChartPoint[];
|
|
113
|
+
readonly symbol?: ChartSymbol;
|
|
114
|
+
readonly symbolSize?: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface RuleMark extends ChartMarkStyle {
|
|
118
|
+
readonly type: "rule";
|
|
119
|
+
readonly data: readonly (
|
|
120
|
+
| (ChartDatum & { readonly x: ChartValue })
|
|
121
|
+
| (ChartDatum & { readonly y: ChartValue })
|
|
122
|
+
| ChartVerticalSpan
|
|
123
|
+
| ChartHorizontalSpan
|
|
124
|
+
)[];
|
|
125
|
+
readonly lineStyle?: ChartLineStyle;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface RectangleMark extends ChartMarkStyle {
|
|
129
|
+
readonly type: "rectangle";
|
|
130
|
+
readonly data: readonly (
|
|
131
|
+
ChartPoint | ChartVerticalSpan | ChartHorizontalSpan | ChartArea
|
|
132
|
+
)[];
|
|
133
|
+
readonly width?: ChartDimension;
|
|
134
|
+
readonly height?: ChartDimension;
|
|
135
|
+
readonly cornerRadius?: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface SectorMark extends ChartMarkStyle {
|
|
139
|
+
readonly type: "sector";
|
|
140
|
+
readonly data: readonly ChartSector[];
|
|
141
|
+
readonly innerRadius?: ChartDimension;
|
|
142
|
+
readonly outerRadius?: ChartDimension;
|
|
143
|
+
readonly angularInset?: number;
|
|
144
|
+
readonly cornerRadius?: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type ChartMark =
|
|
148
|
+
| LineMark
|
|
149
|
+
| AreaMark
|
|
150
|
+
| BarMark
|
|
151
|
+
| PointMark
|
|
152
|
+
| RuleMark
|
|
153
|
+
| RectangleMark
|
|
154
|
+
| SectorMark;
|
|
155
|
+
|
|
156
|
+
export type ChartFormat =
|
|
157
|
+
| {
|
|
158
|
+
readonly style: "number";
|
|
159
|
+
readonly fractionDigits?: number;
|
|
160
|
+
readonly notation?: "compact";
|
|
161
|
+
readonly scale?: number;
|
|
162
|
+
}
|
|
163
|
+
| {
|
|
164
|
+
readonly style: "percent";
|
|
165
|
+
readonly fractionDigits?: number;
|
|
166
|
+
readonly scale?: number;
|
|
167
|
+
}
|
|
168
|
+
| {
|
|
169
|
+
readonly style: "bytes";
|
|
170
|
+
readonly units?: "memory" | "file" | "binary" | "decimal";
|
|
171
|
+
}
|
|
172
|
+
| {
|
|
173
|
+
readonly style: "date";
|
|
174
|
+
readonly date?:
|
|
175
|
+
"omitted" | "numeric" | "abbreviated" | "long" | "complete";
|
|
176
|
+
readonly time?: "omitted" | "shortened" | "standard" | "complete";
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export interface ChartAxis {
|
|
180
|
+
readonly preset?: "automatic" | "extended" | "aligned" | "inset";
|
|
181
|
+
readonly position?: "automatic" | "leading" | "trailing" | "top" | "bottom";
|
|
182
|
+
readonly count?: number;
|
|
183
|
+
readonly values?: readonly (
|
|
184
|
+
ChartValue | { readonly value: ChartValue; readonly label: string }
|
|
185
|
+
)[];
|
|
186
|
+
readonly gridLines?: boolean;
|
|
187
|
+
readonly ticks?: boolean;
|
|
188
|
+
readonly labels?: boolean | ChartFormat;
|
|
189
|
+
readonly title?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type ChartScaleType =
|
|
193
|
+
"linear" | "log" | "squareRoot" | "symmetricLog" | "date" | "category";
|
|
194
|
+
|
|
195
|
+
export type ChartScale =
|
|
196
|
+
| {
|
|
197
|
+
readonly domain:
|
|
198
|
+
readonly [number, number] | readonly [Date, Date] | readonly string[];
|
|
199
|
+
readonly type?: ChartScaleType;
|
|
200
|
+
}
|
|
201
|
+
| {
|
|
202
|
+
readonly domain?: undefined;
|
|
203
|
+
readonly includesZero?: boolean;
|
|
204
|
+
readonly reversed?: boolean;
|
|
205
|
+
readonly type?: ChartScaleType;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export interface ChartLegend {
|
|
209
|
+
readonly position?:
|
|
210
|
+
| "automatic"
|
|
211
|
+
| "overlay"
|
|
212
|
+
| "top"
|
|
213
|
+
| "bottom"
|
|
214
|
+
| "leading"
|
|
215
|
+
| "trailing"
|
|
216
|
+
| "topLeading"
|
|
217
|
+
| "topTrailing"
|
|
218
|
+
| "bottomLeading"
|
|
219
|
+
| "bottomTrailing";
|
|
220
|
+
readonly spacing?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface ChartProps extends CommonViewModifierProps {
|
|
224
|
+
readonly marks: readonly ChartMark[];
|
|
225
|
+
readonly xAxis?: "automatic" | "hidden" | ChartAxis;
|
|
226
|
+
readonly yAxis?: "automatic" | "hidden" | ChartAxis;
|
|
227
|
+
readonly xScale?: ChartScale;
|
|
228
|
+
readonly yScale?: ChartScale;
|
|
229
|
+
readonly seriesColors?: Readonly<Record<string, ColorValue>>;
|
|
230
|
+
readonly legend?: "automatic" | "hidden" | ChartLegend;
|
|
231
|
+
readonly scrollableAxes?: "horizontal" | "vertical" | "both";
|
|
232
|
+
readonly xVisibleDomain?: number;
|
|
233
|
+
readonly yVisibleDomain?: number;
|
|
234
|
+
readonly initialScrollX?: ChartValue;
|
|
235
|
+
readonly initialScrollY?: ChartValue;
|
|
236
|
+
readonly onXSelectionChange?: (value: ChartValue | undefined) => void;
|
|
237
|
+
readonly onYSelectionChange?: (value: ChartValue | undefined) => void;
|
|
238
|
+
readonly animated?: boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export declare function Chart(props: ChartProps): ReactElement;
|
|
242
|
+
|
|
243
|
+
export type DataGridCellImage =
|
|
244
|
+
| { readonly systemName: string; readonly color?: ColorValue }
|
|
245
|
+
| { readonly uri: string };
|
|
246
|
+
|
|
247
|
+
export interface DataGridCell {
|
|
248
|
+
readonly text: string;
|
|
249
|
+
readonly image?: DataGridCellImage;
|
|
250
|
+
readonly color?: ColorValue;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface DataGridFont {
|
|
254
|
+
readonly textStyle?:
|
|
255
|
+
| "largeTitle"
|
|
256
|
+
| "title"
|
|
257
|
+
| "title2"
|
|
258
|
+
| "title3"
|
|
259
|
+
| "headline"
|
|
260
|
+
| "subheadline"
|
|
261
|
+
| "body"
|
|
262
|
+
| "callout"
|
|
263
|
+
| "footnote"
|
|
264
|
+
| "caption"
|
|
265
|
+
| "caption2";
|
|
266
|
+
readonly size?: number;
|
|
267
|
+
readonly weight?:
|
|
268
|
+
| "ultraLight"
|
|
269
|
+
| "thin"
|
|
270
|
+
| "light"
|
|
271
|
+
| "regular"
|
|
272
|
+
| "medium"
|
|
273
|
+
| "semibold"
|
|
274
|
+
| "bold"
|
|
275
|
+
| "heavy"
|
|
276
|
+
| "black";
|
|
277
|
+
readonly design?: "default" | "rounded" | "monospaced" | "serif";
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface DataGridColumn<Item> {
|
|
281
|
+
readonly header: string;
|
|
282
|
+
readonly cell: (item: Item) => string | number | DataGridCell;
|
|
283
|
+
/** Only the cells that have been displayed widen a column; this widens it ahead of them. */
|
|
284
|
+
readonly prototype?: string | number | DataGridCell;
|
|
285
|
+
readonly minWidth?: number;
|
|
286
|
+
readonly maxWidth?: number;
|
|
287
|
+
/** The square space every cell keeps for its image; without it the cells show no image. */
|
|
288
|
+
readonly imageSize?: number;
|
|
289
|
+
readonly alignment?: "leading" | "center" | "trailing";
|
|
290
|
+
readonly font?: DataGridFont;
|
|
291
|
+
readonly monospacedDigit?: boolean;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface DataGridSortIndicator {
|
|
295
|
+
readonly column: number;
|
|
296
|
+
readonly order?: "ascending" | "descending";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface DataGridProps<Item> extends CommonViewModifierProps {
|
|
300
|
+
readonly data: readonly Item[];
|
|
301
|
+
readonly columns: readonly DataGridColumn<Item>[];
|
|
302
|
+
readonly keyExtractor: (item: Item) => string;
|
|
303
|
+
/** The rows beyond the visible ones that `cell` is also called for. */
|
|
304
|
+
readonly overscanCount?: number;
|
|
305
|
+
readonly frozenColumns?: number;
|
|
306
|
+
readonly rowHeight?: number;
|
|
307
|
+
readonly headerHeight?: number;
|
|
308
|
+
readonly headerFont?: DataGridFont;
|
|
309
|
+
readonly headerColor?: ColorValue;
|
|
310
|
+
readonly rowColors?: readonly ColorValue[];
|
|
311
|
+
readonly sortIndicator?: DataGridSortIndicator;
|
|
312
|
+
readonly onCellPress?: (key: string, column: number) => void;
|
|
313
|
+
readonly onHeaderPress?: (column: number) => void;
|
|
314
|
+
readonly onHeaderLongPress?: (column: number) => void;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export declare function DataGrid<Item>(
|
|
318
|
+
props: DataGridProps<Item>,
|
|
319
|
+
): ReactElement;
|
|
320
|
+
|
|
321
|
+
export declare function horizontalSizeClass(
|
|
322
|
+
sizeClass: "compact" | "regular",
|
|
323
|
+
): ModifierConfig;
|
package/swift-ui.mjs
ADDED
package/swiplet.d.ts
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
StandardJSONSchemaV1,
|
|
3
|
+
StandardSchemaV1,
|
|
4
|
+
} from "@standard-schema/spec";
|
|
2
5
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export type IntentChoiceStyle = "default" | "destructive" | "cancel";
|
|
6
|
-
|
|
7
|
-
export type ConfirmationActionName = "add" | "addData" | "book" | "buy" | "call" | "checkIn" | "continue" | "create" | "do" | "download"
|
|
8
|
-
| "filter" | "find" | "get" | "go" | "log" | "open" | "order" | "pay" | "play" | "playSound" | "post" | "request" | "run"
|
|
9
|
-
| "search" | "send" | "set" | "share" | "start" | "startNavigation" | "toggle" | "turnOff" | "turnOn" | "view";
|
|
10
|
-
|
|
11
|
-
export interface Person {
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly handle?: { type: "phoneNumber" | "emailAddress"; value: string };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Placemark {
|
|
17
|
-
readonly name?: string;
|
|
18
|
-
readonly coordinate?: [latitude: number, longitude: number];
|
|
19
|
-
readonly address?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface IntentDialog {
|
|
23
|
-
requestChoice<T extends string | { title: string; style?: IntentChoiceStyle }>(choices: T[], prompt: string, options?: CallOptions): Promise<T>;
|
|
24
|
-
requestConfirmation(prompt: string, options?: CallOptions & { actionName?: ConfirmationActionName | { accept: string; deny: string; destructive?: boolean } }): Promise<void>;
|
|
25
|
-
requestValue(type: "text", prompt?: string, options?: CallOptions & { multiline?: boolean; literal?: boolean }): Promise<string>;
|
|
26
|
-
requestValue(type: "integer", prompt?: string, options?: CallOptions & { stepper?: boolean; min?: number; max?: number }): Promise<number>;
|
|
27
|
-
requestValue(type: "number", prompt?: string, options?: CallOptions & { min?: number; max?: number }): Promise<number>;
|
|
28
|
-
requestValue(type: "date" | "time" | "dateTime", prompt?: string, options?: CallOptions): Promise<Date>;
|
|
29
|
-
requestValue(type: "file", prompt?: string, options?: CallOptions): Promise<{ name: string; type: string; bytes: Uint8Array }>;
|
|
30
|
-
requestValue(type: "person", prompt?: string, options?: CallOptions): Promise<Person>;
|
|
31
|
-
requestValue(type: "placemark", prompt?: string, options?: CallOptions): Promise<Placemark>;
|
|
32
|
-
requestDisambiguation(values: string[], prompt: string, options?: CallOptions): Promise<string>;
|
|
33
|
-
requestValueConfirmation(value: string, prompt: string, options?: CallOptions): Promise<boolean>;
|
|
34
|
-
continueInForeground(prompt?: string, options?: CallOptions & { alwaysConfirm?: boolean }): Promise<void>;
|
|
35
|
-
}
|
|
6
|
+
import type { Jsonify } from "./index";
|
|
36
7
|
|
|
37
8
|
export type ActionCaller = "app" | "shortcuts" | "api";
|
|
38
9
|
|
|
39
|
-
export type Schema<Input = unknown, Output = Input> = StandardSchemaV1<
|
|
10
|
+
export type Schema<Input = unknown, Output = Input> = StandardSchemaV1<
|
|
11
|
+
Input,
|
|
12
|
+
Output
|
|
13
|
+
> &
|
|
14
|
+
StandardJSONSchemaV1<Input, Output>;
|
|
40
15
|
|
|
41
16
|
declare const types: unique symbol;
|
|
42
17
|
|
|
@@ -47,14 +22,16 @@ export interface Action<Input = void, Output = void> {
|
|
|
47
22
|
readonly expose: readonly "shortcuts"[];
|
|
48
23
|
}
|
|
49
24
|
|
|
50
|
-
export interface Extension<
|
|
25
|
+
export interface Extension<
|
|
26
|
+
Actions extends Record<string, Action<any, any>> = {},
|
|
27
|
+
HasRun extends boolean = boolean,
|
|
28
|
+
> {
|
|
51
29
|
readonly [types]: { hasRun: HasRun };
|
|
52
30
|
readonly actions: Actions;
|
|
53
31
|
}
|
|
54
32
|
|
|
55
33
|
export interface RunContext {
|
|
56
34
|
readonly signal: AbortSignal;
|
|
57
|
-
readonly dialog: IntentDialog;
|
|
58
35
|
}
|
|
59
36
|
|
|
60
37
|
export interface ActionContext extends RunContext {
|
|
@@ -66,32 +43,71 @@ type Sent<S> = S extends Schema ? StandardSchemaV1.InferInput<S> : void;
|
|
|
66
43
|
type Returned<S, R> = S extends Schema ? StandardSchemaV1.InferInput<S> : R;
|
|
67
44
|
type Delivered<S, R> = S extends Schema ? StandardSchemaV1.InferOutput<S> : R;
|
|
68
45
|
|
|
69
|
-
export declare function defineAction<
|
|
46
|
+
export declare function defineAction<
|
|
47
|
+
I extends Schema | undefined = undefined,
|
|
48
|
+
O extends Schema | undefined = undefined,
|
|
49
|
+
R = void,
|
|
50
|
+
>(definition: {
|
|
70
51
|
readonly title: string;
|
|
71
52
|
readonly description?: string;
|
|
72
53
|
readonly input?: I;
|
|
73
54
|
readonly output?: O;
|
|
74
55
|
readonly expose?: readonly "shortcuts"[];
|
|
75
|
-
run(
|
|
56
|
+
run(
|
|
57
|
+
input: Received<I>,
|
|
58
|
+
context: ActionContext,
|
|
59
|
+
): Returned<O, R> | Promise<Returned<O, R>>;
|
|
76
60
|
}): Action<Sent<I>, Jsonify<Awaited<Delivered<O, R>>>>;
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
export declare function defineAction<
|
|
62
|
+
I extends Schema | undefined = undefined,
|
|
63
|
+
O extends Schema | undefined = undefined,
|
|
64
|
+
T = void,
|
|
65
|
+
>(definition: {
|
|
66
|
+
readonly title: string;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
readonly input?: I;
|
|
69
|
+
readonly output?: O;
|
|
70
|
+
/** @available apiLevel 3 */
|
|
71
|
+
stream(
|
|
72
|
+
input: Received<I>,
|
|
73
|
+
context: ActionContext,
|
|
74
|
+
): AsyncIterable<Returned<O, T>>;
|
|
75
|
+
}): Action<Sent<I>, AsyncIterable<Jsonify<Delivered<O, T>>>>;
|
|
76
|
+
|
|
77
|
+
export declare function defineExtension<
|
|
78
|
+
Actions extends Record<string, Action<any, any>> = {},
|
|
79
|
+
>(definition: {
|
|
79
80
|
run(context: RunContext): Promise<void>;
|
|
80
81
|
readonly actions?: Actions;
|
|
81
82
|
}): Extension<Actions, true>;
|
|
82
|
-
export declare function defineExtension<
|
|
83
|
-
|
|
84
|
-
}): Extension<Actions, false>;
|
|
83
|
+
export declare function defineExtension<
|
|
84
|
+
Actions extends Record<string, Action<any, any>> = {},
|
|
85
|
+
>(definition: { readonly actions?: Actions }): Extension<Actions, false>;
|
|
85
86
|
|
|
86
87
|
export type ServiceStatus = "starting" | "running" | "stopped" | "failed";
|
|
87
88
|
|
|
88
|
-
type
|
|
89
|
-
?
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
type ActionReturn<Output> = [Output] extends [never]
|
|
90
|
+
? Promise<Output>
|
|
91
|
+
: Output extends AsyncIterable<unknown>
|
|
92
|
+
? Output
|
|
93
|
+
: Promise<Output>;
|
|
94
|
+
|
|
95
|
+
type ActionCall<A> =
|
|
96
|
+
A extends Action<infer Input, infer Output>
|
|
97
|
+
? [Input] extends [void]
|
|
98
|
+
? (
|
|
99
|
+
input?: undefined,
|
|
100
|
+
options?: { signal?: AbortSignal },
|
|
101
|
+
) => ActionReturn<Output>
|
|
102
|
+
: (
|
|
103
|
+
input: Input,
|
|
104
|
+
options?: { signal?: AbortSignal },
|
|
105
|
+
) => ActionReturn<Output>
|
|
106
|
+
: never;
|
|
107
|
+
|
|
108
|
+
export type ActionCalls<E extends Extension<any, any>> = {
|
|
109
|
+
readonly [K in keyof E["actions"]]: ActionCall<E["actions"][K]>;
|
|
110
|
+
};
|
|
95
111
|
|
|
96
112
|
export interface ServiceHandle {
|
|
97
113
|
readonly enabled: boolean;
|
|
@@ -101,6 +117,14 @@ export interface ServiceHandle {
|
|
|
101
117
|
setEnabled(enabled: boolean): Promise<void>;
|
|
102
118
|
}
|
|
103
119
|
|
|
104
|
-
export declare function actions<
|
|
120
|
+
export declare function actions<
|
|
121
|
+
E extends Extension<any, any>,
|
|
122
|
+
>(): ActionCalls<E>;
|
|
123
|
+
|
|
124
|
+
export declare function useService<
|
|
125
|
+
E extends Extension<any, true>,
|
|
126
|
+
>(): ServiceHandle;
|
|
127
|
+
|
|
128
|
+
export declare function exit(): void;
|
|
105
129
|
|
|
106
|
-
export
|
|
130
|
+
export {};
|
package/swiplet.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const outside = () => {
|
|
2
|
-
throw new Error(
|
|
2
|
+
throw new Error(
|
|
3
|
+
"@swipt/api/swiplet runs inside Swipt; build the swiplet with `swipt project build`",
|
|
4
|
+
);
|
|
3
5
|
};
|
|
4
6
|
|
|
5
7
|
export const defineExtension = outside;
|
|
6
8
|
export const defineAction = outside;
|
|
7
9
|
export const actions = outside;
|
|
8
10
|
export const useService = outside;
|
|
11
|
+
export const exit = outside;
|