@await-widget/runtime 0.0.15 → 0.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@await-widget/runtime",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "TypeScript declarations for Await widgets.",
5
5
  "license": "MIT",
6
6
  "author": "LitoMore",
package/types/bridge.d.ts CHANGED
@@ -48,6 +48,7 @@ export declare const AwaitWeather: {
48
48
  };
49
49
  export declare const AwaitHealth: {
50
50
  get(): Promise<AwaitHealthInfo | undefined>;
51
+ get(config: AwaitHealthConfig): Promise<AwaitHealthRangeInfo | undefined>;
51
52
  };
52
53
  export declare const AwaitLocation: {
53
54
  get(config?: AwaitLocationConfig): Promise<AwaitLocationInfo | undefined>;
@@ -118,7 +119,7 @@ export declare const AwaitUI: {
118
119
  readonly displayScale: number;
119
120
  haptic(type: string): void;
120
121
  };
121
- type AwaitDefineConfig<Intents, T extends Record<string, unknown>> = {
122
+ type AwaitDefineConfig<T extends Record<string, unknown>, Intents> = {
122
123
  widget: (entry: WidgetEntry<T>) => NativeView;
123
124
  widgetTimeline?: (
124
125
  context: TimelineContext,
@@ -140,10 +141,13 @@ type AwaitDefineResult<Intents> = {
140
141
  ? (...args: IntentArguments) => IntentInfo
141
142
  : never;
142
143
  };
144
+ type AwaitDefineShape = {
145
+ widgetIntents?: Record<string, (...args: any[]) => void>;
146
+ };
143
147
  export declare const Await: {
144
- define<Intents, T extends Record<string, unknown>>(
145
- config: AwaitDefineConfig<Intents, T>,
146
- ): AwaitDefineResult<Intents>;
148
+ define<T extends Record<string, unknown>, Config extends AwaitDefineShape>(
149
+ config: Config & AwaitDefineConfig<T, Config['widgetIntents']>,
150
+ ): AwaitDefineResult<Config['widgetIntents']>;
147
151
  };
148
152
  export declare const AwaitLaunch: {
149
153
  start(bundleId: string): any;
package/types/model.d.ts CHANGED
@@ -117,23 +117,65 @@ type AwaitWeatherResult = {
117
117
  daily: AwaitWeatherDaily[];
118
118
  };
119
119
 
120
+ type AwaitHealthConfig = {
121
+ start: Date;
122
+ end: Date;
123
+ };
124
+
125
+ type AwaitHealthFitnessInfo = {
126
+ activeEnergyBurned?: number;
127
+ activeEnergyBurnedGoal?: number;
128
+ exerciseTime?: number;
129
+ exerciseTimeGoal?: number;
130
+ standHours?: number;
131
+ standHoursGoal?: number;
132
+ };
133
+
134
+ type AwaitHealthQuantitySample = {
135
+ value: number;
136
+ startDate: Date;
137
+ endDate: Date;
138
+ };
139
+
140
+ type AwaitHealthSleepAnalysisValue =
141
+ | 'inBed'
142
+ | 'awake'
143
+ | 'asleepCore'
144
+ | 'asleepDeep'
145
+ | 'asleepREM'
146
+ | 'asleepUnspecified';
147
+
148
+ type AwaitHealthSleepAnalysisSample = {
149
+ value: AwaitHealthSleepAnalysisValue;
150
+ startDate: Date;
151
+ endDate: Date;
152
+ };
153
+
120
154
  type AwaitHealthInfo = {
121
155
  stepCount?: number;
122
156
  distanceWalkingRunning?: number;
123
157
  flightsClimbed?: number;
124
- fitness?: {
125
- activeEnergyBurned?: number;
126
- activeEnergyBurnedGoal?: number;
127
- exerciseTime?: number;
128
- exerciseTimeGoal?: number;
129
- standHours?: number;
130
- standHoursGoal?: number;
131
- };
158
+ fitness?: AwaitHealthFitnessInfo;
132
159
  heartRate?: number;
133
160
  restingHeartRate?: number;
134
161
  oxygenSaturation?: number;
135
162
  };
136
163
 
164
+ type AwaitHealthRangeFitnessInfo = AwaitHealthFitnessInfo & {
165
+ date: Date;
166
+ };
167
+
168
+ type AwaitHealthRangeInfo = {
169
+ stepCount?: AwaitHealthQuantitySample[];
170
+ distanceWalkingRunning?: AwaitHealthQuantitySample[];
171
+ flightsClimbed?: AwaitHealthQuantitySample[];
172
+ fitness?: AwaitHealthRangeFitnessInfo[];
173
+ heartRate?: AwaitHealthQuantitySample[];
174
+ restingHeartRate?: AwaitHealthQuantitySample[];
175
+ oxygenSaturation?: AwaitHealthQuantitySample[];
176
+ sleepAnalysis?: AwaitHealthSleepAnalysisSample[];
177
+ };
178
+
137
179
  type AwaitLocationConfig = {
138
180
  desiredAccuracyMeters?: number;
139
181
  timeoutSeconds?: number;
@@ -301,9 +343,14 @@ type AwaitAlarmScheduleConfig = {
301
343
  tint?: Color;
302
344
  };
303
345
 
346
+ type WidgetEntryData<T extends Record<string, unknown>> = Omit<
347
+ T,
348
+ keyof TimelineContext | 'date' | 'colorScheme' | 'renderingMode'
349
+ >;
350
+
304
351
  type WidgetEntry<T extends Record<string, unknown> = Record<string, unknown>> =
305
352
  TimelineContext &
306
- T & {
353
+ WidgetEntryData<T> & {
307
354
  date: Date;
308
355
  colorScheme: ColorScheme;
309
356
  renderingMode: RenderingMode;