extprg-types 1.0.1 → 1.0.2
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/index.d.ts +23 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated. Do not edit manually.
|
|
6
|
-
* 2026-05-
|
|
6
|
+
* 2026-05-07T14:05:16.404Z
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
// ── 第三方类型导入 ──
|
|
@@ -2585,9 +2585,24 @@ declare class WorldRenderUtils {
|
|
|
2585
2585
|
renderCuttingFlash(start: Vector, end: Vector, width: number, shadowColor: Color): void;
|
|
2586
2586
|
}
|
|
2587
2587
|
|
|
2588
|
+
// ── Asyncify: 递归包裹所有属性和方法返回值为 Promise ──
|
|
2589
|
+
// 用于模拟 Comlink 代理的行为,所有值访问都是异步的
|
|
2590
|
+
type Asyncify<T> =
|
|
2591
|
+
T extends null | undefined | void | never
|
|
2592
|
+
? T
|
|
2593
|
+
: T extends (...args: infer A) => infer R
|
|
2594
|
+
? (...args: A) => Promise<Asyncify<Awaited<R>>>
|
|
2595
|
+
: T extends Promise<unknown>
|
|
2596
|
+
? T
|
|
2597
|
+
: T extends Array<infer U>
|
|
2598
|
+
? Promise<Asyncify<U>>[]
|
|
2599
|
+
: T extends object
|
|
2600
|
+
? { [K in keyof T]: Asyncify<T[K]> }
|
|
2601
|
+
: Promise<T>;
|
|
2602
|
+
|
|
2588
2603
|
// ── 扩展宿主 API ──
|
|
2589
2604
|
|
|
2590
|
-
export declare function extensionHostApiFactory(extension: Extension): {
|
|
2605
|
+
export declare function extensionHostApiFactory(extension: Extension): Asyncify<{
|
|
2591
2606
|
toast(message: string): Promise<void>;
|
|
2592
2607
|
toast_success(message: string): Promise<void>;
|
|
2593
2608
|
toast_error(message: string): Promise<void>;
|
|
@@ -2614,10 +2629,14 @@ export declare function extensionHostApiFactory(extension: Extension): {
|
|
|
2614
2629
|
entity_registerType(typeName: string, initialData: any, collisionBox: CollisionBox, renderFn: (data: any) => Promise<ImageBitmap>): Promise<void>;
|
|
2615
2630
|
entity_onClick(typeName: string, handler: (payload: ClickEventPayload) => void): Promise<void>;
|
|
2616
2631
|
entity_create(typeName: string, data: any, location: { x: number; y: number }): Promise<ExtensionEntity>;
|
|
2617
|
-
}
|
|
2632
|
+
}>;
|
|
2618
2633
|
|
|
2619
2634
|
declare global {
|
|
2635
|
+
prg: Asyncify<ReturnType<typeof extensionHostApiFactory>>;
|
|
2636
|
+
interface Window {
|
|
2637
|
+
prg: Asyncify<ReturnType<typeof extensionHostApiFactory>>;
|
|
2638
|
+
}
|
|
2620
2639
|
interface DedicatedWorkerGlobalScope {
|
|
2621
|
-
prg: ReturnType<typeof extensionHostApiFactory
|
|
2640
|
+
prg: Asyncify<ReturnType<typeof extensionHostApiFactory>>;
|
|
2622
2641
|
}
|
|
2623
2642
|
}
|