onin-sdk 1.3.0 → 1.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.
@@ -128,6 +128,39 @@ declare function cancel(id: string): Promise<void>;
128
128
  * ```
129
129
  */
130
130
  declare function list(): Promise<ScheduleTask[]>;
131
+ /**
132
+ * 指定具体时间戳执行单次任务
133
+ *
134
+ * @param id - 任务唯一标识
135
+ * @param timestamp - 执行时间的时间戳 (毫秒)
136
+ * @param callback - 任务执行回调
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * // 在指定的未来的某个时刻执行
141
+ * const futureTime = Date.now() + 60 * 1000;
142
+ * await scheduler.at('one-time-event', futureTime, async () => {
143
+ * console.log('Time is up!');
144
+ * });
145
+ * ```
146
+ */
147
+ declare function at(id: string, timestamp: number, callback: TaskCallback): Promise<void>;
148
+ /**
149
+ * 延迟执行单次任务
150
+ *
151
+ * @param id - 任务唯一标识
152
+ * @param delayMs - 延迟时间 (毫秒)
153
+ * @param callback - 任务执行回调
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * // 25分钟后执行 (如番茄钟)
158
+ * await scheduler.timeout('pomodoro-end', 25 * 60 * 1000, async () => {
159
+ * console.log('Pomodoro finished!');
160
+ * });
161
+ * ```
162
+ */
163
+ declare function timeout(id: string, delayMs: number, callback: TaskCallback): Promise<void>;
131
164
  /**
132
165
  * Scheduler API 命名空间
133
166
  */
@@ -136,6 +169,8 @@ export declare const scheduler: {
136
169
  daily: typeof daily;
137
170
  hourly: typeof hourly;
138
171
  weekly: typeof weekly;
172
+ at: typeof at;
173
+ timeout: typeof timeout;
139
174
  cancel: typeof cancel;
140
175
  list: typeof list;
141
176
  };
@@ -0,0 +1,27 @@
1
+ function transformCallback(e, n = !1) {
2
+ return window.__TAURI_INTERNALS__.transformCallback(e, n);
3
+ }
4
+ async function invoke(e, n = {}, r) {
5
+ return window.__TAURI_INTERNALS__.invoke(e, n, r);
6
+ }
7
+ var TauriEvent;
8
+ (function(e) {
9
+ e.WINDOW_RESIZED = "tauri://resize", e.WINDOW_MOVED = "tauri://move", e.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", e.WINDOW_DESTROYED = "tauri://destroyed", e.WINDOW_FOCUS = "tauri://focus", e.WINDOW_BLUR = "tauri://blur", e.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", e.WINDOW_THEME_CHANGED = "tauri://theme-changed", e.WINDOW_CREATED = "tauri://window-created", e.WEBVIEW_CREATED = "tauri://webview-created", e.DRAG_ENTER = "tauri://drag-enter", e.DRAG_OVER = "tauri://drag-over", e.DRAG_DROP = "tauri://drag-drop", e.DRAG_LEAVE = "tauri://drag-leave";
10
+ })(TauriEvent ||= {});
11
+ async function _unlisten(e, r) {
12
+ window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e, r), await invoke("plugin:event|unlisten", {
13
+ event: e,
14
+ eventId: r
15
+ });
16
+ }
17
+ async function listen(r, i, a) {
18
+ return invoke("plugin:event|listen", {
19
+ event: r,
20
+ target: typeof a?.target == "string" ? {
21
+ kind: "AnyLabel",
22
+ label: a.target
23
+ } : a?.target ?? { kind: "Any" },
24
+ handler: transformCallback(i)
25
+ }).then((e) => async () => _unlisten(r, e));
26
+ }
27
+ export { listen };