Comparing version 13.1.0 to 13.2.0
@@ -7,4 +7,5 @@ import { BigIntStr, TuplePush as Push } from '@waiting/shared-types'; | ||
export interface StructDefType { | ||
[prop: string]: Def | StructDefType | StringBuffer | UnionInstanceBase; | ||
[prop: string]: Def | StructDefType | StringBuffer | UnionInstanceBase | StructTypeConstructor; | ||
} | ||
export declare type StructTypeConstructor<T = object> = new () => Record<keyof T, string | number | BigIntStr | Buffer>; | ||
export interface LoadSettings { | ||
@@ -11,0 +12,0 @@ singleton: boolean; |
@@ -1,11 +0,5 @@ | ||
import ref from 'ref-napi'; | ||
import StructDi from 'ref-struct-di'; | ||
import { StructDefType } from './ffi.types.js'; | ||
export declare function UnionType<T>(input: StructDefType): T; | ||
export declare function UnionFactor<T>(input: StructDefType): T; | ||
export declare function StructType(input: StructDefType): StructDi.StructType<{ | ||
[x: string]: ref.Type<any>; | ||
} | { | ||
[x: string]: ref.Type<void>; | ||
}>; | ||
import { StructDefType, StructTypeConstructor } from './ffi.types.js'; | ||
export declare function UnionType<T extends StructDefType>(input: T): StructTypeConstructor<T>; | ||
export declare function UnionFactory<T>(input: StructDefType): T; | ||
export declare function StructType<T extends StructDefType>(input: T): StructTypeConstructor<T>; | ||
export declare function StructFactory<T>(input: StructDefType): T; |
@@ -11,3 +11,3 @@ /* eslint-disable import/no-extraneous-dependencies */ | ||
} | ||
export function UnionFactor(input) { | ||
export function UnionFactory(input) { | ||
// @ts-expect-error | ||
@@ -14,0 +14,0 @@ return new Union(input)(); |
@@ -1,2 +0,1 @@ | ||
import * as UT from '../union/union.types.js'; | ||
/** https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/ns-winuser-rid_device_info */ | ||
@@ -6,3 +5,7 @@ export declare const RID_DEVICE_INFO: { | ||
readonly dwType: import("../def.enum.js").Def.uint32; | ||
readonly DUMMYUNIONNAME: UT.RID_DEVICE_INFO_DUMMYUNIONNAME; | ||
readonly DUMMYUNIONNAME: import("../ffi.types.js").StructTypeConstructor<{ | ||
mouse: import("../def.enum.js").Def; | ||
keyboard: import("../def.enum.js").Def; | ||
hid: import("../def.enum.js").Def; | ||
}>; | ||
}; |
import { DWORD } from '../common.def.js'; | ||
import { UnionType } from '../helper.js'; | ||
import { RID_DEVICE_INFO_DUMMYUNIONNAME } from '../union/union.def.js'; | ||
// import * as UT from '../union/union.types.js' | ||
/** https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/ns-winuser-rid_device_info */ | ||
@@ -8,4 +9,5 @@ export const RID_DEVICE_INFO = { | ||
dwType: DWORD, | ||
// DUMMYUNIONNAME: UnionType<UT.RID_DEVICE_INFO_DUMMYUNIONNAME>(RID_DEVICE_INFO_DUMMYUNIONNAME), | ||
DUMMYUNIONNAME: UnionType(RID_DEVICE_INFO_DUMMYUNIONNAME), | ||
}; | ||
//# sourceMappingURL=winuser.def.js.map |
{ | ||
"name": "win32-def", | ||
"author": "waiting", | ||
"version": "13.1.0", | ||
"version": "13.2.0", | ||
"description": "win32 definitions for node-ffi", | ||
@@ -94,3 +94,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "9fbcafd04cdbed977548f77761a98af03d20fd8e" | ||
"gitHead": "b11688dd236abc92148f3ed13ad642840615a212" | ||
} |
@@ -14,4 +14,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export interface StructDefType { | ||
[prop: string]: Def | StructDefType | StringBuffer | UnionInstanceBase | ||
[prop: string]: Def | StructDefType | StringBuffer | UnionInstanceBase | StructTypeConstructor | ||
} | ||
export type StructTypeConstructor<T = object> = new () => Record<keyof T, string | number | BigIntStr | Buffer> | ||
@@ -18,0 +19,0 @@ export interface LoadSettings { |
@@ -6,3 +6,3 @@ /* eslint-disable import/no-extraneous-dependencies */ | ||
import { StructDefType } from './ffi.types.js' | ||
import { StructDefType, StructTypeConstructor } from './ffi.types.js' | ||
@@ -12,7 +12,7 @@ | ||
const Union = UnionDi(ref) | ||
export function UnionType<T>(input: StructDefType): T { | ||
export function UnionType<T extends StructDefType>(input: T): StructTypeConstructor<T> { | ||
// @ts-expect-error | ||
return Union(input) as unknown as T | ||
return Union(input) | ||
} | ||
export function UnionFactor<T>(input: StructDefType): T { | ||
export function UnionFactory<T>(input: StructDefType): T { | ||
// @ts-expect-error | ||
@@ -23,3 +23,3 @@ return new Union(input)() as unknown as T | ||
const Struct = StructDi(ref) | ||
export function StructType(input: StructDefType) { | ||
export function StructType<T extends StructDefType>(input: T): StructTypeConstructor<T> { | ||
// @ts-expect-error | ||
@@ -26,0 +26,0 @@ return Struct(input) |
import { DWORD } from '../common.def.js' | ||
import { UnionType } from '../helper.js' | ||
import { RID_DEVICE_INFO_DUMMYUNIONNAME } from '../union/union.def.js' | ||
import * as UT from '../union/union.types.js' | ||
// import * as UT from '../union/union.types.js' | ||
@@ -11,4 +11,5 @@ | ||
dwType: DWORD, | ||
DUMMYUNIONNAME: UnionType<UT.RID_DEVICE_INFO_DUMMYUNIONNAME>(RID_DEVICE_INFO_DUMMYUNIONNAME), | ||
// DUMMYUNIONNAME: UnionType<UT.RID_DEVICE_INFO_DUMMYUNIONNAME>(RID_DEVICE_INFO_DUMMYUNIONNAME), | ||
DUMMYUNIONNAME: UnionType(RID_DEVICE_INFO_DUMMYUNIONNAME), | ||
} as const | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
272983
5810