@gtkx/runtime 1.0.0-rc.4 → 1.0.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.
- package/README.md +5 -5
- package/dist/application-class.d.ts +32 -0
- package/dist/application-class.d.ts.map +1 -0
- package/dist/application-class.js +68 -0
- package/dist/application-class.js.map +1 -0
- package/dist/arg.d.ts +2 -1
- package/dist/arg.d.ts.map +1 -1
- package/dist/arg.js +2 -1
- package/dist/arg.js.map +1 -1
- package/dist/bind.d.ts +11 -0
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +11 -0
- package/dist/bind.js.map +1 -1
- package/dist/callback.d.ts +2 -1
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +118 -20
- package/dist/callback.js.map +1 -1
- package/dist/closure.d.ts +26 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +99 -0
- package/dist/closure.js.map +1 -0
- package/dist/descriptors.d.ts +74 -3
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +44 -0
- package/dist/descriptors.js.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fn.d.ts +19 -2
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +64 -27
- package/dist/fn.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/library.d.ts +2 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +2 -1
- package/dist/library.js.map +1 -1
- package/dist/lifecycle.d.ts +43 -11
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +62 -19
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +3 -1
- package/dist/listeners.js.map +1 -1
- package/dist/mixin.d.ts +3 -2
- package/dist/mixin.d.ts.map +1 -1
- package/dist/mixin.js +13 -1
- package/dist/mixin.js.map +1 -1
- package/dist/native-value.d.ts.map +1 -1
- package/dist/native-value.js +4 -3
- package/dist/native-value.js.map +1 -1
- package/dist/object.d.ts +34 -6
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +89 -25
- package/dist/object.js.map +1 -1
- package/dist/param-spec.d.ts +11 -0
- package/dist/param-spec.d.ts.map +1 -0
- package/dist/param-spec.js +149 -0
- package/dist/param-spec.js.map +1 -0
- package/dist/promisify.d.ts.map +1 -1
- package/dist/promisify.js +3 -2
- package/dist/promisify.js.map +1 -1
- package/dist/properties.d.ts +38 -7
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +305 -42
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +117 -12
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +108 -76
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +69 -19
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +70 -26
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +9 -2
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +63 -7
- package/dist/signal.js.map +1 -1
- package/dist/type.d.ts +2 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -1
- package/dist/value.d.ts +8 -1
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +42 -13
- package/dist/value.js.map +1 -1
- package/dist/vfunc-call.d.ts +37 -0
- package/dist/vfunc-call.d.ts.map +1 -0
- package/dist/vfunc-call.js +168 -0
- package/dist/vfunc-call.js.map +1 -0
- package/dist/vfunc-seeds.d.ts +12 -0
- package/dist/vfunc-seeds.d.ts.map +1 -0
- package/dist/vfunc-seeds.js +19 -0
- package/dist/vfunc-seeds.js.map +1 -0
- package/dist/vfunc.d.ts +8 -0
- package/dist/vfunc.d.ts.map +1 -0
- package/dist/vfunc.js +23 -0
- package/dist/vfunc.js.map +1 -0
- package/package.json +4 -4
- package/src/application-class.ts +116 -0
- package/src/arg.ts +2 -1
- package/src/bind.ts +11 -0
- package/src/callback.ts +162 -22
- package/src/closure.ts +136 -0
- package/src/descriptors.ts +85 -24
- package/src/error.ts +1 -0
- package/src/fn.ts +92 -31
- package/src/index.ts +21 -6
- package/src/internal.ts +1 -0
- package/src/library.ts +2 -1
- package/src/lifecycle.ts +90 -23
- package/src/listeners.ts +3 -1
- package/src/mixin.ts +15 -2
- package/src/native-value.ts +5 -3
- package/src/object.ts +128 -34
- package/src/param-spec.ts +235 -0
- package/src/promisify.ts +4 -2
- package/src/properties.ts +458 -45
- package/src/register-class.ts +326 -109
- package/src/registry.ts +138 -40
- package/src/signal.ts +84 -14
- package/src/type.ts +3 -1
- package/src/value.ts +55 -10
- package/src/vfunc-call.ts +243 -0
- package/src/vfunc-seeds.ts +36 -0
- package/src/vfunc.ts +31 -0
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;;;GAGG;AACH,KAAK,SAAS,GAAG,KAAK,GAAG;IACrB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,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"}
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,GAAG,EAAE,MAAM,cAAc,CAAC;AAIhE;;;GAGG;AACH,KAAK,SAAS,GAAG,KAAK,GAAG;IACrB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACrD,kFAAkF;IAClF,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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA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KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;IACrD,CAAC,CAAC;IAEF,MAAM,UAAU,GAA4B,EAAE,GAAG,OAAO,EAAE,CAAC;IAC3D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,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\n/**\n * A wrapped `GError` thrown across the FFI boundary: a JavaScript `Error` that also identifies its\n * GLib domain and code.\n */\ntype ErrorLike = Error & {\n /** Quark of the error domain the code belongs to. */\n domain: number;\n /** Error code, meaningful only within `ErrorLike.domain`. */\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 /** Backs `instanceof`, matching a wrapped GLib error whose domain is this one. */\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"]}
|
package/dist/fn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Descriptor } from "@gtkx/native";
|
|
1
|
+
import type { CallDescriptor, Descriptor, ExternalObject } from "@gtkx/native";
|
|
2
|
+
import type { RefSeeds } from "./vfunc-seeds.js";
|
|
2
3
|
import { type Arg } from "./arg.js";
|
|
3
4
|
/** The signature a native function is bound against. */
|
|
4
5
|
type FnSpec = {
|
|
@@ -8,7 +9,23 @@ type FnSpec = {
|
|
|
8
9
|
returns: Descriptor;
|
|
9
10
|
/** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */
|
|
10
11
|
canThrow?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* How many of `args` precede the callee's ellipsis, marking it variadic. Omitting it binds a
|
|
14
|
+
* fixed-arity call, which passes the wrong argument classes to a variadic callee on some
|
|
15
|
+
* architectures.
|
|
16
|
+
*/
|
|
17
|
+
fixedArgCount?: number;
|
|
11
18
|
};
|
|
19
|
+
declare const buildNativeArgTypes: (args: Arg[], canThrow: boolean) => Descriptor[];
|
|
20
|
+
declare function fromNativeCallable(descriptor: ExternalObject<CallDescriptor>, spec: FnSpec, getRefSeeds?: () => RefSeeds | undefined): (...inputs: unknown[]) => unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Binds a symbol in a shared library to a callable that marshals its inputs and packs output
|
|
23
|
+
* arguments into the result. When the spec sets `canThrow`, the reported `GError` is thrown.
|
|
24
|
+
*
|
|
25
|
+
* @param sharedLibrary Shared library the symbol is looked up in.
|
|
26
|
+
* @param symbol Name of the C symbol to bind.
|
|
27
|
+
* @param spec Argument and return descriptors the call is marshalled through.
|
|
28
|
+
*/
|
|
12
29
|
declare function fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown;
|
|
13
|
-
export { fn };
|
|
30
|
+
export { buildNativeArgTypes, fn, fromNativeCallable };
|
|
14
31
|
//# 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;
|
|
1
|
+
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAO,MAAM,cAAc,CAAC;AAEpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,GAAG,EAAiE,MAAM,UAAU,CAAC;AASnG,wDAAwD;AACxD,KAAK,MAAM,GAAG;IACV,uFAAuF;IACvF,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,+FAA+F;IAC/F,OAAO,EAAE,UAAU,CAAC;IACpB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAcF,QAAA,MAAM,mBAAmB,GAAI,MAAM,GAAG,EAAE,EAAE,UAAU,OAAO,KAAG,UAAU,EAYvE,CAAC;AAgGF,iBAAS,kBAAkB,CACvB,UAAU,EAAE,cAAc,CAAC,cAAc,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,QAAQ,GAAG,SAAS,GACzC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CAkCnC;AAED;;;;;;;GAOG;AACH,iBAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CAKlG;AAED,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/fn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { call, bind as nativeBind } from "@gtkx/native";
|
|
2
|
+
import { isCallerAllocatedArg, isOutputArg, isRefArg, requiresInputArg } from "./arg.js";
|
|
3
3
|
import { wrapCallbackValue } from "./callback.js";
|
|
4
4
|
import { boxedT, refT } from "./descriptors.js";
|
|
5
5
|
import { checkError } from "./error.js";
|
|
@@ -7,6 +7,7 @@ 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 NO_OUT_PARAMS = [];
|
|
10
11
|
const buildNativeArgTypes = (args, canThrow) => {
|
|
11
12
|
const nativeArgTypes = args.map((argSpec) => argSpec.direction !== undefined && argSpec.isCallerAllocated !== true ? refT(argSpec.type) : argSpec.type);
|
|
12
13
|
if (canThrow) {
|
|
@@ -16,12 +17,13 @@ const buildNativeArgTypes = (args, canThrow) => {
|
|
|
16
17
|
};
|
|
17
18
|
const buildArgSpecs = (args) => {
|
|
18
19
|
let inputCursor = 0;
|
|
19
|
-
return args.map((arg) => {
|
|
20
|
+
return args.map((arg, index) => {
|
|
20
21
|
const isRef = isRefArg(arg);
|
|
21
|
-
const requiresInput =
|
|
22
|
+
const requiresInput = requiresInputArg(arg);
|
|
22
23
|
const isOutParam = isOutputArg(arg) && arg.isConsumed !== true;
|
|
23
24
|
return {
|
|
24
25
|
arg,
|
|
26
|
+
index,
|
|
25
27
|
isRef,
|
|
26
28
|
isCallerAllocated: isCallerAllocatedArg(arg),
|
|
27
29
|
requiresInput,
|
|
@@ -34,57 +36,92 @@ const resolveCallerAllocated = (inputs, inputIndex) => {
|
|
|
34
36
|
const wrapper = inputs[inputIndex];
|
|
35
37
|
return wrapper == null ? wrapper : getHandle(wrapper);
|
|
36
38
|
};
|
|
37
|
-
const buildRefValue = (
|
|
38
|
-
value: requiresInput ? inputs[inputIndex] : null,
|
|
39
|
+
const buildRefValue = (spec, inputs, seeds) => ({
|
|
40
|
+
value: spec.requiresInput ? inputs[spec.inputIndex] : (seeds?.get(spec.index) ?? null),
|
|
39
41
|
});
|
|
40
|
-
const buildNativeValue = (spec, inputs) => {
|
|
41
|
-
const { arg, isRef, isCallerAllocated,
|
|
42
|
+
const buildNativeValue = (spec, inputs, seeds) => {
|
|
43
|
+
const { arg, isRef, isCallerAllocated, inputIndex } = spec;
|
|
42
44
|
if (isCallerAllocated) {
|
|
43
45
|
return resolveCallerAllocated(inputs, inputIndex);
|
|
44
46
|
}
|
|
45
47
|
if (isRef) {
|
|
46
|
-
return buildRefValue(
|
|
48
|
+
return buildRefValue(spec, inputs, seeds);
|
|
47
49
|
}
|
|
48
50
|
if (arg.type.kind === "callback") {
|
|
49
51
|
return wrapCallbackValue(arg.type, inputs[inputIndex]);
|
|
50
52
|
}
|
|
51
53
|
return inputs[inputIndex];
|
|
52
54
|
};
|
|
53
|
-
const buildNativeValues = (plans, inputs) => plans.map((plan) => buildNativeValue(plan, inputs));
|
|
54
|
-
const readOutParams = (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!isOutParam) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
outParams.push(isCallerAllocated ? inputs[inputIndex] : fromNative(arg.type, nativeValues[index].value));
|
|
55
|
+
const buildNativeValues = (plans, inputs, seeds) => plans.map((plan) => buildNativeValue(plan, inputs, seeds));
|
|
56
|
+
const readOutParams = (outPlans, inputs, nativeValues) => {
|
|
57
|
+
if (outPlans.length === 0) {
|
|
58
|
+
return NO_OUT_PARAMS;
|
|
61
59
|
}
|
|
62
|
-
return
|
|
60
|
+
return Array.from(outPlans, (plan) => plan.isCallerAllocated
|
|
61
|
+
? inputs[plan.inputIndex]
|
|
62
|
+
: fromNative(plan.arg.type, nativeValues[plan.index].value));
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
const isPassThroughPlan = (plan, index) => plan.inputIndex === index &&
|
|
65
|
+
!plan.isRef &&
|
|
66
|
+
!plan.isCallerAllocated &&
|
|
67
|
+
plan.arg.type.kind !== "callback";
|
|
68
|
+
const resizeInputs = (inputs, argCount) => {
|
|
69
|
+
while (inputs.length < argCount) {
|
|
70
|
+
inputs.push(undefined);
|
|
71
|
+
}
|
|
72
|
+
if (inputs.length > argCount) {
|
|
73
|
+
inputs.length = argCount;
|
|
74
|
+
}
|
|
75
|
+
return inputs;
|
|
76
|
+
};
|
|
77
|
+
const directCallable = (descriptor, returnDescriptor, argCount) => {
|
|
78
|
+
if (returnDescriptor.kind === "void") {
|
|
79
|
+
return (...inputs) => {
|
|
80
|
+
call(descriptor, resizeInputs(inputs, argCount));
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return (...inputs) => fromNative(returnDescriptor, call(descriptor, resizeInputs(inputs, argCount)));
|
|
84
|
+
};
|
|
85
|
+
function fromNativeCallable(descriptor, spec, getRefSeeds) {
|
|
65
86
|
const { args, returns: returnDescriptor, canThrow = false } = spec;
|
|
66
|
-
const nativeArgTypes = buildNativeArgTypes(args, canThrow);
|
|
67
|
-
const nativeFn = bind(sharedLibrary, symbol, nativeArgTypes, returnDescriptor);
|
|
68
87
|
const hasPrimary = returnDescriptor.kind !== "void";
|
|
69
88
|
const plans = buildArgSpecs(args);
|
|
89
|
+
const outPlans = plans.filter((plan) => plan.isOutParam);
|
|
90
|
+
const arePassThrough = plans.every((plan, index) => isPassThroughPlan(plan, index));
|
|
91
|
+
if (!canThrow && arePassThrough) {
|
|
92
|
+
return directCallable(descriptor, returnDescriptor, plans.length);
|
|
93
|
+
}
|
|
70
94
|
const shape = (inputs, nativeValues, nativeResult) => {
|
|
71
95
|
const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;
|
|
72
|
-
return packTupleResult(readOutParams(
|
|
96
|
+
return packTupleResult(readOutParams(outPlans, inputs, nativeValues), primary, hasPrimary);
|
|
73
97
|
};
|
|
74
98
|
if (canThrow) {
|
|
75
99
|
return (...inputs) => {
|
|
76
|
-
const nativeValues = buildNativeValues(plans, inputs);
|
|
100
|
+
const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());
|
|
77
101
|
const errorRef = { value: null };
|
|
78
102
|
nativeValues.push(errorRef);
|
|
79
|
-
const nativeResult =
|
|
103
|
+
const nativeResult = call(descriptor, nativeValues);
|
|
80
104
|
checkError(errorRef);
|
|
81
105
|
return shape(inputs, nativeValues, nativeResult);
|
|
82
106
|
};
|
|
83
107
|
}
|
|
84
108
|
return (...inputs) => {
|
|
85
|
-
const nativeValues = buildNativeValues(plans, inputs);
|
|
86
|
-
return shape(inputs, nativeValues,
|
|
109
|
+
const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());
|
|
110
|
+
return shape(inputs, nativeValues, call(descriptor, nativeValues));
|
|
87
111
|
};
|
|
88
112
|
}
|
|
89
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Binds a symbol in a shared library to a callable that marshals its inputs and packs output
|
|
115
|
+
* arguments into the result. When the spec sets `canThrow`, the reported `GError` is thrown.
|
|
116
|
+
*
|
|
117
|
+
* @param sharedLibrary Shared library the symbol is looked up in.
|
|
118
|
+
* @param symbol Name of the C symbol to bind.
|
|
119
|
+
* @param spec Argument and return descriptors the call is marshalled through.
|
|
120
|
+
*/
|
|
121
|
+
function fn(sharedLibrary, symbol, spec) {
|
|
122
|
+
const nativeArgTypes = buildNativeArgTypes(spec.args, spec.canThrow ?? false);
|
|
123
|
+
const descriptor = nativeBind(sharedLibrary, symbol, nativeArgTypes, spec.returns, spec.fixedArgCount);
|
|
124
|
+
return fromNativeCallable(descriptor, spec);
|
|
125
|
+
}
|
|
126
|
+
export { buildNativeArgTypes, fn, fromNativeCallable };
|
|
90
127
|
//# 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;AAqB7C,MAAM,mBAAmB,GAAG,CAAC,IAAW,EAAE,QAAiB,EAAgB,EAAE;IACzE,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAC5G,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,cAAc,CAAC,IAAI,CACf,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE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D,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\n/** The signature a native function is bound against. */\ntype FnSpec = {\n /** The C arguments in declaration order, including the ones the callee writes into. */\n args: Arg[];\n /** Descriptor for the C return value, packed first when output arguments are also returned. */\n returns: Descriptor;\n /** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */\n canThrow?: boolean;\n};\n\ntype ArgSpec = {\n arg: Arg;\n isRef: boolean;\n isCallerAllocated: boolean;\n requiresInput: 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.isCallerAllocated !== 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 requiresInput = !isRef || isInoutArg(arg);\n const isOutParam = isOutputArg(arg) && arg.isConsumed !== true;\n\n return {\n arg,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n requiresInput,\n inputIndex: requiresInput ? 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 = (requiresInput: boolean, inputs: unknown[], inputIndex: number): Ref => ({\n value: requiresInput ? inputs[inputIndex] : null,\n});\n\nconst buildNativeValue = (spec: ArgSpec, inputs: unknown[]): unknown => {\n const { arg, isRef, isCallerAllocated, requiresInput, inputIndex } = spec;\n\n if (isCallerAllocated) {\n return resolveCallerAllocated(inputs, inputIndex);\n }\n\n if (isRef) {\n return buildRefValue(requiresInput, 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, canThrow = false } = spec;\n const nativeArgTypes = buildNativeArgTypes(args, canThrow);\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 (canThrow) {\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"]}
|
|
1
|
+
{"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAY,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACnG,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;AA4B7C,MAAM,aAAa,GAAc,EAAE,CAAC;AAEpC,MAAM,mBAAmB,GAAG,CAAC,IAAW,EAAE,QAAiB,EAAgB,EAAE;IACzE,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxC,OAAO,CAAC,SAAS,KAAK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BAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACtC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;YACpD,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,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;QAEvE,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,EAAE,CAAC,aAAqB,EAAE,MAAc,EAAE,IAAY;IAC3D,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAEvG,OAAO,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { CallDescriptor, Descriptor, ExternalObject, Ref } from \"@gtkx/native\";\nimport { call, bind as nativeBind } from \"@gtkx/native\";\nimport type { RefSeeds } from \"./vfunc-seeds.js\";\nimport { type Arg, isCallerAllocatedArg, isOutputArg, isRefArg, requiresInputArg } from \"./arg.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\n/** The signature a native function is bound against. */\ntype FnSpec = {\n /** The C arguments in declaration order, including the ones the callee writes into. */\n args: Arg[];\n /** Descriptor for the C return value, packed first when output arguments are also returned. */\n returns: Descriptor;\n /** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */\n canThrow?: boolean;\n /**\n * How many of `args` precede the callee's ellipsis, marking it variadic. Omitting it binds a\n * fixed-arity call, which passes the wrong argument classes to a variadic callee on some\n * architectures.\n */\n fixedArgCount?: number;\n};\n\ntype ArgSpec = {\n arg: Arg;\n index: number;\n isRef: boolean;\n isCallerAllocated: boolean;\n requiresInput: boolean;\n inputIndex: number;\n isOutParam: boolean;\n};\n\nconst NO_OUT_PARAMS: unknown[] = [];\n\nconst buildNativeArgTypes = (args: Arg[], canThrow: boolean): Descriptor[] => {\n const nativeArgTypes = args.map((argSpec) =>\n argSpec.direction !== undefined && argSpec.isCallerAllocated !== 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, index) => {\n const isRef = isRefArg(arg);\n const requiresInput = requiresInputArg(arg);\n const isOutParam = isOutputArg(arg) && arg.isConsumed !== true;\n\n return {\n arg,\n index,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n requiresInput,\n inputIndex: requiresInput ? 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 = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): Ref => ({\n value: spec.requiresInput ? inputs[spec.inputIndex] : (seeds?.get(spec.index) ?? null),\n});\n\nconst buildNativeValue = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): unknown => {\n const { arg, isRef, isCallerAllocated, inputIndex } = spec;\n\n if (isCallerAllocated) {\n return resolveCallerAllocated(inputs, inputIndex);\n }\n\n if (isRef) {\n return buildRefValue(spec, inputs, seeds);\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[], seeds: RefSeeds | undefined): unknown[] =>\n plans.map((plan) => buildNativeValue(plan, inputs, seeds));\n\nconst readOutParams = (outPlans: ArgSpec[], inputs: unknown[], nativeValues: unknown[]): unknown[] => {\n if (outPlans.length === 0) {\n return NO_OUT_PARAMS;\n }\n\n return Array.from(outPlans, (plan) =>\n plan.isCallerAllocated\n ? inputs[plan.inputIndex]\n : fromNative(plan.arg.type, (nativeValues[plan.index] as Ref).value));\n};\n\nconst isPassThroughPlan = (plan: ArgSpec, index: number): boolean =>\n plan.inputIndex === index &&\n !plan.isRef &&\n !plan.isCallerAllocated &&\n plan.arg.type.kind !== \"callback\";\n\nconst resizeInputs = (inputs: unknown[], argCount: number): unknown[] => {\n while (inputs.length < argCount) {\n inputs.push(undefined);\n }\n\n if (inputs.length > argCount) {\n inputs.length = argCount;\n }\n\n return inputs;\n};\n\nconst directCallable = (\n descriptor: ExternalObject<CallDescriptor>,\n returnDescriptor: Descriptor,\n argCount: number,\n): ((...inputs: unknown[]) => unknown) => {\n if (returnDescriptor.kind === \"void\") {\n return (...inputs) => {\n call(descriptor, resizeInputs(inputs, argCount));\n };\n }\n\n return (...inputs) => fromNative(returnDescriptor, call(descriptor, resizeInputs(inputs, argCount)));\n};\n\nfunction fromNativeCallable(\n descriptor: ExternalObject<CallDescriptor>,\n spec: FnSpec,\n getRefSeeds?: () => RefSeeds | undefined,\n): (...inputs: unknown[]) => unknown {\n const { args, returns: returnDescriptor, canThrow = false } = spec;\n const hasPrimary = returnDescriptor.kind !== \"void\";\n const plans = buildArgSpecs(args);\n const outPlans = plans.filter((plan) => plan.isOutParam);\n const arePassThrough = plans.every((plan, index) => isPassThroughPlan(plan, index));\n\n if (!canThrow && arePassThrough) {\n return directCallable(descriptor, returnDescriptor, plans.length);\n }\n\n const shape = (inputs: unknown[], nativeValues: unknown[], nativeResult: unknown): unknown => {\n const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;\n\n return packTupleResult(readOutParams(outPlans, inputs, nativeValues), primary, hasPrimary);\n };\n\n if (canThrow) {\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n const errorRef: Ref = { value: null };\n nativeValues.push(errorRef);\n const nativeResult = call(descriptor, nativeValues);\n checkError(errorRef);\n\n return shape(inputs, nativeValues, nativeResult);\n };\n }\n\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n\n return shape(inputs, nativeValues, call(descriptor, nativeValues));\n };\n}\n\n/**\n * Binds a symbol in a shared library to a callable that marshals its inputs and packs output\n * arguments into the result. When the spec sets `canThrow`, the reported `GError` is thrown.\n *\n * @param sharedLibrary Shared library the symbol is looked up in.\n * @param symbol Name of the C symbol to bind.\n * @param spec Argument and return descriptors the call is marshalled through.\n */\nfunction fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown {\n const nativeArgTypes = buildNativeArgTypes(spec.args, spec.canThrow ?? false);\n const descriptor = nativeBind(sharedLibrary, symbol, nativeArgTypes, spec.returns, spec.fixedArgCount);\n\n return fromNativeCallable(descriptor, spec);\n}\n\nexport { buildNativeArgTypes, fn, fromNativeCallable };\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import "./exit-hook.js";
|
|
2
2
|
/** @public */
|
|
3
|
+
export { type ApplicationClass, type CommandLineApplication, createApplication } from "./application-class.js";
|
|
4
|
+
/** @public */
|
|
5
|
+
export { type ClosureCallback, ClosureMarshalError, toClosure, tryToClosure } from "./closure.js";
|
|
6
|
+
/** @public */
|
|
3
7
|
export { createErrorDomain, type ErrorDomain } from "./error.js";
|
|
4
8
|
/** @public */
|
|
5
|
-
export { onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
|
|
9
|
+
export { onExit, quit, quitApplication, runApplication, type RunApplicationResult } from "./lifecycle.js";
|
|
6
10
|
/** @public */
|
|
7
11
|
export { offSignal, onceSignal, onSignal } from "./listeners.js";
|
|
8
12
|
/** @public */
|
|
@@ -10,15 +14,15 @@ export { installMixins, type Mixin } from "./mixin.js";
|
|
|
10
14
|
/** @public */
|
|
11
15
|
export { fromNative, toNative } from "./native-value.js";
|
|
12
16
|
/** @public */
|
|
13
|
-
export { getObjectProperty, newObjectWithProperties, setObjectProperty } from "./object.js";
|
|
17
|
+
export { type ConstructBinding, type ConstructBindings, getObjectProperty, newObjectWithProperties, registerConstructProperties, setObjectProperty, } from "./object.js";
|
|
14
18
|
/** @public */
|
|
15
19
|
export { promisify } from "./promisify.js";
|
|
16
20
|
/** @public */
|
|
17
|
-
export { registerClass } from "./register-class.js";
|
|
21
|
+
export { type Interface, registerClass } from "./register-class.js";
|
|
18
22
|
/** @public */
|
|
19
|
-
export { getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, type StaticBase, setHandle,
|
|
23
|
+
export { getClassType, getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, type StaticBase, setHandle, wrapHandle, } from "./registry.js";
|
|
20
24
|
/** @public */
|
|
21
|
-
export { connectSignal, emitSignal, getSignalBaseName, type SignalHandler } from "./signal.js";
|
|
25
|
+
export { connectSignal, disconnectSignal, emitSignal, getSignalBaseName, type SignalHandler } from "./signal.js";
|
|
22
26
|
/** @public */
|
|
23
27
|
export { t } from "./t.js";
|
|
24
28
|
/** @public */
|
|
@@ -26,5 +30,9 @@ export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENU
|
|
|
26
30
|
/** @public */
|
|
27
31
|
export { getBoxedValue, setBoxedValue } from "./value.js";
|
|
28
32
|
/** @public */
|
|
29
|
-
export {
|
|
33
|
+
export { callParent, callVfunc } from "./vfunc-call.js";
|
|
34
|
+
/** @public */
|
|
35
|
+
export { alloc, type ExternalObject, type Handle, read, write } from "@gtkx/native";
|
|
36
|
+
/** @public */
|
|
37
|
+
export { type AnyClass } from "@gtkx/utils";
|
|
30
38
|
//# 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,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,cAAc;AACd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC/G,cAAc;AACd,OAAO,EAAE,KAAK,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClG,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACj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,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,KAAK,UAAU,EACf,YAAY,EACZ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,GACX,MAAM,WAAW,CAAC;AACnB,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc;AACd,OAAO,EAAE,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACpF,cAAc;AACd,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import "./exit-hook.js";
|
|
2
2
|
/** @public */
|
|
3
|
+
export { createApplication } from "./application-class.js";
|
|
4
|
+
/** @public */
|
|
5
|
+
export { ClosureMarshalError, toClosure, tryToClosure } from "./closure.js";
|
|
6
|
+
/** @public */
|
|
3
7
|
export { createErrorDomain } from "./error.js";
|
|
4
8
|
/** @public */
|
|
5
9
|
export { onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
|
|
@@ -10,15 +14,15 @@ export { installMixins } from "./mixin.js";
|
|
|
10
14
|
/** @public */
|
|
11
15
|
export { fromNative, toNative } from "./native-value.js";
|
|
12
16
|
/** @public */
|
|
13
|
-
export { getObjectProperty, newObjectWithProperties, setObjectProperty } from "./object.js";
|
|
17
|
+
export { getObjectProperty, newObjectWithProperties, registerConstructProperties, setObjectProperty, } from "./object.js";
|
|
14
18
|
/** @public */
|
|
15
19
|
export { promisify } from "./promisify.js";
|
|
16
20
|
/** @public */
|
|
17
21
|
export { registerClass } from "./register-class.js";
|
|
18
22
|
/** @public */
|
|
19
|
-
export { getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, setHandle,
|
|
23
|
+
export { getClassType, getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, setHandle, wrapHandle, } from "./registry.js";
|
|
20
24
|
/** @public */
|
|
21
|
-
export { connectSignal, emitSignal, getSignalBaseName } from "./signal.js";
|
|
25
|
+
export { connectSignal, disconnectSignal, emitSignal, getSignalBaseName } from "./signal.js";
|
|
22
26
|
/** @public */
|
|
23
27
|
export { t } from "./t.js";
|
|
24
28
|
/** @public */
|
|
@@ -26,5 +30,9 @@ export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENU
|
|
|
26
30
|
/** @public */
|
|
27
31
|
export { getBoxedValue, setBoxedValue } from "./value.js";
|
|
28
32
|
/** @public */
|
|
29
|
-
export {
|
|
33
|
+
export { callParent, callVfunc } from "./vfunc-call.js";
|
|
34
|
+
/** @public */
|
|
35
|
+
export { alloc, read, write } from "@gtkx/native";
|
|
36
|
+
/** @public */
|
|
37
|
+
export {} from "@gtkx/utils";
|
|
30
38
|
//# 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,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AACjE,cAAc;AACd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EAAsD,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC/G,cAAc;AACd,OAAO,EAAwB,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClG,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAoB,MA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V,QAAQ,GACX,MAAM,WAAW,CAAC;AACnB,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc;AACd,OAAO,EAAE,KAAK,EAAoC,IAAI,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACpF,cAAc;AACd,OAAO,EAAiB,MAAM,aAAa,CAAC","sourcesContent":["import \"./exit-hook.js\";\n\n/** @public */\nexport { type ApplicationClass, type CommandLineApplication, createApplication } from \"./application-class.js\";\n/** @public */\nexport { type ClosureCallback, ClosureMarshalError, toClosure, tryToClosure } from \"./closure.js\";\n/** @public */\nexport { createErrorDomain, type ErrorDomain } from \"./error.js\";\n/** @public */\nexport { onExit, quit, quitApplication, runApplication, type RunApplicationResult } from \"./lifecycle.js\";\n/** @public */\nexport { offSignal, onceSignal, onSignal } from \"./listeners.js\";\n/** @public */\nexport { installMixins, type Mixin } from \"./mixin.js\";\n/** @public */\nexport { fromNative, toNative } from \"./native-value.js\";\n/** @public */\nexport {\n type ConstructBinding,\n type ConstructBindings,\n getObjectProperty,\n newObjectWithProperties,\n registerConstructProperties,\n setObjectProperty,\n} from \"./object.js\";\n/** @public */\nexport { promisify } from \"./promisify.js\";\n/** @public */\nexport { type Interface, registerClass } from \"./register-class.js\";\n/** @public */\nexport {\n getClassType,\n getHandle,\n getInstanceType,\n getWrapperClass,\n registerInterface,\n registerWrapperClass,\n type StaticBase,\n setHandle,\n wrapHandle,\n} from \"./registry.js\";\n/** @public */\nexport { connectSignal, disconnectSignal, emitSignal, getSignalBaseName, type SignalHandler } from \"./signal.js\";\n/** @public */\nexport { t } from \"./t.js\";\n/** @public */\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\";\n/** @public */\nexport { getBoxedValue, setBoxedValue } from \"./value.js\";\n/** @public */\nexport { callParent, callVfunc } from \"./vfunc-call.js\";\n/** @public */\nexport { alloc, type ExternalObject, type Handle, read, write } from \"@gtkx/native\";\n/** @public */\nexport { type AnyClass } from \"@gtkx/utils\";\n"]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { checkError, createErrorDomain } from "./error.js";
|
|
2
2
|
export { registerClassType, resolveWrapperClass, wrapHandle } from "./registry.js";
|
|
3
|
+
export { hasSignalListener } from "./signal.js";
|
|
3
4
|
export { resolveType } from "./type.js";
|
|
4
5
|
export { fromValue, getBoxedValue, getValueType, inoutValueForBoxedDescriptor, newValueForDescriptor, outValueForBoxedDescriptor, toValue, } from "./value.js";
|
|
5
6
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { checkError, createErrorDomain } from "./error.js";
|
|
2
2
|
export { registerClassType, resolveWrapperClass, wrapHandle } from "./registry.js";
|
|
3
|
+
export { hasSignalListener } from "./signal.js";
|
|
3
4
|
export { resolveType } from "./type.js";
|
|
4
5
|
export { fromValue, getBoxedValue, getValueType, inoutValueForBoxedDescriptor, newValueForDescriptor, outValueForBoxedDescriptor, toValue, } from "./value.js";
|
|
5
6
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC","sourcesContent":["export { checkError, createErrorDomain } from \"./error.js\";\nexport { registerClassType, resolveWrapperClass, wrapHandle } from \"./registry.js\";\nexport { resolveType } from \"./type.js\";\nexport {\n fromValue,\n getBoxedValue,\n getValueType,\n inoutValueForBoxedDescriptor,\n newValueForDescriptor,\n outValueForBoxedDescriptor,\n toValue,\n} from \"./value.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC","sourcesContent":["export { checkError, createErrorDomain } from \"./error.js\";\nexport { registerClassType, resolveWrapperClass, wrapHandle } from \"./registry.js\";\nexport { hasSignalListener } from \"./signal.js\";\nexport { resolveType } from \"./type.js\";\nexport {\n fromValue,\n getBoxedValue,\n getValueType,\n inoutValueForBoxedDescriptor,\n newValueForDescriptor,\n outValueForBoxedDescriptor,\n toValue,\n} from \"./value.js\";\n"]}
|
package/dist/library.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type BoxedDescriptor, type FundamentalDescriptor } from "./descriptors.js";
|
|
2
2
|
declare const LIB = "libgobject-2.0.so.0,libglib-2.0.so.0";
|
|
3
3
|
declare const VALUE_SIZE = 24;
|
|
4
|
+
declare const CLOSURE_SIZE = 32;
|
|
4
5
|
declare const VALUE_T: BoxedDescriptor;
|
|
5
6
|
declare const PARAM_T: FundamentalDescriptor;
|
|
6
7
|
declare const VARIANT_T: FundamentalDescriptor;
|
|
7
|
-
export { LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
8
|
+
export { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
8
9
|
//# sourceMappingURL=library.d.ts.map
|
package/dist/library.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAU,KAAK,qBAAqB,EAAgB,MAAM,kBAAkB,CAAC;AAE1G,QAAA,MAAM,GAAG,yCAAyC,CAAC;AACnD,QAAA,MAAM,UAAU,KAAK,CAAC;AACtB,QAAA,MAAM,OAAO,EAAE,eAA6F,CAAC;AAE7G,QAAA,MAAM,OAAO,EAAE,qBAGb,CAAC;AAEH,QAAA,MAAM,SAAS,EAAE,qBAGf,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAU,KAAK,qBAAqB,EAAgB,MAAM,kBAAkB,CAAC;AAE1G,QAAA,MAAM,GAAG,yCAAyC,CAAC;AACnD,QAAA,MAAM,UAAU,KAAK,CAAC;AACtB,QAAA,MAAM,YAAY,KAAK,CAAC;AACxB,QAAA,MAAM,OAAO,EAAE,eAA6F,CAAC;AAE7G,QAAA,MAAM,OAAO,EAAE,qBAGb,CAAC;AAEH,QAAA,MAAM,SAAS,EAAE,qBAGf,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/library.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { boxedT, fundamentalT } from "./descriptors.js";
|
|
2
2
|
const LIB = "libgobject-2.0.so.0,libglib-2.0.so.0";
|
|
3
3
|
const VALUE_SIZE = 24;
|
|
4
|
+
const CLOSURE_SIZE = 32;
|
|
4
5
|
const VALUE_T = boxedT("GValue", { sharedLibrary: LIB, getTypeFnName: "g_value_get_type" });
|
|
5
6
|
const PARAM_T = fundamentalT(LIB, "g_param_spec_ref", "g_param_spec_unref", {
|
|
6
7
|
ownership: "borrowed",
|
|
@@ -10,5 +11,5 @@ const VARIANT_T = fundamentalT(LIB, "g_variant_ref", "g_variant_unref", {
|
|
|
10
11
|
ownership: "borrowed",
|
|
11
12
|
typeName: "GVariant",
|
|
12
13
|
});
|
|
13
|
-
export { LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
14
|
+
export { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
14
15
|
//# sourceMappingURL=library.js.map
|
package/dist/library.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAA8B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE1G,MAAM,GAAG,GAAG,sCAAsC,CAAC;AACnD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAoB,MAAM,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAE7G,MAAM,OAAO,GAA0B,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE;IAC/F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,SAAS,GAA0B,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,iBAAiB,EAAE;IAC3F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,UAAU;CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { type BoxedDescriptor, boxedT, type FundamentalDescriptor, fundamentalT } from \"./descriptors.js\";\n\nconst LIB = \"libgobject-2.0.so.0,libglib-2.0.so.0\";\nconst VALUE_SIZE = 24;\nconst VALUE_T: BoxedDescriptor = boxedT(\"GValue\", { sharedLibrary: LIB, getTypeFnName: \"g_value_get_type\" });\n\nconst PARAM_T: FundamentalDescriptor = fundamentalT(LIB, \"g_param_spec_ref\", \"g_param_spec_unref\", {\n ownership: \"borrowed\",\n typeName: \"GParam\",\n});\n\nconst VARIANT_T: FundamentalDescriptor = fundamentalT(LIB, \"g_variant_ref\", \"g_variant_unref\", {\n ownership: \"borrowed\",\n typeName: \"GVariant\",\n});\n\nexport { LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };\n"]}
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAA8B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE1G,MAAM,GAAG,GAAG,sCAAsC,CAAC;AACnD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,OAAO,GAAoB,MAAM,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAE7G,MAAM,OAAO,GAA0B,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE;IAC/F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,SAAS,GAA0B,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,iBAAiB,EAAE;IAC3F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,UAAU;CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { type BoxedDescriptor, boxedT, type FundamentalDescriptor, fundamentalT } from \"./descriptors.js\";\n\nconst LIB = \"libgobject-2.0.so.0,libglib-2.0.so.0\";\nconst VALUE_SIZE = 24;\nconst CLOSURE_SIZE = 32;\nconst VALUE_T: BoxedDescriptor = boxedT(\"GValue\", { sharedLibrary: LIB, getTypeFnName: \"g_value_get_type\" });\n\nconst PARAM_T: FundamentalDescriptor = fundamentalT(LIB, \"g_param_spec_ref\", \"g_param_spec_unref\", {\n ownership: \"borrowed\",\n typeName: \"GParam\",\n});\n\nconst VARIANT_T: FundamentalDescriptor = fundamentalT(LIB, \"g_variant_ref\", \"g_variant_unref\", {\n ownership: \"borrowed\",\n typeName: \"GVariant\",\n});\n\nexport { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };\n"]}
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -6,13 +6,16 @@
|
|
|
6
6
|
type ApplicationLike = {
|
|
7
7
|
/** Returns whether the application has already been registered. */
|
|
8
8
|
getIsRegistered(): boolean;
|
|
9
|
+
/** Returns whether another process owns the application ID, making this one a remote instance. */
|
|
10
|
+
getIsRemote?(): boolean;
|
|
9
11
|
/** Registers the application with the session, returning whether it succeeded. */
|
|
10
12
|
register(cancellable: null): boolean;
|
|
11
13
|
/** Emits `activate`, bringing up the application's initial user interface. */
|
|
12
14
|
activate(): void;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Runs GLib's own `g_application_run`, whose tail emits `shutdown`, destroys the application
|
|
17
|
+
* implementation and clears the registration.
|
|
18
|
+
*/
|
|
16
19
|
run(argv: string[]): number;
|
|
17
20
|
/** Returns the windows currently attached to the application. */
|
|
18
21
|
getWindows?(): object[];
|
|
@@ -20,6 +23,15 @@ type ApplicationLike = {
|
|
|
20
23
|
removeWindow?(window: object): void;
|
|
21
24
|
/** Connects a handler to the application's `activate` or `shutdown` signal. */
|
|
22
25
|
on(signal: "activate" | "shutdown", handler: () => void): unknown;
|
|
26
|
+
/** Emits one of the application's own signals. */
|
|
27
|
+
emit(signal: "shutdown"): unknown;
|
|
28
|
+
};
|
|
29
|
+
/** What {@link runApplication} reports about the process it just started. */
|
|
30
|
+
type RunApplicationResult = {
|
|
31
|
+
/** Whether this process owns the application ID and may build a user interface. */
|
|
32
|
+
isPrimary: boolean;
|
|
33
|
+
/** The status GLib determined for the command line, which the process should exit with. */
|
|
34
|
+
exitStatus: number;
|
|
23
35
|
};
|
|
24
36
|
/**
|
|
25
37
|
* Runs every registered exit callback and shuts down the native runtime. Safe to
|
|
@@ -34,19 +46,39 @@ declare const quit: () => void;
|
|
|
34
46
|
*/
|
|
35
47
|
declare const onExit: (callback: () => void) => void;
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
49
|
+
* Hands `argv` to GLib's own command line handling, which parses the application's options, prints
|
|
50
|
+
* `--help`, runs `handle-local-options`, registers the application, and either activates it or
|
|
51
|
+
* forwards the command line to the process that already owns the application ID. The runtime is
|
|
52
|
+
* held alive while the application is active and released on shutdown.
|
|
53
|
+
*
|
|
54
|
+
* `g_application_run()` is not what starts the application, because it would drive its own main loop
|
|
55
|
+
* and freeze Node; only the local command line handling it delegates to runs here. {@link
|
|
56
|
+
* quitApplication} calls it once no window holds the application open, to reach the teardown only it
|
|
57
|
+
* performs.
|
|
58
|
+
*
|
|
59
|
+
* GLib parses a given application's command line at most once, so starting an application that has
|
|
60
|
+
* already run registers and activates it instead of reading `argv` again.
|
|
39
61
|
*
|
|
40
|
-
*
|
|
62
|
+
* When another process already owns the application ID, this one registers as a remote instance: no
|
|
63
|
+
* user interface may be built here, because a remote application has no `GtkApplicationImpl` and
|
|
64
|
+
* attaching a window to it crashes.
|
|
65
|
+
*
|
|
66
|
+
* @param application The application to start.
|
|
67
|
+
* @param argv The command line, whose first entry names the program as `--help` should print it.
|
|
68
|
+
* @returns Whether this process may build a user interface, and the status to exit with.
|
|
41
69
|
*/
|
|
42
|
-
declare const runApplication: (application: ApplicationLike) =>
|
|
70
|
+
declare const runApplication: (application: ApplicationLike, argv: string[]) => RunApplicationResult;
|
|
43
71
|
/**
|
|
44
|
-
* Detaches every window from the application and runs
|
|
45
|
-
*
|
|
46
|
-
*
|
|
72
|
+
* Detaches every window from the application and runs GLib's own shutdown, which emits `shutdown`,
|
|
73
|
+
* destroys the application implementation and releases the D-Bus registration. Does nothing for an
|
|
74
|
+
* application that is not registered, so a repeated call is a no-op.
|
|
75
|
+
*
|
|
76
|
+
* GLib's own shutdown is reachable once per application: reaching it marks the application as
|
|
77
|
+
* quitting, which GLib never undoes. An application that has already quit falls back to emitting
|
|
78
|
+
* `shutdown`, which releases the runtime and leaves the registration for GLib to drop at finalize.
|
|
47
79
|
*
|
|
48
80
|
* @param application The application to shut down.
|
|
49
81
|
*/
|
|
50
82
|
declare const quitApplication: (application: ApplicationLike) => void;
|
|
51
|
-
export { onExit, quit, runApplication, quitApplication, type ApplicationLike };
|
|
83
|
+
export { onExit, quit, runApplication, quitApplication, type ApplicationLike, type RunApplicationResult };
|
|
52
84
|
//# sourceMappingURL=lifecycle.d.ts.map
|
package/dist/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,KAAK,eAAe,GAAG;IACnB,mEAAmE;IACnE,eAAe,IAAI,OAAO,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,CAAC;IACrC,8EAA8E;IAC9E,QAAQ,IAAI,IAAI,CAAC;IACjB
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