@gtkx/runtime 1.0.0-rc.1 → 1.0.0-rc.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/dist/arg.d.ts +6 -5
- package/dist/arg.d.ts.map +1 -1
- package/dist/arg.js +5 -4
- package/dist/arg.js.map +1 -1
- package/dist/bind.d.ts +3 -2
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +5 -3
- package/dist/bind.js.map +1 -1
- package/dist/callback.d.ts +3 -3
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +51 -33
- package/dist/callback.js.map +1 -1
- package/dist/descriptors.d.ts +67 -64
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +92 -60
- package/dist/descriptors.js.map +1 -1
- package/dist/error.d.ts +5 -6
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +10 -6
- package/dist/error.js.map +1 -1
- package/dist/exit-hook.d.ts +2 -0
- package/dist/exit-hook.d.ts.map +1 -0
- package/dist/exit-hook.js +3 -0
- package/dist/exit-hook.js.map +1 -0
- package/dist/fn.d.ts +2 -2
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +26 -15
- package/dist/fn.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/library.d.ts +6 -5
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +6 -5
- package/dist/library.js.map +1 -1
- package/dist/lifecycle.d.ts +10 -9
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +38 -23
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts +8 -8
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +28 -15
- package/dist/listeners.js.map +1 -1
- package/dist/mixin.d.ts +5 -11
- package/dist/mixin.d.ts.map +1 -1
- package/dist/mixin.js +24 -14
- package/dist/mixin.js.map +1 -1
- package/dist/native-value.d.ts +3 -2
- package/dist/native-value.d.ts.map +1 -1
- package/dist/native-value.js +75 -42
- package/dist/native-value.js.map +1 -1
- package/dist/object.d.ts +4 -3
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +8 -5
- package/dist/object.js.map +1 -1
- package/dist/promisify.d.ts +9 -1
- package/dist/promisify.d.ts.map +1 -1
- package/dist/promisify.js +18 -15
- package/dist/promisify.js.map +1 -1
- package/dist/properties.d.ts +14 -0
- package/dist/properties.d.ts.map +1 -0
- package/dist/properties.js +79 -0
- package/dist/properties.js.map +1 -0
- package/dist/register-class.d.ts +10 -2
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +83 -29
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +23 -21
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +54 -35
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +7 -6
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +19 -12
- package/dist/signal.js.map +1 -1
- package/dist/t.d.ts +2 -2
- package/dist/t.d.ts.map +1 -1
- package/dist/t.js +2 -1
- package/dist/t.js.map +1 -1
- package/dist/tuple.d.ts +3 -2
- package/dist/tuple.d.ts.map +1 -1
- package/dist/tuple.js +7 -4
- package/dist/tuple.js.map +1 -1
- package/dist/type.d.ts +48 -41
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +107 -87
- package/dist/type.js.map +1 -1
- package/dist/value.d.ts +19 -10
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +164 -99
- package/dist/value.js.map +1 -1
- package/package.json +4 -6
- package/src/arg.ts +7 -5
- package/src/bind.ts +13 -4
- package/src/callback.ts +97 -35
- package/src/descriptors.ts +227 -85
- package/src/error.ts +18 -9
- package/src/exit-hook.ts +3 -0
- package/src/fn.ts +53 -22
- package/src/index.ts +4 -2
- package/src/library.ts +7 -5
- package/src/lifecycle.ts +54 -26
- package/src/listeners.ts +46 -18
- package/src/mixin.ts +39 -14
- package/src/native-value.ts +103 -46
- package/src/object.ts +19 -7
- package/src/promisify.ts +42 -15
- package/src/properties.ts +115 -0
- package/src/register-class.ts +157 -30
- package/src/registry.ts +144 -54
- package/src/signal.ts +53 -13
- package/src/t.ts +3 -1
- package/src/tuple.ts +16 -4
- package/src/type.ts +183 -93
- package/src/value.ts +231 -108
package/dist/descriptors.js
CHANGED
|
@@ -1,103 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
const int8T = { kind: "int8" };
|
|
2
|
+
const uint8T = { kind: "uint8" };
|
|
3
|
+
const int16T = { kind: "int16" };
|
|
4
|
+
const uint16T = { kind: "uint16" };
|
|
5
|
+
const int32T = { kind: "int32" };
|
|
6
|
+
const uint32T = { kind: "uint32" };
|
|
7
|
+
const int64T = { kind: "int64" };
|
|
8
|
+
const uint64T = { kind: "uint64" };
|
|
9
|
+
const bigint64T = { kind: "bigint64" };
|
|
10
|
+
const biguint64T = { kind: "biguint64" };
|
|
11
|
+
const gtypeT = { kind: "biguint64", type: true };
|
|
12
|
+
const float32T = { kind: "float32" };
|
|
13
|
+
const float64T = { kind: "float64" };
|
|
14
|
+
const booleanT = { kind: "boolean" };
|
|
15
|
+
const voidT = { kind: "void" };
|
|
16
|
+
const unicharT = { kind: "unichar" };
|
|
17
|
+
const bufferT = { kind: "buffer" };
|
|
18
|
+
const stringT = (ownership = "borrowed", length) => length === undefined ? { kind: "string", ownership } : { kind: "string", ownership, length };
|
|
19
|
+
const objectT = (ownership = "borrowed") => ({ kind: "object", ownership });
|
|
20
|
+
const refT = (innerDescriptor, isInout = false) => isInout ? { kind: "ref", innerDescriptor, inout: true } : { kind: "ref", innerDescriptor };
|
|
21
|
+
const hashTableT = (keyDescriptor, valueDescriptor, ownership = "borrowed") => ({
|
|
22
22
|
kind: "hashtable",
|
|
23
23
|
keyDescriptor,
|
|
24
24
|
valueDescriptor,
|
|
25
25
|
ownership,
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
const enumT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
28
28
|
kind: "enum",
|
|
29
29
|
sharedLibrary,
|
|
30
|
-
getTypeFnName,
|
|
31
|
-
signed,
|
|
30
|
+
getTypeFnName: typeFnName,
|
|
31
|
+
signed: isSigned,
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
const flagsT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
34
34
|
kind: "flags",
|
|
35
35
|
sharedLibrary,
|
|
36
|
-
getTypeFnName,
|
|
37
|
-
signed,
|
|
36
|
+
getTypeFnName: typeFnName,
|
|
37
|
+
signed: isSigned,
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
kind: "boxed",
|
|
42
|
-
ownership: options.ownership ?? "borrowed",
|
|
43
|
-
typeName,
|
|
44
|
-
};
|
|
45
|
-
if (options.sharedLibrary !== undefined)
|
|
39
|
+
const applyBoxedNames = (result, options) => {
|
|
40
|
+
if (options.sharedLibrary !== undefined) {
|
|
46
41
|
result.sharedLibrary = options.sharedLibrary;
|
|
47
|
-
|
|
42
|
+
}
|
|
43
|
+
if (options.getTypeFnName !== undefined) {
|
|
48
44
|
result.getTypeFnName = options.getTypeFnName;
|
|
49
|
-
|
|
45
|
+
}
|
|
46
|
+
if (options.freeFnName !== undefined) {
|
|
50
47
|
result.freeFnName = options.freeFnName;
|
|
51
|
-
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const applyBoxedOptions = (result, options) => {
|
|
51
|
+
applyBoxedNames(result, options);
|
|
52
|
+
if (options.callerAllocated) {
|
|
52
53
|
result.callerAllocated = true;
|
|
53
|
-
|
|
54
|
+
}
|
|
55
|
+
if (options.inline) {
|
|
56
|
+
result.inline = true;
|
|
57
|
+
}
|
|
58
|
+
if (options.size !== undefined) {
|
|
54
59
|
result.size = options.size;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const boxedT = (typeName, options = {}) => {
|
|
63
|
+
const result = {
|
|
64
|
+
kind: "boxed",
|
|
65
|
+
ownership: options.ownership ?? "borrowed",
|
|
66
|
+
typeName,
|
|
67
|
+
};
|
|
68
|
+
applyBoxedOptions(result, options);
|
|
55
69
|
return result;
|
|
56
70
|
};
|
|
57
|
-
|
|
71
|
+
const structT = (ownership = "borrowed", options = {}) => {
|
|
58
72
|
const result = { kind: "struct", ownership };
|
|
59
|
-
if (options.size !== undefined)
|
|
73
|
+
if (options.size !== undefined) {
|
|
60
74
|
result.size = options.size;
|
|
61
|
-
|
|
75
|
+
}
|
|
76
|
+
if (options.wrapperClass !== undefined) {
|
|
62
77
|
result.wrapperClass = options.wrapperClass;
|
|
63
|
-
|
|
78
|
+
}
|
|
79
|
+
if (options.callerAllocated) {
|
|
64
80
|
result.callerAllocated = true;
|
|
81
|
+
}
|
|
82
|
+
if (options.inline) {
|
|
83
|
+
result.inline = true;
|
|
84
|
+
}
|
|
65
85
|
return result;
|
|
66
86
|
};
|
|
67
|
-
|
|
87
|
+
const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
68
88
|
const ownership = options.ownership ?? "borrowed";
|
|
69
89
|
const result = { kind: "fundamental", ownership, sharedLibrary, refFnName, unrefFnName };
|
|
70
|
-
if (options.typeName !== undefined)
|
|
90
|
+
if (options.typeName !== undefined) {
|
|
71
91
|
result.typeName = options.typeName;
|
|
72
|
-
|
|
92
|
+
}
|
|
93
|
+
if (options.wrapperClass !== undefined) {
|
|
73
94
|
result.wrapperClass = options.wrapperClass;
|
|
95
|
+
}
|
|
96
|
+
if (options.inline) {
|
|
97
|
+
result.inline = true;
|
|
98
|
+
}
|
|
74
99
|
return result;
|
|
75
100
|
};
|
|
76
|
-
|
|
101
|
+
const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
|
|
77
102
|
const result = { kind: "array", itemDescriptor, arrayKind, ownership };
|
|
78
|
-
if (options?.elementSize !== undefined)
|
|
103
|
+
if (options?.elementSize !== undefined) {
|
|
79
104
|
result.elementSize = options.elementSize;
|
|
80
|
-
|
|
105
|
+
}
|
|
106
|
+
if (options?.sizeParamIndex !== undefined) {
|
|
81
107
|
result.sizeParamIndex = options.sizeParamIndex;
|
|
82
|
-
|
|
108
|
+
}
|
|
109
|
+
if (options?.fixedSize !== undefined) {
|
|
83
110
|
result.fixedSize = options.fixedSize;
|
|
111
|
+
}
|
|
84
112
|
return result;
|
|
85
113
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
const listT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "glist", ownership);
|
|
115
|
+
const slistT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gslist", ownership);
|
|
116
|
+
const ptrArrayT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gptrarray", ownership);
|
|
117
|
+
const gArrayT = (itemDescriptor, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "garray", ownership, elementSize === undefined ? undefined : { elementSize });
|
|
118
|
+
const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership);
|
|
119
|
+
const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "sized", ownership, { sizeParamIndex, elementSize });
|
|
120
|
+
const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "fixed", ownership, { fixedSize, elementSize });
|
|
121
|
+
const callbackT = (argDescriptors, returnDescriptor, options) => {
|
|
94
122
|
const result = { kind: "callback", argDescriptors, returnDescriptor };
|
|
95
|
-
if (options?.hasDestroy !== undefined)
|
|
123
|
+
if (options?.hasDestroy !== undefined) {
|
|
96
124
|
result.hasDestroy = options.hasDestroy;
|
|
97
|
-
|
|
125
|
+
}
|
|
126
|
+
if (options?.userDataIndex !== undefined) {
|
|
98
127
|
result.userDataIndex = options.userDataIndex;
|
|
99
|
-
|
|
128
|
+
}
|
|
129
|
+
if (options?.scope !== undefined) {
|
|
100
130
|
result.scope = options.scope;
|
|
131
|
+
}
|
|
101
132
|
return result;
|
|
102
133
|
};
|
|
134
|
+
export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, float32T, float64T, booleanT, voidT, unicharT, bufferT, stringT, objectT, refT, hashTableT, enumT, flagsT, boxedT, structT, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, callbackT, };
|
|
103
135
|
//# sourceMappingURL=descriptors.js.map
|
package/dist/descriptors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAiEA,MAAM,CAAC,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE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AAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,GAAc,UAAU,EAAmB,EAAE,CAC7E,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,cAA0B,EAC1B,cAAsB,EACtB,SAAS,GAAc,UAAU,EACjC,WAAoB,EACL,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,cAA0B,EAC1B,SAAiB,EACjB,SAAS,GAAc,UAAU,EACjC,WAAoB,EACL,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,cAA4B,EAC5B,gBAA4B,EAC5B,OAAyB,EACP,EAAE;IACpB,MAAM,MAAM,GAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAC1F,IAAI,OAAO,EAAE,UAAU,KAAK,SAAS;QAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAC9E,IAAI,OAAO,EAAE,aAAa,KAAK,SAAS;QAAE,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACvF,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC/D,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\nexport type Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\nexport type Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\nexport type Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\nexport type Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\nexport type Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\nexport type Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\nexport type Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\nexport type Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\nexport type BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\nexport type BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\nexport type Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\nexport type Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\nexport type EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\nexport type FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\nexport type BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\nexport type StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\nexport type ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\nexport type UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\nexport type VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\nexport type BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\nexport type BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\nexport type StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & { wrapperClass?: AnyClass };\nexport type FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & { wrapperClass?: AnyClass };\nexport type ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\nexport type HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\nexport type CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\nexport type RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\nexport type TypeDescriptor = BigUint64Descriptor & { type: true };\n\ntype BoxedOptions = {\n callerAllocated?: boolean;\n ownership?: Ownership;\n sharedLibrary?: string;\n getTypeFnName?: string;\n freeFnName?: string;\n size?: number;\n};\n\ntype CallbackOptions = {\n hasDestroy?: boolean;\n userDataIndex?: number;\n scope?: CallbackDescriptor[\"scope\"];\n};\n\ntype ArrayOptions = {\n elementSize?: number | undefined;\n sizeParamIndex?: number | undefined;\n fixedSize?: number | undefined;\n};\n\ntype FundamentalOptions = {\n ownership?: Ownership;\n typeName?: string;\n wrapperClass?: AnyClass;\n};\n\ntype StructOptions = {\n callerAllocated?: boolean;\n size?: number;\n wrapperClass?: AnyClass;\n};\n\nexport const int8T: Int8Descriptor = { kind: \"int8\" };\nexport const uint8T: Uint8Descriptor = { kind: \"uint8\" };\nexport const int16T: Int16Descriptor = { kind: \"int16\" };\nexport const uint16T: Uint16Descriptor = { kind: \"uint16\" };\nexport const int32T: Int32Descriptor = { kind: \"int32\" };\nexport const uint32T: Uint32Descriptor = { kind: \"uint32\" };\nexport const int64T: Int64Descriptor = { kind: \"int64\" };\nexport const uint64T: Uint64Descriptor = { kind: \"uint64\" };\nexport const bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\nexport const biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\nexport const gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\nexport const float32T: Float32Descriptor = { kind: \"float32\" };\nexport const float64T: Float64Descriptor = { kind: \"float64\" };\nexport const booleanT: BooleanDescriptor = { kind: \"boolean\" };\nexport const voidT: VoidDescriptor = { kind: \"void\" };\nexport const unicharT: UnicharDescriptor = { kind: \"unichar\" };\nexport const bufferT: BufferDescriptor = { kind: \"buffer\" };\n\nexport const stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\nexport const objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\nexport const refT = (innerDescriptor: Descriptor, inout = false): RefDescriptor =>\n inout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\nexport const hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\nexport const enumT = (sharedLibrary: string, getTypeFnName: string, signed: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName,\n signed,\n});\n\nexport const flagsT = (sharedLibrary: string, getTypeFnName: string, signed: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName,\n signed,\n});\n\nexport const boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n if (options.sharedLibrary !== undefined) result.sharedLibrary = options.sharedLibrary;\n if (options.getTypeFnName !== undefined) result.getTypeFnName = options.getTypeFnName;\n if (options.freeFnName !== undefined) result.freeFnName = options.freeFnName;\n if (options.callerAllocated) result.callerAllocated = true;\n if (options.size !== undefined) result.size = options.size;\n return result;\n};\n\nexport const structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n if (options.size !== undefined) result.size = options.size;\n if (options.wrapperClass !== undefined) result.wrapperClass = options.wrapperClass;\n if (options.callerAllocated) result.callerAllocated = true;\n return result;\n};\n\nexport const fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n if (options.typeName !== undefined) result.typeName = options.typeName;\n if (options.wrapperClass !== undefined) result.wrapperClass = options.wrapperClass;\n return result;\n};\n\nexport const arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n if (options?.elementSize !== undefined) result.elementSize = options.elementSize;\n if (options?.sizeParamIndex !== undefined) result.sizeParamIndex = options.sizeParamIndex;\n if (options?.fixedSize !== undefined) result.fixedSize = options.fixedSize;\n return result;\n};\n\nexport const listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\nexport const slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\nexport const ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\nexport const gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\nexport const byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\nexport const sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\nexport const fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\nexport const callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n if (options?.hasDestroy !== undefined) result.hasDestroy = options.hasDestroy;\n if (options?.userDataIndex !== undefined) result.userDataIndex = options.userDataIndex;\n if (options?.scope !== undefined) result.scope = options.scope;\n return result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAoEA,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/C,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,MAAM,SAAS,GAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC3D,MAAM,UAAU,GAAwB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC9D,MAAM,MAAM,GAAmB,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjE,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxD,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxD,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxD,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/C,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC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AAO,EACP,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,GA6BZ,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\ntype Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\ntype Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\ntype Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\ntype Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\ntype Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\ntype Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\ntype Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\ntype Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\ntype BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\ntype BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\ntype Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\ntype Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\ntype EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\ntype FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\ntype BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\ntype StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\ntype ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\ntype UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\ntype VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\ntype BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\ntype BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\ntype StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & { wrapperClass?: AnyClass };\ntype FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & { wrapperClass?: AnyClass };\ntype ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\ntype HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\ntype CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\ntype RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\ntype TypeDescriptor = BigUint64Descriptor & { type: true };\n\ntype BoxedOptions = {\n callerAllocated?: boolean;\n inline?: boolean;\n ownership?: Ownership;\n sharedLibrary?: string;\n getTypeFnName?: string;\n freeFnName?: string;\n size?: number;\n};\n\ntype CallbackOptions = {\n hasDestroy?: boolean;\n userDataIndex?: number;\n scope?: CallbackDescriptor[\"scope\"];\n};\n\ntype ArrayOptions = {\n elementSize?: number | undefined;\n sizeParamIndex?: number | undefined;\n fixedSize?: number | undefined;\n};\n\ntype FundamentalOptions = {\n ownership?: Ownership;\n typeName?: string;\n wrapperClass?: AnyClass;\n inline?: boolean;\n};\n\ntype StructOptions = {\n callerAllocated?: boolean;\n inline?: boolean;\n size?: number;\n wrapperClass?: AnyClass;\n};\n\nconst int8T: Int8Descriptor = { kind: \"int8\" };\nconst uint8T: Uint8Descriptor = { kind: \"uint8\" };\nconst int16T: Int16Descriptor = { kind: \"int16\" };\nconst uint16T: Uint16Descriptor = { kind: \"uint16\" };\nconst int32T: Int32Descriptor = { kind: \"int32\" };\nconst uint32T: Uint32Descriptor = { kind: \"uint32\" };\nconst int64T: Int64Descriptor = { kind: \"int64\" };\nconst uint64T: Uint64Descriptor = { kind: \"uint64\" };\nconst bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\nconst biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\nconst gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\nconst float32T: Float32Descriptor = { kind: \"float32\" };\nconst float64T: Float64Descriptor = { kind: \"float64\" };\nconst booleanT: BooleanDescriptor = { kind: \"boolean\" };\nconst voidT: VoidDescriptor = { kind: \"void\" };\nconst unicharT: UnicharDescriptor = { kind: \"unichar\" };\nconst bufferT: BufferDescriptor = { kind: \"buffer\" };\n\nconst stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\nconst objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\nconst refT = (innerDescriptor: Descriptor, isInout = false): RefDescriptor =>\n isInout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\nconst hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\nconst enumT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n signed: isSigned,\n});\n\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n signed: isSigned,\n});\n\nconst applyBoxedNames = (result: BoxedDescriptor, options: BoxedOptions): void => {\n if (options.sharedLibrary !== undefined) {\n result.sharedLibrary = options.sharedLibrary;\n }\n\n if (options.getTypeFnName !== undefined) {\n result.getTypeFnName = options.getTypeFnName;\n }\n\n if (options.freeFnName !== undefined) {\n result.freeFnName = options.freeFnName;\n }\n};\n\nconst applyBoxedOptions = (result: BoxedDescriptor, options: BoxedOptions): void => {\n applyBoxedNames(result, options);\n\n if (options.callerAllocated) {\n result.callerAllocated = true;\n }\n\n if (options.inline) {\n result.inline = true;\n }\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n};\n\nconst boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n\n applyBoxedOptions(result, options);\n\n return result;\n};\n\nconst structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.callerAllocated) {\n result.callerAllocated = true;\n }\n\n if (options.inline) {\n result.inline = true;\n }\n\n return result;\n};\n\nconst fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n\n if (options.typeName !== undefined) {\n result.typeName = options.typeName;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.inline) {\n result.inline = true;\n }\n\n return result;\n};\n\nconst arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n\n if (options?.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options?.sizeParamIndex !== undefined) {\n result.sizeParamIndex = options.sizeParamIndex;\n }\n\n if (options?.fixedSize !== undefined) {\n result.fixedSize = options.fixedSize;\n }\n\n return result;\n};\n\nconst listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\nconst slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\nconst ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\nconst gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\nconst byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\nconst sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\nconst fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\nconst callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n\n if (options?.hasDestroy !== undefined) {\n result.hasDestroy = options.hasDestroy;\n }\n\n if (options?.userDataIndex !== undefined) {\n result.userDataIndex = options.userDataIndex;\n }\n\n if (options?.scope !== undefined) {\n result.scope = options.scope;\n }\n\n return result;\n};\n\nexport {\n int8T,\n uint8T,\n int16T,\n uint16T,\n int32T,\n uint32T,\n int64T,\n uint64T,\n bigint64T,\n biguint64T,\n gtypeT,\n float32T,\n float64T,\n booleanT,\n voidT,\n unicharT,\n bufferT,\n stringT,\n objectT,\n refT,\n hashTableT,\n enumT,\n flagsT,\n boxedT,\n structT,\n fundamentalT,\n arrayT,\n listT,\n slistT,\n ptrArrayT,\n gArrayT,\n byteArrayT,\n sizedArrayT,\n fixedArrayT,\n callbackT,\n type Int8Descriptor,\n type Uint8Descriptor,\n type Int16Descriptor,\n type Uint16Descriptor,\n type Int32Descriptor,\n type Uint32Descriptor,\n type Int64Descriptor,\n type Uint64Descriptor,\n type BigInt64Descriptor,\n type BigUint64Descriptor,\n type Float32Descriptor,\n type Float64Descriptor,\n type EnumDescriptor,\n type FlagsDescriptor,\n type BooleanDescriptor,\n type StringDescriptor,\n type ObjectDescriptor,\n type UnicharDescriptor,\n type VoidDescriptor,\n type BufferDescriptor,\n type BoxedDescriptor,\n type StructDescriptor,\n type FundamentalDescriptor,\n type ArrayDescriptor,\n type HashTableDescriptor,\n type CallbackDescriptor,\n type RefDescriptor,\n type TypeDescriptor,\n};\n"]}
|
package/dist/error.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { Ref } from "@gtkx/native";
|
|
2
|
-
type ErrorLike = {
|
|
2
|
+
type ErrorLike = Error & {
|
|
3
3
|
domain: number;
|
|
4
4
|
code: number;
|
|
5
|
-
message: string;
|
|
6
5
|
};
|
|
7
6
|
/**
|
|
8
7
|
* An error enum object carrying its member codes plus an `instanceof` check that
|
|
9
8
|
* matches wrapped GLib errors belonging to a specific error domain.
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
type ErrorDomain<T extends Record<string, number>> = T & {
|
|
12
11
|
[Symbol.hasInstance]: (value: unknown) => value is ErrorLike;
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
declare function checkError(error: Ref): void;
|
|
15
14
|
/**
|
|
16
15
|
* Builds an error domain enum object from its members and a lazy resolver for the
|
|
17
16
|
* domain quark, giving it an `instanceof` check that matches wrapped GLib errors of
|
|
@@ -20,6 +19,6 @@ export declare function checkError(error: Ref): void;
|
|
|
20
19
|
* @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.
|
|
21
20
|
* @param members The error code enum members to expose on the returned object.
|
|
22
21
|
*/
|
|
23
|
-
|
|
24
|
-
export {};
|
|
22
|
+
declare function createErrorDomain<const T extends Record<string, number>>(resolveDomain: () => number, members: T): ErrorDomain<T>;
|
|
23
|
+
export { checkError, createErrorDomain, type ErrorDomain };
|
|
25
24
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,GAAG,EAAE,MAAM,cAAc,CAAC;AAIhE,KAAK,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,GAAG,EAAE,MAAM,cAAc,CAAC;AAIhE,KAAK,SAAS,GAAG,KAAK,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACrD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,SAAS,CAAC;CAChE,CAAC;AAEF,iBAAS,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAUpC;AAID;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7D,aAAa,EAAE,MAAM,MAAM,EAC3B,OAAO,EAAE,CAAC,GACX,WAAW,CAAC,CAAC,CAAC,CAahB;AAED,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
package/dist/error.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { getWrapperClass, wrapHandle } from "./registry.js";
|
|
2
2
|
import { getErrorType, isTypedClass } from "./type.js";
|
|
3
|
-
|
|
4
|
-
if (error.value
|
|
5
|
-
|
|
6
|
-
Error.captureStackTrace(gerror, checkError);
|
|
7
|
-
throw gerror;
|
|
3
|
+
function checkError(error) {
|
|
4
|
+
if (error.value === null) {
|
|
5
|
+
return;
|
|
8
6
|
}
|
|
7
|
+
const gerror = wrapHandle(error.value, getWrapperClass(getErrorType()));
|
|
8
|
+
const callSite = new Error("gtkx call site");
|
|
9
|
+
const callerFrames = (callSite.stack ?? "").split("\n").slice(2);
|
|
10
|
+
gerror.stack = [`${gerror.name}: ${gerror.message}`, ...callerFrames].join("\n");
|
|
11
|
+
throw gerror;
|
|
9
12
|
}
|
|
10
13
|
const isError = (value) => isTypedClass(value) && value.__type__ === getErrorType();
|
|
11
14
|
/**
|
|
@@ -16,7 +19,7 @@ const isError = (value) => isTypedClass(value) && value.__type__ === getErrorTyp
|
|
|
16
19
|
* @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.
|
|
17
20
|
* @param members The error code enum members to expose on the returned object.
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
function createErrorDomain(resolveDomain, members) {
|
|
20
23
|
let domain;
|
|
21
24
|
const hasInstance = (value) => {
|
|
22
25
|
domain ??= resolveDomain();
|
|
@@ -26,4 +29,5 @@ export function createErrorDomain(resolveDomain, members) {
|
|
|
26
29
|
Object.defineProperty(enumObject, Symbol.hasInstance, { value: hasInstance });
|
|
27
30
|
return enumObject;
|
|
28
31
|
}
|
|
32
|
+
export { checkError, createErrorDomain };
|
|
29
33
|
//# sourceMappingURL=error.js.map
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AACA,OAAO,E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AAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;IAE9E,OAAO,UAA4B,CAAC;AACxC,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAoB,CAAC","sourcesContent":["import type { ExternalObject, Handle, Ref } from \"@gtkx/native\";\nimport { getWrapperClass, wrapHandle } from \"./registry.js\";\nimport { getErrorType, isTypedClass } from \"./type.js\";\n\ntype ErrorLike = Error & {\n domain: number;\n code: number;\n};\n\n/**\n * An error enum object carrying its member codes plus an `instanceof` check that\n * matches wrapped GLib errors belonging to a specific error domain.\n */\ntype ErrorDomain<T extends Record<string, number>> = T & {\n [Symbol.hasInstance]: (value: unknown) => value is ErrorLike;\n};\n\nfunction checkError(error: Ref): void {\n if (error.value === null) {\n return;\n }\n\n const gerror = wrapHandle(error.value as ExternalObject<Handle>, getWrapperClass(getErrorType())) as ErrorLike;\n const callSite = new Error(\"gtkx call site\");\n const callerFrames = (callSite.stack ?? \"\").split(\"\\n\").slice(2);\n gerror.stack = [`${gerror.name}: ${gerror.message}`, ...callerFrames].join(\"\\n\");\n throw gerror;\n}\n\nconst isError = (value: unknown): value is ErrorLike => isTypedClass(value) && value.__type__ === getErrorType();\n\n/**\n * Builds an error domain enum object from its members and a lazy resolver for the\n * domain quark, giving it an `instanceof` check that matches wrapped GLib errors of\n * that domain.\n *\n * @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.\n * @param members The error code enum members to expose on the returned object.\n */\nfunction createErrorDomain<const T extends Record<string, number>>(\n resolveDomain: () => number,\n members: T,\n): ErrorDomain<T> {\n let domain: number | undefined;\n\n const hasInstance = (value: unknown): value is ErrorLike => {\n domain ??= resolveDomain();\n\n return isError(value) && value.domain === domain;\n };\n\n const enumObject: Record<string, unknown> = { ...members };\n Object.defineProperty(enumObject, Symbol.hasInstance, { value: hasInstance });\n\n return enumObject as ErrorDomain<T>;\n}\n\nexport { checkError, createErrorDomain, type ErrorDomain };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-hook.d.ts","sourceRoot":"","sources":["../src/exit-hook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../src/exit-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC","sourcesContent":["import { quit } from \"./lifecycle.js\";\n\nprocess.on(\"exit\", quit);\n"]}
|
package/dist/fn.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ type FnSpec = {
|
|
|
5
5
|
returns: Descriptor;
|
|
6
6
|
throws?: boolean;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
export {};
|
|
8
|
+
declare function fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown;
|
|
9
|
+
export { fn };
|
|
10
10
|
//# sourceMappingURL=fn.d.ts.map
|
package/dist/fn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,GAAG,EAA2D,MAAM,UAAU,CAAC;AAU7F,KAAK,MAAM,GAAG;IACV,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,GAAG,EAA2D,MAAM,UAAU,CAAC;AAU7F,KAAK,MAAM,GAAG;IACV,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA2FF,iBAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CA8BlG;AAED,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
package/dist/fn.js
CHANGED
|
@@ -7,51 +7,61 @@ import { LIB } from "./library.js";
|
|
|
7
7
|
import { fromNative } from "./native-value.js";
|
|
8
8
|
import { getHandle } from "./registry.js";
|
|
9
9
|
import { packTupleResult } from "./tuple.js";
|
|
10
|
-
const buildNativeArgTypes = (args,
|
|
10
|
+
const buildNativeArgTypes = (args, canThrow) => {
|
|
11
11
|
const nativeArgTypes = args.map((argSpec) => argSpec.direction !== undefined && argSpec.callerAllocated !== true ? refT(argSpec.type) : argSpec.type);
|
|
12
|
-
if (
|
|
12
|
+
if (canThrow) {
|
|
13
13
|
nativeArgTypes.push(refT(boxedT("GError", { ownership: "full", sharedLibrary: LIB, getTypeFnName: "g_error_get_type" })));
|
|
14
|
+
}
|
|
14
15
|
return nativeArgTypes;
|
|
15
16
|
};
|
|
16
17
|
const buildArgSpecs = (args) => {
|
|
17
18
|
let inputCursor = 0;
|
|
18
19
|
return args.map((arg) => {
|
|
19
20
|
const isRef = isRefArg(arg);
|
|
20
|
-
const
|
|
21
|
+
const isConsumesInput = !isRef || isInoutArg(arg);
|
|
21
22
|
const isOutParam = isOutputArg(arg) && arg.consumed !== true;
|
|
22
23
|
return {
|
|
23
24
|
arg,
|
|
24
25
|
isRef,
|
|
25
26
|
isCallerAllocated: isCallerAllocatedArg(arg),
|
|
26
|
-
consumesInput,
|
|
27
|
-
inputIndex:
|
|
27
|
+
consumesInput: isConsumesInput,
|
|
28
|
+
inputIndex: isConsumesInput ? inputCursor++ : -1,
|
|
28
29
|
isOutParam,
|
|
29
30
|
};
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
|
-
const
|
|
33
|
+
const resolveCallerAllocated = (inputs, inputIndex) => {
|
|
34
|
+
const wrapper = inputs[inputIndex];
|
|
35
|
+
return wrapper == null ? wrapper : getHandle(wrapper);
|
|
36
|
+
};
|
|
37
|
+
const buildRefValue = (isInputConsumed, inputs, inputIndex) => ({
|
|
38
|
+
value: isInputConsumed ? inputs[inputIndex] : null,
|
|
39
|
+
});
|
|
40
|
+
const buildNativeValue = (spec, inputs) => {
|
|
41
|
+
const { arg, isRef, isCallerAllocated, consumesInput, inputIndex } = spec;
|
|
33
42
|
if (isCallerAllocated) {
|
|
34
|
-
|
|
35
|
-
return wrapper == null ? wrapper : getHandle(wrapper);
|
|
43
|
+
return resolveCallerAllocated(inputs, inputIndex);
|
|
36
44
|
}
|
|
37
45
|
if (isRef) {
|
|
38
|
-
return
|
|
46
|
+
return buildRefValue(consumesInput, inputs, inputIndex);
|
|
39
47
|
}
|
|
40
48
|
if (arg.type.kind === "callback") {
|
|
41
49
|
return wrapCallbackValue(arg.type, inputs[inputIndex]);
|
|
42
50
|
}
|
|
43
51
|
return inputs[inputIndex];
|
|
44
|
-
}
|
|
52
|
+
};
|
|
53
|
+
const buildNativeValues = (plans, inputs) => plans.map((plan) => buildNativeValue(plan, inputs));
|
|
45
54
|
const readOutParams = (plans, inputs, nativeValues) => {
|
|
46
55
|
const outParams = [];
|
|
47
|
-
|
|
48
|
-
if (!isOutParam)
|
|
49
|
-
|
|
56
|
+
for (const [index, { arg, isCallerAllocated, inputIndex, isOutParam }] of plans.entries()) {
|
|
57
|
+
if (!isOutParam) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
50
60
|
outParams.push(isCallerAllocated ? inputs[inputIndex] : fromNative(arg.type, nativeValues[index].value));
|
|
51
|
-
}
|
|
61
|
+
}
|
|
52
62
|
return outParams;
|
|
53
63
|
};
|
|
54
|
-
|
|
64
|
+
function fn(sharedLibrary, symbol, spec) {
|
|
55
65
|
const { args, returns: returnDescriptor, throws = false } = spec;
|
|
56
66
|
const nativeArgTypes = buildNativeArgTypes(args, throws);
|
|
57
67
|
const nativeFn = bind(sharedLibrary, symbol, nativeArgTypes, returnDescriptor);
|
|
@@ -76,4 +86,5 @@ export function fn(sharedLibrary, symbol, spec) {
|
|
|
76
86
|
return shape(inputs, nativeValues, nativeFn(...nativeValues));
|
|
77
87
|
};
|
|
78
88
|
}
|
|
89
|
+
export { fn };
|
|
79
90
|
//# sourceMappingURL=fn.js.map
|
package/dist/fn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAiB7C,MAAM,mBAAmB,GAAG,CAAC,IAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,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C,IAAI,CAAC,CAAC;IAElC,MAAM,KAAK,GAAG,CAAC,MAAiB,EAAE,YAAuB,EAAE,YAAqB,EAAW,EAAE;QACzF,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEpF,OAAO,eAAe,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC5F,CAAC,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE;YACjB,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;YAC/C,UAAU,CAAC,QAAQ,CAAC,CAAC;YAErB,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE;QACjB,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEtD,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,EAAE,EAAE,CAAC","sourcesContent":["import type { Descriptor, Ref } from \"@gtkx/native\";\nimport { type Arg, isCallerAllocatedArg, isInoutArg, isOutputArg, isRefArg } from \"./arg.js\";\nimport { bind } from \"./bind.js\";\nimport { wrapCallbackValue } from \"./callback.js\";\nimport { boxedT, refT } from \"./descriptors.js\";\nimport { checkError } from \"./error.js\";\nimport { LIB } from \"./library.js\";\nimport { fromNative } from \"./native-value.js\";\nimport { getHandle } from \"./registry.js\";\nimport { packTupleResult } from \"./tuple.js\";\n\ntype FnSpec = {\n args: Arg[];\n returns: Descriptor;\n throws?: boolean;\n};\n\ntype ArgSpec = {\n arg: Arg;\n isRef: boolean;\n isCallerAllocated: boolean;\n consumesInput: boolean;\n inputIndex: number;\n isOutParam: boolean;\n};\n\nconst buildNativeArgTypes = (args: Arg[], canThrow: boolean): Descriptor[] => {\n const nativeArgTypes = args.map((argSpec) =>\n argSpec.direction !== undefined && argSpec.callerAllocated !== true ? refT(argSpec.type) : argSpec.type,\n );\n\n if (canThrow) {\n nativeArgTypes.push(\n refT(boxedT(\"GError\", { ownership: \"full\", sharedLibrary: LIB, getTypeFnName: \"g_error_get_type\" })),\n );\n }\n\n return nativeArgTypes;\n};\n\nconst buildArgSpecs = (args: Arg[]): ArgSpec[] => {\n let inputCursor = 0;\n\n return args.map((arg) => {\n const isRef = isRefArg(arg);\n const isConsumesInput = !isRef || isInoutArg(arg);\n const isOutParam = isOutputArg(arg) && arg.consumed !== true;\n\n return {\n arg,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n consumesInput: isConsumesInput,\n inputIndex: isConsumesInput ? inputCursor++ : -1,\n isOutParam,\n };\n });\n};\n\nconst resolveCallerAllocated = (inputs: unknown[], inputIndex: number): unknown => {\n const wrapper = inputs[inputIndex];\n\n return wrapper == null ? wrapper : getHandle(wrapper);\n};\n\nconst buildRefValue = (isInputConsumed: boolean, inputs: unknown[], inputIndex: number): Ref => ({\n value: isInputConsumed ? inputs[inputIndex] : null,\n});\n\nconst buildNativeValue = (spec: ArgSpec, inputs: unknown[]): unknown => {\n const { arg, isRef, isCallerAllocated, consumesInput, inputIndex } = spec;\n\n if (isCallerAllocated) {\n return resolveCallerAllocated(inputs, inputIndex);\n }\n\n if (isRef) {\n return buildRefValue(consumesInput, inputs, inputIndex);\n }\n\n if (arg.type.kind === \"callback\") {\n return wrapCallbackValue(arg.type, inputs[inputIndex]);\n }\n\n return inputs[inputIndex];\n};\n\nconst buildNativeValues = (plans: ArgSpec[], inputs: unknown[]): unknown[] =>\n plans.map((plan) => buildNativeValue(plan, inputs));\n\nconst readOutParams = (plans: ArgSpec[], inputs: unknown[], nativeValues: unknown[]): unknown[] => {\n const outParams: unknown[] = [];\n\n for (const [index, { arg, isCallerAllocated, inputIndex, isOutParam }] of plans.entries()) {\n if (!isOutParam) {\n continue;\n }\n\n outParams.push(\n isCallerAllocated ? inputs[inputIndex] : fromNative(arg.type, (nativeValues[index] as Ref).value),\n );\n }\n\n return outParams;\n};\n\nfunction fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown {\n const { args, returns: returnDescriptor, throws = false } = spec;\n const nativeArgTypes = buildNativeArgTypes(args, throws);\n const nativeFn = bind(sharedLibrary, symbol, nativeArgTypes, returnDescriptor);\n const hasPrimary = returnDescriptor.kind !== \"void\";\n const plans = buildArgSpecs(args);\n\n const shape = (inputs: unknown[], nativeValues: unknown[], nativeResult: unknown): unknown => {\n const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;\n\n return packTupleResult(readOutParams(plans, inputs, nativeValues), primary, hasPrimary);\n };\n\n if (throws) {\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs);\n const errorRef: Ref = { value: null };\n nativeValues.push(errorRef);\n const nativeResult = nativeFn(...nativeValues);\n checkError(errorRef);\n\n return shape(inputs, nativeValues, nativeResult);\n };\n }\n\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs);\n\n return shape(inputs, nativeValues, nativeFn(...nativeValues));\n };\n}\n\nexport { fn };\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import "./exit-hook.js";
|
|
2
2
|
export { createErrorDomain, type ErrorDomain } from "./error.js";
|
|
3
3
|
export { type ApplicationLike, onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
|
|
4
4
|
export { offSignal, onceSignal, onSignal } from "./listeners.js";
|
|
5
5
|
export { installMixins, type Mixin } from "./mixin.js";
|
|
6
6
|
export { fromNative } from "./native-value.js";
|
|
7
7
|
export { getObjectProperty, newObjectWithProperties, setObjectProperty } from "./object.js";
|
|
8
|
-
export { promisify } from "./promisify.js";
|
|
8
|
+
export { type FinishResult, promisify } from "./promisify.js";
|
|
9
9
|
export { registerClass } from "./register-class.js";
|
|
10
10
|
export { getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, type StaticBase, setHandle, tryGetHandle, wrapHandle, } from "./registry.js";
|
|
11
11
|
export { connectSignal, emitSignal, getSignalBaseName, type SignalHandler } from "./signal.js";
|
|
12
12
|
export { t } from "./t.js";
|
|
13
13
|
export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENUM, TYPE_FLAGS, TYPE_FLOAT, TYPE_GTYPE, TYPE_INT, TYPE_INT64, TYPE_INTERFACE, TYPE_INVALID, TYPE_LONG, TYPE_NONE, TYPE_OBJECT, TYPE_PARAM, TYPE_POINTER, TYPE_STRING, TYPE_UCHAR, TYPE_UINT, TYPE_UINT64, TYPE_ULONG, TYPE_UNICHAR, TYPE_VARIANT, type TypedClass, typeFromName, typeInterfaces, typeIsA, typeName, typeParent, valueIsA, } from "./type.js";
|
|
14
14
|
export { getBoxedValue, setBoxedValue } from "./value.js";
|
|
15
|
+
export { alloc, type ExternalObject, type Handle, read, setWrapper, write } from "@gtkx/native";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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EACR,UAAU,EACV,QAAQ,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import "./exit-hook.js";
|
|
2
2
|
export { createErrorDomain } from "./error.js";
|
|
3
3
|
export { onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
|
|
4
4
|
export { offSignal, onceSignal, onSignal } from "./listeners.js";
|
|
@@ -12,4 +12,5 @@ export { connectSignal, emitSignal, getSignalBaseName } from "./signal.js";
|
|
|
12
12
|
export { t } from "./t.js";
|
|
13
13
|
export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENUM, TYPE_FLAGS, TYPE_FLOAT, TYPE_GTYPE, TYPE_INT, TYPE_INT64, TYPE_INTERFACE, TYPE_INVALID, TYPE_LONG, TYPE_NONE, TYPE_OBJECT, TYPE_PARAM, TYPE_POINTER, TYPE_STRING, TYPE_UCHAR, TYPE_UINT, TYPE_UINT64, TYPE_ULONG, TYPE_UNICHAR, TYPE_VARIANT, typeFromName, typeInterfaces, typeIsA, typeName, typeParent, valueIsA, } from "./type.js";
|
|
14
14
|
export { getBoxedValue, setBoxedValue } from "./value.js";
|
|
15
|
+
export { alloc, read, setWrapper, write } from "@gtkx/native";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,g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,KAAK,EAAoC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import \"./exit-hook.js\";\n\nexport { createErrorDomain, type ErrorDomain } from \"./error.js\";\nexport { type ApplicationLike, onExit, quit, quitApplication, runApplication } from \"./lifecycle.js\";\nexport { offSignal, onceSignal, onSignal } from \"./listeners.js\";\nexport { installMixins, type Mixin } from \"./mixin.js\";\nexport { fromNative } from \"./native-value.js\";\nexport { getObjectProperty, newObjectWithProperties, setObjectProperty } from \"./object.js\";\nexport { type FinishResult, promisify } from \"./promisify.js\";\nexport { registerClass } from \"./register-class.js\";\nexport {\n getHandle,\n getInstanceType,\n getWrapperClass,\n registerInterface,\n registerWrapperClass,\n type StaticBase,\n setHandle,\n tryGetHandle,\n wrapHandle,\n} from \"./registry.js\";\nexport { connectSignal, emitSignal, getSignalBaseName, type SignalHandler } from \"./signal.js\";\nexport { t } from \"./t.js\";\nexport {\n resolveType,\n TYPE_BOOLEAN,\n TYPE_BOXED,\n TYPE_CHAR,\n TYPE_DOUBLE,\n TYPE_ENUM,\n TYPE_FLAGS,\n TYPE_FLOAT,\n TYPE_GTYPE,\n TYPE_INT,\n TYPE_INT64,\n TYPE_INTERFACE,\n TYPE_INVALID,\n TYPE_LONG,\n TYPE_NONE,\n TYPE_OBJECT,\n TYPE_PARAM,\n TYPE_POINTER,\n TYPE_STRING,\n TYPE_UCHAR,\n TYPE_UINT,\n TYPE_UINT64,\n TYPE_ULONG,\n TYPE_UNICHAR,\n TYPE_VARIANT,\n type TypedClass,\n typeFromName,\n typeInterfaces,\n typeIsA,\n typeName,\n typeParent,\n valueIsA,\n} from \"./type.js\";\nexport { getBoxedValue, setBoxedValue } from \"./value.js\";\nexport { alloc, type ExternalObject, type Handle, read, setWrapper, write } from \"@gtkx/native\";\n"]}
|
package/dist/library.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type BoxedDescriptor, type FundamentalDescriptor } from "./descriptors.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
declare const LIB = "libgobject-2.0.so.0,libglib-2.0.so.0";
|
|
3
|
+
declare const VALUE_SIZE = 24;
|
|
4
|
+
declare const VALUE_T: BoxedDescriptor;
|
|
5
|
+
declare const PARAM_T: FundamentalDescriptor;
|
|
6
|
+
declare const VARIANT_T: FundamentalDescriptor;
|
|
7
|
+
export { LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
7
8
|
//# sourceMappingURL=library.d.ts.map
|